added "gboolean clip_result" to GimpItem::flip().

2003-05-13  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpitem.[ch]: added "gboolean clip_result" to
	GimpItem::flip().

	* app/vectors/gimpvectors.c
	* app/tools/gimpfliptool.c: changed accordingly.

	* app/core/gimpdrawable.c: implement GimpItem::flip() and
	GimpItem::transform().

	* app/core/gimpchannel.c
	* app/core/gimplayer.c: chain up in flip() and transform() and do
	only the layer/channel specific stuff here.

	* app/core/gimpdrawable-transform.[ch]: fixed indentation.
	(gimp_drawable_transform_tiles_flip): added "gboolean clip_result"
	and warn that it is not yet implemented.
	(gimp_drawable_transform_tiles_affine): when transforming a
	channel set bg_color to transparent. Clip channels (but not layer
	masks) only if the passed tiles have bpp == 1 (the channel is
	unfloated).
	(gimp_drawable_transform_affine): clip all unfloated channels.

	* app/core/gimpitem-linked.[ch]: added gimp_item_linked_get_list()
	utility function to avoind iterating all layers/channels/vectors
	in all functions.

	* app/tools/gimptransformtool.c: clip all unfloated channels.

	The clipping fixes above together fix bug #112858.
This commit is contained in:
Michael Natterer 2003-05-13 13:57:11 +00:00 committed by Michael Natterer
parent 6745446916
commit a4395cead9
15 changed files with 322 additions and 300 deletions

View File

@ -1,3 +1,35 @@
2003-05-13 Michael Natterer <mitch@gimp.org>
* app/core/gimpitem.[ch]: added "gboolean clip_result" to
GimpItem::flip().
* app/vectors/gimpvectors.c
* app/tools/gimpfliptool.c: changed accordingly.
* app/core/gimpdrawable.c: implement GimpItem::flip() and
GimpItem::transform().
* app/core/gimpchannel.c
* app/core/gimplayer.c: chain up in flip() and transform() and do
only the layer/channel specific stuff here.
* app/core/gimpdrawable-transform.[ch]: fixed indentation.
(gimp_drawable_transform_tiles_flip): added "gboolean clip_result"
and warn that it is not yet implemented.
(gimp_drawable_transform_tiles_affine): when transforming a
channel set bg_color to transparent. Clip channels (but not layer
masks) only if the passed tiles have bpp == 1 (the channel is
unfloated).
(gimp_drawable_transform_affine): clip all unfloated channels.
* app/core/gimpitem-linked.[ch]: added gimp_item_linked_get_list()
utility function to avoind iterating all layers/channels/vectors
in all functions.
* app/tools/gimptransformtool.c: clip all unfloated channels.
The clipping fixes above together fix bug #112858.
2003-05-13 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.c (gimp_image_mask_extract):

View File

@ -106,13 +106,12 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
GimpImage *gimage;
PixelRegion destPR;
TileManager *tiles;
GimpMatrix3 m;
GimpMatrix3 im;
PixelSurround surround;
GimpImage *gimage;
PixelRegion destPR;
TileManager *tiles;
GimpMatrix3 m;
GimpMatrix3 im;
PixelSurround surround;
gint x1, y1, x2, y2; /* target bounding box */
gint x, y; /* target coordinates */
@ -155,7 +154,6 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* Get the background color */
gimp_image_get_background (gimage, drawable, bg_color);
switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)))
{
case GIMP_RGB:
@ -177,16 +175,15 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
break;
}
/* enable rotating un-floated non-layers */
if (tile_manager_bpp (float_tiles) == 1)
{
bg_color[0] = OPAQUE_OPACITY;
/* "Outside" a channel is transparency, not the bg color */
if (GIMP_IS_CHANNEL (drawable))
bg_color[0] = TRANSPARENT_OPACITY;
/* setting alpha = 0 will cause the channel's value to be treated
* as alpha and the color channel loops never to be entered
*/
alpha = 0;
}
/* setting alpha = 0 will cause the channel's value to be treated
* as alpha and the color channel loops never to be entered
*/
if (tile_manager_bpp (float_tiles) == 1)
alpha = 0;
if (direction == GIMP_TRANSFORM_BACKWARD)
{
@ -203,19 +200,16 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
gimp_matrix3_invert (matrix, m);
}
#ifdef __GNUC__
#warning FIXME: path_transform_current_path
#endif
#if 0
path_transform_current_path (gimage, matrix, FALSE);
#endif
tile_manager_get_offsets (float_tiles, &u1, &v1);
u2 = u1 + tile_manager_width (float_tiles);
v2 = v1 + tile_manager_height (float_tiles);
/* Always clip unfloated channels since they must keep their size */
if (G_TYPE_FROM_INSTANCE (drawable) == GIMP_TYPE_CHANNEL && alpha == 0)
clip_result = TRUE;
/* Find the bounding coordinates of target */
if (alpha == 0 || clip_result)
if (clip_result)
{
x1 = u1;
y1 = v1;
@ -242,9 +236,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
}
/* Get the new temporary buffer for the transformed result */
tiles = tile_manager_new ((x2 - x1), (y2 - y1),
tile_manager_bpp (float_tiles));
pixel_region_init (&destPR, tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
tiles = tile_manager_new (x2 - x1, y2 - y1, tile_manager_bpp (float_tiles));
pixel_region_init (&destPR, tiles, 0, 0, x2 - x, y2 - y1, TRUE);
tile_manager_set_offsets (tiles, x1, y1);
/* initialise the pixel_surround and pixel_cache accessors */
@ -269,8 +262,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
vinc = m[1][0];
winc = m[2][0];
coords = ((interpolation_type != GIMP_INTERPOLATION_NONE) ?
5 : 1);
coords = (interpolation_type != GIMP_INTERPOLATION_NONE) ? 5 : 1;
/* these loops could be rearranged, depending on which bit of code
* you'd most like to write more than once.
@ -336,9 +328,9 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
if (interpolation_type == GIMP_INTERPOLATION_NONE)
{
guchar color[MAX_CHANNELS];
gint iu = RINT (u[0]);
gint iv = RINT (v[0]);
gint b;
gint iu = RINT (u[0]);
gint iv = RINT (v[0]);
gint b;
if (iu >= u1 && iu < u2 &&
iv >= v1 && iv < v2)
@ -435,7 +427,8 @@ TileManager *
gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
TileManager *orig,
GimpOrientationType flip_type,
gdouble axis)
gdouble axis,
gboolean clip_result)
{
TileManager *new;
PixelRegion srcPR, destPR;
@ -449,6 +442,16 @@ gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (orig != NULL, NULL);
#ifdef __GNUC__
#warning FIXME: implement clip_result for flipping
#endif
if (clip_result)
{
g_print ("FIXME: implement clip_result for gimp_drawable_transform_tiles_flip()\n");
return NULL;
}
orig_width = tile_manager_width (orig);
orig_height = tile_manager_height (orig);
orig_bpp = tile_manager_bpp (orig);
@ -530,6 +533,10 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
{
TileManager *new_tiles;
/* always clip unfloated channels so they keep their size */
if (GIMP_IS_CHANNEL (drawable) && tile_manager_bpp (float_tiles) == 1)
clip_result = TRUE;
/* transform the buffer */
new_tiles = gimp_drawable_transform_tiles_affine (drawable,
float_tiles,
@ -602,7 +609,7 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
/* transform the buffer */
new_tiles = gimp_drawable_transform_tiles_flip (drawable, float_tiles,
flip_type, axis);
flip_type, axis, FALSE);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
@ -680,12 +687,12 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimp_layer_new_from_tiles (tiles,
gimage,
gimp_drawable_type_with_alpha (drawable),
_("Transformation"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
_("Transformation"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer)
{
g_warning ("%s: gimp_layer_new_frome_tiles() failed",
G_GNUC_FUNCTION);
G_GNUC_FUNCTION);
return FALSE;
}

View File

@ -43,7 +43,6 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpchannel.h"
#include "gimpdrawable-transform.h"
#include "gimplayer.h"
#include "gimpparasitelist.h"
@ -77,7 +76,8 @@ static void gimp_channel_resize (GimpItem *item,
gint offy);
static void gimp_channel_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis);
gdouble axis,
gboolean flip_result);
static void gimp_channel_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
@ -397,18 +397,11 @@ gimp_channel_resize (GimpItem *item,
static void
gimp_channel_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis)
gdouble axis,
gboolean clip_result)
{
#ifdef __GNUC__
#warning FIXME: implement clip_result for flipping
#endif
g_print ("FIXME: implement channel flipping\n");
#if 0
GimpChannel *channel;
GimpImage *gimage;
TileManager *tiles;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
@ -416,19 +409,15 @@ gimp_channel_flip (GimpItem *item,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Flip Channel"));
tiles = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (channel),
GIMP_DRAWABLE (channel)->tiles,
flip_type, axis,
TRUE /* always clip_result */);
if (G_TYPE_FROM_INSTANCE (item) == GIMP_TYPE_CHANNEL)
clip_result = TRUE;
if (tiles)
gimp_drawable_transform_paste (GIMP_DRAWABLE (channel), tiles, FALSE);
GIMP_ITEM_CLASS (parent_class)->flip (item, flip_type, axis, clip_result);
gimp_image_undo_group_end (gimage);
/* bounds are now unknown */
channel->bounds_known = FALSE;
#endif
}
static void
@ -442,7 +431,6 @@ gimp_channel_transform (GimpItem *item,
{
GimpChannel *channel;
GimpImage *gimage;
TileManager *tiles;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
@ -450,16 +438,12 @@ gimp_channel_transform (GimpItem *item,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Transform Channel"));
tiles = gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (channel),
GIMP_DRAWABLE (channel)->tiles,
matrix, direction,
interpolation_type,
TRUE, /* always clip_result */
progress_callback,
progress_data);
if (G_TYPE_FROM_INSTANCE (item) == GIMP_TYPE_CHANNEL)
clip_result = TRUE;
if (tiles)
gimp_drawable_transform_paste (GIMP_DRAWABLE (channel), tiles, FALSE);
GIMP_ITEM_CLASS (parent_class)->transform (item, matrix, direction,
interpolation_type, clip_result,
progress_callback, progress_data);
gimp_image_undo_group_end (gimage);

View File

@ -43,7 +43,6 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpchannel.h"
#include "gimpdrawable-transform.h"
#include "gimplayer.h"
#include "gimpparasitelist.h"
@ -77,7 +76,8 @@ static void gimp_channel_resize (GimpItem *item,
gint offy);
static void gimp_channel_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis);
gdouble axis,
gboolean flip_result);
static void gimp_channel_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
@ -397,18 +397,11 @@ gimp_channel_resize (GimpItem *item,
static void
gimp_channel_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis)
gdouble axis,
gboolean clip_result)
{
#ifdef __GNUC__
#warning FIXME: implement clip_result for flipping
#endif
g_print ("FIXME: implement channel flipping\n");
#if 0
GimpChannel *channel;
GimpImage *gimage;
TileManager *tiles;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
@ -416,19 +409,15 @@ gimp_channel_flip (GimpItem *item,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Flip Channel"));
tiles = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (channel),
GIMP_DRAWABLE (channel)->tiles,
flip_type, axis,
TRUE /* always clip_result */);
if (G_TYPE_FROM_INSTANCE (item) == GIMP_TYPE_CHANNEL)
clip_result = TRUE;
if (tiles)
gimp_drawable_transform_paste (GIMP_DRAWABLE (channel), tiles, FALSE);
GIMP_ITEM_CLASS (parent_class)->flip (item, flip_type, axis, clip_result);
gimp_image_undo_group_end (gimage);
/* bounds are now unknown */
channel->bounds_known = FALSE;
#endif
}
static void
@ -442,7 +431,6 @@ gimp_channel_transform (GimpItem *item,
{
GimpChannel *channel;
GimpImage *gimage;
TileManager *tiles;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (item);
@ -450,16 +438,12 @@ gimp_channel_transform (GimpItem *item,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Transform Channel"));
tiles = gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (channel),
GIMP_DRAWABLE (channel)->tiles,
matrix, direction,
interpolation_type,
TRUE, /* always clip_result */
progress_callback,
progress_data);
if (G_TYPE_FROM_INSTANCE (item) == GIMP_TYPE_CHANNEL)
clip_result = TRUE;
if (tiles)
gimp_drawable_transform_paste (GIMP_DRAWABLE (channel), tiles, FALSE);
GIMP_ITEM_CLASS (parent_class)->transform (item, matrix, direction,
interpolation_type, clip_result,
progress_callback, progress_data);
gimp_image_undo_group_end (gimage);

View File

@ -106,13 +106,12 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
GimpImage *gimage;
PixelRegion destPR;
TileManager *tiles;
GimpMatrix3 m;
GimpMatrix3 im;
PixelSurround surround;
GimpImage *gimage;
PixelRegion destPR;
TileManager *tiles;
GimpMatrix3 m;
GimpMatrix3 im;
PixelSurround surround;
gint x1, y1, x2, y2; /* target bounding box */
gint x, y; /* target coordinates */
@ -155,7 +154,6 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* Get the background color */
gimp_image_get_background (gimage, drawable, bg_color);
switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)))
{
case GIMP_RGB:
@ -177,16 +175,15 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
break;
}
/* enable rotating un-floated non-layers */
if (tile_manager_bpp (float_tiles) == 1)
{
bg_color[0] = OPAQUE_OPACITY;
/* "Outside" a channel is transparency, not the bg color */
if (GIMP_IS_CHANNEL (drawable))
bg_color[0] = TRANSPARENT_OPACITY;
/* setting alpha = 0 will cause the channel's value to be treated
* as alpha and the color channel loops never to be entered
*/
alpha = 0;
}
/* setting alpha = 0 will cause the channel's value to be treated
* as alpha and the color channel loops never to be entered
*/
if (tile_manager_bpp (float_tiles) == 1)
alpha = 0;
if (direction == GIMP_TRANSFORM_BACKWARD)
{
@ -203,19 +200,16 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
gimp_matrix3_invert (matrix, m);
}
#ifdef __GNUC__
#warning FIXME: path_transform_current_path
#endif
#if 0
path_transform_current_path (gimage, matrix, FALSE);
#endif
tile_manager_get_offsets (float_tiles, &u1, &v1);
u2 = u1 + tile_manager_width (float_tiles);
v2 = v1 + tile_manager_height (float_tiles);
/* Always clip unfloated channels since they must keep their size */
if (G_TYPE_FROM_INSTANCE (drawable) == GIMP_TYPE_CHANNEL && alpha == 0)
clip_result = TRUE;
/* Find the bounding coordinates of target */
if (alpha == 0 || clip_result)
if (clip_result)
{
x1 = u1;
y1 = v1;
@ -242,9 +236,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
}
/* Get the new temporary buffer for the transformed result */
tiles = tile_manager_new ((x2 - x1), (y2 - y1),
tile_manager_bpp (float_tiles));
pixel_region_init (&destPR, tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
tiles = tile_manager_new (x2 - x1, y2 - y1, tile_manager_bpp (float_tiles));
pixel_region_init (&destPR, tiles, 0, 0, x2 - x, y2 - y1, TRUE);
tile_manager_set_offsets (tiles, x1, y1);
/* initialise the pixel_surround and pixel_cache accessors */
@ -269,8 +262,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
vinc = m[1][0];
winc = m[2][0];
coords = ((interpolation_type != GIMP_INTERPOLATION_NONE) ?
5 : 1);
coords = (interpolation_type != GIMP_INTERPOLATION_NONE) ? 5 : 1;
/* these loops could be rearranged, depending on which bit of code
* you'd most like to write more than once.
@ -336,9 +328,9 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
if (interpolation_type == GIMP_INTERPOLATION_NONE)
{
guchar color[MAX_CHANNELS];
gint iu = RINT (u[0]);
gint iv = RINT (v[0]);
gint b;
gint iu = RINT (u[0]);
gint iv = RINT (v[0]);
gint b;
if (iu >= u1 && iu < u2 &&
iv >= v1 && iv < v2)
@ -435,7 +427,8 @@ TileManager *
gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
TileManager *orig,
GimpOrientationType flip_type,
gdouble axis)
gdouble axis,
gboolean clip_result)
{
TileManager *new;
PixelRegion srcPR, destPR;
@ -449,6 +442,16 @@ gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (orig != NULL, NULL);
#ifdef __GNUC__
#warning FIXME: implement clip_result for flipping
#endif
if (clip_result)
{
g_print ("FIXME: implement clip_result for gimp_drawable_transform_tiles_flip()\n");
return NULL;
}
orig_width = tile_manager_width (orig);
orig_height = tile_manager_height (orig);
orig_bpp = tile_manager_bpp (orig);
@ -530,6 +533,10 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
{
TileManager *new_tiles;
/* always clip unfloated channels so they keep their size */
if (GIMP_IS_CHANNEL (drawable) && tile_manager_bpp (float_tiles) == 1)
clip_result = TRUE;
/* transform the buffer */
new_tiles = gimp_drawable_transform_tiles_affine (drawable,
float_tiles,
@ -602,7 +609,7 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
/* transform the buffer */
new_tiles = gimp_drawable_transform_tiles_flip (drawable, float_tiles,
flip_type, axis);
flip_type, axis, FALSE);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
@ -680,12 +687,12 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimp_layer_new_from_tiles (tiles,
gimage,
gimp_drawable_type_with_alpha (drawable),
_("Transformation"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
_("Transformation"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer)
{
g_warning ("%s: gimp_layer_new_frome_tiles() failed",
G_GNUC_FUNCTION);
G_GNUC_FUNCTION);
return FALSE;
}

View File

@ -44,7 +44,8 @@ TileManager * gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
TileManager * gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
TileManager *orig,
GimpOrientationType flip_type,
gdouble axis);
gdouble axis,
gboolean clip_result);
gboolean gimp_drawable_transform_affine (GimpDrawable *drawable,
GimpMatrix3 matrix,

View File

@ -41,6 +41,7 @@
#include "gimpcontext.h"
#include "gimpdrawable.h"
#include "gimpdrawable-preview.h"
#include "gimpdrawable-transform.h"
#include "gimpimage.h"
#include "gimpimage-mask.h"
#include "gimpimage-undo-push.h"
@ -85,6 +86,17 @@ static void gimp_drawable_resize (GimpItem *item,
gint new_height,
gint offset_x,
gint offset_y);
static void gimp_drawable_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result);
static void gimp_drawable_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
/* private variables */
@ -158,6 +170,8 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
item_class->duplicate = gimp_drawable_duplicate;
item_class->scale = gimp_drawable_scale;
item_class->resize = gimp_drawable_resize;
item_class->flip = gimp_drawable_flip;
item_class->transform = gimp_drawable_transform;
klass->visibility_changed = NULL;
}
@ -454,6 +468,70 @@ gimp_drawable_resize (GimpItem *item,
gimp_viewable_size_changed (GIMP_VIEWABLE (drawable));
}
static void
gimp_drawable_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result)
{
GimpDrawable *drawable;
TileManager *tiles;
gint off_x, off_y;
gint old_off_x, old_off_y;
drawable = GIMP_DRAWABLE (item);
gimp_item_offsets (item, &off_x, &off_y);
tile_manager_get_offsets (drawable->tiles, &old_off_x, &old_off_y);
tile_manager_set_offsets (drawable->tiles, off_x, off_y);
tiles = gimp_drawable_transform_tiles_flip (drawable,
drawable->tiles,
flip_type, axis,
clip_result);
tile_manager_set_offsets (drawable->tiles, old_off_x, old_off_y);
if (tiles)
gimp_drawable_transform_paste (drawable, tiles, FALSE);
}
static void
gimp_drawable_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
GimpDrawable *drawable;
TileManager *tiles;
gint off_x, off_y;
gint old_off_x, old_off_y;
drawable = GIMP_DRAWABLE (item);
gimp_item_offsets (item, &off_x, &off_y);
tile_manager_get_offsets (drawable->tiles, &old_off_x, &old_off_y);
tile_manager_set_offsets (drawable->tiles, off_x, off_y);
tiles = gimp_drawable_transform_tiles_affine (drawable,
drawable->tiles,
matrix, direction,
interpolation_type,
clip_result,
progress_callback,
progress_data);
tile_manager_set_offsets (drawable->tiles, old_off_x, old_off_y);
if (tiles)
gimp_drawable_transform_paste (drawable, tiles, FALSE);
}
void
gimp_drawable_configure (GimpDrawable *drawable,
GimpImage *gimage,

View File

@ -28,6 +28,14 @@
#include "gimplist.h"
/* local function prototypes */
static GList * gimp_item_linked_get_list (GimpImage *gimage,
GimpItem *item);
/* public functions */
void
gimp_item_linked_translate (GimpItem *item,
gint offset_x,
@ -35,90 +43,49 @@ gimp_item_linked_translate (GimpItem *item,
gboolean push_undo)
{
GimpImage *gimage;
GimpItem *linked_item;
GList *linked_list;
GList *list;
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
gimage = gimp_item_get_image (item);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
linked_item = (GimpItem *) list->data;
linked_list = gimp_item_linked_get_list (gimage, item);
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_translate (linked_item, offset_x, offset_y, push_undo);
}
for (list = linked_list; list; list = g_list_next (list))
gimp_item_translate (GIMP_ITEM (list->data),
offset_x, offset_y, push_undo);
for (list = GIMP_LIST (gimage->channels)->list;
list;
list = g_list_next (list))
{
linked_item = (GimpItem *) list->data;
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_translate (linked_item, offset_x, offset_y, push_undo);
}
for (list = GIMP_LIST (gimage->vectors)->list;
list;
list = g_list_next (list))
{
linked_item = (GimpItem *) list->data;
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_translate (linked_item, offset_x, offset_y, push_undo);
}
g_list_free (linked_list);
}
void
gimp_item_linked_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis)
gdouble axis,
gboolean clip_result)
{
GimpImage *gimage;
GimpItem *linked_item;
GList *linked_list;
GList *list;
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
gimage = gimp_item_get_image (item);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
linked_item = (GimpItem *) list->data;
linked_list = gimp_item_linked_get_list (gimage, item);
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_flip (linked_item, flip_type, axis);
}
for (list = linked_list; list; list = g_list_next (list))
gimp_item_flip (GIMP_ITEM (list->data),
flip_type, axis, clip_result);
for (list = GIMP_LIST (gimage->channels)->list;
list;
list = g_list_next (list))
{
linked_item = (GimpItem *) list->data;
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_flip (linked_item, flip_type, axis);
}
for (list = GIMP_LIST (gimage->vectors)->list;
list;
list = g_list_next (list))
{
linked_item = (GimpItem *) list->data;
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_flip (linked_item, flip_type, axis);
}
g_list_free (linked_list);
}
void
@ -131,15 +98,38 @@ gimp_item_linked_transform (GimpItem *item,
gpointer progress_data)
{
GimpImage *gimage;
GimpItem *linked_item;
GList *linked_list;
GList *list;
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
gimage = gimp_item_get_image (item);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
linked_list = gimp_item_linked_get_list (gimage, item);
for (list = linked_list; list; list = g_list_next (list))
gimp_item_transform (GIMP_ITEM (list->data),
matrix, direction,
interpolation_type, clip_result,
progress_callback, progress_data);
g_list_free (linked_list);
}
/* private functions */
static GList *
gimp_item_linked_get_list (GimpImage *gimage,
GimpItem *item)
{
GimpItem *linked_item;
GList *list;
GList *linked_list = NULL;
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
@ -147,9 +137,7 @@ gimp_item_linked_transform (GimpItem *item,
linked_item = (GimpItem *) list->data;
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_transform (linked_item, matrix, direction,
interpolation_type, clip_result,
progress_callback, progress_data);
linked_list = g_list_prepend (linked_list, linked_item);
}
for (list = GIMP_LIST (gimage->channels)->list;
@ -159,9 +147,7 @@ gimp_item_linked_transform (GimpItem *item,
linked_item = (GimpItem *) list->data;
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_transform (linked_item, matrix, direction,
interpolation_type, clip_result,
progress_callback, progress_data);
linked_list = g_list_prepend (linked_list, linked_item);
}
for (list = GIMP_LIST (gimage->vectors)->list;
@ -171,8 +157,8 @@ gimp_item_linked_transform (GimpItem *item,
linked_item = (GimpItem *) list->data;
if (linked_item != item && gimp_item_get_linked (linked_item))
gimp_item_transform (linked_item, matrix, direction,
interpolation_type, clip_result,
progress_callback, progress_data);
linked_list = g_list_prepend (linked_list, linked_item);
}
return g_list_reverse (linked_list);
}

View File

@ -26,7 +26,8 @@ void gimp_item_linked_translate (GimpItem *item,
gboolean push_undo);
void gimp_item_linked_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis);
gdouble axis,
gboolean clip_result);
void gimp_item_linked_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,

View File

@ -683,7 +683,8 @@ gimp_item_resize (GimpItem *item,
void
gimp_item_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis)
gdouble axis,
gboolean clip_result)
{
GimpItemClass *item_class;
@ -691,7 +692,7 @@ gimp_item_flip (GimpItem *item,
item_class = GIMP_ITEM_GET_CLASS (item);
item_class->flip (item, flip_type, axis);
item_class->flip (item, flip_type, axis, clip_result);
}
void

View File

@ -82,7 +82,8 @@ struct _GimpItemClass
gint offset_y);
void (* flip) (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis);
gdouble axis,
gboolean clip_result);
void (* transform) (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
@ -152,7 +153,8 @@ void gimp_item_resize_to_image (GimpItem *item);
void gimp_item_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis);
gdouble axis,
gboolean flip_result);
void gimp_item_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,

View File

@ -35,7 +35,6 @@
#include "paint-funcs/paint-funcs.h"
#include "gimpdrawable-invert.h"
#include "gimpdrawable-transform.h"
#include "gimpcontainer.h"
#include "gimpimage.h"
#include "gimpimage-convert.h"
@ -92,7 +91,8 @@ static void gimp_layer_resize (GimpItem *item,
gint offset_y);
static void gimp_layer_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis);
gdouble axis,
gboolean clip_result);
static void gimp_layer_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
@ -474,13 +474,11 @@ gimp_layer_resize (GimpItem *item,
static void
gimp_layer_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis)
gdouble axis,
gboolean clip_result)
{
GimpLayer *layer;
GimpImage *gimage;
TileManager *tiles;
gint off_x, off_y;
gint old_off_x, old_off_y;
GimpLayer *layer;
GimpImage *gimage;
layer = GIMP_LAYER (item);
gimage = gimp_item_get_image (item);
@ -488,43 +486,12 @@ gimp_layer_flip (GimpItem *item,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Flip Layer"));
gimp_item_offsets (item, &off_x, &off_y);
tile_manager_get_offsets (GIMP_DRAWABLE (layer)->tiles,
&old_off_x, &old_off_y);
tile_manager_set_offsets (GIMP_DRAWABLE (layer)->tiles,
off_x, off_y);
tiles = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (layer),
GIMP_DRAWABLE (layer)->tiles,
flip_type, axis);
tile_manager_set_offsets (GIMP_DRAWABLE (layer)->tiles,
old_off_x, old_off_y);
if (tiles)
gimp_drawable_transform_paste (GIMP_DRAWABLE (layer), tiles, FALSE);
GIMP_ITEM_CLASS (parent_class)->flip (item, flip_type, axis, clip_result);
/* If there is a layer mask, make sure it gets flipped also */
if (layer->mask)
{
tile_manager_get_offsets (GIMP_DRAWABLE (layer->mask)->tiles,
&old_off_x, &old_off_y);
tile_manager_set_offsets (GIMP_DRAWABLE (layer->mask)->tiles,
off_x, off_y);
tiles =
gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (layer->mask),
GIMP_DRAWABLE (layer->mask)->tiles,
flip_type, axis);
tile_manager_set_offsets (GIMP_DRAWABLE (layer->mask)->tiles,
old_off_x, old_off_y);
if (tiles)
gimp_drawable_transform_paste (GIMP_DRAWABLE (layer->mask), tiles,
FALSE);
}
gimp_item_flip (GIMP_ITEM (layer->mask),
flip_type, axis, clip_result);
gimp_image_undo_group_end (gimage);
@ -541,11 +508,8 @@ gimp_layer_transform (GimpItem *item,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
GimpLayer *layer;
GimpImage *gimage;
TileManager *tiles;
gint off_x, off_y;
gint old_off_x, old_off_y;
GimpLayer *layer;
GimpImage *gimage;
layer = GIMP_LAYER (item);
gimage = gimp_item_get_image (item);
@ -553,51 +517,16 @@ gimp_layer_transform (GimpItem *item,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
_("Transform Layer"));
gimp_item_offsets (item, &off_x, &off_y);
tile_manager_get_offsets (GIMP_DRAWABLE (layer)->tiles,
&old_off_x, &old_off_y);
tile_manager_set_offsets (GIMP_DRAWABLE (layer)->tiles,
off_x, off_y);
tiles = gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (layer),
GIMP_DRAWABLE (layer)->tiles,
matrix, direction,
interpolation_type,
clip_result,
progress_callback,
progress_data);
tile_manager_set_offsets (GIMP_DRAWABLE (layer)->tiles,
old_off_x, old_off_y);
if (tiles)
gimp_drawable_transform_paste (GIMP_DRAWABLE (layer), tiles, FALSE);
GIMP_ITEM_CLASS (parent_class)->transform (item, matrix, direction,
interpolation_type, clip_result,
progress_callback, progress_data);
/* If there is a layer mask, make sure it gets flipped also */
if (layer->mask)
{
tile_manager_get_offsets (GIMP_DRAWABLE (layer->mask)->tiles,
&old_off_x, &old_off_y);
tile_manager_set_offsets (GIMP_DRAWABLE (layer->mask)->tiles,
off_x, off_y);
tiles =
gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (layer->mask),
GIMP_DRAWABLE (layer->mask)->tiles,
matrix, direction,
interpolation_type,
clip_result,
progress_callback,
progress_data);
tile_manager_set_offsets (GIMP_DRAWABLE (layer->mask)->tiles,
old_off_x, old_off_y);
if (tiles)
gimp_drawable_transform_paste (GIMP_DRAWABLE (layer->mask), tiles,
FALSE);
}
gimp_item_transform (GIMP_ITEM (layer->mask),
matrix, direction,
interpolation_type, clip_result,
progress_callback, progress_data);
gimp_image_undo_group_end (gimage);

View File

@ -264,9 +264,9 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
}
if (gimp_item_get_linked (active_item))
gimp_item_linked_flip (active_item, options->flip_type, axis);
gimp_item_linked_flip (active_item, options->flip_type, axis, FALSE);
return gimp_drawable_transform_tiles_flip (active_drawable,
trans_tool->original,
options->flip_type, axis);
options->flip_type, axis, FALSE);
}

View File

@ -35,8 +35,8 @@
#include "base/tile-manager.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpdrawable-transform.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
@ -775,6 +775,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpDrawable *active_drawable;
GimpItem *active_item;
GimpProgress *progress;
gboolean clip_result;
TileManager *ret;
tool = GIMP_TOOL (tr_tool);
@ -797,12 +798,19 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
gimp_progress_update_and_flush : NULL,
progress);
clip_result = options->clip;
/* always clip unfloated channels so they keep their size */
if (GIMP_IS_CHANNEL (active_drawable) &&
tile_manager_bpp (tr_tool->original) == 1)
clip_result = TRUE;
ret = gimp_drawable_transform_tiles_affine (active_drawable,
tr_tool->original,
tr_tool->transform,
options->direction,
options->interpolation,
options->clip,
clip_result,
progress ?
gimp_progress_update_and_flush :
NULL,

View File

@ -72,7 +72,8 @@ static void gimp_vectors_resize (GimpItem *item,
gint offset_y);
static void gimp_vectors_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis);
gdouble axis,
gboolean clip_result);
static void gimp_vectors_transform (GimpItem *item,
GimpMatrix3 matrix,
GimpTransformDirection direction,
@ -363,7 +364,8 @@ gimp_vectors_resize (GimpItem *item,
static void
gimp_vectors_flip (GimpItem *item,
GimpOrientationType flip_type,
gdouble axis)
gdouble axis,
gboolean clip_result)
{
GimpVectors *vectors;
GList *list;