[gimp] libimp: merge public gimppixbuf functions into gimplayer and gimpdrawable



commit b2582e80f681b43973712058eeec5a39d5f62c12
Author: Michael Natterer <mitch gimp org>
Date:   Wed Aug 7 22:26:05 2019 +0200

    libimp: merge public gimppixbuf functions into gimplayer and gimpdrawable
    
    and remove gimppuxbuf.h from the public API. Keep the files privately
    for _gimp_pixbuf_from_data().

 libgimp/Makefile.am    |   3 +-
 libgimp/Makefile.gi    |   2 -
 libgimp/gimp.h         |   1 -
 libgimp/gimpdrawable.c | 101 +++++++++++++++++++++++++++++-
 libgimp/gimpdrawable.h |  49 +++++++++------
 libgimp/gimpimage.c    |  60 +++++++++++++++++-
 libgimp/gimpimage.h    |   4 ++
 libgimp/gimplayer.c    |   2 -
 libgimp/gimppixbuf.c   | 167 ++-----------------------------------------------
 libgimp/gimppixbuf.h   |  37 ++---------
 libgimp/gimptypes.h    |  19 ++++++
 11 files changed, 225 insertions(+), 220 deletions(-)
---
diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am
index f9fa4546e4..55a4e4cd2e 100644
--- a/libgimp/Makefile.am
+++ b/libgimp/Makefile.am
@@ -117,6 +117,8 @@ libgimp_private_sources = \
        gimpdb-private.h        \
        gimppdbprocedure.c      \
        gimppdbprocedure.h      \
+       gimppixbuf.c            \
+       gimppixbuf.h            \
        gimpplugin-private.c    \
        gimpplugin-private.h    \
        gimp-debug.c            \
@@ -189,7 +191,6 @@ gimpinclude_HEADERS = \
        gimpitemcombobox.h              \
        gimppaletteselectbutton.h       \
        gimppatternselectbutton.h       \
-       gimppixbuf.h                    \
        gimpprocbrowserdialog.h         \
        gimpprocview.h                  \
        gimpprogressbar.h               \
diff --git a/libgimp/Makefile.gi b/libgimp/Makefile.gi
index a199273ee1..d9ad257763 100644
--- a/libgimp/Makefile.gi
+++ b/libgimp/Makefile.gi
@@ -136,8 +136,6 @@ libgimp_introspectable = \
        $(top_srcdir)/libgimp/gimppatternselect.h       \
        $(top_srcdir)/libgimp/gimppdb.c                 \
        $(top_srcdir)/libgimp/gimppdb.h                 \
-       $(top_srcdir)/libgimp/gimppixbuf.c              \
-       $(top_srcdir)/libgimp/gimppixbuf.h              \
        $(top_srcdir)/libgimp/gimpplugin.c              \
        $(top_srcdir)/libgimp/gimpplugin.h              \
        $(top_srcdir)/libgimp/gimpprocedure.c           \
diff --git a/libgimp/gimp.h b/libgimp/gimp.h
index 940607e875..6bc74b6102 100644
--- a/libgimp/gimp.h
+++ b/libgimp/gimp.h
@@ -49,7 +49,6 @@
 #include <libgimp/gimpparamspecs.h>
 #include <libgimp/gimppatternselect.h>
 #include <libgimp/gimppdb.h>
-#include <libgimp/gimppixbuf.h>
 #include <libgimp/gimpplugin.h>
 #include <libgimp/gimpprocedure.h>
 #include <libgimp/gimpprogress.h>
diff --git a/libgimp/gimpdrawable.c b/libgimp/gimpdrawable.c
index 196f36001d..31d9060ad7 100644
--- a/libgimp/gimpdrawable.c
+++ b/libgimp/gimpdrawable.c
@@ -20,10 +20,9 @@
 
 #include "config.h"
 
-#define GIMP_DISABLE_DEPRECATION_WARNINGS
-
 #include "gimp.h"
 
+#include "gimppixbuf.h"
 #include "gimptilebackendplugin.h"
 
 
@@ -53,6 +52,48 @@ gimp_drawable_get_thumbnail_data (gint32  drawable_ID,
   return image_data;
 }
 
+/**
+ * gimp_drawable_get_thumbnail:
+ * @drawable_ID: the drawable ID
+ * @width:       the requested thumbnail width  (<= 1024 pixels)
+ * @height:      the requested thumbnail height (<= 1024 pixels)
+ * @alpha:       how to handle an alpha channel
+ *
+ * Retrieves a thumbnail pixbuf for the drawable identified by
+ * @drawable_ID. The thumbnail will be not larger than the requested
+ * size.
+ *
+ * Returns: (transfer full): a new #GdkPixbuf
+ *
+ * Since: 2.2
+ **/
+GdkPixbuf *
+gimp_drawable_get_thumbnail (gint32                  drawable_ID,
+                             gint                    width,
+                             gint                    height,
+                             GimpPixbufTransparency  alpha)
+{
+  gint    thumb_width  = width;
+  gint    thumb_height = height;
+  gint    thumb_bpp;
+  guchar *data;
+
+  g_return_val_if_fail (width  > 0 && width  <= 1024, NULL);
+  g_return_val_if_fail (height > 0 && height <= 1024, NULL);
+
+  data = gimp_drawable_get_thumbnail_data (drawable_ID,
+                                           &thumb_width,
+                                           &thumb_height,
+                                           &thumb_bpp);
+
+  if (data)
+    return _gimp_pixbuf_from_data (data,
+                                   thumb_width, thumb_height, thumb_bpp,
+                                   alpha);
+
+  return NULL;
+}
+
 guchar *
 gimp_drawable_get_sub_thumbnail_data (gint32  drawable_ID,
                                       gint    src_x,
@@ -85,6 +126,62 @@ gimp_drawable_get_sub_thumbnail_data (gint32  drawable_ID,
   return image_data;
 }
 
+/**
+ * gimp_drawable_get_sub_thumbnail:
+ * @drawable_ID: the drawable ID
+ * @src_x:       the x coordinate of the area
+ * @src_y:       the y coordinate of the area
+ * @src_width:   the width of the area
+ * @src_height:  the height of the area
+ * @dest_width:  the requested thumbnail width  (<= 1024 pixels)
+ * @dest_height: the requested thumbnail height (<= 1024 pixels)
+ * @alpha:       how to handle an alpha channel
+ *
+ * Retrieves a thumbnail pixbuf for the drawable identified by
+ * @drawable_ID. The thumbnail will be not larger than the requested
+ * size.
+ *
+ * Returns: (transfer full): a new #GdkPixbuf
+ *
+ * Since: 2.2
+ **/
+GdkPixbuf *
+gimp_drawable_get_sub_thumbnail (gint32                  drawable_ID,
+                                 gint                    src_x,
+                                 gint                    src_y,
+                                 gint                    src_width,
+                                 gint                    src_height,
+                                 gint                    dest_width,
+                                 gint                    dest_height,
+                                 GimpPixbufTransparency  alpha)
+{
+  gint    thumb_width  = dest_width;
+  gint    thumb_height = dest_height;
+  gint    thumb_bpp;
+  guchar *data;
+
+  g_return_val_if_fail (src_x >= 0, NULL);
+  g_return_val_if_fail (src_y >= 0, NULL);
+  g_return_val_if_fail (src_width  > 0, NULL);
+  g_return_val_if_fail (src_height > 0, NULL);
+  g_return_val_if_fail (dest_width  > 0 && dest_width  <= 1024, NULL);
+  g_return_val_if_fail (dest_height > 0 && dest_height <= 1024, NULL);
+
+  data = gimp_drawable_get_sub_thumbnail_data (drawable_ID,
+                                               src_x, src_y,
+                                               src_width, src_height,
+                                               &thumb_width,
+                                               &thumb_height,
+                                               &thumb_bpp);
+
+  if (data)
+    return _gimp_pixbuf_from_data (data,
+                                   thumb_width, thumb_height, thumb_bpp,
+                                   alpha);
+
+  return NULL;
+}
+
 /**
  * gimp_drawable_get_buffer:
  * @drawable_ID: the ID of the #GimpDrawable to get the buffer for.
diff --git a/libgimp/gimpdrawable.h b/libgimp/gimpdrawable.h
index d2675791cf..04b05610d8 100644
--- a/libgimp/gimpdrawable.h
+++ b/libgimp/gimpdrawable.h
@@ -30,24 +30,37 @@ G_BEGIN_DECLS
 /* For information look into the C source or the html documentation */
 
 
-GeglBuffer   * gimp_drawable_get_buffer             (gint32         drawable_ID);
-GeglBuffer   * gimp_drawable_get_shadow_buffer      (gint32         drawable_ID);
-
-const Babl   * gimp_drawable_get_format             (gint32         drawable_ID);
-const Babl   * gimp_drawable_get_thumbnail_format   (gint32         drawable_ID);
-
-guchar       * gimp_drawable_get_thumbnail_data     (gint32         drawable_ID,
-                                                     gint          *width,
-                                                     gint          *height,
-                                                     gint          *bpp);
-guchar       * gimp_drawable_get_sub_thumbnail_data (gint32         drawable_ID,
-                                                     gint           src_x,
-                                                     gint           src_y,
-                                                     gint           src_width,
-                                                     gint           src_height,
-                                                     gint          *dest_width,
-                                                     gint          *dest_height,
-                                                     gint          *bpp);
+GeglBuffer * gimp_drawable_get_buffer             (gint32         drawable_ID);
+GeglBuffer * gimp_drawable_get_shadow_buffer      (gint32         drawable_ID);
+
+const Babl * gimp_drawable_get_format             (gint32         drawable_ID);
+const Babl * gimp_drawable_get_thumbnail_format   (gint32         drawable_ID);
+
+guchar     * gimp_drawable_get_thumbnail_data     (gint32         drawable_ID,
+                                                   gint          *width,
+                                                   gint          *height,
+                                                   gint          *bpp);
+GdkPixbuf  * gimp_drawable_get_thumbnail          (gint32         drawable_ID,
+                                                   gint           width,
+                                                   gint           height,
+                                                   GimpPixbufTransparency alpha);
+
+guchar     * gimp_drawable_get_sub_thumbnail_data (gint32         drawable_ID,
+                                                   gint           src_x,
+                                                   gint           src_y,
+                                                   gint           src_width,
+                                                   gint           src_height,
+                                                   gint          *dest_width,
+                                                   gint          *dest_height,
+                                                   gint          *bpp);
+GdkPixbuf  * gimp_drawable_get_sub_thumbnail      (gint32         drawable_ID,
+                                                   gint           src_x,
+                                                   gint           src_y,
+                                                   gint           src_width,
+                                                   gint           src_height,
+                                                   gint           dest_width,
+                                                   gint           dest_height,
+                                                   GimpPixbufTransparency alpha);
 
 
 G_END_DECLS
diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c
index 762367e45c..44f00b44fe 100644
--- a/libgimp/gimpimage.c
+++ b/libgimp/gimpimage.c
@@ -21,7 +21,9 @@
 #include "config.h"
 
 #include "gimp.h"
-#include "gimpimage.h"
+
+#include "gimppixbuf.h"
+
 
 /**
  * gimp_image_get_colormap:
@@ -74,6 +76,22 @@ gimp_image_set_colormap (gint32        image_ID,
   return _gimp_image_set_colormap (image_ID, num_colors * 3, colormap);
 }
 
+/**
+ * gimp_image_get_thumbnail_data:
+ * @image_ID: The image.
+ * @width:    (inout): The requested thumbnail width.
+ * @height:   (inout): The requested thumbnail height.
+ * @bpp:      (out): The previews bpp.
+ *
+ * Get a thumbnail of an image.
+ *
+ * This function gets data from which a thumbnail of an image preview
+ * can be created. Maximum x or y dimension is 1024 pixels. The pixels
+ * are returned in RGB[A] or GRAY[A] format. The bpp return value
+ * gives the number of bytes per pixel in the image.
+ *
+ * Returns: (transfer full): the thumbnail data.
+ **/
 guchar *
 gimp_image_get_thumbnail_data (gint32  image_ID,
                                gint   *width,
@@ -100,6 +118,46 @@ gimp_image_get_thumbnail_data (gint32  image_ID,
   return image_data;
 }
 
+/**
+ * gimp_image_get_thumbnail:
+ * @image_ID: the image ID
+ * @width:    the requested thumbnail width  (<= 1024 pixels)
+ * @height:   the requested thumbnail height (<= 1024 pixels)
+ * @alpha:    how to handle an alpha channel
+ *
+ * Retrieves a thumbnail pixbuf for the image identified by @image_ID.
+ * The thumbnail will be not larger than the requested size.
+ *
+ * Returns: (transfer full): a new #GdkPixbuf
+ *
+ * Since: 2.2
+ **/
+GdkPixbuf *
+gimp_image_get_thumbnail (gint32                  image_ID,
+                          gint                    width,
+                          gint                    height,
+                          GimpPixbufTransparency  alpha)
+{
+  gint    thumb_width  = width;
+  gint    thumb_height = height;
+  gint    thumb_bpp;
+  guchar *data;
+
+  g_return_val_if_fail (width  > 0 && width  <= 1024, NULL);
+  g_return_val_if_fail (height > 0 && height <= 1024, NULL);
+
+  data = gimp_image_get_thumbnail_data (image_ID,
+                                        &thumb_width,
+                                        &thumb_height,
+                                        &thumb_bpp);
+  if (data)
+    return _gimp_pixbuf_from_data (data,
+                                   thumb_width, thumb_height, thumb_bpp,
+                                   alpha);
+  else
+    return NULL;
+}
+
 /**
  * gimp_image_get_metadata:
  * @image_ID: The image.
diff --git a/libgimp/gimpimage.h b/libgimp/gimpimage.h
index 2e8f7f0e5b..c71ebddfa7 100644
--- a/libgimp/gimpimage.h
+++ b/libgimp/gimpimage.h
@@ -40,6 +40,10 @@ guchar       * gimp_image_get_thumbnail_data (gint32        image_ID,
                                               gint         *width,
                                               gint         *height,
                                               gint         *bpp);
+GdkPixbuf    * gimp_image_get_thumbnail      (gint32        image_ID,
+                                              gint          width,
+                                              gint          height,
+                                              GimpPixbufTransparency  alpha);
 
 GimpMetadata * gimp_image_get_metadata       (gint32        image_ID);
 gboolean       gimp_image_set_metadata       (gint32        image_ID,
diff --git a/libgimp/gimplayer.c b/libgimp/gimplayer.c
index b48804e443..7c6ce1e5a6 100644
--- a/libgimp/gimplayer.c
+++ b/libgimp/gimplayer.c
@@ -22,8 +22,6 @@
 
 #include <string.h>
 
-#define GIMP_DISABLE_DEPRECATION_WARNINGS
-
 #include "gimp.h"
 
 
diff --git a/libgimp/gimppixbuf.c b/libgimp/gimppixbuf.c
index 1c509e4614..ccf1b72e41 100644
--- a/libgimp/gimppixbuf.c
+++ b/libgimp/gimppixbuf.c
@@ -26,171 +26,16 @@
 #include "gimppixbuf.h"
 
 
-/**
- * SECTION: gimppixbuf
- * @title: gimppixbuf
- * @short_description: Get a thumbnail pixbuf for a drawable or image.
- *
- * Get a thumbnail pixbuf for a drawable or image.
- **/
-
-
-static GdkPixbuf * gimp_pixbuf_from_data (guchar                 *data,
-                                          gint                    width,
-                                          gint                    height,
-                                          gint                    bpp,
-                                          GimpPixbufTransparency  alpha);
-
-
-/**
- * gimp_image_get_thumbnail:
- * @image_ID: the image ID
- * @width:    the requested thumbnail width  (<= 1024 pixels)
- * @height:   the requested thumbnail height (<= 1024 pixels)
- * @alpha:    how to handle an alpha channel
- *
- * Retrieves a thumbnail pixbuf for the image identified by @image_ID.
- * The thumbnail will be not larger than the requested size.
- *
- * Returns: (transfer full): a new #GdkPixbuf
- *
- * Since: 2.2
- **/
-GdkPixbuf *
-gimp_image_get_thumbnail (gint32                  image_ID,
-                          gint                    width,
-                          gint                    height,
-                          GimpPixbufTransparency  alpha)
-{
-  gint    thumb_width  = width;
-  gint    thumb_height = height;
-  gint    thumb_bpp;
-  guchar *data;
-
-  g_return_val_if_fail (width  > 0 && width  <= 1024, NULL);
-  g_return_val_if_fail (height > 0 && height <= 1024, NULL);
-
-  data = gimp_image_get_thumbnail_data (image_ID,
-                                        &thumb_width,
-                                        &thumb_height,
-                                        &thumb_bpp);
-  if (data)
-    return gimp_pixbuf_from_data (data,
-                                  thumb_width, thumb_height, thumb_bpp,
-                                  alpha);
-  else
-    return NULL;
-}
-
-/**
- * gimp_drawable_get_thumbnail:
- * @drawable_ID: the drawable ID
- * @width:       the requested thumbnail width  (<= 1024 pixels)
- * @height:      the requested thumbnail height (<= 1024 pixels)
- * @alpha:       how to handle an alpha channel
- *
- * Retrieves a thumbnail pixbuf for the drawable identified by
- * @drawable_ID. The thumbnail will be not larger than the requested
- * size.
- *
- * Returns: (transfer full): a new #GdkPixbuf
- *
- * Since: 2.2
- **/
-GdkPixbuf *
-gimp_drawable_get_thumbnail (gint32                  drawable_ID,
-                             gint                    width,
-                             gint                    height,
-                             GimpPixbufTransparency  alpha)
-{
-  gint    thumb_width  = width;
-  gint    thumb_height = height;
-  gint    thumb_bpp;
-  guchar *data;
-
-  g_return_val_if_fail (width  > 0 && width  <= 1024, NULL);
-  g_return_val_if_fail (height > 0 && height <= 1024, NULL);
-
-  data = gimp_drawable_get_thumbnail_data (drawable_ID,
-                                           &thumb_width,
-                                           &thumb_height,
-                                           &thumb_bpp);
-
-  if (data)
-    return gimp_pixbuf_from_data (data,
-                                  thumb_width, thumb_height, thumb_bpp,
-                                  alpha);
-
-  return NULL;
-}
-
-/**
- * gimp_drawable_get_sub_thumbnail:
- * @drawable_ID: the drawable ID
- * @src_x:       the x coordinate of the area
- * @src_y:       the y coordinate of the area
- * @src_width:   the width of the area
- * @src_height:  the height of the area
- * @dest_width:  the requested thumbnail width  (<= 1024 pixels)
- * @dest_height: the requested thumbnail height (<= 1024 pixels)
- * @alpha:       how to handle an alpha channel
- *
- * Retrieves a thumbnail pixbuf for the drawable identified by
- * @drawable_ID. The thumbnail will be not larger than the requested
- * size.
- *
- * Returns: (transfer full): a new #GdkPixbuf
- *
- * Since: 2.2
- **/
-GdkPixbuf *
-gimp_drawable_get_sub_thumbnail (gint32                  drawable_ID,
-                                 gint                    src_x,
-                                 gint                    src_y,
-                                 gint                    src_width,
-                                 gint                    src_height,
-                                 gint                    dest_width,
-                                 gint                    dest_height,
-                                 GimpPixbufTransparency  alpha)
-{
-  gint    thumb_width  = dest_width;
-  gint    thumb_height = dest_height;
-  gint    thumb_bpp;
-  guchar *data;
-
-  g_return_val_if_fail (src_x >= 0, NULL);
-  g_return_val_if_fail (src_y >= 0, NULL);
-  g_return_val_if_fail (src_width  > 0, NULL);
-  g_return_val_if_fail (src_height > 0, NULL);
-  g_return_val_if_fail (dest_width  > 0 && dest_width  <= 1024, NULL);
-  g_return_val_if_fail (dest_height > 0 && dest_height <= 1024, NULL);
-
-  data = gimp_drawable_get_sub_thumbnail_data (drawable_ID,
-                                               src_x, src_y,
-                                               src_width, src_height,
-                                               &thumb_width,
-                                               &thumb_height,
-                                               &thumb_bpp);
-
-  if (data)
-    return gimp_pixbuf_from_data (data,
-                                  thumb_width, thumb_height, thumb_bpp,
-                                  alpha);
-
-  return NULL;
-}
-
-
 /*
  * The data that is passed to this function is either freed here or
  * owned by the returned pixbuf.
  */
-static GdkPixbuf *
-gimp_pixbuf_from_data (guchar                 *data,
-                       gint                    width,
-                       gint                    height,
-                       gint                    bpp,
-                       GimpPixbufTransparency  alpha)
+GdkPixbuf *
+_gimp_pixbuf_from_data (guchar                 *data,
+                        gint                    width,
+                        gint                    height,
+                        gint                    bpp,
+                        GimpPixbufTransparency  alpha)
 {
   GdkPixbuf *pixbuf;
 
diff --git a/libgimp/gimppixbuf.h b/libgimp/gimppixbuf.h
index b7347844fd..87646bee52 100644
--- a/libgimp/gimppixbuf.h
+++ b/libgimp/gimppixbuf.h
@@ -31,39 +31,12 @@ G_BEGIN_DECLS
 /* For information look into the C source or the html documentation */
 
 
-/**
- * GimpPixbufTransparency:
- * @GIMP_PIXBUF_KEEP_ALPHA:   Create a pixbuf with alpha
- * @GIMP_PIXBUF_SMALL_CHECKS: Show transparency as small checks
- * @GIMP_PIXBUF_LARGE_CHECKS: Show transparency as large checks
- *
- * How to deal with transparency when creating thubnail pixbufs from
- * images and drawables.
- **/
-typedef enum
-{
-  GIMP_PIXBUF_KEEP_ALPHA,
-  GIMP_PIXBUF_SMALL_CHECKS,
-  GIMP_PIXBUF_LARGE_CHECKS
-} GimpPixbufTransparency;
-
+GdkPixbuf * _gimp_pixbuf_from_data (guchar                 *data,
+                                    gint                    width,
+                                    gint                    height,
+                                    gint                    bpp,
+                                    GimpPixbufTransparency  alpha);
 
-GdkPixbuf * gimp_image_get_thumbnail        (gint32                  image_ID,
-                                             gint                    width,
-                                             gint                    height,
-                                             GimpPixbufTransparency  alpha);
-GdkPixbuf * gimp_drawable_get_thumbnail     (gint32                  drawable_ID,
-                                             gint                    width,
-                                             gint                    height,
-                                             GimpPixbufTransparency  alpha);
-GdkPixbuf * gimp_drawable_get_sub_thumbnail (gint32                  drawable_ID,
-                                             gint                    src_x,
-                                             gint                    src_y,
-                                             gint                    src_width,
-                                             gint                    src_height,
-                                             gint                    dest_width,
-                                             gint                    dest_height,
-                                             GimpPixbufTransparency  alpha);
 
 G_END_DECLS
 
diff --git a/libgimp/gimptypes.h b/libgimp/gimptypes.h
index 9342117564..5136684890 100644
--- a/libgimp/gimptypes.h
+++ b/libgimp/gimptypes.h
@@ -38,6 +38,25 @@ typedef union  _GimpParamData   GimpParamData;
 typedef struct _GimpParam       GimpParam;
 
 
+/* FIXME move somewhere else */
+
+/**
+ * GimpPixbufTransparency:
+ * @GIMP_PIXBUF_KEEP_ALPHA:   Create a pixbuf with alpha
+ * @GIMP_PIXBUF_SMALL_CHECKS: Show transparency as small checks
+ * @GIMP_PIXBUF_LARGE_CHECKS: Show transparency as large checks
+ *
+ * How to deal with transparency when creating thubnail pixbufs from
+ * images and drawables.
+ **/
+typedef enum
+{
+  GIMP_PIXBUF_KEEP_ALPHA,
+  GIMP_PIXBUF_SMALL_CHECKS,
+  GIMP_PIXBUF_LARGE_CHECKS
+} GimpPixbufTransparency;
+
+
 G_END_DECLS
 
 #endif /* __GIMP_TYPES_H__ */


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