[gegl] crop: clip crop rect to input extents



commit 09e6133a340b666245749b682d9b76dd8b0d26d7
Author: Ell <ell_se yahoo com>
Date:   Sat Dec 3 12:40:54 2016 -0500

    crop: clip crop rect to input extents
    
    If we don't do that, then the operation's output buffer, which is
    a subbuffer of the input buffer, may contain regions that are not
    backed by any storage, when the crop rect is not a subset of the
    input buffer's extents.  If the output buffer is then resued for
    in-place output as part of a following node, on the premise that
    it actually is as big as it pretends to be, then any output
    written to these regions is erroneously discarded.

 operations/core/crop.c |   30 +++++++-----------------------
 1 files changed, 7 insertions(+), 23 deletions(-)
---
diff --git a/operations/core/crop.c b/operations/core/crop.c
index 04a0f9c..26d687d 100644
--- a/operations/core/crop.c
+++ b/operations/core/crop.c
@@ -96,6 +96,8 @@ gegl_crop_get_bounding_box (GeglOperation *operation)
   result.width  = o->width;
   result.height = o->height;
 
+  gegl_rectangle_intersect (&result, &result, in_rect);
+
   return result;
 }
 
@@ -104,13 +106,7 @@ gegl_crop_get_invalidated_by_change (GeglOperation       *operation,
                                      const gchar         *input_pad,
                                      const GeglRectangle *input_region)
 {
-  GeglProperties   *o = GEGL_PROPERTIES (operation);
-  GeglRectangle result;
-
-  result.x = o->x;
-  result.y = o->y;
-  result.width = o->width;
-  result.height = o->height;
+  GeglRectangle result = gegl_crop_get_bounding_box (operation);
 
   gegl_rectangle_intersect (&result, &result, input_region);
 
@@ -122,13 +118,7 @@ gegl_crop_get_required_for_output (GeglOperation       *operation,
                                    const gchar         *input_pad,
                                    const GeglRectangle *roi)
 {
-  GeglProperties   *o = GEGL_PROPERTIES (operation);
-  GeglRectangle result;
-
-  result.x      = o->x;
-  result.y      = o->y;
-  result.width  = o->width;
-  result.height = o->height;
+  GeglRectangle result = gegl_crop_get_bounding_box (operation);
 
   gegl_rectangle_intersect (&result, &result, roi);
   return result;
@@ -141,15 +131,9 @@ gegl_crop_process (GeglOperation        *operation,
                    const GeglRectangle  *result,
                    gint                  level)
 {
-  GeglProperties *o = GEGL_PROPERTIES (operation);
-  GeglBuffer     *input;
-  gboolean        success = FALSE;
-  GeglRectangle   extent;
-
-  extent.x      = o->x;
-  extent.y      = o->y;
-  extent.width  = o->width;
-  extent.height = o->height;
+  GeglBuffer    *input;
+  gboolean       success = FALSE;
+  GeglRectangle  extent = gegl_crop_get_bounding_box (operation);
 
   input = gegl_operation_context_get_source (context, "input");
 


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