[gimp/metadata-browser] libgimpcolor: add Cairo <-> GEGL utility functions from app/
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] libgimpcolor: add Cairo <-> GEGL utility functions from app/
- Date: Thu, 13 Sep 2012 00:04:03 +0000 (UTC)
commit b7e9b43ff6e5577adaf2c10c87217fffb1e304ce
Author: Michael Natterer <mitch gimp org>
Date: Thu May 3 04:07:16 2012 +0200
libgimpcolor: add Cairo <-> GEGL utility functions from app/
app/core/gimp-cairo.c | 28 -----------------------
app/core/gimp-cairo.h | 26 ++++++++++-----------
app/text/gimptextlayer.c | 3 +-
app/widgets/gimpviewrenderer.c | 5 +--
libgimpcolor/gimpcairo.c | 48 +++++++++++++++++++++++++++++++++++++++-
libgimpcolor/gimpcairo.h | 19 +++++++++------
libgimpcolor/gimpcolor.def | 2 +
7 files changed, 75 insertions(+), 56 deletions(-)
---
diff --git a/app/core/gimp-cairo.c b/app/core/gimp-cairo.c
index cda6b07..c39b162 100644
--- a/app/core/gimp-cairo.c
+++ b/app/core/gimp-cairo.c
@@ -37,34 +37,6 @@
static cairo_user_data_key_t surface_data_key = { 0, };
-GeglBuffer *
-gimp_cairo_image_surface_create_buffer (cairo_surface_t *surface)
-{
- const Babl *format;
- gint width;
- gint height;
-
- g_return_val_if_fail (surface != NULL, NULL);
- g_return_val_if_fail (cairo_surface_get_type (surface) ==
- CAIRO_SURFACE_TYPE_IMAGE, NULL);
-
- width = cairo_image_surface_get_width (surface);
- height = cairo_image_surface_get_height (surface);
-
- if (cairo_surface_get_content (surface) == CAIRO_CONTENT_COLOR_ALPHA)
- format = babl_format ("cairo-ARGB32");
- else
- format = babl_format ("cairo-RGB24");
-
- return
- gegl_buffer_linear_new_from_data (cairo_image_surface_get_data (surface),
- format,
- GEGL_RECTANGLE (0, 0, width, height),
- cairo_image_surface_get_stride (surface),
- (GDestroyNotify) cairo_surface_destroy,
- cairo_surface_reference (surface));
-}
-
cairo_pattern_t *
gimp_cairo_stipple_pattern_create (const GimpRGB *fg,
const GimpRGB *bg,
diff --git a/app/core/gimp-cairo.h b/app/core/gimp-cairo.h
index a98003c..1c9e1b1 100644
--- a/app/core/gimp-cairo.h
+++ b/app/core/gimp-cairo.h
@@ -25,21 +25,19 @@
#define __APP_GIMP_CAIRO_H__
-GeglBuffer * gimp_cairo_image_surface_create_buffer (cairo_surface_t *surface);
+cairo_pattern_t * gimp_cairo_stipple_pattern_create (const GimpRGB *fg,
+ const GimpRGB *bg,
+ gint index);
-cairo_pattern_t * gimp_cairo_stipple_pattern_create (const GimpRGB *fg,
- const GimpRGB *bg,
- gint index);
-
-void gimp_cairo_add_arc (cairo_t *cr,
- gdouble center_x,
- gdouble center_y,
- gdouble radius,
- gdouble start_angle,
- gdouble slice_angle);
-void gimp_cairo_add_segments (cairo_t *cr,
- GimpSegment *segs,
- gint n_segs);
+void gimp_cairo_add_arc (cairo_t *cr,
+ gdouble center_x,
+ gdouble center_y,
+ gdouble radius,
+ gdouble start_angle,
+ gdouble slice_angle);
+void gimp_cairo_add_segments (cairo_t *cr,
+ GimpSegment *segs,
+ gint n_segs);
#endif /* __APP_GIMP_CAIRO_H__ */
diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c
index 10299f3..0c6a6f6 100644
--- a/app/text/gimptextlayer.c
+++ b/app/text/gimptextlayer.c
@@ -36,7 +36,6 @@
#include "gegl/gimp-gegl-utils.h"
#include "core/gimp.h"
-#include "core/gimp-cairo.h"
#include "core/gimp-utils.h"
#include "core/gimpcontext.h"
#include "core/gimpcontainer.h"
@@ -671,7 +670,7 @@ gimp_text_layer_render_layout (GimpTextLayer *layer,
cairo_surface_flush (surface);
- buffer = gimp_cairo_image_surface_create_buffer (surface);
+ buffer = gimp_cairo_surface_create_buffer (surface);
gegl_buffer_copy (buffer, NULL,
gimp_drawable_get_buffer (drawable), NULL);
diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c
index 5dccdf7..c919af7 100644
--- a/app/widgets/gimpviewrenderer.c
+++ b/app/widgets/gimpviewrenderer.c
@@ -33,7 +33,6 @@
#include "widgets-types.h"
-#include "core/gimp-cairo.h"
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
#include "core/gimptempbuf.h"
@@ -1037,7 +1036,7 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
width, height);
src_buffer = gimp_temp_buf_create_buffer (temp_buf);
- dest_buffer = gimp_cairo_image_surface_create_buffer (alpha_surface);
+ dest_buffer = gimp_cairo_surface_create_buffer (alpha_surface);
gegl_buffer_copy (src_buffer,
GEGL_RECTANGLE (x - temp_buf_x,
@@ -1066,7 +1065,7 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
cairo_surface_flush (surface);
src_buffer = gimp_temp_buf_create_buffer (temp_buf);
- dest_buffer = gimp_cairo_image_surface_create_buffer (surface);
+ dest_buffer = gimp_cairo_surface_create_buffer (surface);
gegl_buffer_copy (src_buffer,
GEGL_RECTANGLE (x - temp_buf_x,
diff --git a/libgimpcolor/gimpcairo.c b/libgimpcolor/gimpcairo.c
index d0ab383..0382fa7 100644
--- a/libgimpcolor/gimpcairo.c
+++ b/libgimpcolor/gimpcairo.c
@@ -22,8 +22,8 @@
#include "config.h"
-#include <glib-object.h>
#include <cairo.h>
+#include <gegl.h>
#include "libgimpbase/gimpbase.h"
@@ -140,3 +140,49 @@ gimp_cairo_checkerboard_create (cairo_t *cr,
return pattern;
}
+
+const Babl *
+gimp_cairo_surface_get_format (cairo_surface_t *surface)
+{
+ g_return_val_if_fail (surface != NULL, NULL);
+ g_return_val_if_fail (cairo_surface_get_type (surface) ==
+ CAIRO_SURFACE_TYPE_IMAGE, NULL);
+
+ switch (cairo_image_surface_get_format (surface))
+ {
+ case CAIRO_FORMAT_RGB24:
+ return babl_format ("cairo-ARGB32");
+
+ case CAIRO_FORMAT_ARGB32:
+ return babl_format ("cairo-RGB24");
+
+ default:
+ break;
+ }
+
+ g_return_val_if_reached (NULL);
+}
+
+GeglBuffer *
+gimp_cairo_surface_create_buffer (cairo_surface_t *surface)
+{
+ const Babl *format;
+ gint width;
+ gint height;
+
+ g_return_val_if_fail (surface != NULL, NULL);
+ g_return_val_if_fail (cairo_surface_get_type (surface) ==
+ CAIRO_SURFACE_TYPE_IMAGE, NULL);
+
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+ format = gimp_cairo_surface_get_format (surface);
+
+ return
+ gegl_buffer_linear_new_from_data (cairo_image_surface_get_data (surface),
+ format,
+ GEGL_RECTANGLE (0, 0, width, height),
+ cairo_image_surface_get_stride (surface),
+ (GDestroyNotify) cairo_surface_destroy,
+ cairo_surface_reference (surface));
+}
diff --git a/libgimpcolor/gimpcairo.h b/libgimpcolor/gimpcairo.h
index 2b005ed..88454f6 100644
--- a/libgimpcolor/gimpcairo.h
+++ b/libgimpcolor/gimpcairo.h
@@ -24,15 +24,18 @@
#define __GIMP_CAIRO_H__
-void gimp_cairo_set_source_rgb (cairo_t *cr,
- const GimpRGB *color);
-void gimp_cairo_set_source_rgba (cairo_t *cr,
- const GimpRGB *color);
-
-cairo_pattern_t * gimp_cairo_checkerboard_create (cairo_t *cr,
- gint size,
- const GimpRGB *light,
- const GimpRGB *dark);
+void gimp_cairo_set_source_rgb (cairo_t *cr,
+ const GimpRGB *color);
+void gimp_cairo_set_source_rgba (cairo_t *cr,
+ const GimpRGB *color);
+
+cairo_pattern_t * gimp_cairo_checkerboard_create (cairo_t *cr,
+ gint size,
+ const GimpRGB *light,
+ const GimpRGB *dark);
+
+const Babl * gimp_cairo_surface_get_format (cairo_surface_t *surface);
+GeglBuffer * gimp_cairo_surface_create_buffer (cairo_surface_t *surface);
/* some useful macros for writing directly to a Cairo surface */
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index 380bbc0..d7697ed 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -10,6 +10,8 @@ EXPORTS
gimp_cairo_checkerboard_create
gimp_cairo_set_source_rgb
gimp_cairo_set_source_rgba
+ gimp_cairo_surface_create_buffer
+ gimp_cairo_surface_get_format
gimp_cmyk_get_type
gimp_cmyk_get_uchar
gimp_cmyk_set
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]