[gimp] app: remove mamber GimpDrawable::bytes



commit a62071e9ebc0e2555f9738e539221c9931f24c76
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 16 00:16:31 2011 +0100

    app: remove mamber GimpDrawable::bytes
    
    because it's always the same as GIMP_IMAGE_TYPE_BYTES(drawable->type)

 app/core/gimpchannel.c         |    8 +++++---
 app/core/gimpdrawable-shadow.c |   12 ++++++++----
 app/core/gimpdrawable.c        |   24 ++++++++++++------------
 app/core/gimpdrawable.h        |    1 -
 app/core/gimpgrouplayer.c      |    3 +--
 app/core/gimpimage-convert.c   |    4 ++--
 app/text/gimptextlayer-xcf.c   |    3 +--
 app/text/gimptextlayer.c       |    2 +-
 8 files changed, 30 insertions(+), 27 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 3940c95..fa3caca 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -618,9 +618,11 @@ gimp_channel_scale (GimpItem              *item,
   /*  don't waste CPU cycles scaling an empty channel  */
   if (channel->bounds_known && channel->empty)
     {
-      GimpDrawable *drawable  = GIMP_DRAWABLE (item);
-      TileManager  *new_tiles = tile_manager_new (new_width, new_height,
-                                                  drawable->bytes);
+      GimpDrawable *drawable = GIMP_DRAWABLE (item);
+      TileManager  *new_tiles;
+
+      new_tiles = tile_manager_new (new_width, new_height,
+                                    gimp_drawable_bytes (drawable));
 
       gimp_drawable_set_tiles_full (drawable,
                                     gimp_item_is_attached (item), NULL,
diff --git a/app/core/gimpdrawable-shadow.c b/app/core/gimpdrawable-shadow.c
index 5e852a2..d60af5c 100644
--- a/app/core/gimpdrawable-shadow.c
+++ b/app/core/gimpdrawable-shadow.c
@@ -40,9 +40,13 @@ gimp_drawable_get_shadow_tiles (GimpDrawable *drawable)
 
   if (drawable->private->shadow)
     {
-      if ((gimp_item_get_width  (item) != tile_manager_width  (drawable->private->shadow)) ||
-          (gimp_item_get_height (item) != tile_manager_height (drawable->private->shadow)) ||
-          (drawable->bytes             != tile_manager_bpp    (drawable->private->shadow)))
+      gint width  = gimp_item_get_width  (item);
+      gint height = gimp_item_get_height (item);
+      gint bytes  = gimp_drawable_bytes (drawable);
+
+      if ((width  != tile_manager_width  (drawable->private->shadow)) ||
+          (height != tile_manager_height (drawable->private->shadow)) ||
+          (bytes  != tile_manager_bpp    (drawable->private->shadow)))
         {
           gimp_drawable_free_shadow_tiles (drawable);
         }
@@ -54,7 +58,7 @@ gimp_drawable_get_shadow_tiles (GimpDrawable *drawable)
 
   drawable->private->shadow = tile_manager_new (gimp_item_get_width  (item),
                                                 gimp_item_get_height (item),
-                                                drawable->bytes);
+                                                gimp_drawable_bytes (drawable));
 
   return drawable->private->shadow;
 }
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index e27448d..935aa16 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -258,8 +258,7 @@ gimp_drawable_init (GimpDrawable *drawable)
                                                    GIMP_TYPE_DRAWABLE,
                                                    GimpDrawablePrivate);
 
-  drawable->bytes = 0;
-  drawable->type  = -1;
+  drawable->type = -1;
 }
 
 /* sorry for the evil casts */
@@ -418,8 +417,7 @@ gimp_drawable_duplicate (GimpItem *item,
 
       gimp_item_get_offset (item, &offset_x, &offset_y);
 
-      new_drawable->type  = image_type;
-      new_drawable->bytes = GIMP_IMAGE_TYPE_BYTES (image_type);
+      new_drawable->type = image_type;
 
       if (new_drawable->private->tiles)
         tile_manager_unref (new_drawable->private->tiles);
@@ -427,7 +425,7 @@ gimp_drawable_duplicate (GimpItem *item,
       new_drawable->private->tiles =
         tile_manager_new (gimp_item_get_width  (new_item),
                           gimp_item_get_height (new_item),
-                          new_drawable->bytes);
+                          GIMP_IMAGE_TYPE_BYTES (new_drawable->type));
 
       pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
                          0, 0,
@@ -458,7 +456,8 @@ gimp_drawable_scale (GimpItem              *item,
   GimpDrawable *drawable = GIMP_DRAWABLE (item);
   TileManager  *new_tiles;
 
-  new_tiles = tile_manager_new (new_width, new_height, drawable->bytes);
+  new_tiles = tile_manager_new (new_width, new_height,
+                                GIMP_IMAGE_TYPE_BYTES (drawable->type));
 
   GIMP_TIMER_START ();
 
@@ -560,7 +559,8 @@ gimp_drawable_resize (GimpItem    *item,
                             &copy_width,
                             &copy_height);
 
-  new_tiles = tile_manager_new (new_width, new_height, drawable->bytes);
+  new_tiles = tile_manager_new (new_width, new_height,
+                                GIMP_IMAGE_TYPE_BYTES (drawable->type));
 
   /*  Determine whether the new tiles need to be initially cleared  */
   if (copy_width  != new_width ||
@@ -830,7 +830,6 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
 
   drawable->private->tiles = tiles;
   drawable->type           = type;
-  drawable->bytes          = tile_manager_bpp (tiles);
 
   gimp_item_set_offset (item, offset_x, offset_y);
   gimp_item_set_size (item,
@@ -1198,10 +1197,11 @@ gimp_drawable_new (GType          type,
                                            offset_x, offset_y,
                                            width, height));
 
-  drawable->type  = image_type;
-  drawable->bytes = GIMP_IMAGE_TYPE_BYTES (image_type);
+  drawable->type = image_type;
 
-  drawable->private->tiles = tile_manager_new (width, height, drawable->bytes);
+  drawable->private->tiles =
+    tile_manager_new (width, height,
+                      GIMP_IMAGE_TYPE_BYTES (drawable->type));
 
   return drawable;
 }
@@ -1797,7 +1797,7 @@ gimp_drawable_bytes (const GimpDrawable *drawable)
 {
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
 
-  return drawable->bytes;
+  return GIMP_IMAGE_TYPE_BYTES (drawable->type);
 }
 
 gint
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 15531f2..4fe2375 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -37,7 +37,6 @@ struct _GimpDrawable
 {
   GimpItem       parent_instance;
 
-  gint           bytes;              /* bytes per pixel                */
   GimpImageType  type;               /* type of drawable               */
 
   GimpDrawablePrivate *private;
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 799f8cf..ba5c8de 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -809,8 +809,7 @@ gimp_group_layer_convert_type (GimpDrawable      *drawable,
    *  type to the new values so the projection will create its tiles
    *  with the right depth
    */
-  drawable->type  = new_type;
-  drawable->bytes = GIMP_IMAGE_TYPE_BYTES (new_type);
+  drawable->type = new_type;
 
   gimp_projectable_structure_changed (GIMP_PROJECTABLE (drawable));
 
diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c
index aa69b96..81d8c808 100644
--- a/app/core/gimpimage-convert.c
+++ b/app/core/gimpimage-convert.c
@@ -3584,7 +3584,7 @@ median_cut_pass2_fs_dither_gray (QuantizeObj *quantobj,
                      gimp_item_get_height (GIMP_ITEM (layer)),
                      TRUE);
 
-  src_bytes  = GIMP_DRAWABLE (layer)->bytes;
+  src_bytes  = gimp_drawable_bytes (GIMP_DRAWABLE (layer));
   dest_bytes = tile_manager_bpp (new_tiles);
   width      = gimp_item_get_width  (GIMP_ITEM (layer));
   height     = gimp_item_get_height (GIMP_ITEM (layer));
@@ -3850,7 +3850,7 @@ median_cut_pass2_fs_dither_rgb (QuantizeObj *quantobj,
                      gimp_item_get_height (GIMP_ITEM (layer)),
                      TRUE);
 
-  src_bytes  = GIMP_DRAWABLE(layer)->bytes;
+  src_bytes  = gimp_drawable_bytes (GIMP_DRAWABLE (layer));
   dest_bytes = tile_manager_bpp (new_tiles);
   width      = gimp_item_get_width  (GIMP_ITEM (layer));
   height     = gimp_item_get_height (GIMP_ITEM (layer));
diff --git a/app/text/gimptextlayer-xcf.c b/app/text/gimptextlayer-xcf.c
index 60ab846..00291c5 100644
--- a/app/text/gimptextlayer-xcf.c
+++ b/app/text/gimptextlayer-xcf.c
@@ -194,8 +194,7 @@ gimp_text_layer_from_layer (GimpLayer *layer,
   drawable->private->tiles = gimp_drawable_get_tiles (GIMP_DRAWABLE (layer));
   GIMP_DRAWABLE (layer)->private->tiles = NULL;
 
-  drawable->bytes = gimp_drawable_bytes (GIMP_DRAWABLE (layer));
-  drawable->type  = gimp_drawable_type (GIMP_DRAWABLE (layer));
+  drawable->type = gimp_drawable_type (GIMP_DRAWABLE (layer));
 
   gimp_layer_set_opacity    (GIMP_LAYER (text_layer),
                              gimp_layer_get_opacity (layer), FALSE);
diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c
index 2c97ed1..e0f4636 100644
--- a/app/text/gimptextlayer.c
+++ b/app/text/gimptextlayer.c
@@ -589,7 +589,7 @@ gimp_text_layer_render (GimpTextLayer *layer)
        height != gimp_item_get_height (item)))
     {
       TileManager *new_tiles = tile_manager_new (width, height,
-                                                 drawable->bytes);
+                                                 gimp_drawable_bytes (drawable));
 
       gimp_drawable_set_tiles (drawable, FALSE, NULL, new_tiles,
                                gimp_drawable_type (drawable));



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