[gimp] app: remove the "offset" API from TileManager



commit bc8d5f84d6a31c54e1bcee71ac66be55fa5e50cf
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 26 08:30:15 2011 +0100

    app: remove the "offset" API from TileManager
    
    It made the transform code hard to read and never belonged into the
    tile manager anyway. It's a simple pixel buffer that should not know
    about any position in an image. Instead, pass around the offsets of
    tile managers explicitly, so everything is less obscure for the price
    of having more parameters. This will also help replacing TileManagers
    with GeglBuffers.

 app/base/tile-manager-private.h   |    2 -
 app/base/tile-manager.c           |   23 ---------
 app/base/tile-manager.h           |    7 ---
 app/core/gimp-edit.c              |    8 ++-
 app/core/gimp-transform-region.c  |    6 ++-
 app/core/gimp-transform-region.h  |    2 +
 app/core/gimpbuffer.c             |   11 +++-
 app/core/gimpbuffer.h             |    8 +++-
 app/core/gimpdrawable-transform.c |   99 ++++++++++++++++++++++++++++--------
 app/core/gimpdrawable-transform.h |   20 +++++++-
 app/core/gimpdrawable.c           |   49 ++++++------------
 app/core/gimpselection.c          |   10 ++--
 app/core/gimpselection.h          |    2 +
 app/paint/gimpperspectiveclone.c  |    3 +-
 app/tools/gimpfliptool.c          |   14 ++++-
 app/tools/gimptransformtool.c     |   34 +++++++++---
 app/tools/gimptransformtool.h     |    6 ++-
 app/widgets/gimpclipboard.c       |    3 +-
 18 files changed, 192 insertions(+), 115 deletions(-)
---
diff --git a/app/base/tile-manager-private.h b/app/base/tile-manager-private.h
index 850a8fd..d844a29 100644
--- a/app/base/tile-manager-private.h
+++ b/app/base/tile-manager-private.h
@@ -23,8 +23,6 @@ struct _TileManager
 {
   gint               ref_count;     /*  reference counter                    */
 
-  gint               x, y;          /*  tile manager offsets                 */
-
   gint               width;         /*  the width of the tiled area          */
   gint               height;        /*  the height of the tiled area         */
   gint               bpp;           /*  the bpp of each tile                 */
diff --git a/app/base/tile-manager.c b/app/base/tile-manager.c
index 2f29c32..127e9ee 100644
--- a/app/base/tile-manager.c
+++ b/app/base/tile-manager.c
@@ -591,29 +591,6 @@ tile_manager_tiles_per_row (const TileManager *tm)
   return tm->ntile_rows;
 }
 
-void
-tile_manager_get_offsets (const TileManager *tm,
-                          gint              *x,
-                          gint              *y)
-{
-  g_return_if_fail (tm != NULL);
-  g_return_if_fail (x != NULL && y != NULL);
-
-  *x = tm->x;
-  *y = tm->y;
-}
-
-void
-tile_manager_set_offsets (TileManager *tm,
-                          gint         x,
-                          gint         y)
-{
-  g_return_if_fail (tm != NULL);
-
-  tm->x = x;
-  tm->y = y;
-}
-
 gint64
 tile_manager_get_memsize (const TileManager *tm,
                           gboolean           sparse)
diff --git a/app/base/tile-manager.h b/app/base/tile-manager.h
index 336c9cd..b027143 100644
--- a/app/base/tile-manager.h
+++ b/app/base/tile-manager.h
@@ -98,13 +98,6 @@ gint          tile_manager_bpp               (const TileManager *tm);
 gint          tile_manager_tiles_per_col     (const TileManager *tm);
 gint          tile_manager_tiles_per_row     (const TileManager *tm);
 
-void          tile_manager_get_offsets       (const TileManager *tm,
-                                              gint              *x,
-                                              gint              *y);
-void          tile_manager_set_offsets       (TileManager       *tm,
-                                              gint               x,
-                                              gint               y);
-
 gint64        tile_manager_get_memsize       (const TileManager *tm,
                                               gboolean           sparse);
 
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index a2d427a..adf7a76 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -495,6 +495,8 @@ gimp_edit_extract (GimpImage     *image,
                    GError       **error)
 {
   TileManager *tiles;
+  gint         offset_x;
+  gint         offset_y;
 
   if (cut_pixels)
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_CUT, C_("undo-type", "Cut"));
@@ -502,14 +504,16 @@ gimp_edit_extract (GimpImage     *image,
   /*  Cut/copy the mask portion from the image  */
   tiles = gimp_selection_extract (GIMP_SELECTION (gimp_image_get_mask (image)),
                                   pickable, context,
-                                  cut_pixels, FALSE, FALSE, error);
+                                  cut_pixels, FALSE, FALSE,
+                                  &offset_x, &offset_y, error);
 
   if (cut_pixels)
     gimp_image_undo_group_end (image);
 
   if (tiles)
     {
-      GimpBuffer *buffer = gimp_buffer_new (tiles, _("Global Buffer"), FALSE);
+      GimpBuffer *buffer = gimp_buffer_new (tiles, _("Global Buffer"),
+                                            offset_x, offset_y, FALSE);
 
       tile_manager_unref (tiles);
 
diff --git a/app/core/gimp-transform-region.c b/app/core/gimp-transform-region.c
index e18702c..ff1430b 100644
--- a/app/core/gimp-transform-region.c
+++ b/app/core/gimp-transform-region.c
@@ -169,6 +169,8 @@ void
 gimp_transform_region (GimpPickable          *pickable,
                        GimpContext           *context,
                        TileManager           *orig_tiles,
+                       gint                   orig_offset_x,
+                       gint                   orig_offset_y,
                        PixelRegion           *destPR,
                        gint                   dest_x1,
                        gint                   dest_y1,
@@ -187,8 +189,8 @@ gimp_transform_region (GimpPickable          *pickable,
 
   g_return_if_fail (GIMP_IS_PICKABLE (pickable));
 
-  tile_manager_get_offsets (orig_tiles, &u1, &v1);
-
+  u1 = orig_offset_x;
+  v1 = orig_offset_y;
   u2 = u1 + tile_manager_width (orig_tiles);
   v2 = v1 + tile_manager_height (orig_tiles);
 
diff --git a/app/core/gimp-transform-region.h b/app/core/gimp-transform-region.h
index 11a16b3..2306b89 100644
--- a/app/core/gimp-transform-region.h
+++ b/app/core/gimp-transform-region.h
@@ -22,6 +22,8 @@
 void   gimp_transform_region (GimpPickable          *pickable,
                               GimpContext           *context,
                               TileManager           *orig_tiles,
+                              gint                   orig_offset_x,
+                              gint                   orig_offset_y,
                               PixelRegion           *destPR,
                               gint                   dest_x1,
                               gint                   dest_y1,
diff --git a/app/core/gimpbuffer.c b/app/core/gimpbuffer.c
index 8e69658..cec9a01 100644
--- a/app/core/gimpbuffer.c
+++ b/app/core/gimpbuffer.c
@@ -216,6 +216,8 @@ gimp_buffer_get_description (GimpViewable  *viewable,
 GimpBuffer *
 gimp_buffer_new (TileManager *tiles,
                  const gchar *name,
+                 gint         offset_x,
+                 gint         offset_y,
                  gboolean     copy_pixels)
 {
   GimpBuffer *buffer;
@@ -236,12 +238,17 @@ gimp_buffer_new (TileManager *tiles,
   else
     buffer->tiles = tile_manager_ref (tiles);
 
+  buffer->offset_x = offset_x;
+  buffer->offset_y = offset_y;
+
   return buffer;
 }
 
 GimpBuffer *
 gimp_buffer_new_from_pixbuf (GdkPixbuf   *pixbuf,
-                             const gchar *name)
+                             const gchar *name,
+                             gint         offset_x,
+                             gint         offset_y)
 {
   GimpBuffer  *buffer;
   TileManager *tiles;
@@ -272,7 +279,7 @@ gimp_buffer_new_from_pixbuf (GdkPixbuf   *pixbuf,
       pixel_region_set_row (&destPR, 0, y, width, pixels);
    }
 
-  buffer = gimp_buffer_new (tiles, name, FALSE);
+  buffer = gimp_buffer_new (tiles, name, offset_x, offset_y, FALSE);
 
   tile_manager_unref (tiles);
 
diff --git a/app/core/gimpbuffer.h b/app/core/gimpbuffer.h
index 7e4e002..72cd2eb 100644
--- a/app/core/gimpbuffer.h
+++ b/app/core/gimpbuffer.h
@@ -37,6 +37,8 @@ struct _GimpBuffer
   GimpViewable  parent_instance;
 
   TileManager  *tiles;
+  gint          offset_x;
+  gint          offset_y;
 };
 
 struct _GimpBufferClass
@@ -49,9 +51,13 @@ GType           gimp_buffer_get_type        (void) G_GNUC_CONST;
 
 GimpBuffer    * gimp_buffer_new             (TileManager      *tiles,
                                              const gchar      *name,
+                                             gint              offset_x,
+                                             gint              offset_y,
                                              gboolean          copy_pixels);
 GimpBuffer    * gimp_buffer_new_from_pixbuf (GdkPixbuf        *pixbuf,
-                                             const gchar      *name);
+                                             const gchar      *name,
+                                             gint              offset_x,
+                                             gint              offset_y);
 
 gint            gimp_buffer_get_width       (const GimpBuffer *buffer);
 gint            gimp_buffer_get_height      (const GimpBuffer *buffer);
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index 5e4af20..cdd8125 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -71,11 +71,15 @@ TileManager *
 gimp_drawable_transform_tiles_affine (GimpDrawable           *drawable,
                                       GimpContext            *context,
                                       TileManager            *orig_tiles,
+                                      gint                    orig_offset_x,
+                                      gint                    orig_offset_y,
                                       const GimpMatrix3      *matrix,
                                       GimpTransformDirection  direction,
                                       GimpInterpolationType   interpolation_type,
                                       gint                    recursion_level,
                                       GimpTransformResize     clip_result,
+                                      gint                   *new_offset_x,
+                                      gint                   *new_offset_y,
                                       GimpProgress           *progress)
 {
   GimpImage   *image;
@@ -91,6 +95,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable           *drawable,
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
   g_return_val_if_fail (orig_tiles != NULL, NULL);
   g_return_val_if_fail (matrix != NULL, NULL);
+  g_return_val_if_fail (new_offset_x != NULL, NULL);
+  g_return_val_if_fail (new_offset_y != NULL, NULL);
   g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
@@ -111,8 +117,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable           *drawable,
       gimp_matrix3_invert (&m);
     }
 
-  tile_manager_get_offsets (orig_tiles, &u1, &v1);
-
+  u1 = orig_offset_x;
+  v1 = orig_offset_y;
   u2 = u1 + tile_manager_width (orig_tiles);
   v2 = v1 + tile_manager_height (orig_tiles);
 
@@ -131,11 +137,12 @@ gimp_drawable_transform_tiles_affine (GimpDrawable           *drawable,
                                 tile_manager_bpp (orig_tiles));
   pixel_region_init (&destPR, new_tiles,
                      0, 0, x2 - x1, y2 - y1, TRUE);
-  tile_manager_set_offsets (new_tiles, x1, y1);
 
   gimp_transform_region (GIMP_PICKABLE (drawable),
                          context,
                          orig_tiles,
+                         orig_offset_x,
+                         orig_offset_y,
                          &destPR,
                          x1,
                          y1,
@@ -146,6 +153,9 @@ gimp_drawable_transform_tiles_affine (GimpDrawable           *drawable,
                          recursion_level,
                          progress);
 
+  *new_offset_x = x1;
+  *new_offset_y = y1;
+
   return new_tiles;
 }
 
@@ -153,9 +163,13 @@ TileManager *
 gimp_drawable_transform_tiles_flip (GimpDrawable        *drawable,
                                     GimpContext         *context,
                                     TileManager         *orig_tiles,
+                                    gint                 orig_offset_x,
+                                    gint                 orig_offset_y,
                                     GimpOrientationType  flip_type,
                                     gdouble              axis,
-                                    gboolean             clip_result)
+                                    gboolean             clip_result,
+                                    gint                *new_offset_x,
+                                    gint                *new_offset_y)
 {
   GimpImage   *image;
   TileManager *new_tiles;
@@ -174,12 +188,12 @@ gimp_drawable_transform_tiles_flip (GimpDrawable        *drawable,
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
 
+  orig_x      = orig_offset_x;
+  orig_y      = orig_offset_y;
   orig_width  = tile_manager_width (orig_tiles);
   orig_height = tile_manager_height (orig_tiles);
   orig_bpp    = tile_manager_bpp (orig_tiles);
 
-  tile_manager_get_offsets (orig_tiles, &orig_x, &orig_y);
-
   new_x      = orig_x;
   new_y      = orig_y;
   new_width  = orig_width;
@@ -210,7 +224,8 @@ gimp_drawable_transform_tiles_flip (GimpDrawable        *drawable,
       gint   clip_x, clip_y;
       gint   clip_width, clip_height;
 
-      tile_manager_set_offsets (new_tiles, orig_x, orig_y);
+      *new_offset_x = orig_x;
+      *new_offset_y = orig_y;
 
       gimp_image_get_background (image, context, gimp_drawable_type (drawable),
                                  bg_color);
@@ -237,7 +252,8 @@ gimp_drawable_transform_tiles_flip (GimpDrawable        *drawable,
     }
   else
     {
-      tile_manager_set_offsets (new_tiles, new_x, new_y);
+      *new_offset_x = new_x;
+      *new_offset_y = new_y;
 
       orig_x = 0;
       orig_y = 0;
@@ -321,10 +337,14 @@ TileManager *
 gimp_drawable_transform_tiles_rotate (GimpDrawable     *drawable,
                                       GimpContext      *context,
                                       TileManager      *orig_tiles,
+                                      gint              orig_offset_x,
+                                      gint              orig_offset_y,
                                       GimpRotationType  rotate_type,
                                       gdouble           center_x,
                                       gdouble           center_y,
-                                      gboolean          clip_result)
+                                      gboolean          clip_result,
+                                      gint             *new_offset_x,
+                                      gint             *new_offset_y)
 {
   GimpImage   *image;
   TileManager *new_tiles;
@@ -344,12 +364,12 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable     *drawable,
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
 
+  orig_x      = orig_offset_x;
+  orig_y      = orig_offset_y;
   orig_width  = tile_manager_width (orig_tiles);
   orig_height = tile_manager_height (orig_tiles);
   orig_bpp    = tile_manager_bpp (orig_tiles);
 
-  tile_manager_get_offsets (orig_tiles, &orig_x, &orig_y);
-
   switch (rotate_type)
     {
     case GIMP_ROTATE_90:
@@ -394,7 +414,8 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable     *drawable,
 
       new_tiles = tile_manager_new (orig_width, orig_height, orig_bpp);
 
-      tile_manager_set_offsets (new_tiles, orig_x, orig_y);
+      *new_offset_x = orig_x;
+      *new_offset_y = orig_y;
 
       gimp_image_get_background (image, context, gimp_drawable_type (drawable),
                                  bg_color);
@@ -469,7 +490,8 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable     *drawable,
     {
       new_tiles = tile_manager_new (new_width, new_height, orig_bpp);
 
-      tile_manager_set_offsets (new_tiles, new_x, new_y);
+      *new_offset_x = new_x;
+      *new_offset_y = new_y;
 
       orig_x = 0;
       orig_y = 0;
@@ -555,6 +577,10 @@ gimp_drawable_transform_affine (GimpDrawable           *drawable,
 {
   GimpImage    *image;
   TileManager  *orig_tiles;
+  gint          offset_x;
+  gint          offset_y;
+  gint          new_offset_x;
+  gint          new_offset_y;
   gboolean      new_layer;
   GimpDrawable *result = NULL;
 
@@ -572,7 +598,8 @@ gimp_drawable_transform_affine (GimpDrawable           *drawable,
                                C_("undo-type", "Transform"));
 
   /* Cut/Copy from the specified drawable */
-  orig_tiles = gimp_drawable_transform_cut (drawable, context, &new_layer);
+  orig_tiles = gimp_drawable_transform_cut (drawable, context,
+                                            &offset_x, &offset_y, &new_layer);
 
   if (orig_tiles)
     {
@@ -601,11 +628,14 @@ gimp_drawable_transform_affine (GimpDrawable           *drawable,
       /* transform the buffer */
       new_tiles = gimp_drawable_transform_tiles_affine (drawable, context,
                                                         orig_tiles,
+                                                        offset_x, offset_y,
                                                         matrix,
                                                         direction,
                                                         interpolation_type,
                                                         recursion_level,
                                                         clip_result,
+                                                        &new_offset_x,
+                                                        &new_offset_y,
                                                         progress);
 
       /* Free the cut/copied buffer */
@@ -614,6 +644,7 @@ gimp_drawable_transform_affine (GimpDrawable           *drawable,
       if (new_tiles)
         {
           result = gimp_drawable_transform_paste (drawable, new_tiles,
+                                                  new_offset_x, new_offset_y,
                                                   new_layer);
           tile_manager_unref (new_tiles);
         }
@@ -634,6 +665,10 @@ gimp_drawable_transform_flip (GimpDrawable        *drawable,
 {
   GimpImage    *image;
   TileManager  *orig_tiles;
+  gint          offset_x;
+  gint          offset_y;
+  gint          new_offset_x;
+  gint          new_offset_y;
   gboolean      new_layer;
   GimpDrawable *result = NULL;
 
@@ -649,7 +684,8 @@ gimp_drawable_transform_flip (GimpDrawable        *drawable,
                                C_("undo-type", "Flip"));
 
   /* Cut/Copy from the specified drawable */
-  orig_tiles = gimp_drawable_transform_cut (drawable, context, &new_layer);
+  orig_tiles = gimp_drawable_transform_cut (drawable, context,
+                                            &offset_x, &offset_y, &new_layer);
 
   if (orig_tiles)
     {
@@ -677,8 +713,12 @@ gimp_drawable_transform_flip (GimpDrawable        *drawable,
         {
           new_tiles = gimp_drawable_transform_tiles_flip (drawable, context,
                                                           orig_tiles,
+                                                          offset_x,
+                                                          offset_y,
                                                           flip_type, axis,
-                                                          clip_result);
+                                                          clip_result,
+                                                          &new_offset_x,
+                                                          &new_offset_y);
 
           /* Free the cut/copied buffer */
           tile_manager_unref (orig_tiles);
@@ -687,6 +727,7 @@ gimp_drawable_transform_flip (GimpDrawable        *drawable,
       if (new_tiles)
         {
           result = gimp_drawable_transform_paste (drawable, new_tiles,
+                                                  new_offset_x, new_offset_y,
                                                   new_layer);
           tile_manager_unref (new_tiles);
         }
@@ -708,6 +749,10 @@ gimp_drawable_transform_rotate (GimpDrawable     *drawable,
 {
   GimpImage    *image;
   TileManager  *orig_tiles;
+  gint          offset_x;
+  gint          offset_y;
+  gint          new_offset_x;
+  gint          new_offset_y;
   gboolean      new_layer;
   GimpDrawable *result = NULL;
 
@@ -723,7 +768,8 @@ gimp_drawable_transform_rotate (GimpDrawable     *drawable,
                                C_("undo-type", "Rotate"));
 
   /* Cut/Copy from the specified drawable */
-  orig_tiles = gimp_drawable_transform_cut (drawable, context, &new_layer);
+  orig_tiles = gimp_drawable_transform_cut (drawable, context,
+                                            &offset_x, &offset_y, &new_layer);
 
   if (orig_tiles)
     {
@@ -750,9 +796,13 @@ gimp_drawable_transform_rotate (GimpDrawable     *drawable,
       /* transform the buffer */
       new_tiles = gimp_drawable_transform_tiles_rotate (drawable, context,
                                                         orig_tiles,
+                                                        offset_x,
+                                                        offset_y,
                                                         rotate_type,
                                                         center_x, center_y,
-                                                        clip_result);
+                                                        clip_result,
+                                                        &new_offset_x,
+                                                        &new_offset_y);
 
       /* Free the cut/copied buffer */
       tile_manager_unref (orig_tiles);
@@ -760,6 +810,7 @@ gimp_drawable_transform_rotate (GimpDrawable     *drawable,
       if (new_tiles)
         {
           result = gimp_drawable_transform_paste (drawable, new_tiles,
+                                                  new_offset_x, new_offset_y,
                                                   new_layer);
           tile_manager_unref (new_tiles);
         }
@@ -774,6 +825,8 @@ gimp_drawable_transform_rotate (GimpDrawable     *drawable,
 TileManager *
 gimp_drawable_transform_cut (GimpDrawable *drawable,
                              GimpContext  *context,
+                             gint         *offset_x,
+                             gint         *offset_y,
                              gboolean     *new_layer)
 {
   GimpImage   *image;
@@ -782,6 +835,8 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
   g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+  g_return_val_if_fail (offset_x != NULL, NULL);
+  g_return_val_if_fail (offset_y != NULL, NULL);
   g_return_val_if_fail (new_layer != NULL, NULL);
 
   image = gimp_item_get_image (GIMP_ITEM (drawable));
@@ -801,6 +856,7 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
                                           GIMP_PICKABLE (drawable),
                                           context,
                                           TRUE, FALSE, TRUE,
+                                          offset_x, offset_y,
                                           NULL);
           /*  clear the selection  */
           gimp_channel_clear (gimp_image_get_mask (image), NULL, TRUE);
@@ -819,6 +875,7 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
                                       GIMP_PICKABLE (drawable),
                                       context,
                                       FALSE, TRUE, GIMP_IS_LAYER (drawable),
+                                      offset_x, offset_y,
                                       NULL);
 
       *new_layer = FALSE;
@@ -830,13 +887,13 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
 GimpDrawable *
 gimp_drawable_transform_paste (GimpDrawable *drawable,
                                TileManager  *tiles,
+                               gint          offset_x,
+                               gint          offset_y,
                                gboolean      new_layer)
 {
   GimpImage   *image;
   GimpLayer   *layer     = NULL;
   const gchar *undo_desc = NULL;
-  gint         offset_x;
-  gint         offset_y;
 
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
   g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
@@ -851,8 +908,6 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
   else
     return NULL;
 
-  tile_manager_get_offsets (tiles, &offset_x, &offset_y);
-
   gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE, undo_desc);
 
   if (new_layer)
diff --git a/app/core/gimpdrawable-transform.h b/app/core/gimpdrawable-transform.h
index c530a2a..dcf66cd 100644
--- a/app/core/gimpdrawable-transform.h
+++ b/app/core/gimpdrawable-transform.h
@@ -35,26 +35,38 @@ typedef enum
 TileManager  * gimp_drawable_transform_tiles_affine (GimpDrawable           *drawable,
                                                      GimpContext            *context,
                                                      TileManager            *orig_tiles,
+                                                     gint                    orig_offset_x,
+                                                     gint                    orig_offset_y,
                                                      const GimpMatrix3      *matrix,
                                                      GimpTransformDirection  direction,
                                                      GimpInterpolationType   interpolation_type,
                                                      gint                    recursion_level,
                                                      GimpTransformResize     clip_result,
+                                                     gint                   *new_offset_x,
+                                                     gint                   *new_offset_y,
                                                      GimpProgress           *progress);
 TileManager  * gimp_drawable_transform_tiles_flip   (GimpDrawable           *drawable,
                                                      GimpContext            *context,
                                                      TileManager            *orig_tiles,
+                                                     gint                    orig_offset_x,
+                                                     gint                    orig_offset_y,
                                                      GimpOrientationType     flip_type,
                                                      gdouble                 axis,
-                                                     gboolean                clip_result);
+                                                     gboolean                clip_result,
+                                                     gint                   *new_offset_x,
+                                                     gint                   *new_offset_y);
 
 TileManager  * gimp_drawable_transform_tiles_rotate (GimpDrawable           *drawable,
                                                      GimpContext            *context,
                                                      TileManager            *orig_tiles,
+                                                     gint                    orig_offset_x,
+                                                     gint                    orig_offset_y,
                                                      GimpRotationType        rotate_type,
                                                      gdouble                 center_x,
                                                      gdouble                 center_y,
-                                                     gboolean                clip_result);
+                                                     gboolean                clip_result,
+                                                     gint                   *new_offset_x,
+                                                     gint                   *new_offset_y);
 
 GimpDrawable * gimp_drawable_transform_affine       (GimpDrawable           *drawable,
                                                      GimpContext            *context,
@@ -80,9 +92,13 @@ GimpDrawable * gimp_drawable_transform_rotate       (GimpDrawable           *dra
 
 TileManager  * gimp_drawable_transform_cut          (GimpDrawable           *drawable,
                                                      GimpContext            *context,
+                                                     gint                   *offset_x,
+                                                     gint                   *offset_y,
                                                      gboolean               *new_layer);
 GimpDrawable * gimp_drawable_transform_paste        (GimpDrawable           *drawable,
                                                      TileManager            *tiles,
+                                                     gint                    offset_x,
+                                                     gint                    offset_y,
                                                      gboolean                new_layer);
 
 
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 86955fc..dfc92e8 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -611,26 +611,21 @@ gimp_drawable_flip (GimpItem            *item,
   GimpDrawable *drawable = GIMP_DRAWABLE (item);
   TileManager  *tiles;
   gint          off_x, off_y;
-  gint          old_off_x, old_off_y;
+  gint          new_off_x, new_off_y;
 
   gimp_item_get_offset (item, &off_x, &off_y);
 
-  tile_manager_get_offsets (gimp_drawable_get_tiles (drawable),
-                            &old_off_x, &old_off_y);
-  tile_manager_set_offsets (gimp_drawable_get_tiles (drawable),
-                            off_x, off_y);
-
   tiles = gimp_drawable_transform_tiles_flip (drawable, context,
                                               gimp_drawable_get_tiles (drawable),
+                                              off_x, off_y,
                                               flip_type, axis,
-                                              clip_result);
-
-  tile_manager_set_offsets (gimp_drawable_get_tiles (drawable),
-                            old_off_x, old_off_y);
+                                              clip_result,
+                                              &new_off_x, &new_off_y);
 
   if (tiles)
     {
-      gimp_drawable_transform_paste (drawable, tiles, FALSE);
+      gimp_drawable_transform_paste (drawable, tiles,
+                                     new_off_x, new_off_y, FALSE);
       tile_manager_unref (tiles);
     }
 }
@@ -646,26 +641,21 @@ gimp_drawable_rotate (GimpItem         *item,
   GimpDrawable *drawable = GIMP_DRAWABLE (item);
   TileManager  *tiles;
   gint          off_x, off_y;
-  gint          old_off_x, old_off_y;
+  gint          new_off_x, new_off_y;
 
   gimp_item_get_offset (item, &off_x, &off_y);
 
-  tile_manager_get_offsets (gimp_drawable_get_tiles (drawable),
-                            &old_off_x, &old_off_y);
-  tile_manager_set_offsets (gimp_drawable_get_tiles (drawable),
-                            off_x, off_y);
-
   tiles = gimp_drawable_transform_tiles_rotate (drawable, context,
                                                 gimp_drawable_get_tiles (drawable),
+                                                off_x, off_y,
                                                 rotate_type, center_x, center_y,
-                                                clip_result);
-
-  tile_manager_set_offsets (gimp_drawable_get_tiles (drawable),
-                            old_off_x, old_off_y);
+                                                clip_result,
+                                                &new_off_x, &new_off_y);
 
   if (tiles)
     {
-      gimp_drawable_transform_paste (drawable, tiles, FALSE);
+      gimp_drawable_transform_paste (drawable, tiles,
+                                     new_off_x, new_off_y, FALSE);
       tile_manager_unref (tiles);
     }
 }
@@ -683,29 +673,24 @@ gimp_drawable_transform (GimpItem               *item,
   GimpDrawable *drawable = GIMP_DRAWABLE (item);
   TileManager  *tiles;
   gint          off_x, off_y;
-  gint          old_off_x, old_off_y;
+  gint          new_off_x, new_off_y;
 
   gimp_item_get_offset (item, &off_x, &off_y);
 
-  tile_manager_get_offsets (gimp_drawable_get_tiles (drawable),
-                            &old_off_x, &old_off_y);
-  tile_manager_set_offsets (gimp_drawable_get_tiles (drawable),
-                            off_x, off_y);
-
   tiles = gimp_drawable_transform_tiles_affine (drawable, context,
                                                 gimp_drawable_get_tiles (drawable),
+                                                off_x, off_y,
                                                 matrix, direction,
                                                 interpolation_type,
                                                 recursion_level,
                                                 clip_result,
+                                                &new_off_x, &new_off_y,
                                                 progress);
 
-  tile_manager_set_offsets (gimp_drawable_get_tiles (drawable),
-                            old_off_x, old_off_y);
-
   if (tiles)
     {
-      gimp_drawable_transform_paste (drawable, tiles, FALSE);
+      gimp_drawable_transform_paste (drawable, tiles,
+                                     new_off_y, new_off_y, FALSE);
       tile_manager_unref (tiles);
     }
 }
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index d883497..07cee4f 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -627,6 +627,8 @@ gimp_selection_extract (GimpSelection *selection,
                         gboolean       cut_image,
                         gboolean       keep_indexed,
                         gboolean       add_alpha,
+                        gint          *offset_x,
+                        gint          *offset_y,
                         GError       **error)
 {
   GimpImage         *image;
@@ -736,7 +738,6 @@ gimp_selection_extract (GimpSelection *selection,
 
   /*  Allocate the temp buffer  */
   tiles = tile_manager_new (x2 - x1, y2 - y1, bytes);
-  tile_manager_set_offsets (tiles, x1 + off_x, y1 + off_y);
 
   /* configure the pixel regions  */
   pixel_region_init (&srcPR, gimp_pickable_get_tiles (pickable),
@@ -809,6 +810,9 @@ gimp_selection_extract (GimpSelection *selection,
         }
     }
 
+  *offset_x = x1 + off_x;
+  *offset_y = y1 + off_y;
+
   return tiles;
 }
 
@@ -851,7 +855,7 @@ gimp_selection_float (GimpSelection *selection,
 
   /*  Cut or copy the selected region  */
   tiles = gimp_selection_extract (selection, GIMP_PICKABLE (drawable), context,
-                                  cut_image, FALSE, TRUE, NULL);
+                                  cut_image, FALSE, TRUE, &x1, &y1, NULL);
 
   /*  Clear the selection  */
   gimp_channel_clear (GIMP_CHANNEL (selection), NULL, TRUE);
@@ -867,8 +871,6 @@ gimp_selection_float (GimpSelection *selection,
                                      GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
 
   /*  Set the offsets  */
-  tile_manager_get_offsets (tiles, &x1, &y1);
-
   gimp_item_set_offset (GIMP_ITEM (layer), x1 + off_x, y1 + off_y);
 
   /*  Free the temp buffer  */
diff --git a/app/core/gimpselection.h b/app/core/gimpselection.h
index 86513d6..e1cf29c 100644
--- a/app/core/gimpselection.h
+++ b/app/core/gimpselection.h
@@ -64,6 +64,8 @@ TileManager * gimp_selection_extract       (GimpSelection *selection,
                                             gboolean       cut_image,
                                             gboolean       keep_indexed,
                                             gboolean       add_alpha,
+                                            gint          *offset_x,
+                                            gint          *offset_y,
                                             GError       **error);
 
 GimpLayer   * gimp_selection_float         (GimpSelection *selection,
diff --git a/app/paint/gimpperspectiveclone.c b/app/paint/gimpperspectiveclone.c
index 0135698..3ac0cc3 100644
--- a/app/paint/gimpperspectiveclone.c
+++ b/app/paint/gimpperspectiveclone.c
@@ -380,8 +380,6 @@ gimp_perspective_clone_get_source (GimpSourceCore   *source_core,
 
   orig_tiles = tile_manager_new (xmax - xmin, ymax - ymin, bytes);
 
-  tile_manager_set_offsets (orig_tiles, xmin, ymin);
-
   pixel_region_init (&destPR, orig_tiles,
                      0, 0, xmax - xmin, ymax - ymin,
                      TRUE);
@@ -405,6 +403,7 @@ gimp_perspective_clone_get_source (GimpSourceCore   *source_core,
   gimp_transform_region (src_pickable,
                          GIMP_CONTEXT (paint_options),
                          orig_tiles,
+                         xmin, ymin,
                          &destPR,
                          x1d, y1d, x2d, y2d,
                          &matrix,
diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c
index f612543..2e388f5 100644
--- a/app/tools/gimpfliptool.c
+++ b/app/tools/gimpfliptool.c
@@ -58,7 +58,9 @@ static void          gimp_flip_tool_cursor_update (GimpTool          *tool,
 
 static TileManager * gimp_flip_tool_transform     (GimpTransformTool *tool,
                                                    GimpItem          *item,
-                                                   GimpDisplay       *display);
+                                                   GimpDisplay       *display,
+                                                   gint              *new_offset_x,
+                                                   gint              *new_offset_y);
 
 
 G_DEFINE_TYPE (GimpFlipTool, gimp_flip_tool, GIMP_TYPE_TRANSFORM_TOOL)
@@ -175,7 +177,9 @@ gimp_flip_tool_cursor_update (GimpTool         *tool,
 static TileManager *
 gimp_flip_tool_transform (GimpTransformTool *trans_tool,
                           GimpItem          *active_item,
-                          GimpDisplay       *display)
+                          GimpDisplay       *display,
+                          gint              *new_offset_x,
+                          gint              *new_offset_y)
 {
   GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (trans_tool);
   GimpContext     *context = GIMP_CONTEXT (options);
@@ -211,8 +215,12 @@ 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,
                                                 options->flip_type, axis,
-                                                FALSE);
+                                                FALSE,
+                                                new_offset_x,
+                                                new_offset_y);
     }
   else
     {
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 353ddfc..b86fc48 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -124,7 +124,9 @@ static void      gimp_transform_tool_dialog_update          (GimpTransformTool
 static TileManager *
                  gimp_transform_tool_real_transform         (GimpTransformTool     *tr_tool,
                                                              GimpItem              *item,
-                                                             GimpDisplay           *display);
+                                                             GimpDisplay           *display,
+                                                             gint                  *new_offset_x,
+                                                             gint                  *new_offset_y);
 
 static void      gimp_transform_tool_halt                   (GimpTransformTool     *tr_tool);
 static void      gimp_transform_tool_bounds                 (GimpTransformTool     *tr_tool,
@@ -1140,7 +1142,9 @@ gimp_transform_tool_dialog_update (GimpTransformTool *tr_tool)
 static TileManager *
 gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
                                     GimpItem          *active_item,
-                                    GimpDisplay       *display)
+                                    GimpDisplay       *display,
+                                    gint              *new_offset_x,
+                                    gint              *new_offset_y)
 {
   GimpTool             *tool    = GIMP_TOOL (tr_tool);
   GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
@@ -1178,11 +1182,15 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
       ret = gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (active_item),
                                                   context,
                                                   tr_tool->original,
+                                                  tr_tool->original_offset_x,
+                                                  tr_tool->original_offset_y,
                                                   &tr_tool->transform,
                                                   options->direction,
                                                   options->interpolation,
                                                   options->recursion_level,
                                                   clip_result,
+                                                  new_offset_x,
+                                                  new_offset_y,
                                                   progress);
     }
   else
@@ -1214,6 +1222,8 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
   GimpImage            *image          = gimp_display_get_image (display);
   GimpItem             *active_item    = NULL;
   TileManager          *new_tiles;
+  gint                  new_offset_x;
+  gint                  new_offset_y;
   const gchar          *null_message   = NULL;
   const gchar          *locked_message = NULL;
   gboolean              new_layer;
@@ -1285,14 +1295,17 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
     case GIMP_TRANSFORM_TYPE_LAYER:
       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,
-                                                         &new_layer);
+        {
+          tr_tool->original = gimp_drawable_transform_cut (tool->drawable,
+                                                           context,
+                                                           &tr_tool->original_offset_x,
+                                                           &tr_tool->original_offset_y,
+                                                           &new_layer);
+        }
       break;
 
     case GIMP_TRANSFORM_TYPE_SELECTION:
       tr_tool->original = tile_manager_ref (gimp_drawable_get_tiles (GIMP_DRAWABLE (active_item)));
-      tile_manager_set_offsets (tr_tool->original, 0, 0);
       break;
 
     case GIMP_TRANSFORM_TYPE_PATH:
@@ -1303,7 +1316,9 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
    */
   new_tiles = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->transform (tr_tool,
                                                                   active_item,
-                                                                  display);
+                                                                  display,
+                                                                  &new_offset_x,
+                                                                  &new_offset_y);
 
   switch (options->type)
     {
@@ -1315,6 +1330,7 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
            */
           gimp_drawable_transform_paste (tool->drawable,
                                          new_tiles,
+                                         new_offset_x, new_offset_y,
                                          new_layer);
           tile_manager_unref (new_tiles);
         }
@@ -1534,8 +1550,8 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
   /*  find the boundaries  */
   if (tr_tool->original)
     {
-      tile_manager_get_offsets (tr_tool->original, &tr_tool->x1, &tr_tool->y1);
-
+      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);
     }
diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h
index 433bbf8..4012281 100644
--- a/app/tools/gimptransformtool.h
+++ b/app/tools/gimptransformtool.h
@@ -73,6 +73,8 @@ struct _GimpTransformTool
   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             */
 
@@ -117,7 +119,9 @@ struct _GimpTransformToolClass
                                    GimpDisplay       *display);
   TileManager * (* transform)     (GimpTransformTool *tool,
                                    GimpItem          *item,
-                                   GimpDisplay       *display);
+                                   GimpDisplay       *display,
+                                   gint              *new_offset_x,
+                                   gint              *new_offset_y);
 };
 
 
diff --git a/app/widgets/gimpclipboard.c b/app/widgets/gimpclipboard.c
index 83bf847..9367c74 100644
--- a/app/widgets/gimpclipboard.c
+++ b/app/widgets/gimpclipboard.c
@@ -342,7 +342,8 @@ gimp_clipboard_get_buffer (Gimp *gimp)
 
           if (pixbuf)
             {
-              buffer = gimp_buffer_new_from_pixbuf (pixbuf, _("Clipboard"));
+              buffer = gimp_buffer_new_from_pixbuf (pixbuf, _("Clipboard"),
+                                                    0, 0);
               g_object_unref (pixbuf);
             }
         }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]