[gimp/gimp-2-10] app: add gimp_tile_handler_validate_buffer_set_extent()



commit d3af77890d8f687912122d938233d258cff7d2cb
Author: Ell <ell_se yahoo com>
Date:   Tue Aug 13 17:35:35 2019 +0300

    app: add gimp_tile_handler_validate_buffer_set_extent()
    
    ... which sets the extent of a buffer with an assigned
    GimpTileHandlerValidate, clipping the dirty region to the new
    extent.
    
    (cherry picked from commit b4ee9ff055b4e99efb49f33b541bea26c9555c6a)

 app/gegl/gimptilehandlervalidate.c | 25 +++++++++++++++++++++
 app/gegl/gimptilehandlervalidate.h | 45 ++++++++++++++++++++------------------
 2 files changed, 49 insertions(+), 21 deletions(-)
---
diff --git a/app/gegl/gimptilehandlervalidate.c b/app/gegl/gimptilehandlervalidate.c
index 2e7e3b6657..0d8e0a3c23 100644
--- a/app/gegl/gimptilehandlervalidate.c
+++ b/app/gegl/gimptilehandlervalidate.c
@@ -23,6 +23,7 @@
 #include "gimp-gegl-types.h"
 
 #include "gimp-gegl-loops.h"
+#include "gimp-gegl-utils.h"
 #include "gimptilehandlervalidate.h"
 
 
@@ -557,6 +558,30 @@ gimp_tile_handler_validate_validate (GimpTileHandlerValidate *validate,
     }
 }
 
+gboolean
+gimp_tile_handler_validate_buffer_set_extent (GeglBuffer          *buffer,
+                                              const GeglRectangle *extent)
+{
+  GimpTileHandlerValidate *validate;
+
+  g_return_val_if_fail (GEGL_IS_BUFFER (buffer), FALSE);
+  g_return_val_if_fail (extent != NULL, FALSE);
+
+  validate = gimp_tile_handler_validate_get_assigned (buffer);
+
+  g_return_val_if_fail (validate != NULL, FALSE);
+
+  if (gimp_gegl_buffer_set_extent (buffer, extent))
+    {
+      cairo_region_intersect_rectangle (validate->dirty_region,
+                                        (const cairo_rectangle_int_t *) extent);
+
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 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 63a6e97a47..ae1e125eb6 100644
--- a/app/gegl/gimptilehandlervalidate.h
+++ b/app/gegl/gimptilehandlervalidate.h
@@ -69,33 +69,36 @@ struct _GimpTileHandlerValidateClass
 };
 
 
-GType                     gimp_tile_handler_validate_get_type        (void) G_GNUC_CONST;
+GType                     gimp_tile_handler_validate_get_type          (void) G_GNUC_CONST;
 
-GeglTileHandler         * gimp_tile_handler_validate_new             (GeglNode                *graph);
+GeglTileHandler         * gimp_tile_handler_validate_new               (GeglNode                *graph);
 
-void                      gimp_tile_handler_validate_assign          (GimpTileHandlerValidate *validate,
-                                                                      GeglBuffer              *buffer);
-void                      gimp_tile_handler_validate_unassign        (GimpTileHandlerValidate *validate,
-                                                                      GeglBuffer              *buffer);
-GimpTileHandlerValidate * gimp_tile_handler_validate_get_assigned    (GeglBuffer              *buffer);
+void                      gimp_tile_handler_validate_assign            (GimpTileHandlerValidate *validate,
+                                                                        GeglBuffer              *buffer);
+void                      gimp_tile_handler_validate_unassign          (GimpTileHandlerValidate *validate,
+                                                                        GeglBuffer              *buffer);
+GimpTileHandlerValidate * gimp_tile_handler_validate_get_assigned      (GeglBuffer              *buffer);
 
-void                      gimp_tile_handler_validate_invalidate      (GimpTileHandlerValidate *validate,
-                                                                      const GeglRectangle     *rect);
-void                      gimp_tile_handler_validate_undo_invalidate (GimpTileHandlerValidate *validate,
-                                                                      const GeglRectangle     *rect);
+void                      gimp_tile_handler_validate_invalidate        (GimpTileHandlerValidate *validate,
+                                                                        const GeglRectangle     *rect);
+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_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_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,
-                                                                      const GeglRectangle     *dst_rect);
+gboolean                  gimp_tile_handler_validate_buffer_set_extent (GeglBuffer              *buffer,
+                                                                        const GeglRectangle     *extent);
+
+void                      gimp_tile_handler_validate_buffer_copy       (GeglBuffer              *src_buffer,
+                                                                        const GeglRectangle     *src_rect,
+                                                                        GeglBuffer              *dst_buffer,
+                                                                        const GeglRectangle     *dst_rect);
 
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]