[gimp] app: rename gimp_layer_new_from_buffer() to gimp_layer_new_from_gegl_buffer()



commit 6446c007cf2398f27d261d10e21d7027c3bceb3b
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jun 20 00:02:11 2015 +0200

    app: rename gimp_layer_new_from_buffer() to gimp_layer_new_from_gegl_buffer()
    
    and add new function gimp_layer_new_from_buffer() which takes a
    GimpBuffer. This will make sense soon :)

 app/actions/edit-commands.c       |    6 ++--
 app/actions/layers-commands.c     |   12 ++++++----
 app/core/gimp-edit.c              |    3 +-
 app/core/gimpdrawable-transform.c |   12 +++++-----
 app/core/gimpimage-new.c          |    3 +-
 app/core/gimplayer-new.c          |   35 ++++++++++++++++++++++++++++-
 app/core/gimplayer-new.h          |   44 +++++++++++++++++++++----------------
 app/core/gimpselection.c          |    9 ++++---
 app/pdb/layer-cmds.c              |   13 ++++++-----
 tools/pdbgen/pdb/layer.pdb        |   13 ++++++-----
 10 files changed, 96 insertions(+), 54 deletions(-)
---
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index b8ec5b2..e0d3f4e 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -360,12 +360,12 @@ edit_paste_as_new_layer_cmd_callback (GtkAction *action,
     {
       GimpLayer *layer;
 
-      layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (buffer),
-                                          image,
+      layer = gimp_layer_new_from_buffer (buffer, image,
                                           gimp_image_get_layer_format (image,
                                                                        TRUE),
                                           _("Clipboard"),
-                                          GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+                                          GIMP_OPACITY_OPAQUE,
+                                          GIMP_NORMAL_MODE);
       g_object_unref (buffer);
 
       gimp_image_add_layer (image, layer,
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 08fc3cf..a8af7e2 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -357,11 +357,13 @@ layers_new_from_visible_cmd_callback (GtkAction *action,
 
   gimp_pickable_flush (pickable);
 
-  layer = gimp_layer_new_from_buffer (gimp_pickable_get_buffer (pickable),
-                                      image,
-                                      gimp_image_get_layer_format (image, TRUE),
-                                      _("Visible"),
-                                      GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+  layer = gimp_layer_new_from_gegl_buffer (gimp_pickable_get_buffer (pickable),
+                                           image,
+                                           gimp_image_get_layer_format (image,
+                                                                        TRUE),
+                                           _("Visible"),
+                                           GIMP_OPACITY_OPAQUE,
+                                           GIMP_NORMAL_MODE);
 
   gimp_image_add_layer (image, layer,
                         GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 0e058ba..d395c14 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -178,8 +178,7 @@ gimp_edit_paste (GimpImage    *image,
   else
     format = gimp_image_get_layer_format (image, TRUE);
 
-  layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (paste),
-                                      image,
+  layer = gimp_layer_new_from_buffer (paste, image,
                                       format,
                                       _("Pasted Layer"),
                                       GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index ce4c15c..e3fb1e5 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -893,8 +893,8 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
       gint x, y, w, h;
 
       /* set the keep_indexed flag to FALSE here, since we use
-       * gimp_layer_new_from_buffer() later which assumes that the buffer
-       * are either RGB or GRAY.  Eeek!!!              (Sven)
+       * gimp_layer_new_from_gegl_buffer() later which assumes that
+       * the buffer are either RGB or GRAY.  Eeek!!!  (Sven)
        */
       if (gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &w, &h))
         {
@@ -959,10 +959,10 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
   if (new_layer)
     {
       layer =
-        gimp_layer_new_from_buffer (buffer, image,
-                                    gimp_drawable_get_format_with_alpha (drawable),
-                                    _("Transformation"),
-                                    GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+        gimp_layer_new_from_gegl_buffer (buffer, image,
+                                         gimp_drawable_get_format_with_alpha (drawable),
+                                         _("Transformation"),
+                                         GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
 
       gimp_item_set_offset (GIMP_ITEM (layer), offset_x, offset_y);
 
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index 657d4cb..b3c0280 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -316,8 +316,7 @@ gimp_image_new_from_buffer (Gimp       *gimp,
   if (icc_data)
     gimp_image_set_icc_profile (image, icc_data, icc_len, NULL);
 
-  layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (paste),
-                                      image,
+  layer = gimp_layer_new_from_buffer (paste, image,
                                       gimp_image_get_layer_format (image,
                                                                    has_alpha),
                                       _("Pasted Layer"),
diff --git a/app/core/gimplayer-new.c b/app/core/gimplayer-new.c
index 969758b..7035239 100644
--- a/app/core/gimplayer-new.c
+++ b/app/core/gimplayer-new.c
@@ -25,6 +25,7 @@
 
 #include "core-types.h"
 
+#include "gimpbuffer.h"
 #include "gimpimage.h"
 #include "gimplayer.h"
 #include "gimplayer-new.h"
@@ -75,13 +76,45 @@ gimp_layer_new (GimpImage            *image,
  * Return value: The new layer.
  **/
 GimpLayer *
-gimp_layer_new_from_buffer (GeglBuffer           *buffer,
+gimp_layer_new_from_buffer (GimpBuffer           *buffer,
                             GimpImage            *dest_image,
                             const Babl           *format,
                             const gchar          *name,
                             gdouble               opacity,
                             GimpLayerModeEffects  mode)
 {
+  g_return_val_if_fail (GIMP_IS_BUFFER (buffer), NULL);
+  g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
+  g_return_val_if_fail (format != NULL, NULL);
+
+  return gimp_layer_new_from_gegl_buffer (gimp_buffer_get_buffer (buffer),
+                                          dest_image, format,
+                                          name, opacity, mode);
+}
+
+/**
+ * gimp_layer_new_from_gegl_buffer:
+ * @buffer:     The buffer to make the new layer from.
+ * @dest_image: The image the new layer will be added to.
+ * @format:     The #Babl format of the new layer.
+ * @name:       The new layer's name.
+ * @opacity:    The new layer's opacity.
+ * @mode:       The new layer's mode.
+ *
+ * Copies %buffer to a layer taking into consideration the
+ * possibility of transforming the contents to meet the requirements
+ * of the target image type
+ *
+ * Return value: The new layer.
+ **/
+GimpLayer *
+gimp_layer_new_from_gegl_buffer (GeglBuffer           *buffer,
+                                 GimpImage            *dest_image,
+                                 const Babl           *format,
+                                 const gchar          *name,
+                                 gdouble               opacity,
+                                 GimpLayerModeEffects  mode)
+{
   GimpLayer  *layer;
   GeglBuffer *dest;
 
diff --git a/app/core/gimplayer-new.h b/app/core/gimplayer-new.h
index e2f5bd9..df99831 100644
--- a/app/core/gimplayer-new.h
+++ b/app/core/gimplayer-new.h
@@ -19,26 +19,32 @@
 #define __GIMP_LAYER_NEW_H__
 
 
-GimpLayer * gimp_layer_new             (GimpImage            *image,
-                                        gint                  width,
-                                        gint                  height,
-                                        const Babl           *format,
-                                        const gchar          *name,
-                                        gdouble               opacity,
-                                        GimpLayerModeEffects  mode);
+GimpLayer * gimp_layer_new                  (GimpImage            *image,
+                                             gint                  width,
+                                             gint                  height,
+                                             const Babl           *format,
+                                             const gchar          *name,
+                                             gdouble               opacity,
+                                             GimpLayerModeEffects  mode);
 
-GimpLayer * gimp_layer_new_from_buffer (GeglBuffer           *buffer,
-                                        GimpImage            *dest_image,
-                                        const Babl           *format,
-                                        const gchar          *name,
-                                        gdouble               opacity,
-                                        GimpLayerModeEffects  mode);
-GimpLayer * gimp_layer_new_from_pixbuf (GdkPixbuf            *pixbuf,
-                                        GimpImage            *dest_image,
-                                        const Babl           *format,
-                                        const gchar          *name,
-                                        gdouble               opacity,
-                                        GimpLayerModeEffects  mode);
+GimpLayer * gimp_layer_new_from_buffer      (GimpBuffer           *buffer,
+                                             GimpImage            *dest_image,
+                                             const Babl           *format,
+                                             const gchar          *name,
+                                             gdouble               opacity,
+                                             GimpLayerModeEffects  mode);
+GimpLayer * gimp_layer_new_from_gegl_buffer (GeglBuffer           *buffer,
+                                             GimpImage            *dest_image,
+                                             const Babl           *format,
+                                             const gchar          *name,
+                                             gdouble               opacity,
+                                             GimpLayerModeEffects  mode);
+GimpLayer * gimp_layer_new_from_pixbuf      (GdkPixbuf            *pixbuf,
+                                             GimpImage            *dest_image,
+                                             const Babl           *format,
+                                             const gchar          *name,
+                                             gdouble               opacity,
+                                             GimpLayerModeEffects  mode);
 
 
 #endif /* __GIMP_LAYER_NEW_H__ */
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 1361862..49c2c35 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -841,10 +841,11 @@ gimp_selection_float (GimpSelection *selection,
    *  because it may be different from the image's type if we cut from
    *  a channel or layer mask
    */
-  layer = gimp_layer_new_from_buffer (buffer, image,
-                                      gimp_drawable_get_format_with_alpha (drawable),
-                                      _("Floated Layer"),
-                                      GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+  layer = gimp_layer_new_from_gegl_buffer (buffer, image,
+                                           gimp_drawable_get_format_with_alpha (drawable),
+                                           _("Floated Layer"),
+                                           GIMP_OPACITY_OPAQUE,
+                                           GIMP_NORMAL_MODE);
 
   /*  Set the offsets  */
   gimp_item_set_offset (GIMP_ITEM (layer), x1 + off_x, y1 + off_y);
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index 3d0cd53..55192a2 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -168,12 +168,13 @@ layer_new_from_visible_invoker (GimpProcedure         *procedure,
 
       gimp_pickable_flush (pickable);
 
-      layer = gimp_layer_new_from_buffer (gimp_pickable_get_buffer (pickable),
-                                          dest_image,
-                                          gimp_image_get_layer_format (dest_image,
-                                                                       TRUE),
-                                          name,
-                                          GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+      layer = gimp_layer_new_from_gegl_buffer (gimp_pickable_get_buffer (pickable),
+                                               dest_image,
+                                               gimp_image_get_layer_format (dest_image,
+                                                                            TRUE),
+                                               name,
+                                               GIMP_OPACITY_OPAQUE,
+                                               GIMP_NORMAL_MODE);
     }
 
   return_vals = gimp_procedure_get_return_values (procedure, success,
diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb
index f9e7a16..264bb37 100644
--- a/tools/pdbgen/pdb/layer.pdb
+++ b/tools/pdbgen/pdb/layer.pdb
@@ -146,12 +146,13 @@ HELP
 
   gimp_pickable_flush (pickable);
 
-  layer = gimp_layer_new_from_buffer (gimp_pickable_get_buffer (pickable),
-                                      dest_image,
-                                      gimp_image_get_layer_format (dest_image,
-                                                                   TRUE),
-                                      name,
-                                      GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+  layer = gimp_layer_new_from_gegl_buffer (gimp_pickable_get_buffer (pickable),
+                                           dest_image,
+                                           gimp_image_get_layer_format (dest_image,
+                                                                        TRUE),
+                                           name,
+                                           GIMP_OPACITY_OPAQUE,
+                                           GIMP_NORMAL_MODE);
 }
 CODE
     );


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