From 69b2aa880f9e5f5209912cd2cc645f6255c17f94 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 17 Mar 2012 21:59:10 +0100 Subject: [PATCH] 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 56ed2de675..f8a93abd08 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 812e1c1f73..ef84855428 100644 --- a/app/core/gimppattern-load.c +++ b/app/core/gimppattern-load.c @@ -41,6 +41,8 @@ #define _O_BINARY 0 #endif +#include + #include "libgimpbase/gimpbase.h" #include "core-types.h" diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c index f216ed2cce..21e2e331f5 100644 --- a/app/core/gimppattern.c +++ b/app/core/gimppattern.c @@ -19,7 +19,7 @@ #include -#include +#include #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 e4db63473e..31a03e0683 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 3de6b09a86..2e26826c99 100644 --- a/app/widgets/gimpdevices.c +++ b/app/widgets/gimpdevices.c @@ -26,6 +26,7 @@ #undef GSEAL_ENABLE #include +#include #include #include "libgimpcolor/gimpcolor.h" diff --git a/app/widgets/gimpdevicestatus.c b/app/widgets/gimpdevicestatus.c index d6330c894e..b14637c7c6 100644 --- a/app/widgets/gimpdevicestatus.c +++ b/app/widgets/gimpdevicestatus.c @@ -22,6 +22,7 @@ #undef GSEAL_ENABLE +#include #include #include "libgimpcolor/gimpcolor.h" diff --git a/app/widgets/gimppatternselect.c b/app/widgets/gimppatternselect.c index 40b27e97c4..e500d0cdd7 100644 --- a/app/widgets/gimppatternselect.c +++ b/app/widgets/gimppatternselect.c @@ -20,6 +20,7 @@ #include "config.h" +#include #include #include "libgimpwidgets/gimpwidgets.h" diff --git a/app/widgets/gimptoolbox-indicator-area.c b/app/widgets/gimptoolbox-indicator-area.c index ee6614627b..32dcdab9bb 100644 --- a/app/widgets/gimptoolbox-indicator-area.c +++ b/app/widgets/gimptoolbox-indicator-area.c @@ -20,6 +20,7 @@ #include #include +#include #include #include "libgimpwidgets/gimpwidgets.h"