app: add GimpTileHandlerValidate::{begin,end}_validate() vfuncs
Add begin_validate() and end_validate() virtual functions, and
corresponding free functions, to GimpTileHandlerValidate. These
functions are called before/after validation happens, and should
perform any necessary steps to prepare for validation. The default
implementation suspends validation on tile access, so that the
assigned buffer may be accessed without causing validation.
Implement the new functions in GimpTileHandlerProjectable, by
calling gimp_projectable_begin_render() and
gimp_projectable_end_render(), respectively, instead of calling
these functions in the ::validate() implementation (which, in turn,
allows us to use the default ::validate() implementation.)
In GimpProjection, use the new functions in place of
gimp_projectable_{begin,end}_render().
(cherry picked from commit 5a623fc54b
)
This commit is contained in:
@ -678,11 +678,11 @@ gimp_projection_finish_draw (GimpProjection *proj)
|
||||
{
|
||||
gimp_projection_chunk_render_stop (proj);
|
||||
|
||||
gimp_projectable_begin_render (proj->priv->projectable);
|
||||
gimp_tile_handler_validate_begin_validate (proj->priv->validate_handler);
|
||||
|
||||
while (gimp_projection_chunk_render_iteration (proj, FALSE));
|
||||
|
||||
gimp_projectable_end_render (proj->priv->projectable);
|
||||
gimp_tile_handler_validate_end_validate (proj->priv->validate_handler);
|
||||
}
|
||||
}
|
||||
|
||||
@ -854,7 +854,7 @@ gimp_projection_chunk_render_callback (gpointer data)
|
||||
*/
|
||||
chunk_render->n_pixels = 0;
|
||||
|
||||
gimp_projectable_begin_render (proj->priv->projectable);
|
||||
gimp_tile_handler_validate_begin_validate (proj->priv->validate_handler);
|
||||
|
||||
do
|
||||
{
|
||||
@ -871,7 +871,7 @@ gimp_projection_chunk_render_callback (gpointer data)
|
||||
}
|
||||
while (g_timer_elapsed (timer, NULL) < GIMP_PROJECTION_CHUNK_TIME);
|
||||
|
||||
gimp_projectable_end_render (proj->priv->projectable);
|
||||
gimp_tile_handler_validate_end_validate (proj->priv->validate_handler);
|
||||
|
||||
/* adjust the target number of pixels to be processed on the next frame,
|
||||
* according to the number of pixels processed during this frame and the
|
||||
|
@ -27,11 +27,8 @@
|
||||
#include "gimptilehandlerprojectable.h"
|
||||
|
||||
|
||||
static void gimp_tile_handler_projectable_validate (GimpTileHandlerValidate *validate,
|
||||
const GeglRectangle *rect,
|
||||
const Babl *format,
|
||||
gpointer dest_buf,
|
||||
gint dest_stride);
|
||||
static void gimp_tile_handler_projectable_begin_validate (GimpTileHandlerValidate *validate);
|
||||
static void gimp_tile_handler_projectable_end_validate (GimpTileHandlerValidate *validate);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpTileHandlerProjectable, gimp_tile_handler_projectable,
|
||||
@ -47,7 +44,8 @@ gimp_tile_handler_projectable_class_init (GimpTileHandlerProjectableClass *klass
|
||||
|
||||
validate_class = GIMP_TILE_HANDLER_VALIDATE_CLASS (klass);
|
||||
|
||||
validate_class->validate = gimp_tile_handler_projectable_validate;
|
||||
validate_class->begin_validate = gimp_tile_handler_projectable_begin_validate;
|
||||
validate_class->end_validate = gimp_tile_handler_projectable_end_validate;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -56,24 +54,23 @@ gimp_tile_handler_projectable_init (GimpTileHandlerProjectable *projectable)
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tile_handler_projectable_validate (GimpTileHandlerValidate *validate,
|
||||
const GeglRectangle *rect,
|
||||
const Babl *format,
|
||||
gpointer dest_buf,
|
||||
gint dest_stride)
|
||||
gimp_tile_handler_projectable_begin_validate (GimpTileHandlerValidate *validate)
|
||||
{
|
||||
GimpTileHandlerProjectable *handler = GIMP_TILE_HANDLER_PROJECTABLE (validate);
|
||||
GeglNode *graph;
|
||||
|
||||
graph = gimp_projectable_get_graph (handler->projectable);
|
||||
GIMP_TILE_HANDLER_VALIDATE_CLASS (parent_class)->begin_validate (validate);
|
||||
|
||||
gimp_projectable_begin_render (handler->projectable);
|
||||
}
|
||||
|
||||
gegl_node_blit (graph, 1.0, rect, format,
|
||||
dest_buf, dest_stride,
|
||||
GEGL_BLIT_DEFAULT);
|
||||
static void
|
||||
gimp_tile_handler_projectable_end_validate (GimpTileHandlerValidate *validate)
|
||||
{
|
||||
GimpTileHandlerProjectable *handler = GIMP_TILE_HANDLER_PROJECTABLE (validate);
|
||||
|
||||
gimp_projectable_end_render (handler->projectable);
|
||||
|
||||
GIMP_TILE_HANDLER_VALIDATE_CLASS (parent_class)->end_validate (validate);
|
||||
}
|
||||
|
||||
GeglTileHandler *
|
||||
@ -85,6 +82,9 @@ gimp_tile_handler_projectable_new (GimpProjectable *projectable)
|
||||
|
||||
handler = g_object_new (GIMP_TYPE_TILE_HANDLER_PROJECTABLE, NULL);
|
||||
|
||||
GIMP_TILE_HANDLER_VALIDATE (handler)->graph =
|
||||
g_object_ref (gimp_projectable_get_graph (projectable));
|
||||
|
||||
handler->projectable = projectable;
|
||||
|
||||
return GEGL_TILE_HANDLER (handler);
|
||||
|
@ -35,28 +35,30 @@ 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_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 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,
|
||||
@ -74,6 +76,8 @@ gimp_tile_handler_validate_class_init (GimpTileHandlerValidateClass *klass)
|
||||
object_class->set_property = gimp_tile_handler_validate_set_property;
|
||||
object_class->get_property = gimp_tile_handler_validate_get_property;
|
||||
|
||||
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;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FORMAT,
|
||||
@ -178,6 +182,18 @@ gimp_tile_handler_validate_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tile_handler_validate_real_begin_validate (GimpTileHandlerValidate *validate)
|
||||
{
|
||||
validate->suspend_validate++;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tile_handler_validate_real_end_validate (GimpTileHandlerValidate *validate)
|
||||
{
|
||||
validate->suspend_validate--;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tile_handler_validate_real_validate (GimpTileHandlerValidate *validate,
|
||||
const GeglRectangle *rect,
|
||||
@ -235,6 +251,8 @@ gimp_tile_handler_validate_validate (GeglTileSource *source,
|
||||
tile_bpp = babl_format_get_bytes_per_pixel (validate->format);
|
||||
tile_stride = tile_bpp * validate->tile_width;
|
||||
|
||||
gimp_tile_handler_validate_begin_validate (validate);
|
||||
|
||||
gegl_tile_lock (tile);
|
||||
|
||||
GIMP_TILE_HANDLER_VALIDATE_GET_CLASS (validate)->validate
|
||||
@ -248,6 +266,8 @@ gimp_tile_handler_validate_validate (GeglTileSource *source,
|
||||
tile_stride);
|
||||
|
||||
gegl_tile_unlock (tile);
|
||||
|
||||
gimp_tile_handler_validate_end_validate (validate);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -277,6 +297,8 @@ gimp_tile_handler_validate_validate (GeglTileSource *source,
|
||||
0, tile_stride * validate->tile_height);
|
||||
}
|
||||
|
||||
gimp_tile_handler_validate_begin_validate (validate);
|
||||
|
||||
gegl_tile_lock (tile);
|
||||
|
||||
n_rects = cairo_region_num_rectangles (tile_region);
|
||||
@ -305,6 +327,8 @@ gimp_tile_handler_validate_validate (GeglTileSource *source,
|
||||
}
|
||||
|
||||
gegl_tile_unlock (tile);
|
||||
|
||||
gimp_tile_handler_validate_end_validate (validate);
|
||||
}
|
||||
|
||||
cairo_region_destroy (tile_region);
|
||||
@ -415,6 +439,25 @@ gimp_tile_handler_validate_undo_invalidate (GimpTileHandlerValidate *validate,
|
||||
(cairo_rectangle_int_t *) rect);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tile_handler_validate_begin_validate (GimpTileHandlerValidate *validate)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TILE_HANDLER_VALIDATE (validate));
|
||||
|
||||
if (validate->validating++ == 0)
|
||||
GIMP_TILE_HANDLER_VALIDATE_GET_CLASS (validate)->begin_validate (validate);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tile_handler_validate_end_validate (GimpTileHandlerValidate *validate)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TILE_HANDLER_VALIDATE (validate));
|
||||
g_return_if_fail (validate->validating > 0);
|
||||
|
||||
if (--validate->validating == 0)
|
||||
GIMP_TILE_HANDLER_VALIDATE_GET_CLASS (validate)->end_validate (validate);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_tile_handler_validate_buffer_copy (GeglBuffer *src_buffer,
|
||||
const GeglRectangle *src_rect,
|
||||
|
@ -48,6 +48,7 @@ struct _GimpTileHandlerValidate
|
||||
gint tile_width;
|
||||
gint tile_height;
|
||||
gboolean whole_tile;
|
||||
gint validating;
|
||||
gint suspend_validate;
|
||||
};
|
||||
|
||||
@ -55,11 +56,13 @@ struct _GimpTileHandlerValidateClass
|
||||
{
|
||||
GeglTileHandlerClass parent_class;
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
@ -78,6 +81,9 @@ void gimp_tile_handler_validate_invalidate (GimpTileHa
|
||||
void gimp_tile_handler_validate_undo_invalidate (GimpTileHandlerValidate *validate,
|
||||
const GeglRectangle *rect);
|
||||
|
||||
void gimp_tile_handler_validate_begin_validate (GimpTileHandlerValidate *validate);
|
||||
void gimp_tile_handler_validate_end_validate (GimpTileHandlerValidate *validate);
|
||||
|
||||
void gimp_tile_handler_validate_buffer_copy (GeglBuffer *src_buffer,
|
||||
const GeglRectangle *src_rect,
|
||||
GeglBuffer *dst_buffer,
|
||||
|
Reference in New Issue
Block a user