mirror of https://github.com/GNOME/gimp.git
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().
This commit is contained in:
parent
5a623fc54b
commit
0ad41cfe0c
|
@ -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_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_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);
|
||||
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,
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue