[gimp] Remove "old_base_type" parameters from gimp_drawable_convert_tiles_foo()



commit f3bae9ac57a16533bd3bf69c723741da30e4d132
Author: Michael Natterer <mitch gimp org>
Date:   Tue Sep 8 17:49:48 2009 +0200

    Remove "old_base_type" parameters from gimp_drawable_convert_tiles_foo()
    
    I have no idea how ancient these parameters were, but the drawable
    knows about its type itself, so no need to pass it in.

 app/core/gimpchannel.c          |   11 ++++-------
 app/core/gimpdrawable-convert.c |   20 +++++++++++---------
 app/core/gimpdrawable-convert.h |   10 ++++------
 app/core/gimpimage-convert.c    |    4 ++--
 app/core/gimplayer.c            |   19 ++++++-------------
 5 files changed, 27 insertions(+), 37 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 87fd9d2..43ab0b8 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -430,13 +430,10 @@ static void
 gimp_channel_convert (GimpItem  *item,
                       GimpImage *dest_image)
 {
-  GimpChannel       *channel  = GIMP_CHANNEL (item);
-  GimpDrawable      *drawable = GIMP_DRAWABLE (item);
-  GimpImageBaseType  old_base_type;
-
-  old_base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
+  GimpChannel  *channel  = GIMP_CHANNEL (item);
+  GimpDrawable *drawable = GIMP_DRAWABLE (item);
 
-  if (old_base_type != GIMP_GRAY)
+  if (! gimp_drawable_is_gray (drawable))
     {
       TileManager   *new_tiles;
       GimpImageType  new_type = GIMP_GRAY_IMAGE;
@@ -448,7 +445,7 @@ gimp_channel_convert (GimpItem  *item,
                                     gimp_item_get_height (item),
                                     GIMP_IMAGE_TYPE_BYTES (new_type));
 
-      gimp_drawable_convert_tiles_grayscale (drawable, new_tiles, old_base_type);
+      gimp_drawable_convert_tiles_grayscale (drawable, new_tiles);
 
       gimp_drawable_set_tiles (drawable, FALSE, NULL,
                                new_tiles, new_type);
diff --git a/app/core/gimpdrawable-convert.c b/app/core/gimpdrawable-convert.c
index 18cb548..c4a79b5 100644
--- a/app/core/gimpdrawable-convert.c
+++ b/app/core/gimpdrawable-convert.c
@@ -29,16 +29,17 @@
 
 #include "gimpdrawable.h"
 #include "gimpdrawable-convert.h"
+#include "gimpimage.h"
 
 
 void
-gimp_drawable_convert_tiles_rgb (GimpDrawable      *drawable,
-                                 TileManager       *new_tiles,
-                                 GimpImageBaseType  old_base_type)
+gimp_drawable_convert_tiles_rgb (GimpDrawable *drawable,
+                                 TileManager  *new_tiles)
 {
   PixelRegion   srcPR, destPR;
   gint          row, col;
   gint          offset;
+  GimpImageType type;
   gint          has_alpha;
   const guchar *src, *s;
   guchar       *dest, *d;
@@ -48,6 +49,7 @@ gimp_drawable_convert_tiles_rgb (GimpDrawable      *drawable,
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (new_tiles != NULL);
 
+  type      = gimp_drawable_type (drawable);
   has_alpha = gimp_drawable_has_alpha (drawable);
 
   g_return_if_fail (tile_manager_bpp (new_tiles) == (has_alpha ? 4 : 3));
@@ -65,8 +67,7 @@ gimp_drawable_convert_tiles_rgb (GimpDrawable      *drawable,
                      gimp_item_get_height (GIMP_ITEM (drawable)),
                      TRUE);
 
-
-  switch (old_base_type)
+  switch (GIMP_IMAGE_TYPE_BASE_TYPE (type))
     {
     case GIMP_GRAY:
       for (pr = pixel_regions_register (2, &srcPR, &destPR);
@@ -136,13 +137,13 @@ gimp_drawable_convert_tiles_rgb (GimpDrawable      *drawable,
 }
 
 void
-gimp_drawable_convert_tiles_grayscale (GimpDrawable      *drawable,
-                                       TileManager       *new_tiles,
-                                       GimpImageBaseType  old_base_type)
+gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
+                                       TileManager  *new_tiles)
 {
   PixelRegion   srcPR, destPR;
   gint          row, col;
   gint          offset, val;
+  GimpImageType type;
   gboolean      has_alpha;
   const guchar *src, *s;
   guchar       *dest, *d;
@@ -152,6 +153,7 @@ gimp_drawable_convert_tiles_grayscale (GimpDrawable      *drawable,
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (new_tiles != NULL);
 
+  type      = gimp_drawable_type (drawable);
   has_alpha = gimp_drawable_has_alpha (drawable);
 
   g_return_if_fail (tile_manager_bpp (new_tiles) == (has_alpha ? 2 : 1));
@@ -169,7 +171,7 @@ gimp_drawable_convert_tiles_grayscale (GimpDrawable      *drawable,
                      gimp_item_get_height (GIMP_ITEM (drawable)),
                      TRUE);
 
-  switch (old_base_type)
+  switch (GIMP_IMAGE_TYPE_BASE_TYPE (type))
     {
     case GIMP_RGB:
       for (pr = pixel_regions_register (2, &srcPR, &destPR);
diff --git a/app/core/gimpdrawable-convert.h b/app/core/gimpdrawable-convert.h
index 966c6a1..a258ac2 100644
--- a/app/core/gimpdrawable-convert.h
+++ b/app/core/gimpdrawable-convert.h
@@ -19,12 +19,10 @@
 #define __GIMP_DRAWABLE_CONVERT_H__
 
 
-void   gimp_drawable_convert_tiles_rgb       (GimpDrawable       *drawable,
-                                              TileManager        *new_tiles,
-                                              GimpImageBaseType   old_base_type);
-void   gimp_drawable_convert_tiles_grayscale (GimpDrawable       *drawable,
-                                              TileManager        *new_tiles,
-                                              GimpImageBaseType   old_base_type);
+void   gimp_drawable_convert_tiles_rgb       (GimpDrawable *drawable,
+                                              TileManager  *new_tiles);
+void   gimp_drawable_convert_tiles_grayscale (GimpDrawable *drawable,
+                                              TileManager  *new_tiles);
 
 
 #endif  /*  __GIMP_DRAWABLE_CONVERT_H__  */
diff --git a/app/core/gimpimage-convert.c b/app/core/gimpimage-convert.c
index a45ed4e..081f51a 100644
--- a/app/core/gimpimage-convert.c
+++ b/app/core/gimpimage-convert.c
@@ -975,11 +975,11 @@ gimp_image_convert (GimpImage               *image,
         {
         case GIMP_RGB:
           gimp_drawable_convert_tiles_rgb (GIMP_DRAWABLE (layer),
-                                           new_tiles, old_type);
+                                           new_tiles);
           break;
         case GIMP_GRAY:
           gimp_drawable_convert_tiles_grayscale (GIMP_DRAWABLE (layer),
-                                                 new_tiles, old_type);
+                                                 new_tiles);
           break;
         case GIMP_INDEXED:
           quantobj->nth_layer = nth_layer;
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 2facbca..1a38bf5 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -557,15 +557,11 @@ gimp_layer_convert (GimpItem  *item,
       switch (new_base_type)
         {
         case GIMP_RGB:
-          gimp_drawable_convert_tiles_rgb (drawable,
-                                           new_tiles,
-                                           old_base_type);
+          gimp_drawable_convert_tiles_rgb (drawable, new_tiles);
           break;
 
         case GIMP_GRAY:
-          gimp_drawable_convert_tiles_grayscale (drawable,
-                                                 new_tiles,
-                                                 old_base_type);
+          gimp_drawable_convert_tiles_grayscale (drawable, new_tiles);
           break;
 
         case GIMP_INDEXED:
@@ -1529,23 +1525,20 @@ gimp_layer_create_mask (const GimpLayer *layer,
 
     case GIMP_ADD_COPY_MASK:
       {
-        TileManager   *copy_tiles = NULL;
-        GimpImageType  layer_type = gimp_drawable_type (drawable);
+        TileManager *copy_tiles = NULL;
 
-        if (GIMP_IMAGE_TYPE_BASE_TYPE (layer_type) != GIMP_GRAY)
+        if (! gimp_drawable_is_gray (drawable))
           {
             GimpImageType copy_type;
 
-            copy_type = (GIMP_IMAGE_TYPE_HAS_ALPHA (layer_type) ?
+            copy_type = (gimp_drawable_has_alpha (drawable) ?
                          GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE);
 
             copy_tiles = tile_manager_new (gimp_item_get_width  (item),
                                            gimp_item_get_height (item),
                                            GIMP_IMAGE_TYPE_BYTES (copy_type));
 
-            gimp_drawable_convert_tiles_grayscale (drawable,
-                                                   copy_tiles,
-                                                   GIMP_IMAGE_TYPE_BASE_TYPE (layer_type));
+            gimp_drawable_convert_tiles_grayscale (drawable, copy_tiles);
 
             pixel_region_init (&srcPR, copy_tiles,
                                0, 0,



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