[gimp] app: move functions to create layers to new files gimplayer-new.[ch]



commit db09d0f3d3644432f20c58468ca7984b4c4f6061
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jun 17 13:21:01 2015 +0200

    app: move functions to create layers to new files gimplayer-new.[ch]

 app/actions/debug-commands.c       |    1 +
 app/actions/edit-commands.c        |    1 +
 app/actions/layers-commands.c      |    1 +
 app/core/Makefile.am               |    2 +
 app/core/gimp-edit.c               |    1 +
 app/core/gimp-utils.c              |    1 +
 app/core/gimpdrawable-transform.c  |    1 +
 app/core/gimpimage-merge.c         |    1 +
 app/core/gimpimage-new.c           |    1 +
 app/core/gimplayer-new.c           |  153 ++++++++++++++++++++++++++++++++++++
 app/core/gimplayer-new.h           |   44 ++++++++++
 app/core/gimplayer.c               |  122 ----------------------------
 app/core/gimplayer.h               |   21 -----
 app/core/gimpselection.c           |    1 +
 app/display/gimpdisplayshell-dnd.c |    1 +
 app/pdb/layer-cmds.c               |    1 +
 app/tests/gimp-app-test-utils.c    |    1 +
 app/widgets/gimplayertreeview.c    |    1 +
 app/xcf/xcf-load.c                 |    1 +
 tools/pdbgen/pdb/layer.pdb         |    1 +
 20 files changed, 214 insertions(+), 143 deletions(-)
---
diff --git a/app/actions/debug-commands.c b/app/actions/debug-commands.c
index de26878..9779dab 100644
--- a/app/actions/debug-commands.c
+++ b/app/actions/debug-commands.c
@@ -32,6 +32,7 @@
 #include "core/gimpcontext.h"
 #include "core/gimpimage.h"
 #include "core/gimplayer.h"
+#include "core/gimplayer-new.h"
 #include "core/gimppickable.h"
 #include "core/gimpprojectable.h"
 #include "core/gimpprojection.h"
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index 017270d..b8ec5b2 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -33,6 +33,7 @@
 #include "core/gimpcontainer.h"
 #include "core/gimpdrawable.h"
 #include "core/gimplayer.h"
+#include "core/gimplayer-new.h"
 #include "core/gimpimage.h"
 #include "core/gimpimage-new.h"
 #include "core/gimpimage-undo.h"
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 409024e..08fc3cf 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -40,6 +40,7 @@
 #include "core/gimpimage-undo-push.h"
 #include "core/gimpitemundo.h"
 #include "core/gimplayer-floating-sel.h"
+#include "core/gimplayer-new.h"
 #include "core/gimppickable.h"
 #include "core/gimppickable-auto-shrink.h"
 #include "core/gimptoolinfo.h"
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index a84d984..4dba1ca 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -284,6 +284,8 @@ libappcore_a_sources = \
        gimplayer.h                             \
        gimplayer-floating-sel.c                \
        gimplayer-floating-sel.h                \
+       gimplayer-new.c                         \
+       gimplayer-new.h                         \
        gimplayermask.c                         \
        gimplayermask.h                         \
        gimplayermaskpropundo.c                 \
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 7ff569a..0e058ba 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -41,6 +41,7 @@
 #include "gimpimage-undo.h"
 #include "gimplayer.h"
 #include "gimplayer-floating-sel.h"
+#include "gimplayer-new.h"
 #include "gimplist.h"
 #include "gimppattern.h"
 #include "gimppickable.h"
diff --git a/app/core/gimp-utils.c b/app/core/gimp-utils.c
index e7032e4..4f2236f 100644
--- a/app/core/gimp-utils.c
+++ b/app/core/gimp-utils.c
@@ -751,6 +751,7 @@ gimp_file_is_executable (GFile *file)
 #include "gegl/gimp-babl.h"
 #include "gimpimage.h"
 #include "gimplayer.h"
+#include "gimplayer-new.h"
 
 void
 gimp_create_image_from_buffer (Gimp       *gimp,
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index eb41d31..ce4c15c 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -43,6 +43,7 @@
 #include "gimpimage-undo-push.h"
 #include "gimplayer.h"
 #include "gimplayer-floating-sel.h"
+#include "gimplayer-new.h"
 #include "gimppickable.h"
 #include "gimpprogress.h"
 #include "gimpselection.h"
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index aec9c75..590a4c2 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -43,6 +43,7 @@
 #include "gimpimage-undo.h"
 #include "gimpitemstack.h"
 #include "gimplayer-floating-sel.h"
+#include "gimplayer-new.h"
 #include "gimplayermask.h"
 #include "gimpmarshal.h"
 #include "gimpparasitelist.h"
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index 3fa4688..657d4cb 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -41,6 +41,7 @@
 #include "gimpimage-profile.h"
 #include "gimpimage-undo.h"
 #include "gimplayer.h"
+#include "gimplayer-new.h"
 #include "gimptemplate.h"
 
 #include "gimp-intl.h"
diff --git a/app/core/gimplayer-new.c b/app/core/gimplayer-new.c
new file mode 100644
index 0000000..969758b
--- /dev/null
+++ b/app/core/gimplayer-new.c
@@ -0,0 +1,153 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * 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 <cairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gegl.h>
+
+#include "libgimpcolor/gimpcolor.h"
+
+#include "core-types.h"
+
+#include "gimpimage.h"
+#include "gimplayer.h"
+#include "gimplayer-new.h"
+
+
+GimpLayer *
+gimp_layer_new (GimpImage            *image,
+                gint                  width,
+                gint                  height,
+                const Babl           *format,
+                const gchar          *name,
+                gdouble               opacity,
+                GimpLayerModeEffects  mode)
+{
+  GimpLayer *layer;
+
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+  g_return_val_if_fail (width > 0, NULL);
+  g_return_val_if_fail (height > 0, NULL);
+  g_return_val_if_fail (format != NULL, NULL);
+
+  layer = GIMP_LAYER (gimp_drawable_new (GIMP_TYPE_LAYER,
+                                         image, name,
+                                         0, 0, width, height,
+                                         format));
+
+  opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
+
+  layer->opacity = opacity;
+  layer->mode    = mode;
+
+  return layer;
+}
+
+/**
+ * gimp_layer_new_from_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_buffer (GeglBuffer           *buffer,
+                            GimpImage            *dest_image,
+                            const Babl           *format,
+                            const gchar          *name,
+                            gdouble               opacity,
+                            GimpLayerModeEffects  mode)
+{
+  GimpLayer  *layer;
+  GeglBuffer *dest;
+
+  g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
+  g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
+  g_return_val_if_fail (format != NULL, NULL);
+
+  /*  do *not* use the buffer's format because this function gets
+   *  buffers of any format passed, and converts them
+   */
+  layer = gimp_layer_new (dest_image,
+                          gegl_buffer_get_width  (buffer),
+                          gegl_buffer_get_height (buffer),
+                          format,
+                          name, opacity, mode);
+
+  dest = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
+  gegl_buffer_copy (buffer, NULL, GEGL_ABYSS_NONE, dest, NULL);
+
+  return layer;
+}
+
+/**
+ * gimp_layer_new_from_pixbuf:
+ * @pixbuf:     The pixbuf 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 %pixbuf 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_pixbuf (GdkPixbuf            *pixbuf,
+                            GimpImage            *dest_image,
+                            const Babl           *format,
+                            const gchar          *name,
+                            gdouble               opacity,
+                            GimpLayerModeEffects  mode)
+{
+  GeglBuffer *buffer;
+  GimpLayer  *layer;
+  gint        width;
+  gint        height;
+
+  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
+  g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
+  g_return_val_if_fail (format != NULL, NULL);
+
+  width  = gdk_pixbuf_get_width (pixbuf);
+  height = gdk_pixbuf_get_height (pixbuf);
+
+  layer = gimp_layer_new (dest_image, width, height,
+                          format, name, opacity, mode);
+
+  buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
+
+  gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0, width, height), 0,
+                   gimp_pixbuf_get_format (pixbuf),
+                   gdk_pixbuf_get_pixels (pixbuf),
+                   gdk_pixbuf_get_rowstride (pixbuf));
+
+  return layer;
+}
diff --git a/app/core/gimplayer-new.h b/app/core/gimplayer-new.h
new file mode 100644
index 0000000..e2f5bd9
--- /dev/null
+++ b/app/core/gimplayer-new.h
@@ -0,0 +1,44 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * 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_LAYER_NEW_H__
+#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_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);
+
+
+#endif /* __GIMP_LAYER_NEW_H__ */
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 15e1fdb..e6a2ec5 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1192,128 +1192,6 @@ gimp_layer_layer_mask_update (GimpDrawable *drawable,
 /*  public functions  */
 
 GimpLayer *
-gimp_layer_new (GimpImage            *image,
-                gint                  width,
-                gint                  height,
-                const Babl           *format,
-                const gchar          *name,
-                gdouble               opacity,
-                GimpLayerModeEffects  mode)
-{
-  GimpLayer *layer;
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
-  g_return_val_if_fail (width > 0, NULL);
-  g_return_val_if_fail (height > 0, NULL);
-  g_return_val_if_fail (format != NULL, NULL);
-
-  layer = GIMP_LAYER (gimp_drawable_new (GIMP_TYPE_LAYER,
-                                         image, name,
-                                         0, 0, width, height,
-                                         format));
-
-  opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
-
-  layer->opacity = opacity;
-  layer->mode    = mode;
-
-  return layer;
-}
-
-/**
- * gimp_layer_new_from_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_buffer (GeglBuffer           *buffer,
-                            GimpImage            *dest_image,
-                            const Babl           *format,
-                            const gchar          *name,
-                            gdouble               opacity,
-                            GimpLayerModeEffects  mode)
-{
-  GimpLayer  *layer;
-  GeglBuffer *dest;
-
-  g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
-  g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
-  g_return_val_if_fail (format != NULL, NULL);
-
-  /*  do *not* use the buffer's format because this function gets
-   *  buffers of any format passed, and converts them
-   */
-  layer = gimp_layer_new (dest_image,
-                          gegl_buffer_get_width  (buffer),
-                          gegl_buffer_get_height (buffer),
-                          format,
-                          name, opacity, mode);
-
-  dest = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
-  gegl_buffer_copy (buffer, NULL, GEGL_ABYSS_NONE, dest, NULL);
-
-  return layer;
-}
-
-/**
- * gimp_layer_new_from_pixbuf:
- * @pixbuf:     The pixbuf 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 %pixbuf 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_pixbuf (GdkPixbuf            *pixbuf,
-                            GimpImage            *dest_image,
-                            const Babl           *format,
-                            const gchar          *name,
-                            gdouble               opacity,
-                            GimpLayerModeEffects  mode)
-{
-  GeglBuffer *buffer;
-  GimpLayer  *layer;
-  gint        width;
-  gint        height;
-
-  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
-  g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
-  g_return_val_if_fail (format != NULL, NULL);
-
-  width  = gdk_pixbuf_get_width (pixbuf);
-  height = gdk_pixbuf_get_height (pixbuf);
-
-  layer = gimp_layer_new (dest_image, width, height,
-                          format, name, opacity, mode);
-
-  buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
-
-  gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0, width, height), 0,
-                   gimp_pixbuf_get_format (pixbuf),
-                   gdk_pixbuf_get_pixels (pixbuf),
-                   gdk_pixbuf_get_rowstride (pixbuf));
-
-  return layer;
-}
-
-GimpLayer *
 gimp_layer_get_parent (GimpLayer *layer)
 {
   g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
diff --git a/app/core/gimplayer.h b/app/core/gimplayer.h
index 2f962d7..db2f276 100644
--- a/app/core/gimplayer.h
+++ b/app/core/gimplayer.h
@@ -76,27 +76,6 @@ struct _GimpLayerClass
 
 GType           gimp_layer_get_type            (void) G_GNUC_CONST;
 
-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_get_parent          (GimpLayer            *layer);
 
 GimpLayerMask * gimp_layer_get_mask            (const GimpLayer      *layer);
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 52d0a00..1361862 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -36,6 +36,7 @@
 #include "gimpimage-undo.h"
 #include "gimpimage-undo-push.h"
 #include "gimplayer.h"
+#include "gimplayer-new.h"
 #include "gimplayermask.h"
 #include "gimplayer-floating-sel.h"
 #include "gimppickable.h"
diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c
index ed86cd2..74e736c 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -37,6 +37,7 @@
 #include "core/gimpimage-new.h"
 #include "core/gimpimage-undo.h"
 #include "core/gimplayer.h"
+#include "core/gimplayer-new.h"
 #include "core/gimplayermask.h"
 #include "core/gimppattern.h"
 #include "core/gimpprogress.h"
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index 52eae7d..3d0cd53 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -35,6 +35,7 @@
 #include "core/gimpimage-undo.h"
 #include "core/gimpimage.h"
 #include "core/gimpitem-linked.h"
+#include "core/gimplayer-new.h"
 #include "core/gimplayer.h"
 #include "core/gimplayermask.h"
 #include "core/gimpparamspecs.h"
diff --git a/app/tests/gimp-app-test-utils.c b/app/tests/gimp-app-test-utils.c
index 511bb59..f7b6a07 100644
--- a/app/tests/gimp-app-test-utils.c
+++ b/app/tests/gimp-app-test-utils.c
@@ -32,6 +32,7 @@
 #include "core/gimp.h"
 #include "core/gimpimage.h"
 #include "core/gimplayer.h"
+#include "core/gimplayer-new.h"
 
 #include "tests.h"
 
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index b6224f9..9c0647c 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -37,6 +37,7 @@
 #include "core/gimpimage.h"
 #include "core/gimpitemundo.h"
 #include "core/gimplayer.h"
+#include "core/gimplayer-new.h"
 #include "core/gimplayermask.h"
 #include "core/gimptreehandler.h"
 
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index caaa110..a62b37c 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -48,6 +48,7 @@
 #include "core/gimpimage-undo.h"
 #include "core/gimpitemstack.h"
 #include "core/gimplayer-floating-sel.h"
+#include "core/gimplayer-new.h"
 #include "core/gimplayermask.h"
 #include "core/gimpparasitelist.h"
 #include "core/gimpprogress.h"
diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb
index ca2f25b..f9e7a16 100644
--- a/tools/pdbgen/pdb/layer.pdb
+++ b/tools/pdbgen/pdb/layer.pdb
@@ -1199,6 +1199,7 @@ CODE
               "core/gimpimage-undo.h"
               "core/gimpitem-linked.h"
               "core/gimpgrouplayer.h"
+              "core/gimplayer-new.h"
               "core/gimppickable.h"
               "core/gimpprogress.h"
               "gimppdbcontext.h"


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