[gegl] buffer: in gegl_buffer_copy(), add fast abyss-only path



commit 5aab7938a1b61238085dc353e1163795fdf66871
Author: Ell <ell_se yahoo com>
Date:   Fri May 31 18:49:59 2019 -0400

    buffer: in gegl_buffer_copy(), add fast abyss-only path
    
    In gegl_buffer_copy(), when the source region is fully outside the
    source buffer's abyss, and the abyss content is a solid color, use
    gegl_buffer_set_color_from_pixel() to fill the destination region
    of the destination buffer, which uses COW.

 gegl/buffer/gegl-buffer-access.c | 46 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 3db572aa4..8f0d42aff 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -2407,6 +2407,52 @@ gegl_buffer_copy (GeglBuffer          *src,
   dest_rect_r.height = src_rect->height;
   dst_rect = &dest_rect_r;
 
+  if (! gegl_rectangle_intersect (NULL, src_rect, &src->abyss))
+    {
+      switch (repeat_mode)
+        {
+        case GEGL_ABYSS_CLAMP:
+        case GEGL_ABYSS_LOOP:
+          if (! gegl_rectangle_is_empty (&src->abyss))
+            break;
+
+          /* fall through */
+
+        case GEGL_ABYSS_NONE:
+          {
+            const gfloat color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+
+            gegl_buffer_set_color_from_pixel (dst, dst_rect, color,
+                                              gegl_babl_rgba_linear_float ());
+
+            return;
+          }
+
+        case GEGL_ABYSS_BLACK:
+          {
+            const gfloat color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+
+            gegl_buffer_set_color_from_pixel (dst, dst_rect, color,
+                                              gegl_babl_rgba_linear_float ());
+
+            return;
+          }
+
+        case GEGL_ABYSS_WHITE:
+          {
+            const gfloat color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+            gegl_buffer_set_color_from_pixel (dst, dst_rect, color,
+                                              gegl_babl_rgba_linear_float ());
+
+            return;
+          }
+
+        default:
+          break;
+        }
+    }
+
   if (src->soft_format == dst->soft_format &&
       src_rect->width >= src->tile_width &&
       src_rect->height >= src->tile_height &&


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