Commit afb57d59 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/paint/gimpbrushcore.c app/paint/gimpdodgeburn.c

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

	* app/paint/gimpbrushcore.c
	* app/paint/gimpdodgeburn.c
	* app/paint/gimppaintcore.[ch]
	* app/tools/gimpairbrushtool.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpconvolvetool.c
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimpinktool.c
	* app/tools/gimppaintbrushtool.c
	* app/tools/gimppenciltool.c
	* app/tools/gimpsmudgetool.c: code review / cleanup.
parent fa079482
2004-05-28 Michael Natterer <mitch@gimp.org>
* app/paint/gimpbrushcore.c
* app/paint/gimpdodgeburn.c
* app/paint/gimppaintcore.[ch]
* app/tools/gimpairbrushtool.c
* app/tools/gimpclonetool.c
* app/tools/gimpconvolvetool.c
* app/tools/gimpdodgeburntool.c
* app/tools/gimpinktool.c
* app/tools/gimppaintbrushtool.c
* app/tools/gimppenciltool.c
* app/tools/gimpsmudgetool.c: code review / cleanup.
2004-05-28 Sven Neumann <sven@gimp.org>
* plug-ins/common/CML_explorer.c
......
This diff is collapsed.
......@@ -222,11 +222,9 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
* paint from this stroke yet)
*/
{
GimpItem *item;
GimpItem *item = GIMP_ITEM (drawable);
gint x1, y1, x2, y2;
item = GIMP_ITEM (drawable);
x1 = CLAMP (area->x, 0, gimp_item_width (item));
y1 = CLAMP (area->y, 0, gimp_item_height (item));
x2 = CLAMP (area->x + area->width, 0, gimp_item_width (item));
......
......@@ -74,13 +74,13 @@ static TempBuf * gimp_paint_core_real_get_paint_area (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *options);
static void paint_mask_to_canvas_tiles (GimpPaintCore *core,
PixelRegion *paint_maskPR,
gdouble paint_opacity);
static void paint_mask_to_canvas_buf (GimpPaintCore *core,
PixelRegion *paint_maskPR,
gdouble paint_opacity);
static void canvas_tiles_to_canvas_buf (GimpPaintCore *core);
static void paint_mask_to_canvas_tiles (GimpPaintCore *core,
PixelRegion *paint_maskPR,
gdouble paint_opacity);
static void paint_mask_to_canvas_buf (GimpPaintCore *core,
PixelRegion *paint_maskPR,
gdouble paint_opacity);
static void canvas_tiles_to_canvas_buf (GimpPaintCore *core);
static GimpObjectClass *parent_class = NULL;
......@@ -139,6 +139,7 @@ gimp_paint_core_init (GimpPaintCore *core)
core->ID = global_core_ID++;
core->distance = 0.0;
core->pixel_dist = 0.0;
core->x1 = 0;
core->y1 = 0;
core->x2 = 0;
......@@ -213,9 +214,9 @@ gimp_paint_core_real_get_paint_area (GimpPaintCore *core,
void
gimp_paint_core_paint (GimpPaintCore *core,
GimpDrawable *drawable,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state,
GimpPaintCoreState paint_state,
guint32 time)
{
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
......@@ -242,7 +243,7 @@ gimp_paint_core_paint (GimpPaintCore *core,
gboolean
gimp_paint_core_start (GimpPaintCore *core,
GimpDrawable *drawable,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpCoords *coords)
{
......@@ -294,7 +295,7 @@ gimp_paint_core_start (GimpPaintCore *core,
void
gimp_paint_core_finish (GimpPaintCore *core,
GimpDrawable *drawable)
GimpDrawable *drawable)
{
GimpPaintInfo *paint_info;
GimpImage *gimage;
......@@ -481,16 +482,16 @@ gimp_paint_core_constrain (GimpPaintCore *core)
* be a superset of those plotted for the longer line.
*/
if (fabs (dx) > fabs (dy))
core->cur_coords.y = core->last_coords.y +
gimp_paint_core_constrain_helper (dx,dy);
core->cur_coords.y = (core->last_coords.y +
gimp_paint_core_constrain_helper (dx,dy));
else
core->cur_coords.x = core->last_coords.x +
gimp_paint_core_constrain_helper (dy,dx);
core->cur_coords.x = (core->last_coords.x +
gimp_paint_core_constrain_helper (dy,dx));
}
void
gimp_paint_core_interpolate (GimpPaintCore *core,
GimpDrawable *drawable,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
guint32 time)
{
......@@ -507,8 +508,8 @@ gimp_paint_core_interpolate (GimpPaintCore *core,
/* protected functions */
TempBuf *
gimp_paint_core_get_paint_area (GimpPaintCore *core,
GimpDrawable *drawable,
gimp_paint_core_get_paint_area (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), NULL);
......@@ -522,20 +523,20 @@ gimp_paint_core_get_paint_area (GimpPaintCore *core,
TempBuf *
gimp_paint_core_get_orig_image (GimpPaintCore *core,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2)
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2)
{
PixelRegion srcPR;
PixelRegion destPR;
Tile *undo_tile;
gboolean release_tile;
gint h;
gint refd;
gint pixelwidth;
gint dwidth;
gint dheight;
gint drawable_width;
gint drawable_height;
guchar *s;
guchar *d;
gpointer pr;
......@@ -545,18 +546,18 @@ gimp_paint_core_get_orig_image (GimpPaintCore *core,
x1, y1,
(x2 - x1), (y2 - y1));
dwidth = gimp_item_width (GIMP_ITEM (drawable));
dheight = gimp_item_height (GIMP_ITEM (drawable));
drawable_width = gimp_item_width (GIMP_ITEM (drawable));
drawable_height = gimp_item_height (GIMP_ITEM (drawable));
x1 = CLAMP (x1, 0, dwidth);
y1 = CLAMP (y1, 0, dheight);
x2 = CLAMP (x2, 0, dwidth);
y2 = CLAMP (y2, 0, dheight);
x1 = CLAMP (x1, 0, drawable_width);
y1 = CLAMP (y1, 0, drawable_height);
x2 = CLAMP (x2, 0, drawable_width);
y2 = CLAMP (y2, 0, drawable_height);
/* configure the pixel regions */
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1,
(x2 - x1), (y2 - y1),
(x2 - x1), (y2 - y1),
FALSE);
destPR.bytes = core->orig_buf->bytes;
......@@ -576,36 +577,38 @@ gimp_paint_core_get_orig_image (GimpPaintCore *core,
/* If the undo tile corresponding to this location is valid, use it */
undo_tile = tile_manager_get_tile (core->undo_tiles,
srcPR.x, srcPR.y,
FALSE, FALSE);
FALSE, FALSE);
if (tile_is_valid (undo_tile))
{
refd = 1;
undo_tile = tile_manager_get_tile (core->undo_tiles,
{
release_tile = TRUE;
undo_tile = tile_manager_get_tile (core->undo_tiles,
srcPR.x, srcPR.y,
TRUE, FALSE);
s = (guchar *) tile_data_pointer (undo_tile, 0, 0) +
srcPR.rowstride * (srcPR.y % TILE_HEIGHT) +
srcPR.bytes * (srcPR.x % TILE_WIDTH); /* dubious... */
}
TRUE, FALSE);
s = ((guchar *) tile_data_pointer (undo_tile, 0, 0) +
srcPR.rowstride * (srcPR.y % TILE_HEIGHT) +
srcPR.bytes * (srcPR.x % TILE_WIDTH)); /* dubious... */
}
else
{
refd = 0;
s = srcPR.data;
}
{
release_tile = FALSE;
s = srcPR.data;
}
d = destPR.data;
pixelwidth = srcPR.w * srcPR.bytes;
h = srcPR.h;
while (h --)
{
memcpy (d, s, pixelwidth);
s += srcPR.rowstride;
d += destPR.rowstride;
}
if (refd)
tile_release (undo_tile, FALSE);
{
memcpy (d, s, pixelwidth);
s += srcPR.rowstride;
d += destPR.rowstride;
}
if (release_tile)
tile_release (undo_tile, FALSE);
}
return core->orig_buf;
......@@ -711,11 +714,11 @@ gimp_paint_core_paste (GimpPaintCore *core,
*/
void
gimp_paint_core_replace (GimpPaintCore *core,
PixelRegion *paint_maskPR,
GimpDrawable *drawable,
gdouble paint_opacity,
gdouble image_opacity,
GimpPaintApplicationMode mode)
PixelRegion *paint_maskPR,
GimpDrawable *drawable,
gdouble paint_opacity,
gdouble image_opacity,
GimpPaintApplicationMode mode)
{
GimpImage *gimage;
PixelRegion srcPR;
......@@ -725,9 +728,9 @@ gimp_paint_core_replace (GimpPaintCore *core,
if (! gimp_drawable_has_alpha (drawable))
{
gimp_paint_core_paste (core, paint_maskPR, drawable,
paint_opacity,
paint_opacity,
image_opacity, GIMP_NORMAL_MODE,
mode);
mode);
return;
}
......@@ -822,9 +825,9 @@ canvas_tiles_to_canvas_buf (GimpPaintCore *core)
srcPR.data = temp_buf_data (core->canvas_buf);
pixel_region_init (&maskPR, core->canvas_tiles,
core->canvas_buf->x,
core->canvas_buf->x,
core->canvas_buf->y,
core->canvas_buf->width,
core->canvas_buf->width,
core->canvas_buf->height,
FALSE);
......@@ -841,9 +844,9 @@ paint_mask_to_canvas_tiles (GimpPaintCore *core,
/* combine the paint mask and the canvas tiles */
pixel_region_init (&srcPR, core->canvas_tiles,
core->canvas_buf->x,
core->canvas_buf->x,
core->canvas_buf->y,
core->canvas_buf->width,
core->canvas_buf->width,
core->canvas_buf->height,
TRUE);
......@@ -893,18 +896,18 @@ gimp_paint_core_validate_undo_tiles (GimpPaintCore *core,
for (i = y; i < (y + h); i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
{
for (j = x; j < (x + w); j += (TILE_WIDTH - (j % TILE_WIDTH)))
{
dest_tile = tile_manager_get_tile (core->undo_tiles, j, i,
{
dest_tile = tile_manager_get_tile (core->undo_tiles, j, i,
FALSE, FALSE);
if (! tile_is_valid (dest_tile))
{
src_tile = tile_manager_get_tile (gimp_drawable_data (drawable),
j, i, TRUE, FALSE);
tile_manager_map_tile (core->undo_tiles, j, i, src_tile);
tile_release (src_tile, FALSE);
}
}
if (! tile_is_valid (dest_tile))
{
src_tile = tile_manager_get_tile (gimp_drawable_data (drawable),
j, i, TRUE, FALSE);
tile_manager_map_tile (core->undo_tiles, j, i, src_tile);
tile_release (src_tile, FALSE);
}
}
}
}
......@@ -922,17 +925,17 @@ gimp_paint_core_validate_canvas_tiles (GimpPaintCore *core,
for (i = y; i < (y + h); i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
{
for (j = x; j < (x + w); j += (TILE_WIDTH - (j % TILE_WIDTH)))
{
tile = tile_manager_get_tile (core->canvas_tiles, j, i,
{
tile = tile_manager_get_tile (core->canvas_tiles, j, i,
FALSE, FALSE);
if (! tile_is_valid (tile))
{
tile = tile_manager_get_tile (core->canvas_tiles, j, i,
if (! tile_is_valid (tile))
{
tile = tile_manager_get_tile (core->canvas_tiles, j, i,
TRUE, TRUE);
memset (tile_data_pointer (tile, 0, 0), 0, tile_size (tile));
tile_release (tile, TRUE);
}
}
memset (tile_data_pointer (tile, 0, 0), 0, tile_size (tile));
tile_release (tile, TRUE);
}
}
}
}
......@@ -71,10 +71,10 @@ struct _GimpPaintCore
gboolean use_pressure; /* look at coords->pressure */
TileManager *undo_tiles; /* tiles which have been modified */
TileManager *canvas_tiles; /* the mask used for painting */
TileManager *canvas_tiles; /* the buffer to paint the mask to */
TempBuf *orig_buf; /* the unmodified drawable pixels */
TempBuf *canvas_buf; /* the buffer to paint to */
TempBuf *canvas_buf; /* the buffer to paint pixels to */
};
......
......@@ -42,8 +42,6 @@ static void gimp_airbrush_tool_init (GimpAirbrushTool *airbrush);
static GtkWidget * gimp_airbrush_options_gui (GimpToolOptions *tool_options);
/* functions */
void
gimp_airbrush_tool_register (GimpToolRegisterCallback callback,
gpointer data)
......
......@@ -86,8 +86,6 @@ static GtkWidget * gimp_clone_options_gui (GimpToolOptions *tool_options);
static GimpPaintToolClass *parent_class;
/* public functions */
void
gimp_clone_tool_register (GimpToolRegisterCallback callback,
gpointer data)
......@@ -134,18 +132,12 @@ gimp_clone_tool_get_type (void)
return tool_type;
}
/* static functions */
static void
gimp_clone_tool_class_init (GimpCloneToolClass *klass)
{
GObjectClass *object_class;
GimpToolClass *tool_class;
GimpDrawToolClass *draw_tool_class;
object_class = G_OBJECT_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -161,11 +153,7 @@ gimp_clone_tool_class_init (GimpCloneToolClass *klass)
static void
gimp_clone_tool_init (GimpCloneTool *clone)
{
GimpTool *tool;
GimpPaintTool *paint_tool;
tool = GIMP_TOOL (clone);
paint_tool = GIMP_PAINT_TOOL (clone);
GimpTool *tool = GIMP_TOOL (clone);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_CLONE_TOOL_CURSOR);
}
......@@ -201,9 +189,7 @@ gimp_clone_tool_button_press (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpPaintTool *paint_tool;
paint_tool = GIMP_PAINT_TOOL (tool);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
GIMP_CLONE (paint_tool->core)->set_source = TRUE;
......@@ -221,9 +207,7 @@ gimp_clone_tool_motion (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpPaintTool *paint_tool;
paint_tool = GIMP_PAINT_TOOL (tool);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
GIMP_CLONE (paint_tool->core)->set_source = TRUE;
......@@ -273,9 +257,7 @@ gimp_clone_tool_cursor_update (GimpTool *tool,
static void
gimp_clone_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool;
tool = GIMP_TOOL (draw_tool);
GimpTool *tool = GIMP_TOOL (draw_tool);
if (gimp_tool_control_is_active (tool->control))
{
......@@ -285,9 +267,7 @@ gimp_clone_tool_draw (GimpDrawTool *draw_tool)
if (draw_tool->gdisp && options->clone_type == GIMP_IMAGE_CLONE)
{
GimpClone *clone;
clone = GIMP_CLONE (GIMP_PAINT_TOOL (draw_tool)->core);
GimpClone *clone = GIMP_CLONE (GIMP_PAINT_TOOL (draw_tool)->core);
if (clone->src_drawable)
{
......
......@@ -19,22 +19,11 @@
#include "config.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "base/pixel-region.h"
#include "base/temp-buf.h"
#include "paint-funcs/paint-funcs.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
#include "paint/gimpconvolveoptions.h"
......@@ -50,13 +39,6 @@
#include "gimp-intl.h"
#define FIELD_COLS 4
#define MIN_BLUR 64 /* (8/9 original pixel) */
#define MAX_BLUR 0.25 /* (1/33 original pixel) */
#define MIN_SHARPEN -512
#define MAX_SHARPEN -64
static void gimp_convolve_tool_class_init (GimpConvolveToolClass *klass);
static void gimp_convolve_tool_init (GimpConvolveTool *tool);
......@@ -76,8 +58,6 @@ static GtkWidget * gimp_convolve_options_gui (GimpToolOptions *options)
static GimpPaintToolClass *parent_class;
/* public functions */
void
gimp_convolve_tool_register (GimpToolRegisterCallback callback,
gpointer data)
......@@ -123,14 +103,10 @@ gimp_convolve_tool_get_type (void)
return tool_type;
}
/* static functions */
static void
gimp_convolve_tool_class_init (GimpConvolveToolClass *klass)
{
GimpToolClass *tool_class;
tool_class = GIMP_TOOL_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -141,11 +117,7 @@ gimp_convolve_tool_class_init (GimpConvolveToolClass *klass)
static void
gimp_convolve_tool_init (GimpConvolveTool *convolve)
{
GimpTool *tool;
GimpPaintTool *paint_tool;
tool = GIMP_TOOL (convolve);
paint_tool = GIMP_PAINT_TOOL (convolve);
GimpTool *tool = GIMP_TOOL (convolve);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_BLUR_TOOL_CURSOR);
......
......@@ -52,7 +52,7 @@ static void gimp_dodge_burn_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp);
static GtkWidget * gimp_dodge_burn_options_gui (GimpToolOptions *tool_options);
static GtkWidget * gimp_dodge_burn_options_gui (GimpToolOptions *tool_options);
static GimpPaintToolClass *parent_class = NULL;
......@@ -106,9 +106,7 @@ gimp_dodge_burn_tool_get_type (void)
static void
gimp_dodge_burn_tool_class_init (GimpDodgeBurnToolClass *klass)
{
GimpToolClass *tool_class;
tool_class = GIMP_TOOL_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -119,11 +117,7 @@ gimp_dodge_burn_tool_class_init (GimpDodgeBurnToolClass *klass)
static void
gimp_dodge_burn_tool_init (GimpDodgeBurnTool *dodgeburn)
{
GimpTool *tool;
GimpPaintTool *paint_tool;
tool = GIMP_TOOL (dodgeburn);
paint_tool = GIMP_PAINT_TOOL (dodgeburn);
GimpTool *tool = GIMP_TOOL (dodgeburn);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_DODGE_TOOL_CURSOR);
......
......@@ -37,8 +37,7 @@
#include "gimp-intl.h"
static void gimp_ink_tool_class_init (GimpInkToolClass *klass);
static void gimp_ink_tool_init (GimpInkTool *tool);
static void gimp_ink_tool_init (GimpInkTool *tool);
void
......@@ -71,29 +70,24 @@ gimp_ink_tool_get_type (void)
static const GTypeInfo tool_info =
{
sizeof (GimpInkToolClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_ink_tool_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpInkTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_ink_tool_init,
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
NULL, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpInkTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_ink_tool_init,
};
tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL,
"GimpInkTool",
"GimpInkTool",
&tool_info, 0);
}
return tool_type;
}
static void
gimp_ink_tool_class_init (GimpInkToolClass *klass)
{
}
static void
gimp_ink_tool_init (GimpInkTool *ink_tool)
{
......
......@@ -38,8 +38,6 @@
static void gimp_paintbrush_tool_init (GimpPaintbrushTool *tool);
/* public functions */
void
gimp_paintbrush_tool_register (GimpToolRegisterCallback callback,
gpointer data)
......@@ -86,9 +84,6 @@ gimp_paintbrush_tool_get_type (void)
return tool_type;
}
/* private functions */
static void
gimp_paintbrush_tool_init (GimpPaintbrushTool *paintbrush)
{
......
......@@ -38,8 +38,6 @@
static void gimp_pencil_tool_init (GimpPencilTool *pencil);
/* functions */
void
gimp_pencil_tool_register (GimpToolRegisterCallback callback,
gpointer data)
......
......@@ -42,8 +42,6 @@ static void gimp_smudge_tool_init (GimpSmudgeTool *tool);
static GtkWidget * gimp_smudge_options_gui (GimpToolOptions *tool_options);
/* global functions */
void
gimp_smudge_tool_register (GimpToolRegisterCallback callback,
gpointer data)
......
......@@ -86,8 +86,6 @@ static GtkWidget * gimp_clone_options_gui (GimpToolOptions *tool_options);
static GimpPaintToolClass *parent_class;