[gimp] app: pass the orig_tiles and their offset to GimpTransformTool::transform()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: pass the orig_tiles and their offset to GimpTransformTool::transform()
- Date: Sat, 26 Mar 2011 17:47:54 +0000 (UTC)
commit ae72971866a2973f5e5d62369f351f340d274c63
Author: Michael Natterer <mitch gimp org>
Date: Sat Mar 26 18:45:58 2011 +0100
app: pass the orig_tiles and their offset to GimpTransformTool::transform()
instead of keeping them around as members. This is another artifact
from ancient times. Also get rid of some more legacy junk
code. Disable more code in GimpTransformToolUndo but keep it around
even though it does nothing at the moment.
app/tools/gimpfliptool.c | 14 +++-
app/tools/gimptransformtool.c | 123 +++++++++++++++---------------------
app/tools/gimptransformtool.h | 7 +-
app/tools/gimptransformtoolundo.c | 10 +++-
4 files changed, 73 insertions(+), 81 deletions(-)
---
diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c
index 2e388f5..0c6b63c 100644
--- a/app/tools/gimpfliptool.c
+++ b/app/tools/gimpfliptool.c
@@ -59,6 +59,9 @@ static void gimp_flip_tool_cursor_update (GimpTool *tool,
static TileManager * gimp_flip_tool_transform (GimpTransformTool *tool,
GimpItem *item,
GimpDisplay *display,
+ TileManager *orig_tiles,
+ gint orig_offset_x,
+ gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y);
@@ -178,6 +181,9 @@ static TileManager *
gimp_flip_tool_transform (GimpTransformTool *trans_tool,
GimpItem *active_item,
GimpDisplay *display,
+ TileManager *orig_tiles,
+ gint orig_offset_x,
+ gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y)
{
@@ -206,7 +212,7 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
gimp_item_linked_flip (active_item, context, options->flip_type, axis,
FALSE);
- if (trans_tool->original)
+ if (orig_tiles)
{
/* this happens when transforming a normal drawable or the
* selection
@@ -214,9 +220,9 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
ret = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (active_item),
context,
- trans_tool->original,
- trans_tool->original_offset_x,
- trans_tool->original_offset_y,
+ orig_tiles,
+ orig_offset_x,
+ orig_offset_y,
options->flip_type, axis,
FALSE,
new_offset_x,
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index b86fc48..599b259 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -125,6 +125,9 @@ static TileManager *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *item,
GimpDisplay *display,
+ TileManager *orig_tiles,
+ gint orig_offset_x,
+ gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y);
@@ -204,7 +207,6 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
GIMP_CURSOR_PRECISION_SUBPIXEL);
tr_tool->function = TRANSFORM_CREATING;
- tr_tool->original = NULL;
for (i = 0; i < TRANS_INFO_SIZE; i++)
{
@@ -259,12 +261,6 @@ gimp_transform_tool_finalize (GObject *object)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (object);
- if (tr_tool->original)
- {
- tile_manager_unref (tr_tool->original);
- tr_tool->original = NULL;
- }
-
if (tr_tool->dialog)
{
gtk_widget_destroy (tr_tool->dialog);
@@ -1143,6 +1139,9 @@ static TileManager *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *active_item,
GimpDisplay *display,
+ TileManager *orig_tiles,
+ gint orig_offset_x,
+ gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y)
{
@@ -1164,7 +1163,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
options->clip,
progress);
- if (tr_tool->original)
+ if (orig_tiles)
{
/* this happens when transforming a normal drawable or the
* selection
@@ -1176,14 +1175,14 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
* so they keep their size
*/
if (GIMP_IS_CHANNEL (active_item) &&
- tile_manager_bpp (tr_tool->original) == 1)
+ tile_manager_bpp (orig_tiles) == 1)
clip_result = GIMP_TRANSFORM_RESIZE_CLIP;
ret = gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (active_item),
context,
- tr_tool->original,
- tr_tool->original_offset_x,
- tr_tool->original_offset_y,
+ orig_tiles,
+ orig_offset_x,
+ orig_offset_y,
&tr_tool->transform,
options->direction,
options->interpolation,
@@ -1221,6 +1220,9 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
GimpContext *context = GIMP_CONTEXT (options);
GimpImage *image = gimp_display_get_image (display);
GimpItem *active_item = NULL;
+ TileManager *orig_tiles;
+ gint orig_offset_x;
+ gint orig_offset_y;
TileManager *new_tiles;
gint new_offset_x;
gint new_offset_y;
@@ -1275,19 +1277,9 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
/* We're going to dirty this image, but we want to keep the tool around */
gimp_tool_control_set_preserve (tool->control, TRUE);
- /* Start a transform undo group */
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
tr_tool->undo_desc);
- /* With the old UI, if original is NULL, then this is the
- * first transformation. In the new UI, it is always so, right?
- */
- g_assert (tr_tool->original == NULL);
-
- /* Copy the current selection to the transform tool's private
- * selection pointer, so that the original source can be repeatedly
- * modified.
- */
tool->drawable = gimp_image_get_active_drawable (image);
switch (options->type)
@@ -1296,16 +1288,18 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
if (! gimp_viewable_get_children (GIMP_VIEWABLE (tool->drawable)) &&
! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
- tr_tool->original = gimp_drawable_transform_cut (tool->drawable,
- context,
- &tr_tool->original_offset_x,
- &tr_tool->original_offset_y,
- &new_layer);
+ orig_tiles = gimp_drawable_transform_cut (tool->drawable,
+ context,
+ &orig_offset_x,
+ &orig_offset_y,
+ &new_layer);
}
break;
case GIMP_TRANSFORM_TYPE_SELECTION:
- tr_tool->original = tile_manager_ref (gimp_drawable_get_tiles (GIMP_DRAWABLE (active_item)));
+ orig_tiles = tile_manager_ref (gimp_drawable_get_tiles (GIMP_DRAWABLE (active_item)));
+ orig_offset_x = 0;
+ orig_offset_y = 0;
break;
case GIMP_TRANSFORM_TYPE_PATH:
@@ -1317,9 +1311,14 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
new_tiles = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->transform (tr_tool,
active_item,
display,
+ orig_tiles,
+ orig_offset_x,
+ orig_offset_y,
&new_offset_x,
&new_offset_y);
+ tile_manager_unref (orig_tiles);
+
switch (options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
@@ -1346,9 +1345,6 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
gimp_drawable_type (GIMP_DRAWABLE (active_item)));
tile_manager_unref (new_tiles);
}
-
- tile_manager_unref (tr_tool->original);
- tr_tool->original = NULL;
break;
case GIMP_TRANSFORM_TYPE_PATH:
@@ -1362,7 +1358,6 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
"transform-tool", tr_tool,
NULL);
- /* push the undo group end */
gimp_image_undo_group_end (image);
/* We're done dirtying the image, and would like to be restarted
@@ -1524,12 +1519,6 @@ gimp_transform_tool_halt (GimpTransformTool *tr_tool)
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tr_tool));
}
- if (tr_tool->original)
- {
- tile_manager_unref (tr_tool->original);
- tr_tool->original = NULL;
- }
-
/* inactivate the tool */
tr_tool->function = TRANSFORM_CREATING;
@@ -1548,44 +1537,34 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
GimpImage *image = gimp_display_get_image (display);
/* find the boundaries */
- if (tr_tool->original)
- {
- tr_tool->x1 = tr_tool->original_offset_x;
- tr_tool->y1 = tr_tool->original_offset_y;
- tr_tool->x2 = tr_tool->x1 + tile_manager_width (tr_tool->original);
- tr_tool->y2 = tr_tool->y1 + tile_manager_height (tr_tool->original);
- }
- else
+ switch (options->type)
{
- switch (options->type)
- {
- case GIMP_TRANSFORM_TYPE_LAYER:
- {
- GimpDrawable *drawable;
- gint offset_x;
- gint offset_y;
-
- drawable = gimp_image_get_active_drawable (image);
+ case GIMP_TRANSFORM_TYPE_LAYER:
+ {
+ GimpDrawable *drawable;
+ gint offset_x;
+ gint offset_y;
- gimp_item_get_offset (GIMP_ITEM (drawable), &offset_x, &offset_y);
+ drawable = gimp_image_get_active_drawable (image);
- gimp_item_mask_bounds (GIMP_ITEM (drawable),
- &tr_tool->x1, &tr_tool->y1,
- &tr_tool->x2, &tr_tool->y2);
- tr_tool->x1 += offset_x;
- tr_tool->y1 += offset_y;
- tr_tool->x2 += offset_x;
- tr_tool->y2 += offset_y;
- }
- break;
+ gimp_item_get_offset (GIMP_ITEM (drawable), &offset_x, &offset_y);
- case GIMP_TRANSFORM_TYPE_SELECTION:
- case GIMP_TRANSFORM_TYPE_PATH:
- gimp_channel_bounds (gimp_image_get_mask (image),
+ gimp_item_mask_bounds (GIMP_ITEM (drawable),
&tr_tool->x1, &tr_tool->y1,
&tr_tool->x2, &tr_tool->y2);
- break;
- }
+ tr_tool->x1 += offset_x;
+ tr_tool->y1 += offset_y;
+ tr_tool->x2 += offset_x;
+ tr_tool->y2 += offset_y;
+ }
+ break;
+
+ case GIMP_TRANSFORM_TYPE_SELECTION:
+ case GIMP_TRANSFORM_TYPE_PATH:
+ gimp_channel_bounds (gimp_image_get_mask (image),
+ &tr_tool->x1, &tr_tool->y1,
+ &tr_tool->x2, &tr_tool->y2);
+ break;
}
tr_tool->cx = (gdouble) (tr_tool->x1 + tr_tool->x2) / 2.0;
diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h
index 4012281..e466223 100644
--- a/app/tools/gimptransformtool.h
+++ b/app/tools/gimptransformtool.h
@@ -72,10 +72,6 @@ struct _GimpTransformTool
TransInfo old_trans_info; /* for resetting everything */
TransInfo prev_trans_info; /* for cancelling a drag operation */
- TileManager *original; /* pointer to original tiles */
- gint original_offset_x;
- gint original_offset_y;
-
TransformAction function; /* current tool activity */
gboolean use_grid; /* does the tool use the grid */
@@ -120,6 +116,9 @@ struct _GimpTransformToolClass
TileManager * (* transform) (GimpTransformTool *tool,
GimpItem *item,
GimpDisplay *display,
+ TileManager *orig_tiles,
+ gint orig_offset_x,
+ gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y);
};
diff --git a/app/tools/gimptransformtoolundo.c b/app/tools/gimptransformtoolundo.c
index d6aa80a..726a61a 100644
--- a/app/tools/gimptransformtoolundo.c
+++ b/app/tools/gimptransformtoolundo.c
@@ -95,7 +95,7 @@ gimp_transform_tool_undo_constructed (GObject *object)
g_assert (GIMP_IS_TRANSFORM_TOOL (transform_tool_undo->transform_tool));
- transform_tool = GIMP_TRANSFORM_TOOL (transform_tool_undo->transform_tool);
+ transform_tool = transform_tool_undo->transform_tool;
for (i = 0; i < TRANS_INFO_SIZE; i++)
transform_tool_undo->trans_info[i] = transform_tool->old_trans_info[i];
@@ -161,7 +161,9 @@ gimp_transform_tool_undo_pop (GimpUndo *undo,
if (transform_tool_undo->transform_tool)
{
GimpTransformTool *transform_tool;
+#if 0
TileManager *temp;
+#endif
gdouble d;
gint i;
@@ -175,12 +177,15 @@ gimp_transform_tool_undo_pop (GimpUndo *undo,
transform_tool->trans_info[i] = d;
}
+#if 0
/* swap the original buffer--the source buffer for repeated transforms
*/
temp = transform_tool_undo->original;
transform_tool_undo->original = transform_tool->original;
transform_tool->original = temp;
+#endif
+#if 0
/* If we're re-implementing the first transform, reactivate tool */
if (undo_mode == GIMP_UNDO_MODE_REDO && transform_tool->original)
{
@@ -188,6 +193,7 @@ gimp_transform_tool_undo_pop (GimpUndo *undo,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (transform_tool));
}
+#endif
}
}
@@ -204,11 +210,13 @@ gimp_transform_tool_undo_free (GimpUndo *undo,
transform_tool_undo->transform_tool = NULL;
}
+#if 0
if (transform_tool_undo->original)
{
tile_manager_unref (transform_tool_undo->original);
transform_tool_undo->original = NULL;
}
+#endif
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]