[gimp/gimp-2-10] app: add GimpTileHandlerValidate::validate_buffer() vfunc
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add GimpTileHandlerValidate::validate_buffer() vfunc
- Date: Wed, 28 Nov 2018 18:27:41 +0000 (UTC)
commit 50b3c2b8ba58a7536f1219e755dc03807848e7cb
Author: Ell <ell_se yahoo com>
Date: Tue Nov 27 13:49:38 2018 -0500
app: add GimpTileHandlerValidate::validate_buffer() vfunc
... which is similar to the ::validate() vfunc, however, it should
render the result to the provided GeglBuffer, instead of to a
memory buffer.
Provide a default implementation, which uses
gegl_node_blit_buffer() if the default ::validate() implementation
is used, or, otherwise, calls uses
gegl_buffer_linear_{open,close}(), and passes the returned memory
buffer to ::validate().
(cherry picked from commit 0ad41cfe0c15aaea3d910bc57353c872760f2dd1)
app/gegl/gimptilehandlervalidate.c | 80 ++++++++++++++++++++++++++------------
app/gegl/gimptilehandlervalidate.h | 17 ++++----
2 files changed, 66 insertions(+), 31 deletions(-)
---
diff --git a/app/gegl/gimptilehandlervalidate.c b/app/gegl/gimptilehandlervalidate.c
index 1c18b8322e..9280e3122d 100644
--- a/app/gegl/gimptilehandlervalidate.c
+++ b/app/gegl/gimptilehandlervalidate.c
@@ -35,30 +35,33 @@ enum
};
-static void gimp_tile_handler_validate_finalize (GObject *object);
-static void gimp_tile_handler_validate_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_tile_handler_validate_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gimp_tile_handler_validate_real_begin_validate (GimpTileHandlerValidate *validate);
-static void gimp_tile_handler_validate_real_end_validate (GimpTileHandlerValidate *validate);
-static void gimp_tile_handler_validate_real_validate (GimpTileHandlerValidate *validate,
- const GeglRectangle *rect,
- const Babl *format,
- gpointer dest_buf,
- gint dest_stride);
-
-static gpointer gimp_tile_handler_validate_command (GeglTileSource *source,
- GeglTileCommand command,
- gint x,
- gint y,
- gint z,
- gpointer data);
+static void gimp_tile_handler_validate_finalize (GObject *object);
+static void gimp_tile_handler_validate_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_tile_handler_validate_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gimp_tile_handler_validate_real_begin_validate (GimpTileHandlerValidate *validate);
+static void gimp_tile_handler_validate_real_end_validate (GimpTileHandlerValidate *validate);
+static void gimp_tile_handler_validate_real_validate (GimpTileHandlerValidate *validate,
+ const GeglRectangle *rect,
+ const Babl *format,
+ gpointer dest_buf,
+ gint dest_stride);
+static void gimp_tile_handler_validate_real_validate_buffer (GimpTileHandlerValidate *validate,
+ const GeglRectangle *rect,
+ GeglBuffer *buffer);
+
+static gpointer gimp_tile_handler_validate_command (GeglTileSource *source,
+ GeglTileCommand command,
+ gint x,
+ gint y,
+ gint z,
+ gpointer data);
G_DEFINE_TYPE (GimpTileHandlerValidate, gimp_tile_handler_validate,
@@ -79,6 +82,7 @@ gimp_tile_handler_validate_class_init (GimpTileHandlerValidateClass *klass)
klass->begin_validate = gimp_tile_handler_validate_real_begin_validate;
klass->end_validate = gimp_tile_handler_validate_real_end_validate;
klass->validate = gimp_tile_handler_validate_real_validate;
+ klass->validate_buffer = gimp_tile_handler_validate_real_validate_buffer;
g_object_class_install_property (object_class, PROP_FORMAT,
g_param_spec_pointer ("format", NULL, NULL,
@@ -214,6 +218,34 @@ gimp_tile_handler_validate_real_validate (GimpTileHandlerValidate *validate,
GEGL_BLIT_DEFAULT);
}
+static void
+gimp_tile_handler_validate_real_validate_buffer (GimpTileHandlerValidate *validate,
+ const GeglRectangle *rect,
+ GeglBuffer *buffer)
+{
+ GimpTileHandlerValidateClass *klass;
+
+ klass = GIMP_TILE_HANDLER_VALIDATE_GET_CLASS (validate);
+
+ if (klass->validate == gimp_tile_handler_validate_real_validate)
+ {
+ gegl_node_blit_buffer (validate->graph, buffer, rect, 0,
+ GEGL_ABYSS_NONE);
+ }
+ else
+ {
+ const Babl *format = gegl_buffer_get_format (buffer);
+ gpointer data;
+ gint stride;
+
+ data = gegl_buffer_linear_open (buffer, rect, &stride, format);
+
+ klass->validate (validate, rect, format, data, stride);
+
+ gegl_buffer_linear_close (buffer, data);
+ }
+}
+
static GeglTile *
gimp_tile_handler_validate_validate (GeglTileSource *source,
GeglTile *tile,
diff --git a/app/gegl/gimptilehandlervalidate.h b/app/gegl/gimptilehandlervalidate.h
index 28ebf375f5..b892cf5c4e 100644
--- a/app/gegl/gimptilehandlervalidate.h
+++ b/app/gegl/gimptilehandlervalidate.h
@@ -56,13 +56,16 @@ struct _GimpTileHandlerValidateClass
{
GeglTileHandlerClass parent_class;
- void (* begin_validate) (GimpTileHandlerValidate *validate);
- void (* end_validate) (GimpTileHandlerValidate *validate);
- void (* validate) (GimpTileHandlerValidate *validate,
- const GeglRectangle *rect,
- const Babl *format,
- gpointer dest_buf,
- gint dest_stride);
+ void (* begin_validate) (GimpTileHandlerValidate *validate);
+ void (* end_validate) (GimpTileHandlerValidate *validate);
+ void (* validate) (GimpTileHandlerValidate *validate,
+ const GeglRectangle *rect,
+ const Babl *format,
+ gpointer dest_buf,
+ gint dest_stride);
+ void (* validate_buffer) (GimpTileHandlerValidate *validate,
+ const GeglRectangle *rect,
+ GeglBuffer *buffer);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]