[gimp/goat-invasion: 105/401] app: add gimp_pattern_create_buffer() and use it in gimp_edit_fill_internal()



commit e8cfdafb81577ef1c99d66436510045a40100ba4
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 17 21:59:10 2012 +0100

    app: add gimp_pattern_create_buffer() and use it in gimp_edit_fill_internal()

 app/core/gimp-edit.c                     |   26 +++-----------------------
 app/core/gimppattern-load.c              |    2 ++
 app/core/gimppattern.c                   |   24 +++++++++++++++++++++++-
 app/core/gimppattern.h                   |   11 ++++++-----
 app/widgets/gimpdevices.c                |    1 +
 app/widgets/gimpdevicestatus.c           |    1 +
 app/widgets/gimppatternselect.c          |    1 +
 app/widgets/gimptoolbox-indicator-area.c |    1 +
 8 files changed, 38 insertions(+), 29 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 56ed2de..f8a93ab 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -570,7 +570,7 @@ gimp_edit_fill_internal (GimpImage            *image,
       break;
 
     case GIMP_WHITE_FILL:
-      gimp_rgb_set (&color, 1.0, 1.0, 1.0);
+      gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0);
       break;
 
     case GIMP_PATTERN_FILL:
@@ -593,22 +593,7 @@ gimp_edit_fill_internal (GimpImage            *image,
 
   if (pattern)
     {
-      GeglBuffer    *src_buffer;
-      GeglRectangle  rect = { 0, };
-      gint           pat_bytes;
-
-      rect.width  = pattern->mask->width;
-      rect.height = pattern->mask->height;
-
-      pat_bytes = pattern->mask->bytes;
-
-      src_buffer =
-        gegl_buffer_linear_new_from_data (temp_buf_get_data (pattern->mask),
-                                          gimp_bpp_to_babl_format (pat_bytes,
-                                                                   TRUE),
-                                          &rect,
-                                          rect.width * pat_bytes,
-                                          NULL, NULL);
+      GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
 
       gegl_buffer_set_pattern (dest_buffer, NULL, src_buffer, 0, 0);
 
@@ -616,14 +601,9 @@ gimp_edit_fill_internal (GimpImage            *image,
     }
   else
     {
-      GeglColor *gegl_color;
+      GeglColor *gegl_color = gegl_color_new (NULL);
 
-      if (gimp_drawable_has_alpha (drawable))
-        gimp_rgb_set_alpha (&color, 1.0);
-
-      gegl_color = gegl_color_new (NULL);
       gimp_gegl_color_set_rgba (gegl_color, &color);
-
       gegl_buffer_set_color (dest_buffer, NULL, gegl_color);
 
       g_object_unref (gegl_color);
diff --git a/app/core/gimppattern-load.c b/app/core/gimppattern-load.c
index 812e1c1..ef84855 100644
--- a/app/core/gimppattern-load.c
+++ b/app/core/gimppattern-load.c
@@ -41,6 +41,8 @@
 #define _O_BINARY 0
 #endif
 
+#include <gegl.h>
+
 #include "libgimpbase/gimpbase.h"
 
 #include "core-types.h"
diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c
index f216ed2..21e2e33 100644
--- a/app/core/gimppattern.c
+++ b/app/core/gimppattern.c
@@ -19,7 +19,7 @@
 
 #include <string.h>
 
-#include <glib-object.h>
+#include <gegl.h>
 
 #include "libgimpbase/gimpbase.h"
 
@@ -27,6 +27,8 @@
 
 #include "base/temp-buf.h"
 
+#include "gegl/gimp-gegl-utils.h"
+
 #include "gimppattern.h"
 #include "gimppattern-load.h"
 #include "gimptagged.h"
@@ -263,3 +265,23 @@ gimp_pattern_get_mask (const GimpPattern *pattern)
 
   return pattern->mask;
 }
+
+GeglBuffer *
+gimp_pattern_create_buffer (const GimpPattern *pattern)
+{
+  GeglRectangle rect = { 0, };
+  gint          bytes;
+
+  g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
+
+  rect.width  = pattern->mask->width;
+  rect.height = pattern->mask->height;
+
+  bytes = pattern->mask->bytes;
+
+  return gegl_buffer_linear_new_from_data (temp_buf_get_data (pattern->mask),
+                                           gimp_bpp_to_babl_format (bytes, TRUE),
+                                           &rect,
+                                           rect.width * bytes,
+                                           NULL, NULL);
+}
diff --git a/app/core/gimppattern.h b/app/core/gimppattern.h
index e4db634..31a03e0 100644
--- a/app/core/gimppattern.h
+++ b/app/core/gimppattern.h
@@ -45,13 +45,14 @@ struct _GimpPatternClass
 };
 
 
-GType      gimp_pattern_get_type     (void) G_GNUC_CONST;
+GType        gimp_pattern_get_type      (void) G_GNUC_CONST;
 
-GimpData * gimp_pattern_new          (GimpContext       *context,
-                                      const gchar       *name);
-GimpData * gimp_pattern_get_standard (GimpContext       *context);
+GimpData   * gimp_pattern_new           (GimpContext       *context,
+                                         const gchar       *name);
+GimpData   * gimp_pattern_get_standard  (GimpContext       *context);
 
-TempBuf  * gimp_pattern_get_mask     (const GimpPattern *pattern);
+TempBuf    * gimp_pattern_get_mask      (const GimpPattern *pattern);
+GeglBuffer * gimp_pattern_create_buffer (const GimpPattern *pattern);
 
 
 #endif /* __GIMP_PATTERN_H__ */
diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c
index 3de6b09..2e26826 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -26,6 +26,7 @@
 #undef GSEAL_ENABLE
 
 #include <glib/gstdio.h>
+#include <gegl.h>
 #include <gtk/gtk.h>
 
 #include "libgimpcolor/gimpcolor.h"
diff --git a/app/widgets/gimpdevicestatus.c b/app/widgets/gimpdevicestatus.c
index d6330c8..b14637c 100644
--- a/app/widgets/gimpdevicestatus.c
+++ b/app/widgets/gimpdevicestatus.c
@@ -22,6 +22,7 @@
 
 #undef GSEAL_ENABLE
 
+#include <gegl.h>
 #include <gtk/gtk.h>
 
 #include "libgimpcolor/gimpcolor.h"
diff --git a/app/widgets/gimppatternselect.c b/app/widgets/gimppatternselect.c
index 40b27e9..e500d0c 100644
--- a/app/widgets/gimppatternselect.c
+++ b/app/widgets/gimppatternselect.c
@@ -20,6 +20,7 @@
 
 #include "config.h"
 
+#include <gegl.h>
 #include <gtk/gtk.h>
 
 #include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/widgets/gimptoolbox-indicator-area.c b/app/widgets/gimptoolbox-indicator-area.c
index ee66146..32dcdab 100644
--- a/app/widgets/gimptoolbox-indicator-area.c
+++ b/app/widgets/gimptoolbox-indicator-area.c
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <gegl.h>
 #include <gtk/gtk.h>
 
 #include "libgimpwidgets/gimpwidgets.h"



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