[gimp] app: add "direct" parameter to gimp_projection_flush_now()



commit dac9bfe3342a0ac23da759e382d732e606796197
Author: Ell <ell_se yahoo com>
Date:   Sun Dec 2 09:44:52 2018 -0500

    app: add "direct" parameter to gimp_projection_flush_now()
    
    Add a boolean "direct" parameter to gimp_projection_flush_now(),
    which specifies if the projection buffer should only be invalidated
    (FALSE), or rendered directly (TRUE).
    
    Pass TRUE when flushing the projection during painting, so that the
    affected regions are rendered in a single step, instead of tile-by-
    tile.  We previously only invalidated the projection buffer, but
    since we synchronously flush the display right after that, the
    invalidated regions would still get rendered, albeit less
    efficiently.
    
    Likewise, pass TRUE when benchmarking the projection through the
    debug action, and avoid flushing the display, to more accurately
    measure the render time.

 app/actions/debug-commands.c    |  6 +++---
 app/core/gimpprojection.c       | 19 +++++++++++--------
 app/core/gimpprojection.h       |  3 ++-
 app/tools/gimppainttool-paint.c |  6 +++---
 4 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/app/actions/debug-commands.c b/app/actions/debug-commands.c
index 562f95b61d..dadace17b1 100644
--- a/app/actions/debug-commands.c
+++ b/app/actions/debug-commands.c
@@ -293,15 +293,15 @@ debug_benchmark_projection (GimpDisplay *display)
     {
       GimpProjection *projection = gimp_image_get_projection (image);
 
+      gimp_projection_stop_rendering (projection);
+
       GIMP_TIMER_START ();
 
       gimp_image_invalidate (image,
                              0, 0,
                              gimp_image_get_width  (image),
                              gimp_image_get_height (image));
-      gimp_projection_flush_now (projection);
-
-      gimp_display_flush_now (display);
+      gimp_projection_flush_now (projection, TRUE);
 
       GIMP_TIMER_END ("Validation of the entire projection");
 
diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c
index 0baae20083..1615481f7b 100644
--- a/app/core/gimpprojection.c
+++ b/app/core/gimpprojection.c
@@ -180,7 +180,8 @@ static void        gimp_projection_add_update_area       (GimpProjection  *proj,
                                                           gint             w,
                                                           gint             h);
 static void        gimp_projection_flush_whenever        (GimpProjection  *proj,
-                                                          gboolean         now);
+                                                          gboolean         now,
+                                                          gboolean         direct);
 static void        gimp_projection_chunk_render_start    (GimpProjection  *proj);
 static void        gimp_projection_chunk_render_stop     (GimpProjection  *proj);
 static gboolean    gimp_projection_chunk_render_callback (gpointer         data);
@@ -414,7 +415,7 @@ gimp_projection_pickable_flush (GimpPickable *pickable)
   gimp_projection_get_buffer (pickable);
 
   gimp_projection_finish_draw (proj);
-  gimp_projection_flush_now (proj);
+  gimp_projection_flush_now (proj, FALSE);
 
   if (proj->priv->invalidate_preview)
     {
@@ -667,16 +668,17 @@ gimp_projection_flush (GimpProjection *proj)
   g_return_if_fail (GIMP_IS_PROJECTION (proj));
 
   /* Construct in chunks */
-  gimp_projection_flush_whenever (proj, FALSE);
+  gimp_projection_flush_whenever (proj, FALSE, FALSE);
 }
 
 void
-gimp_projection_flush_now (GimpProjection *proj)
+gimp_projection_flush_now (GimpProjection *proj,
+                           gboolean        direct)
 {
   g_return_if_fail (GIMP_IS_PROJECTION (proj));
 
   /* Construct NOW */
-  gimp_projection_flush_whenever (proj, TRUE);
+  gimp_projection_flush_whenever (proj, TRUE, direct);
 }
 
 void
@@ -780,7 +782,8 @@ gimp_projection_add_update_area (GimpProjection *proj,
 
 static void
 gimp_projection_flush_whenever (GimpProjection *proj,
-                                gboolean        now)
+                                gboolean        now,
+                                gboolean        direct)
 {
   if (! proj->priv->buffer)
     return;
@@ -800,7 +803,7 @@ gimp_projection_flush_whenever (GimpProjection *proj,
                                           i, &rect);
 
               gimp_projection_paint_area (proj,
-                                          FALSE, /* sic! */
+                                          direct,
                                           rect.x,
                                           rect.y,
                                           rect.width,
@@ -1050,7 +1053,7 @@ gimp_projection_chunk_render_iteration (GimpProjection *proj,
       chunk_render->work_height = work_h;
     }
 
-  gimp_projection_paint_area (proj, TRUE /* sic! */,
+  gimp_projection_paint_area (proj, TRUE,
                               work_x, work_y, work_w, work_h);
 
   chunk_render->n_pixels += work_w * work_h;
diff --git a/app/core/gimpprojection.h b/app/core/gimpprojection.h
index 269e5b91d6..36d76d076c 100644
--- a/app/core/gimpprojection.h
+++ b/app/core/gimpprojection.h
@@ -71,7 +71,8 @@ void             gimp_projection_set_priority_rect (GimpProjection    *proj,
 void             gimp_projection_stop_rendering    (GimpProjection    *proj);
 
 void             gimp_projection_flush             (GimpProjection    *proj);
-void             gimp_projection_flush_now         (GimpProjection    *proj);
+void             gimp_projection_flush_now         (GimpProjection    *proj,
+                                                    gboolean           direct);
 void             gimp_projection_finish_draw       (GimpProjection    *proj);
 
 gint64           gimp_projection_estimate_memsize  (GimpImageBaseType  type,
diff --git a/app/tools/gimppainttool-paint.c b/app/tools/gimppainttool-paint.c
index 51fb4bce2e..ffb0f7518e 100644
--- a/app/tools/gimppainttool-paint.c
+++ b/app/tools/gimppainttool-paint.c
@@ -187,7 +187,7 @@ gimp_paint_tool_paint_timeout (GimpPaintTool *paint_tool)
 
       gimp_draw_tool_pause (draw_tool);
 
-      gimp_projection_flush_now (gimp_image_get_projection (image));
+      gimp_projection_flush_now (gimp_image_get_projection (image), TRUE);
       gimp_display_flush_now (display);
 
       gimp_draw_tool_resume (draw_tool);
@@ -326,7 +326,7 @@ gimp_paint_tool_paint_start (GimpPaintTool     *paint_tool,
                              GIMP_PAINT_STATE_MOTION, time);
     }
 
-  gimp_projection_flush_now (gimp_image_get_projection (image));
+  gimp_projection_flush_now (gimp_image_get_projection (image), TRUE);
   gimp_display_flush_now (display);
 
   /*  Start the display update timeout  */
@@ -475,7 +475,7 @@ gimp_paint_tool_paint_push (GimpPaintTool          *paint_tool,
 
       func (paint_tool, data);
 
-      gimp_projection_flush_now (gimp_image_get_projection (image));
+      gimp_projection_flush_now (gimp_image_get_projection (image), TRUE);
       gimp_display_flush_now (display);
 
       gimp_draw_tool_resume (draw_tool);


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