Commit 2716d25d authored by Martin Nordholts's avatar Martin Nordholts

Rename brush stuff with 'scale' to 'transform'.

Applied patch from Alexia Death that prepares brushes for
arbitrary transforms by renaming stuff with 'scale' to
'transform'. Takes us one step closer to fixing bug #520078.

* app/core/gimpbrush.[ch]
* app/core/gimpbrushgenerated.c
* app/paint/gimpbrushcore.[ch]
* app/paint/gimpsmudge.c

* app/core/gimpbrush-transform.[ch]: New names of
* app/core/gimpbrush-scale.[ch]

* app/core/Makefile.am: Update.

svn path=/trunk/; revision=27975
parent 431cb58e
2009-02-01 Martin Nordholts <martinn@svn.gnome.org>
Applied patch from Alexia Death that prepares brushes for
arbitrary transforms by renaming stuff with 'scale' to
'transform'. Takes us one step closer to fixing bug #520078.
* app/core/gimpbrush.[ch]
* app/core/gimpbrushgenerated.c
* app/paint/gimpbrushcore.[ch]
* app/paint/gimpsmudge.c
* app/core/gimpbrush-transform.[ch]: New names of
* app/core/gimpbrush-scale.[ch]
* app/core/Makefile.am: Update.
2009-02-01 Martin Nordholts <martinn@svn.gnome.org>
* app/core/gimplayer.[ch]: Add const qualifier to
......
......@@ -54,8 +54,8 @@ libappcore_a_sources = \
gimpbrush-header.h \
gimpbrush-load.c \
gimpbrush-load.h \
gimpbrush-scale.c \
gimpbrush-scale.h \
gimpbrush-transform.c \
gimpbrush-transform.h \
gimpbrushclipboard.c \
gimpbrushclipboard.h \
gimpbrushgenerated.c \
......
......@@ -24,7 +24,7 @@
#include "core-types.h"
#include "gimpbrush.h"
#include "gimpbrush-scale.h"
#include "gimpbrush-transform.h"
#include "base/pixel-region.h"
#include "base/temp-buf.h"
......@@ -48,7 +48,7 @@ static TempBuf * gimp_brush_scale_pixmap_down (TempBuf *pixmap,
/* public functions */
void
gimp_brush_real_scale_size (GimpBrush *brush,
gimp_brush_real_transform_size (GimpBrush *brush,
gdouble scale,
gint *width,
gint *height)
......@@ -58,20 +58,20 @@ gimp_brush_real_scale_size (GimpBrush *brush,
}
TempBuf *
gimp_brush_real_scale_mask (GimpBrush *brush,
gimp_brush_real_transform_mask (GimpBrush *brush,
gdouble scale)
{
gint dest_width;
gint dest_height;
gimp_brush_scale_size (brush, scale, &dest_width, &dest_height);
gimp_brush_transform_size (brush, scale, &dest_width, &dest_height);
if (dest_width <= 0 || dest_height <= 0)
return NULL;
if (scale <= 1.0)
{
/* Downscaling with brush_scale_mask is much faster than with
/* Downscaling with brush_transform_mask is much faster than with
* gimp_brush_scale_buf.
*/
return gimp_brush_scale_mask_down (brush->mask,
......@@ -82,13 +82,13 @@ gimp_brush_real_scale_mask (GimpBrush *brush,
}
TempBuf *
gimp_brush_real_scale_pixmap (GimpBrush *brush,
gimp_brush_real_transform_pixmap (GimpBrush *brush,
gdouble scale)
{
gint dest_width;
gint dest_height;
gimp_brush_scale_size (brush, scale, &dest_width, &dest_height);
gimp_brush_transform_size (brush, scale, &dest_width, &dest_height);
if (dest_width <= 0 || dest_height <= 0)
return NULL;
......
......@@ -23,13 +23,13 @@
/* virtual functions of GimpBrush, don't call directly */
void gimp_brush_real_scale_size (GimpBrush *brush,
void gimp_brush_real_transform_size (GimpBrush *brush,
gdouble scale,
gint *scaled_width,
gint *scaled_height);
TempBuf * gimp_brush_real_scale_mask (GimpBrush *brush,
TempBuf * gimp_brush_real_transform_mask (GimpBrush *brush,
gdouble scale);
TempBuf * gimp_brush_real_scale_pixmap (GimpBrush *brush,
TempBuf * gimp_brush_real_transform_pixmap (GimpBrush *brush,
gdouble scale);
......
......@@ -28,7 +28,7 @@
#include "gimpbrush.h"
#include "gimpbrush-load.h"
#include "gimpbrush-scale.h"
#include "gimpbrush-transform.h"
#include "gimpbrushgenerated.h"
#include "gimpmarshal.h"
#include "gimptagged.h"
......@@ -126,9 +126,9 @@ gimp_brush_class_init (GimpBrushClass *klass)
klass->select_brush = gimp_brush_real_select_brush;
klass->want_null_motion = gimp_brush_real_want_null_motion;
klass->scale_size = gimp_brush_real_scale_size;
klass->scale_mask = gimp_brush_real_scale_mask;
klass->scale_pixmap = gimp_brush_real_scale_pixmap;
klass->transform_size = gimp_brush_real_transform_size;
klass->transform_mask = gimp_brush_real_transform_mask;
klass->transform_pixmap = gimp_brush_real_transform_pixmap;
klass->spacing_changed = NULL;
g_object_class_install_property (object_class, PROP_SPACING,
......@@ -276,13 +276,13 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
if (scale != 1.0)
{
mask_buf = gimp_brush_scale_mask (brush, scale);
mask_buf = gimp_brush_transform_mask (brush, scale);
if (! mask_buf)
mask_buf = temp_buf_new (1, 1, 1, 0, 0, transp);
if (pixmap_buf)
pixmap_buf = gimp_brush_scale_pixmap (brush, scale);
pixmap_buf = gimp_brush_transform_pixmap (brush, scale);
mask_width = mask_buf->width;
mask_height = mask_buf->height;
......@@ -456,7 +456,7 @@ gimp_brush_want_null_motion (GimpBrush *brush,
}
void
gimp_brush_scale_size (GimpBrush *brush,
gimp_brush_transform_size (GimpBrush *brush,
gdouble scale,
gint *width,
gint *height)
......@@ -474,11 +474,11 @@ gimp_brush_scale_size (GimpBrush *brush,
return;
}
GIMP_BRUSH_GET_CLASS (brush)->scale_size (brush, scale, width, height);
GIMP_BRUSH_GET_CLASS (brush)->transform_size (brush, scale, width, height);
}
TempBuf *
gimp_brush_scale_mask (GimpBrush *brush,
gimp_brush_transform_mask (GimpBrush *brush,
gdouble scale)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
......@@ -487,11 +487,11 @@ gimp_brush_scale_mask (GimpBrush *brush,
if (scale == 1.0)
return temp_buf_copy (brush->mask, NULL);
return GIMP_BRUSH_GET_CLASS (brush)->scale_mask (brush, scale);
return GIMP_BRUSH_GET_CLASS (brush)->transform_mask (brush, scale);
}
TempBuf *
gimp_brush_scale_pixmap (GimpBrush *brush,
gimp_brush_transform_pixmap (GimpBrush *brush,
gdouble scale)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
......@@ -501,7 +501,7 @@ gimp_brush_scale_pixmap (GimpBrush *brush,
if (scale == 1.0)
return temp_buf_copy (brush->pixmap, NULL);
return GIMP_BRUSH_GET_CLASS (brush)->scale_pixmap (brush, scale);
return GIMP_BRUSH_GET_CLASS (brush)->transform_pixmap (brush, scale);
}
TempBuf *
......
......@@ -56,13 +56,13 @@ struct _GimpBrushClass
gboolean (* want_null_motion) (GimpBrush *brush,
GimpCoords *last_coords,
GimpCoords *cur_coords);
void (* scale_size) (GimpBrush *brush,
void (* transform_size) (GimpBrush *brush,
gdouble scale,
gint *width,
gint *height);
TempBuf * (* scale_mask) (GimpBrush *brush,
TempBuf * (* transform_mask) (GimpBrush *brush,
gdouble scale);
TempBuf * (* scale_pixmap) (GimpBrush *brush,
TempBuf * (* transform_pixmap) (GimpBrush *brush,
gdouble scale);
/* signals */
......@@ -82,14 +82,14 @@ gboolean gimp_brush_want_null_motion (GimpBrush *brush,
GimpCoords *last_coords,
GimpCoords *cur_coords);
/* Gets width and height of a scaled mask of the brush, for provided scale. */
void gimp_brush_scale_size (GimpBrush *brush,
/* Gets width and height of a transformed mask of the brush, for provided parameters. */
void gimp_brush_transform_size (GimpBrush *brush,
gdouble scale,
gint *width,
gint *height);
TempBuf * gimp_brush_scale_mask (GimpBrush *brush,
TempBuf * gimp_brush_transform_mask (GimpBrush *brush,
gdouble scale);
TempBuf * gimp_brush_scale_pixmap (GimpBrush *brush,
TempBuf * gimp_brush_transform_pixmap (GimpBrush *brush,
gdouble scale);
TempBuf * gimp_brush_get_mask (const GimpBrush *brush);
......
......@@ -63,11 +63,11 @@ static void gimp_brush_generated_dirty (GimpData *data);
static const gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
static void gimp_brush_generated_scale_size (GimpBrush *gbrush,
static void gimp_brush_generated_transform_size(GimpBrush *gbrush,
gdouble scale,
gint *width,
gint *height);
static TempBuf * gimp_brush_generated_scale_mask (GimpBrush *gbrush,
static TempBuf * gimp_brush_generated_transform_mask(GimpBrush *gbrush,
gdouble scale);
static TempBuf * gimp_brush_generated_calc (GimpBrushGenerated *brush,
......@@ -114,8 +114,8 @@ gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
data_class->get_extension = gimp_brush_generated_get_extension;
data_class->duplicate = gimp_brush_generated_duplicate;
brush_class->scale_size = gimp_brush_generated_scale_size;
brush_class->scale_mask = gimp_brush_generated_scale_mask;
brush_class->transform_size = gimp_brush_generated_transform_size;
brush_class->transform_mask = gimp_brush_generated_transform_mask;
g_object_class_install_property (object_class, PROP_SHAPE,
g_param_spec_enum ("shape", NULL, NULL,
......@@ -277,7 +277,7 @@ gimp_brush_generated_duplicate (GimpData *data)
}
static void
gimp_brush_generated_scale_size (GimpBrush *gbrush,
gimp_brush_generated_transform_size (GimpBrush *gbrush,
gdouble scale,
gint *width,
gint *height)
......@@ -301,7 +301,7 @@ gimp_brush_generated_scale_size (GimpBrush *gbrush,
}
static TempBuf *
gimp_brush_generated_scale_mask (GimpBrush *gbrush,
gimp_brush_generated_transform_mask (GimpBrush *gbrush,
gdouble scale)
{
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (gbrush);
......@@ -498,7 +498,7 @@ gimp_brush_generated_calc (GimpBrushGenerated *brush,
return mask;
}
/* This function is shared between gimp_brush_generated_scale_size and
/* This function is shared between gimp_brush_generated_transform_size and
* gimp_brush_generated_calc, therefore we provide a bunch of optional
* pointers for returnvalues.
*/
......
......@@ -101,9 +101,9 @@ static TempBuf * gimp_brush_core_solidify_mask (GimpBrushCore *core,
gdouble y);
static gdouble gimp_brush_core_clamp_brush_scale (GimpBrushCore *core,
gdouble scale);
static TempBuf * gimp_brush_core_scale_mask (GimpBrushCore *core,
static TempBuf * gimp_brush_core_transform_mask (GimpBrushCore *core,
GimpBrush *brush);
static TempBuf * gimp_brush_core_scale_pixmap (GimpBrushCore *core,
static TempBuf * gimp_brush_core_transform_pixmap (GimpBrushCore *core,
GimpBrush *brush);
static void gimp_brush_core_invalidate_cache (GimpBrush *brush,
......@@ -171,23 +171,37 @@ gimp_brush_core_init (GimpBrushCore *core)
core->pressure_brush = NULL;
for (i = 0; i < BRUSH_CORE_SOLID_SUBSAMPLE; i++)
for (j = 0; j < BRUSH_CORE_SOLID_SUBSAMPLE; j++)
core->solid_brushes[i][j] = NULL;
core->last_solid_brush = NULL;
core->solid_cache_invalid = FALSE;
core->scale_brush = NULL;
core->last_scale_brush = NULL;
core->last_scale_width = 0;
core->last_scale_height = 0;
core->transform_brush = NULL;
core->last_transform_brush = NULL;
core->last_transform_width = 0;
core->last_transform_height = 0;
core->last_scale = 1.0;
core->scale_pixmap = NULL;
core->last_scale_pixmap = NULL;
core->last_scale_pixmap_width = 0;
core->last_scale_pixmap_height = 0;
core->transform_pixmap = NULL;
core->last_transform_pixmap = NULL;
core->last_transform_pixmap_width = 0;
core->last_transform_pixmap_height = 0;
core->last_brush_mask = NULL;
core->cache_invalid = FALSE;
core->rand = g_rand_new ();
core->brush_bound_segs = NULL;
core->n_brush_bound_segs = 0;
core->brush_bound_width = 0;
core->brush_bound_height = 0;
for (i = 0; i < BRUSH_CORE_SOLID_SUBSAMPLE; i++)
{
for (j = 0; j < BRUSH_CORE_SOLID_SUBSAMPLE; j++)
{
core->solid_brushes[i][j] = NULL;
}
}
for (i = 0; i < BRUSH_CORE_JITTER_LUTSIZE - 1; ++i)
{
......@@ -200,18 +214,13 @@ gimp_brush_core_init (GimpBrushCore *core)
g_assert (BRUSH_CORE_SUBSAMPLE == KERNEL_SUBSAMPLE);
for (i = 0; i < KERNEL_SUBSAMPLE + 1; i++)
{
for (j = 0; j < KERNEL_SUBSAMPLE + 1; j++)
{
core->kernel_brushes[i][j] = NULL;
}
}
core->last_brush_mask = NULL;
core->cache_invalid = FALSE;
core->rand = g_rand_new ();
core->brush_bound_segs = NULL;
core->n_brush_bound_segs = 0;
core->brush_bound_width = 0;
core->brush_bound_height = 0;
}
static void
......@@ -234,16 +243,16 @@ gimp_brush_core_finalize (GObject *object)
core->solid_brushes[i][j] = NULL;
}
if (core->scale_brush)
if (core->transform_brush)
{
temp_buf_free (core->scale_brush);
core->scale_brush = NULL;
temp_buf_free (core->transform_brush);
core->transform_brush = NULL;
}
if (core->scale_pixmap)
if (core->transform_pixmap)
{
temp_buf_free (core->scale_pixmap);
core->scale_pixmap = NULL;
temp_buf_free (core->transform_pixmap);
core->transform_pixmap = NULL;
}
if (core->rand)
......@@ -694,7 +703,7 @@ gimp_brush_core_get_paint_area (GimpPaintCore *paint_core,
core->scale = gimp_brush_core_clamp_brush_scale (core, core->scale);
gimp_brush_scale_size (core->brush, core->scale, &brush_width, &brush_height);
gimp_brush_transform_size (core->brush, core->scale, &brush_width, &brush_height);
/* adjust the x and y coordinates to the upper left corner of the brush */
x = (gint) floor (paint_core->cur_coords.x) - (brush_width / 2);
......@@ -785,7 +794,7 @@ gimp_brush_core_create_bound_segs (GimpBrushCore *core,
{
scale = gimp_brush_core_clamp_brush_scale (core, scale);
mask = gimp_brush_scale_mask (core->main_brush, scale);
mask = gimp_brush_transform_mask (core->main_brush, scale);
}
if (mask)
......@@ -1278,7 +1287,7 @@ gimp_brush_core_clamp_brush_scale (GimpBrushCore *core,
}
static TempBuf *
gimp_brush_core_scale_mask (GimpBrushCore *core,
gimp_brush_core_transform_mask (GimpBrushCore *core,
GimpBrush *brush)
{
gint width;
......@@ -1290,36 +1299,36 @@ gimp_brush_core_scale_mask (GimpBrushCore *core,
if (core->scale == 1.0)
return brush->mask;
gimp_brush_scale_size (brush, core->scale, &width, &height);
gimp_brush_transform_size (brush, core->scale, &width, &height);
if (! core->cache_invalid &&
core->scale_brush &&
brush->mask == core->last_scale_brush &&
width == core->last_scale_width &&
height == core->last_scale_height &&
core->transform_brush &&
brush->mask == core->last_transform_brush &&
width == core->last_transform_width &&
height == core->last_transform_height &&
core->scale == core->last_scale)
{
return core->scale_brush;
return core->transform_brush;
}
core->last_scale_brush = brush->mask;
core->last_scale_width = width;
core->last_scale_height = height;
core->last_transform_brush = brush->mask;
core->last_transform_width = width;
core->last_transform_height = height;
core->last_scale = core->scale;
if (core->scale_brush)
temp_buf_free (core->scale_brush);
if (core->transform_brush)
temp_buf_free (core->transform_brush);
core->scale_brush = gimp_brush_scale_mask (brush, core->scale);
core->transform_brush = gimp_brush_transform_mask (brush, core->scale);
core->cache_invalid = TRUE;
core->solid_cache_invalid = TRUE;
return core->scale_brush;
return core->transform_brush;
}
static TempBuf *
gimp_brush_core_scale_pixmap (GimpBrushCore *core,
gimp_brush_core_transform_pixmap (GimpBrushCore *core,
GimpBrush *brush)
{
gint width;
......@@ -1331,29 +1340,29 @@ gimp_brush_core_scale_pixmap (GimpBrushCore *core,
if (core->scale == 1.0)
return brush->pixmap;
gimp_brush_scale_size (brush, core->scale, &width, &height);
gimp_brush_transform_size (brush, core->scale, &width, &height);
if (! core->cache_invalid &&
core->scale_pixmap &&
brush->pixmap == core->last_scale_pixmap &&
width == core->last_scale_pixmap_width &&
height == core->last_scale_pixmap_height)
core->transform_pixmap &&
brush->pixmap == core->last_transform_pixmap &&
width == core->last_transform_pixmap_width &&
height == core->last_transform_pixmap_height)
{
return core->scale_pixmap;
return core->transform_pixmap;
}
core->last_scale_pixmap = brush->pixmap;
core->last_scale_pixmap_width = width;
core->last_scale_pixmap_height = height;
core->last_transform_pixmap = brush->pixmap;
core->last_transform_pixmap_width = width;
core->last_transform_pixmap_height = height;
if (core->scale_pixmap)
temp_buf_free (core->scale_pixmap);
if (core->transform_pixmap)
temp_buf_free (core->transform_pixmap);
core->scale_pixmap = gimp_brush_scale_pixmap (brush, core->scale);
core->transform_pixmap = gimp_brush_transform_pixmap (brush, core->scale);
core->cache_invalid = TRUE;
return core->scale_pixmap;
return core->transform_pixmap;
}
TempBuf *
......@@ -1364,7 +1373,7 @@ gimp_brush_core_get_brush_mask (GimpBrushCore *core,
GimpPaintCore *paint_core = GIMP_PAINT_CORE (core);
TempBuf *mask;
mask = gimp_brush_core_scale_mask (core, core->brush);
mask = gimp_brush_core_transform_mask (core, core->brush);
if (! mask)
return NULL;
......@@ -1429,13 +1438,13 @@ gimp_brush_core_color_area_with_pixmap (GimpBrushCore *core,
image = gimp_item_get_image (GIMP_ITEM (drawable));
/* scale the brushes */
pixmap_mask = gimp_brush_core_scale_pixmap (core, core->brush);
pixmap_mask = gimp_brush_core_transform_pixmap (core, core->brush);
if (! pixmap_mask)
return;
if (mode != GIMP_BRUSH_HARD)
brush_mask = gimp_brush_core_scale_mask (core, core->brush);
brush_mask = gimp_brush_core_transform_mask (core, core->brush);
else
brush_mask = NULL;
......
......@@ -53,16 +53,16 @@ struct _GimpBrushCore
TempBuf *last_solid_brush;
gboolean solid_cache_invalid;
TempBuf *scale_brush;
TempBuf *last_scale_brush;
gint last_scale_width;
gint last_scale_height;
TempBuf *transform_brush;
TempBuf *last_transform_brush;
gint last_transform_width;
gint last_transform_height;
gdouble last_scale;
TempBuf *scale_pixmap;
TempBuf *last_scale_pixmap;
gint last_scale_pixmap_width;
gint last_scale_pixmap_height;
TempBuf *transform_pixmap;
TempBuf *last_transform_pixmap;
gint last_transform_pixmap_width;
gint last_transform_pixmap_height;
TempBuf *kernel_brushes[BRUSH_CORE_SUBSAMPLE + 1][BRUSH_CORE_SUBSAMPLE + 1];
......
......@@ -328,7 +328,7 @@ gimp_smudge_brush_coords (GimpPaintCore *paint_core,
gint width;
gint height;
gimp_brush_scale_size (brush_core->brush, brush_core->scale,
gimp_brush_transform_size (brush_core->brush, brush_core->scale,
&width, &height);
/* Note: these are the brush mask size plus a border of 1 pixel */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment