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.
This commit is contained in:
Ell 2018-12-02 09:44:52 -05:00
parent 62aae3f3a4
commit dac9bfe334
4 changed files with 19 additions and 15 deletions

View File

@ -293,15 +293,15 @@ debug_benchmark_projection (GimpDisplay *display)
{ {
GimpProjection *projection = gimp_image_get_projection (image); GimpProjection *projection = gimp_image_get_projection (image);
gimp_projection_stop_rendering (projection);
GIMP_TIMER_START (); GIMP_TIMER_START ();
gimp_image_invalidate (image, gimp_image_invalidate (image,
0, 0, 0, 0,
gimp_image_get_width (image), gimp_image_get_width (image),
gimp_image_get_height (image)); gimp_image_get_height (image));
gimp_projection_flush_now (projection); gimp_projection_flush_now (projection, TRUE);
gimp_display_flush_now (display);
GIMP_TIMER_END ("Validation of the entire projection"); GIMP_TIMER_END ("Validation of the entire projection");

View File

@ -180,7 +180,8 @@ static void gimp_projection_add_update_area (GimpProjection *proj,
gint w, gint w,
gint h); gint h);
static void gimp_projection_flush_whenever (GimpProjection *proj, 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_start (GimpProjection *proj);
static void gimp_projection_chunk_render_stop (GimpProjection *proj); static void gimp_projection_chunk_render_stop (GimpProjection *proj);
static gboolean gimp_projection_chunk_render_callback (gpointer data); 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_get_buffer (pickable);
gimp_projection_finish_draw (proj); gimp_projection_finish_draw (proj);
gimp_projection_flush_now (proj); gimp_projection_flush_now (proj, FALSE);
if (proj->priv->invalidate_preview) if (proj->priv->invalidate_preview)
{ {
@ -667,16 +668,17 @@ gimp_projection_flush (GimpProjection *proj)
g_return_if_fail (GIMP_IS_PROJECTION (proj)); g_return_if_fail (GIMP_IS_PROJECTION (proj));
/* Construct in chunks */ /* Construct in chunks */
gimp_projection_flush_whenever (proj, FALSE); gimp_projection_flush_whenever (proj, FALSE, FALSE);
} }
void void
gimp_projection_flush_now (GimpProjection *proj) gimp_projection_flush_now (GimpProjection *proj,
gboolean direct)
{ {
g_return_if_fail (GIMP_IS_PROJECTION (proj)); g_return_if_fail (GIMP_IS_PROJECTION (proj));
/* Construct NOW */ /* Construct NOW */
gimp_projection_flush_whenever (proj, TRUE); gimp_projection_flush_whenever (proj, TRUE, direct);
} }
void void
@ -780,7 +782,8 @@ gimp_projection_add_update_area (GimpProjection *proj,
static void static void
gimp_projection_flush_whenever (GimpProjection *proj, gimp_projection_flush_whenever (GimpProjection *proj,
gboolean now) gboolean now,
gboolean direct)
{ {
if (! proj->priv->buffer) if (! proj->priv->buffer)
return; return;
@ -800,7 +803,7 @@ gimp_projection_flush_whenever (GimpProjection *proj,
i, &rect); i, &rect);
gimp_projection_paint_area (proj, gimp_projection_paint_area (proj,
FALSE, /* sic! */ direct,
rect.x, rect.x,
rect.y, rect.y,
rect.width, rect.width,
@ -1050,7 +1053,7 @@ gimp_projection_chunk_render_iteration (GimpProjection *proj,
chunk_render->work_height = work_h; 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); work_x, work_y, work_w, work_h);
chunk_render->n_pixels += work_w * work_h; chunk_render->n_pixels += work_w * work_h;

View File

@ -71,7 +71,8 @@ void gimp_projection_set_priority_rect (GimpProjection *proj,
void gimp_projection_stop_rendering (GimpProjection *proj); void gimp_projection_stop_rendering (GimpProjection *proj);
void gimp_projection_flush (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); void gimp_projection_finish_draw (GimpProjection *proj);
gint64 gimp_projection_estimate_memsize (GimpImageBaseType type, gint64 gimp_projection_estimate_memsize (GimpImageBaseType type,

View File

@ -187,7 +187,7 @@ gimp_paint_tool_paint_timeout (GimpPaintTool *paint_tool)
gimp_draw_tool_pause (draw_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_display_flush_now (display);
gimp_draw_tool_resume (draw_tool); gimp_draw_tool_resume (draw_tool);
@ -326,7 +326,7 @@ gimp_paint_tool_paint_start (GimpPaintTool *paint_tool,
GIMP_PAINT_STATE_MOTION, time); 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); gimp_display_flush_now (display);
/* Start the display update timeout */ /* Start the display update timeout */
@ -475,7 +475,7 @@ gimp_paint_tool_paint_push (GimpPaintTool *paint_tool,
func (paint_tool, data); 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_display_flush_now (display);
gimp_draw_tool_resume (draw_tool); gimp_draw_tool_resume (draw_tool);