[gimp/goat-invasion: 581/608] app: create gimp-babl-compat.[ch] for gimp_babl_format_get_image_type()



commit 1b28a9265fb2ad13eae1eeea682d8c00e62d8531
Author: Michael Natterer <mitch gimp org>
Date:   Wed Apr 25 13:02:20 2012 +0200

    app: create gimp-babl-compat.[ch] for gimp_babl_format_get_image_type()
    
    and remove gimp_drawable_type().

 app/core/gimpdrawable-combine.c   |    3 +-
 app/core/gimpdrawable.c           |   12 ------
 app/core/gimpdrawable.h           |    1 -
 app/core/gimpimage-merge.c        |    6 ++-
 app/core/gimplayer-project.c      |    4 ++-
 app/gegl/Makefile.am              |    2 +
 app/gegl/gimp-babl-compat.c       |   69 +++++++++++++++++++++++++++++++++++++
 app/gegl/gimp-babl-compat.h       |   28 +++++++++++++++
 app/gegl/gimp-gegl-utils.c        |   41 ----------------------
 app/gegl/gimp-gegl-utils.h        |    2 -
 app/pdb/buffer-cmds.c             |    2 +-
 app/pdb/drawable-cmds.c           |    2 +-
 app/plug-in/gimppluginprocedure.c |    2 +-
 app/xcf/xcf-save.c                |    2 +-
 tools/pdbgen/pdb/buffer.pdb       |    2 +-
 tools/pdbgen/pdb/drawable.pdb     |    2 +-
 16 files changed, 114 insertions(+), 66 deletions(-)
---
diff --git a/app/core/gimpdrawable-combine.c b/app/core/gimpdrawable-combine.c
index 4abc088..36dcf81 100644
--- a/app/core/gimpdrawable-combine.c
+++ b/app/core/gimpdrawable-combine.c
@@ -27,6 +27,7 @@
 
 #include "paint-funcs/paint-funcs.h"
 
+#include "gegl/gimp-babl-compat.h"
 #include "gegl/gimp-gegl-loops.h"
 #include "gegl/gimp-gegl-nodes.h"
 #include "gegl/gimp-gegl-utils.h"
@@ -179,7 +180,7 @@ gimp_drawable_real_apply_buffer (GimpDrawable         *drawable,
       /*  determine what sort of operation is being attempted and
        *  if it's actually legal...
        */
-      operation = gimp_image_get_combination_mode (gimp_drawable_type (drawable),
+      operation = gimp_image_get_combination_mode (gimp_babl_format_get_image_type (gimp_drawable_get_format (drawable)),
                                                    src2PR.bytes);
       if (operation == -1)
         {
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 8e5e76c..a76ac48 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1633,18 +1633,6 @@ gimp_drawable_has_alpha (const GimpDrawable *drawable)
   return babl_format_has_alpha (format);
 }
 
-GimpImageType
-gimp_drawable_type (const GimpDrawable *drawable)
-{
-  const Babl *format;
-
-  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
-
-  format = gegl_buffer_get_format (drawable->private->buffer);
-
-  return gimp_babl_format_get_image_type (format);
-}
-
 GimpImageBaseType
 gimp_drawable_get_base_type (const GimpDrawable *drawable)
 {
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index a30c2a6..87374d1 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -228,7 +228,6 @@ const Babl    * gimp_drawable_get_format_with_alpha
 const Babl    * gimp_drawable_get_format_without_alpha
                                                  (const GimpDrawable *drawable);
 gboolean        gimp_drawable_has_alpha          (const GimpDrawable *drawable);
-GimpImageType   gimp_drawable_type               (const GimpDrawable *drawable);
 GimpImageBaseType gimp_drawable_get_base_type    (const GimpDrawable *drawable);
 GimpPrecision   gimp_drawable_get_precision      (const GimpDrawable *drawable);
 gboolean        gimp_drawable_is_rgb             (const GimpDrawable *drawable);
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 0f3fe8e..29f8b52 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -31,6 +31,7 @@
 
 #include "paint-funcs/paint-funcs.h"
 
+#include "gegl/gimp-babl-compat.h"
 #include "gegl/gimp-gegl-utils.h"
 
 #include "vectors/gimpvectors.h"
@@ -404,7 +405,7 @@ static CombinationMode
 gimp_image_merge_layers_get_operation (GimpLayer *dest,
                                        GimpLayer *src)
 {
-  GimpImageType type  = gimp_drawable_type (GIMP_DRAWABLE (dest));
+  GimpImageType type  = gimp_babl_format_get_image_type (gimp_drawable_get_format (GIMP_DRAWABLE (dest)));
   gint          bytes = gimp_drawable_bytes (GIMP_DRAWABLE (src));
 
   return gimp_image_get_combination_mode (type, bytes);
@@ -517,7 +518,8 @@ gimp_image_merge_layers (GimpImage     *image,
   name = g_strdup (gimp_object_get_name (layer));
 
   if (merge_type == GIMP_FLATTEN_IMAGE ||
-      gimp_drawable_type (GIMP_DRAWABLE (layer)) == GIMP_INDEXED_IMAGE)
+      (gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)) &&
+       ! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))))
     {
       GeglColor *color;
       GimpRGB    bg;
diff --git a/app/core/gimplayer-project.c b/app/core/gimplayer-project.c
index 15397f0..487cbcc 100644
--- a/app/core/gimplayer-project.c
+++ b/app/core/gimplayer-project.c
@@ -28,6 +28,8 @@
 
 #include "paint-funcs/paint-funcs.h"
 
+#include "gegl/gimp-babl-compat.h"
+
 #include "gimpimage.h"
 #include "gimplayer.h"
 #include "gimplayer-project.h"
@@ -92,7 +94,7 @@ gimp_layer_project_region (GimpDrawable *drawable,
       /*  Based on the type of the layer, project the layer onto the
        *  projection image...
        */
-      switch (gimp_drawable_type (drawable))
+      switch (gimp_babl_format_get_image_type (gimp_drawable_get_format (drawable)))
         {
         case GIMP_RGB_IMAGE:
         case GIMP_GRAY_IMAGE:
diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am
index bac873d..c63af32 100644
--- a/app/gegl/Makefile.am
+++ b/app/gegl/Makefile.am
@@ -20,6 +20,8 @@ libappgegl_a_sources = \
 	gimp-gegl-types.h			\
 	gimp-babl.c				\
 	gimp-babl.h				\
+	gimp-babl-compat.c			\
+	gimp-babl-compat.h			\
 	gimp-gegl.c				\
 	gimp-gegl.h				\
 	gimp-gegl-config-proxy.c		\
diff --git a/app/gegl/gimp-babl-compat.c b/app/gegl/gimp-babl-compat.c
new file mode 100644
index 0000000..353233d
--- /dev/null
+++ b/app/gegl/gimp-babl-compat.c
@@ -0,0 +1,69 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimp-babl-compat.h
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "gimp-gegl-types.h"
+
+#include "gimp-babl-compat.h"
+
+
+GimpImageType
+gimp_babl_format_get_image_type (const Babl *format)
+{
+  g_return_val_if_fail (format != NULL, -1);
+
+  if (format == babl_format ("Y u8")   ||
+      format == babl_format ("Y' u8")  ||
+      format == babl_format ("Y u16")  ||
+      format == babl_format ("Y float"))
+    {
+      return GIMP_GRAY_IMAGE;
+    }
+  else if (format == babl_format ("Y'A u8")  ||
+           format == babl_format ("YA u16")  ||
+           format == babl_format ("YA float"))
+    {
+      return GIMP_GRAYA_IMAGE;
+    }
+  else if (format == babl_format ("R'G'B' u8") ||
+           format == babl_format ("RGB u16")   ||
+           format == babl_format ("RGB float"))
+    {
+      return GIMP_RGB_IMAGE;
+    }
+  else if (format == babl_format ("R'G'B'A u8") ||
+           format == babl_format ("RGBA u16")   ||
+           format == babl_format ("RGBA float"))
+    {
+      return GIMP_RGBA_IMAGE;
+    }
+  else if (babl_format_is_palette (format))
+    {
+      if (babl_format_has_alpha (format))
+        return GIMP_INDEXEDA_IMAGE;
+      else
+        return GIMP_INDEXED_IMAGE;
+    }
+
+  g_return_val_if_reached (-1);
+}
diff --git a/app/gegl/gimp-babl-compat.h b/app/gegl/gimp-babl-compat.h
new file mode 100644
index 0000000..d5b87c2
--- /dev/null
+++ b/app/gegl/gimp-babl-compat.h
@@ -0,0 +1,28 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimp-babl-compat.h
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_BABL_COMPAT_H__
+#define __GIMP_BABL_COMPAT_H__
+
+
+GimpImageType   gimp_babl_format_get_image_type (const Babl *format);
+
+
+#endif /* __GIMP_BABL_COMPAT_H__ */
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 285de12..ba5b38c 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -32,47 +32,6 @@
 #include "gimptilebackendtilemanager.h"
 
 
-GimpImageType
-gimp_babl_format_get_image_type (const Babl *format)
-{
-  g_return_val_if_fail (format != NULL, -1);
-
-  if (format == babl_format ("Y u8")   ||
-      format == babl_format ("Y' u8")  ||
-      format == babl_format ("Y u16")  ||
-      format == babl_format ("Y float"))
-    {
-      return GIMP_GRAY_IMAGE;
-    }
-  else if (format == babl_format ("Y'A u8")  ||
-           format == babl_format ("YA u16")  ||
-           format == babl_format ("YA float"))
-    {
-      return GIMP_GRAYA_IMAGE;
-    }
-  else if (format == babl_format ("R'G'B' u8") ||
-           format == babl_format ("RGB u16")   ||
-           format == babl_format ("RGB float"))
-    {
-      return GIMP_RGB_IMAGE;
-    }
-  else if (format == babl_format ("R'G'B'A u8") ||
-           format == babl_format ("RGBA u16")   ||
-           format == babl_format ("RGBA float"))
-    {
-      return GIMP_RGBA_IMAGE;
-    }
-  else if (babl_format_is_palette (format))
-    {
-      if (babl_format_has_alpha (format))
-        return GIMP_INDEXEDA_IMAGE;
-      else
-        return GIMP_INDEXED_IMAGE;
-    }
-
-  g_return_val_if_reached (-1);
-}
-
 const gchar *
 gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation)
 {
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index f7dac68..aec50db 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -25,8 +25,6 @@
 #include <gdk-pixbuf/gdk-pixbuf.h> /* temp hack */
 
 
-GimpImageType    gimp_babl_format_get_image_type (const Babl            *format);
-
 const gchar * gimp_interpolation_to_gegl_filter  (GimpInterpolationType  interpolation) G_GNUC_CONST;
 
 GeglBuffer  * gimp_gegl_buffer_new               (const GeglRectangle   *rect,
diff --git a/app/pdb/buffer-cmds.c b/app/pdb/buffer-cmds.c
index 832b684..b4bc986 100644
--- a/app/pdb/buffer-cmds.c
+++ b/app/pdb/buffer-cmds.c
@@ -30,7 +30,7 @@
 #include "core/gimpcontainer-filter.h"
 #include "core/gimpcontainer.h"
 #include "core/gimpparamspecs.h"
-#include "gegl/gimp-gegl-utils.h"
+#include "gegl/gimp-babl-compat.h"
 
 #include "gimppdb.h"
 #include "gimppdb-utils.h"
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index cf7ce71..ed0178a 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -33,8 +33,8 @@
 #include "core/gimpimage.h"
 #include "core/gimpparamspecs.h"
 #include "core/gimptempbuf.h"
+#include "gegl/gimp-babl-compat.h"
 #include "gegl/gimp-babl.h"
-#include "gegl/gimp-gegl-utils.h"
 #include "plug-in/gimpplugin-cleanup.h"
 #include "plug-in/gimpplugin.h"
 #include "plug-in/gimppluginmanager.h"
diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c
index 8d3f6dd..01f6707 100644
--- a/app/plug-in/gimppluginprocedure.c
+++ b/app/plug-in/gimppluginprocedure.c
@@ -28,7 +28,7 @@
 
 #include "plug-in-types.h"
 
-#include "gegl/gimp-gegl-utils.h"
+#include "gegl/gimp-babl-compat.h"
 
 #include "core/gimp.h"
 #include "core/gimp-utils.h"
diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c
index 3250b05..2e1adbb 100644
--- a/app/xcf/xcf-save.c
+++ b/app/xcf/xcf-save.c
@@ -28,8 +28,8 @@
 
 #include "core/core-types.h"
 
+#include "gegl/gimp-babl-compat.h"
 #include "gegl/gimp-gegl-tile-compat.h"
-#include "gegl/gimp-gegl-utils.h"
 
 #include "core/gimp.h"
 #include "core/gimpcontainer.h"
diff --git a/tools/pdbgen/pdb/buffer.pdb b/tools/pdbgen/pdb/buffer.pdb
index 55dec98..b4091b0 100644
--- a/tools/pdbgen/pdb/buffer.pdb
+++ b/tools/pdbgen/pdb/buffer.pdb
@@ -235,7 +235,7 @@ CODE
 
 
 @headers = qw(<string.h>
-              "gegl/gimp-gegl-utils.h"
+              "gegl/gimp-babl-compat.h"
               "core/gimp.h"
               "core/gimpbuffer.h"
               "core/gimpcontainer.h"
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index d5feba9..4735b12 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -944,7 +944,7 @@ CODE
 
 @headers = qw("config/gimpcoreconfig.h"
               "gegl/gimp-babl.h"
-              "gegl/gimp-gegl-utils.h"
+              "gegl/gimp-babl-compat.h"
               "core/gimp.h"
               "core/gimpdrawable-offset.h"
               "core/gimptempbuf.h"



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