[gimp/gimp-2-10] app: add gimp_tile_handler_validate_validate()
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add gimp_tile_handler_validate_validate()
- Date: Wed, 28 Nov 2018 18:27:46 +0000 (UTC)
commit a4fb3e11d67792592e9c90719e98a33bc5466295
Author: Ell <ell_se yahoo com>
Date: Wed Nov 28 13:04:46 2018 -0500
app: add gimp_tile_handler_validate_validate()
... which validates a given rectangle directly into the buffer,
possibly intersecting it with the dirty region. This is more
efficient than either invalidating, un-invalidating, and rendering
a given rect, as we're doing in GimpProjection, or validating the
buffer tile-by-tile, as we're doing in gimp:buffer-source-validate.
(cherry picked from commit 82a60997d485f4df5f39c97fe10bcae7893dd235)
app/gegl/gimptilehandlervalidate.c | 74 +++++++++++++++++++++++++++++++++++---
app/gegl/gimptilehandlervalidate.h | 5 +++
2 files changed, 74 insertions(+), 5 deletions(-)
---
diff --git a/app/gegl/gimptilehandlervalidate.c b/app/gegl/gimptilehandlervalidate.c
index 9280e3122d..ff15f5786e 100644
--- a/app/gegl/gimptilehandlervalidate.c
+++ b/app/gegl/gimptilehandlervalidate.c
@@ -247,10 +247,10 @@ gimp_tile_handler_validate_real_validate_buffer (GimpTileHandlerValidate *valida
}
static GeglTile *
-gimp_tile_handler_validate_validate (GeglTileSource *source,
- GeglTile *tile,
- gint x,
- gint y)
+gimp_tile_handler_validate_validate_tile (GeglTileSource *source,
+ GeglTile *tile,
+ gint x,
+ gint y)
{
GimpTileHandlerValidate *validate = GIMP_TILE_HANDLER_VALIDATE (source);
cairo_rectangle_int_t tile_rect;
@@ -382,7 +382,7 @@ gimp_tile_handler_validate_command (GeglTileSource *source,
retval = gegl_tile_handler_source_command (source, command, x, y, z, data);
if (command == GEGL_TILE_GET && z == 0)
- retval = gimp_tile_handler_validate_validate (source, retval, x, y);
+ retval = gimp_tile_handler_validate_validate_tile (source, retval, x, y);
return retval;
}
@@ -490,6 +490,70 @@ gimp_tile_handler_validate_end_validate (GimpTileHandlerValidate *validate)
GIMP_TILE_HANDLER_VALIDATE_GET_CLASS (validate)->end_validate (validate);
}
+void
+gimp_tile_handler_validate_validate (GimpTileHandlerValidate *validate,
+ GeglBuffer *buffer,
+ const GeglRectangle *rect,
+ gboolean intersect)
+{
+ GimpTileHandlerValidateClass *klass;
+
+ g_return_if_fail (GIMP_IS_TILE_HANDLER_VALIDATE (validate));
+ g_return_if_fail (gimp_tile_handler_validate_get_assigned (buffer) ==
+ validate);
+
+ klass = GIMP_TILE_HANDLER_VALIDATE_GET_CLASS (validate);
+
+ if (intersect)
+ {
+ cairo_region_t *region = cairo_region_copy (validate->dirty_region);
+
+ cairo_region_intersect_rectangle (region,
+ (const cairo_rectangle_int_t *) rect);
+
+ if (! cairo_region_is_empty (region))
+ {
+ gint n_rects;
+ gint i;
+
+ gimp_tile_handler_validate_begin_validate (validate);
+
+ n_rects = cairo_region_num_rectangles (region);
+
+ for (i = 0; i < n_rects; i++)
+ {
+ cairo_rectangle_int_t blit_rect;
+
+ cairo_region_get_rectangle (region, i, &blit_rect);
+
+ klass->validate_buffer (validate,
+ (const GeglRectangle *) &blit_rect,
+ buffer);
+ }
+
+ gimp_tile_handler_validate_end_validate (validate);
+
+ cairo_region_subtract_rectangle (
+ validate->dirty_region,
+ (const cairo_rectangle_int_t *) rect);
+ }
+
+ cairo_region_destroy (region);
+ }
+ else
+ {
+ gimp_tile_handler_validate_begin_validate (validate);
+
+ klass->validate_buffer (validate, rect, buffer);
+
+ gimp_tile_handler_validate_end_validate (validate);
+
+ cairo_region_subtract_rectangle (
+ validate->dirty_region,
+ (const cairo_rectangle_int_t *) rect);
+ }
+}
+
void
gimp_tile_handler_validate_buffer_copy (GeglBuffer *src_buffer,
const GeglRectangle *src_rect,
diff --git a/app/gegl/gimptilehandlervalidate.h b/app/gegl/gimptilehandlervalidate.h
index b892cf5c4e..63a6e97a47 100644
--- a/app/gegl/gimptilehandlervalidate.h
+++ b/app/gegl/gimptilehandlervalidate.h
@@ -87,6 +87,11 @@ void gimp_tile_handler_validate_undo_invalidate (GimpTileHa
void gimp_tile_handler_validate_begin_validate (GimpTileHandlerValidate *validate);
void gimp_tile_handler_validate_end_validate (GimpTileHandlerValidate *validate);
+void gimp_tile_handler_validate_validate (GimpTileHandlerValidate *validate,
+ GeglBuffer *buffer,
+ const GeglRectangle *rect,
+ gboolean intersect);
+
void gimp_tile_handler_validate_buffer_copy (GeglBuffer *src_buffer,
const GeglRectangle *src_rect,
GeglBuffer *dst_buffer,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]