Commit 9a41a73d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/paint/Makefile.am app/paint/gimpbrushcore-kernels.h new GimpPaintCore

2004-05-25  Michael Natterer  <mitch@gimp.org>

	* app/paint/Makefile.am
	* app/paint/gimpbrushcore-kernels.h
	* app/paint/gimpbrushcore.[ch]: new GimpPaintCore subclass
	containing all the brush painting specific stuff.

	* app/paint/gimppaintcore-kernels.h: removed this file.

	* app/paint/gimppaintcore.[ch]: removed all brush stuff.

	* app/paint/gimpairbrush.c
	* app/paint/gimpclone.[ch]
	* app/paint/gimpconvolve.[ch]
	* app/paint/gimpdodgeburn.[ch]
	* app/paint/gimperaser.[ch]
	* app/paint/gimppaintbrush.[ch]
	* app/paint/gimppencil.c
	* app/paint/gimpsmudge.[ch]: changed accordingly. Derive all
	classes which used to derive directly from GimpPaintCore from
	GimpBrushCore now. Lots of cleanup.

	* app/paint/paint-types.h
	* app/paint/gimp-paint.c
	* app/paint/gimppaintcore-stroke.c
	* app/tools/gimppainttool.c
	* tools/kernelgen.c: changed accordingly.
parent 013cc9c3
2004-05-25 Michael Natterer <mitch@gimp.org>
* app/paint/Makefile.am
* app/paint/gimpbrushcore-kernels.h
* app/paint/gimpbrushcore.[ch]: new GimpPaintCore subclass
containing all the brush painting specific stuff.
* app/paint/gimppaintcore-kernels.h: removed this file.
* app/paint/gimppaintcore.[ch]: removed all brush stuff.
* app/paint/gimpairbrush.c
* app/paint/gimpclone.[ch]
* app/paint/gimpconvolve.[ch]
* app/paint/gimpdodgeburn.[ch]
* app/paint/gimperaser.[ch]
* app/paint/gimppaintbrush.[ch]
* app/paint/gimppencil.c
* app/paint/gimpsmudge.[ch]: changed accordingly. Derive all
classes which used to derive directly from GimpPaintCore from
GimpBrushCore now. Lots of cleanup.
* app/paint/paint-types.h
* app/paint/gimp-paint.c
* app/paint/gimppaintcore-stroke.c
* app/tools/gimppainttool.c
* tools/kernelgen.c: changed accordingly.
2004-05-25 Maurits Rijk <m.rijk@chello.nl>
* plug-ins/common/align_layers.c
......
......@@ -24,6 +24,9 @@ libapppaint_a_sources = \
gimpairbrush.h \
gimpairbrushoptions.c \
gimpairbrushoptions.h \
gimpbrushcore.c \
gimpbrushcore.h \
gimpbrushcore-kernels.h \
gimpclone.c \
gimpclone.h \
gimpcloneoptions.c \
......@@ -42,7 +45,6 @@ libapppaint_a_sources = \
gimperaseroptions.h \
gimppaintcore.c \
gimppaintcore.h \
gimppaintcore-kernels.h \
gimppaintcore-stroke.c \
gimppaintcore-stroke.h \
gimppaintcore-undo.c \
......
......@@ -32,6 +32,7 @@
#include "gimpconvolve.h"
#include "gimpdodgeburn.h"
#include "gimperaser.h"
#include "gimppaintoptions.h"
#include "gimppaintbrush.h"
#include "gimppencil.h"
#include "gimpsmudge.h"
......
......@@ -78,14 +78,14 @@ gimp_airbrush_get_type (void)
static const GTypeInfo info =
{
sizeof (GimpAirbrushClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_airbrush_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpAirbrush),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_airbrush_init,
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_airbrush_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpAirbrush),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_airbrush_init,
};
type = g_type_register_static (GIMP_TYPE_PAINTBRUSH,
......@@ -99,11 +99,8 @@ gimp_airbrush_get_type (void)
static void
gimp_airbrush_class_init (GimpAirbrushClass *klass)
{
GObjectClass *object_class;
GimpPaintCoreClass *paint_core_class;
object_class = G_OBJECT_CLASS (klass);
paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -138,11 +135,8 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state)
{
GimpAirbrush *airbrush;
GimpAirbrushOptions *options;
airbrush = GIMP_AIRBRUSH (paint_core);
options = GIMP_AIRBRUSH_OPTIONS (paint_options);
GimpAirbrush *airbrush = GIMP_AIRBRUSH (paint_core);
GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (paint_options);
switch (paint_state)
{
......@@ -206,12 +200,10 @@ gimp_airbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
GimpAirbrushOptions *options;
GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (paint_options);
gdouble opacity;
gboolean saved_pressure;
options = GIMP_AIRBRUSH_OPTIONS (paint_options);
opacity = options->pressure / 100.0;
saved_pressure = paint_options->pressure_options->pressure;
......
/* gimppaintcore-kernels.h
/* gimpbrushcore-kernels.h
*
* This file was generated using kernelgen as found in the tools dir.
* (threshold = 0.25)
*/
#ifndef __GIMP_PAINT_CORE_KERNELS_H__
#define __GIMP_PAINT_CORE_KERNELS_H__
#ifndef __GIMP_BRUSH_CORE_KERNELS_H__
#define __GIMP_BRUSH_CORE_KERNELS_H__
#define KERNEL_WIDTH 3
#define KERNEL_HEIGHT 3
......@@ -52,4 +52,4 @@ static const int subsample[5][5][9] =
}
};
#endif /* __GIMP_PAINT_CORE_KERNELS_H__ */
#endif /* __GIMP_BRUSH_CORE_KERNELS_H__ */
This diff is collapsed.
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_BRUSH_CORE_H__
#define __GIMP_BRUSH_CORE_H__
#include "gimppaintcore.h"
#define BRUSH_CORE_SUBSAMPLE 4
#define BRUSH_CORE_SOLID_SUBSAMPLE 2
#define GIMP_TYPE_BRUSH_CORE (gimp_brush_core_get_type ())
#define GIMP_BRUSH_CORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BRUSH_CORE, GimpBrushCore))
#define GIMP_BRUSH_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BRUSH_CORE, GimpBrushCoreClass))
#define GIMP_IS_BRUSH_CORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_BRUSH_CORE))
#define GIMP_IS_BRUSH_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BRUSH_CORE))
#define GIMP_BRUSH_CORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BRUSH_CORE, GimpBrushCoreClass))
typedef struct _GimpBrushCoreClass GimpBrushCoreClass;
struct _GimpBrushCore
{
GimpPaintCore parent_instance;
GimpBrush *brush;
gdouble spacing;
/* brush buffers */
MaskBuf *pressure_brush;
MaskBuf *solid_brushes[BRUSH_CORE_SOLID_SUBSAMPLE][BRUSH_CORE_SOLID_SUBSAMPLE];
MaskBuf *last_solid_brush;
gboolean solid_cache_invalid;
MaskBuf *scale_brush;
MaskBuf *last_scale_brush;
gint last_scale_width;
gint last_scale_height;
MaskBuf *scale_pixmap;
MaskBuf *last_scale_pixmap;
gint last_scale_pixmap_width;
gint last_scale_pixmap_height;
MaskBuf *kernel_brushes[BRUSH_CORE_SUBSAMPLE + 1][BRUSH_CORE_SUBSAMPLE + 1];
MaskBuf *last_brush_mask;
gboolean cache_invalid;
/* don't use these... */
GimpBrush *grr_brush;
BoundSeg *brush_bound_segs;
gint n_brush_bound_segs;
};
struct _GimpBrushCoreClass
{
GimpPaintCoreClass parent_class;
};
GType gimp_brush_core_get_type (void) G_GNUC_CONST;
void gimp_brush_core_paste_canvas (GimpBrushCore *core,
GimpDrawable *drawable,
gdouble brush_opacity,
gdouble image_opacity,
GimpLayerModeEffects paint_mode,
GimpBrushApplicationMode brush_hardness,
gdouble brush_scale,
GimpPaintApplicationMode mode);
void gimp_brush_core_replace_canvas (GimpBrushCore *core,
GimpDrawable *drawable,
gdouble brush_opacity,
gdouble image_opacity,
GimpBrushApplicationMode brush_hardness,
gdouble brush_scale,
GimpPaintApplicationMode mode);
void gimp_brush_core_color_area_with_pixmap
(GimpBrushCore *core,
GimpImage *dest,
GimpDrawable *drawable,
TempBuf *area,
gdouble scale,
GimpBrushApplicationMode mode);
#endif /* __GIMP_BRUSH_CORE_H__ */
......@@ -31,7 +31,6 @@
#include "paint-funcs/paint-funcs.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimppattern.h"
......@@ -42,41 +41,41 @@
#include "gimp-intl.h"
static void gimp_clone_class_init (GimpCloneClass *klass);
static void gimp_clone_init (GimpClone *clone);
static void gimp_clone_class_init (GimpCloneClass *klass);
static void gimp_clone_init (GimpClone *clone);
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state);
static void gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state);
static void gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static void gimp_clone_line_image (GimpImage *dest,
GimpImage *src,
GimpDrawable *d_drawable,
GimpDrawable *s_drawable,
guchar *s,
guchar *d,
gint has_alpha,
gint src_bytes,
gint dest_bytes,
gint width);
static void gimp_clone_line_pattern (GimpImage *dest,
GimpDrawable *drawable,
GimpPattern *pattern,
guchar *d,
gint x,
gint y,
gint bytes,
gint width);
static void gimp_clone_line_image (GimpImage *dest,
GimpImage *src,
GimpDrawable *d_drawable,
GimpDrawable *s_drawable,
guchar *s,
guchar *d,
gint has_alpha,
gint src_bytes,
gint dest_bytes,
gint width);
static void gimp_clone_line_pattern (GimpImage *dest,
GimpDrawable *drawable,
GimpPattern *pattern,
guchar *d,
gint x,
gint y,
gint bytes,
gint width);
static void gimp_clone_set_src_drawable (GimpClone *clone,
GimpDrawable *drawable);
static void gimp_clone_set_src_drawable (GimpClone *clone,
GimpDrawable *drawable);
static GimpPaintCoreClass *parent_class = NULL;
static GimpBrushCoreClass *parent_class = NULL;
void
......@@ -99,17 +98,17 @@ gimp_clone_get_type (void)
static const GTypeInfo info =
{
sizeof (GimpCloneClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_clone_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpClone),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_clone_init,
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_clone_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpClone),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_clone_init,
};
type = g_type_register_static (GIMP_TYPE_PAINT_CORE,
type = g_type_register_static (GIMP_TYPE_BRUSH_CORE,
"GimpClone",
&info, 0);
}
......@@ -120,9 +119,7 @@ gimp_clone_get_type (void)
static void
gimp_clone_class_init (GimpCloneClass *klass)
{
GimpPaintCoreClass *paint_core_class;
paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -132,9 +129,7 @@ gimp_clone_class_init (GimpCloneClass *klass)
static void
gimp_clone_init (GimpClone *clone)
{
GimpPaintCore *paint_core;
paint_core = GIMP_PAINT_CORE (clone);
GimpPaintCore *paint_core = GIMP_PAINT_CORE (clone);
paint_core->flags |= CORE_HANDLES_CHANGING_BRUSH;
paint_core->flags |= CORE_TRACES_ON_WINDOW;
......@@ -165,13 +160,9 @@ gimp_clone_paint (GimpPaintCore *paint_core,
static gint orig_src_x = 0;
static gint orig_src_y = 0;
GimpClone *clone;
GimpCloneOptions *options;
GimpContext *context;
clone = GIMP_CLONE (paint_core);
options = GIMP_CLONE_OPTIONS (paint_options);
context = GIMP_CONTEXT (paint_options);
GimpClone *clone = GIMP_CLONE (paint_core);
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
switch (paint_state)
{
......@@ -272,12 +263,12 @@ gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
GimpClone *clone;
GimpCloneOptions *options;
GimpPressureOptions *pressure_options;
GimpClone *clone = GIMP_CLONE (paint_core);
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpPressureOptions *pressure_options = paint_options->pressure_options;
GimpImage *gimage;
GimpImage *src_gimage = NULL;
GimpContext *context;
guchar *s;
guchar *d;
TempBuf *area;
......@@ -292,18 +283,10 @@ gimp_clone_motion (GimpPaintCore *paint_core,
gint offset_x;
gint offset_y;
clone = GIMP_CLONE (paint_core);
options = GIMP_CLONE_OPTIONS (paint_options);
context = GIMP_CONTEXT (paint_options);
pressure_options = paint_options->pressure_options;
if (! (gimage = gimp_item_get_image (GIMP_ITEM (drawable))))
return;
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
opacity = gimp_paint_options_get_fade (paint_options, gimage,
paint_core->pixel_dist);
if (opacity == 0.0)
return;
......@@ -449,7 +432,7 @@ gimp_clone_motion (GimpPaintCore *paint_core,
opacity *= PRESSURE_SCALE * paint_core->cur_coords.pressure;
/* paste the newly painted canvas to the gimage which is being worked on */
gimp_paint_core_paste_canvas (paint_core, drawable,
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
MIN (opacity, GIMP_OPACITY_OPAQUE),
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context),
......
......@@ -20,7 +20,7 @@
#define __GIMP_CLONE_H__
#include "gimppaintcore.h"
#include "gimpbrushcore.h"
#define GIMP_TYPE_CLONE (gimp_clone_get_type ())
......@@ -36,7 +36,7 @@ typedef struct _GimpCloneClass GimpCloneClass;
struct _GimpClone
{
GimpPaintCore parent_instance;
GimpBrushCore parent_instance;
gboolean set_source;
......@@ -62,7 +62,7 @@ struct _GimpClone
struct _GimpCloneClass
{
GimpPaintCoreClass parent_class;
GimpBrushCoreClass parent_class;
};
......
......@@ -68,21 +68,21 @@ static void gimp_convolve_motion (GimpPaintCore *paint_core,
static void gimp_convolve_calculate_matrix (GimpConvolveType type,
gdouble rate);
static void gimp_convolve_integer_matrix (gfloat *source,
static void gimp_convolve_integer_matrix (const gfloat *source,
gint *dest,
gint size);
static void gimp_convolve_copy_matrix (gfloat *src,
static void gimp_convolve_copy_matrix (const gfloat *src,
gfloat *dest,
gint size);
static gint gimp_convolve_sum_matrix (gint *matrix,
static gint gimp_convolve_sum_matrix (const gint *matrix,
gint size);
static gint matrix [25];
static gint matrix_size;
static gint matrix_divisor;
static gint matrix[25];
static gint matrix_size;
static gint matrix_divisor;
static gfloat custom_matrix [25] =
static gfloat custom_matrix[25] =
{
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
......@@ -91,7 +91,7 @@ static gfloat custom_matrix [25] =
0, 0, 0, 0, 0,
};
static gfloat blur_matrix [25] =
static gfloat blur_matrix[25] =
{
0, 0, 0, 0, 0,
0, 1, 1, 1, 0,
......@@ -100,7 +100,7 @@ static gfloat blur_matrix [25] =
0, 0 ,0, 0, 0,
};
static gfloat sharpen_matrix [25] =
static gfloat sharpen_matrix[25] =
{
0, 0, 0, 0, 0,
0, 1, 1, 1, 0,
......@@ -109,7 +109,8 @@ static gfloat sharpen_matrix [25] =
0, 0, 0, 0, 0,
};
static GimpPaintCoreClass *parent_class;
static GimpBrushCoreClass *parent_class;
void
......@@ -132,17 +133,17 @@ gimp_convolve_get_type (void)
static const GTypeInfo info =
{
sizeof (GimpConvolveClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_convolve_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpConvolve),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_convolve_init,
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_convolve_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpConvolve),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_convolve_init,
};
type = g_type_register_static (GIMP_TYPE_PAINT_CORE,
type = g_type_register_static (GIMP_TYPE_BRUSH_CORE,
"GimpConvolve",
&info, 0);
}
......@@ -153,9 +154,7 @@ gimp_convolve_get_type (void)
static void
gimp_convolve_class_init (GimpConvolveClass *klass)
{
GimpPaintCoreClass *paint_core_class;
paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -189,9 +188,10 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
GimpConvolveOptions *options;
GimpPressureOptions *pressure_options;
GimpContext *context;
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_core);
GimpConvolveOptions *options = GIMP_CONVOLVE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpPressureOptions *pressure_options = paint_options->pressure_options;
GimpImage *gimage;
TempBuf *area;
guchar *temp_data;
......@@ -205,25 +205,18 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
gint marginx = 0;
gint marginy = 0;
options = GIMP_CONVOLVE_OPTIONS (paint_options);
context = GIMP_CONTEXT (paint_options);
pressure_options = paint_options->pressure_options;
if (! (gimage = gimp_item_get_image (GIMP_ITEM (drawable))))
return;
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
if (gimp_drawable_is_indexed (drawable))
return;
/* If the brush is smaller than the convolution matrix, don't convolve */
if (paint_core->brush->mask->width < matrix_size ||
paint_core->brush->mask->height < matrix_size)
if (brush_core->brush->mask->width < matrix_size ||
brush_core->brush->mask->height < matrix_size)
return;
opacity = gimp_paint_options_get_fade (paint_options, gimage,
paint_core->pixel_dist);
if (opacity == 0.0)
return;
......@@ -259,15 +252,35 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
/* Image region near edges? If so, paint area will be clipped */
/* with respect to brush mask + 1 pixel border (# 19285) */
if ((marginx = (gint) paint_core->cur_coords.x - paint_core->brush->mask->width / 2 - 1) != area->x)
area_hclip = CONVOLVE_NCLIP;
else if ((marginx = area->width - paint_core->brush->mask->width - 2) != 0)
area_hclip = CONVOLVE_PCLIP;
marginx = ((gint) paint_core->cur_coords.x -
brush_core->brush->mask->width / 2 - 1);
if (marginx != area->x)
{
area_hclip = CONVOLVE_NCLIP;
}
else
{
marginx = area->width - brush_core->brush->mask->width - 2;
if (marginx != 0)
area_hclip = CONVOLVE_PCLIP;
}
if ((marginy = (gint) paint_core->cur_coords.y - paint_core->brush->mask->height / 2 - 1) != area->y)
area_vclip = CONVOLVE_NCLIP;
else if ((marginy = area->height - paint_core->brush->mask->height - 2) != 0)
area_vclip = CONVOLVE_PCLIP;
marginy = ((gint) paint_core->cur_coords.y -
brush_core->brush->mask->height / 2 - 1);
if (marginy != area->y)
{
area_vclip = CONVOLVE_NCLIP;
}
else
{
marginy = area->height - brush_core->brush->mask->height - 2;
if (marginy != 0)
area_vclip = CONVOLVE_PCLIP;
}
/* Has the TempBuf been clipped by a canvas edge or two? */