[gegl/wip/rishi/process-blit-to-cache: 2/2] processor: Simplify and optimize rendering to the cache



commit a96c10eeaa3647772edb6625aeb1de8565509c58
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Dec 21 00:01:51 2018 +0100

    processor: Simplify and optimize rendering to the cache
    
    A GeglNode which is not a sink or is a sink that needs its entire input
    in one go, has to be rendered to its own GeglCache. In such cases,
    it is easier to ask gegl_node_blit to render to the cache, instead of
    doing it manually by rendering to a linear memory buffer and then
    writing it to the cache.
    
    If the GeglNode caches naturally during processing, then there's no
    need to separately write to the cache once the processing is over. This
    is something that gegl_node_blit is smart enough to know.

 gegl/process/gegl-processor.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)
---
diff --git a/gegl/process/gegl-processor.c b/gegl/process/gegl-processor.c
index 5e8d49cbd..dab0567f7 100644
--- a/gegl/process/gegl-processor.c
+++ b/gegl/process/gegl-processor.c
@@ -431,7 +431,6 @@ render_rectangle (GeglProcessor *processor)
   const gint  max_area = processor->chunk_size * (1<<processor->level) * (1<<processor->level);
   GeglCache  *cache    = NULL;
   const Babl *format   = NULL;
-  gint        pxsize;
 
   /* Retrieve the cache if the processor's node is not buffered if its
    * operation is a sink and it doesn't use the full area  */
@@ -441,7 +440,6 @@ render_rectangle (GeglProcessor *processor)
     {
       cache = gegl_node_get_cache (processor->input);
       format = gegl_buffer_get_format ((GeglBuffer *)cache);
-      pxsize = babl_format_get_bytes_per_pixel (format);
     }
 
   if (processor->dirty_rectangles)
@@ -507,31 +505,13 @@ render_rectangle (GeglProcessor *processor)
 
           if (!found_full)
             {
-              /* create a buffer and initialise it */
-              guchar *buf;
-
-              buf = g_malloc (dr->width * dr->height * pxsize);
-              g_assert (buf);
-
-              /* FIXME: Check if the node caches naturally, if so the buffer_set call isn't needed */
-
               /* do the image calculations using the buffer */
               gegl_node_blit (processor->input, 1.0/(1<<processor->level),
-                              dr, format, buf,
-                              GEGL_AUTO_ROWSTRIDE, GEGL_BLIT_DEFAULT);
-
-              /* copy the buffer data into the cache */
-              {
-                gint level = processor->level;
-                GeglRectangle sr = {dr->x >> level, dr->y >> level, dr->width >> level, dr->height >> level 
};
-                gegl_buffer_set (GEGL_BUFFER (cache), &sr, level, format, buf, GEGL_AUTO_ROWSTRIDE);
-              }
+                              dr, format, NULL,
+                              GEGL_AUTO_ROWSTRIDE, GEGL_BLIT_CACHE);
 
               /* tells the cache that the rectangle (dr) has been computed */
               gegl_cache_computed (cache, dr, processor->level);
-
-              /* release the buffer */
-              g_free (buf);
             }
           g_slice_free (GeglRectangle, dr);
         }


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