Commit 40e7ca74 authored by Michael Natterer's avatar Michael Natterer 😴

app: speed up image rendering by removing expose overhead

measure the time it takes to render projection chunks and continue
rendering until 0.01 seconds have passed. This ways we avoid excessive
expose roundtrips.
parent b05ff480
......@@ -35,6 +35,8 @@
#include "gimpprojectable.h"
#include "gimpprojection.h"
#include "gimp-log.h"
/* just a bit less than GDK_PRIORITY_REDRAW */
#define GIMP_PROJECTION_IDLE_PRIORITY (G_PRIORITY_HIGH_IDLE + 20 + 1)
......@@ -43,6 +45,9 @@
#define GIMP_PROJECTION_CHUNK_WIDTH 256
#define GIMP_PROJECTION_CHUNK_HEIGHT 128
/* how much time, in seconds, do we allow chunk rendering to take */
#define GIMP_PROJECTION_CHUNK_TIME 0.01
enum
{
......@@ -506,16 +511,31 @@ gimp_projection_chunk_render_stop (GimpProjection *proj)
static gboolean
gimp_projection_chunk_render_callback (gpointer data)
{
GimpProjection *proj = data;
GimpProjection *proj = data;
GTimer *timer = g_timer_new ();
gint chunks = 0;
gboolean retval = TRUE;
if (! gimp_projection_chunk_render_iteration (proj))
do
{
gimp_projection_chunk_render_stop (proj);
if (! gimp_projection_chunk_render_iteration (proj))
{
gimp_projection_chunk_render_stop (proj);
retval = FALSE;
return FALSE;
break;
}
chunks++;
}
while (g_timer_elapsed (timer, NULL) < GIMP_PROJECTION_CHUNK_TIME);
return TRUE;
GIMP_LOG (PROJECTION, "%d chunks in %f seconds\n",
chunks, g_timer_elapsed (timer, NULL));
g_timer_destroy (timer);
return retval;
}
static void
......
......@@ -43,7 +43,8 @@ static const GDebugKey log_keys[] =
{ "auto-tab-style", GIMP_LOG_AUTO_TAB_STYLE },
{ "instances", GIMP_LOG_INSTANCES },
{ "rectangle-tool", GIMP_LOG_RECTANGLE_TOOL },
{ "brush-cache", GIMP_LOG_BRUSH_CACHE }
{ "brush-cache", GIMP_LOG_BRUSH_CACHE },
{ "projection", GIMP_LOG_PROJECTION }
};
......
......@@ -39,7 +39,8 @@ typedef enum
GIMP_LOG_AUTO_TAB_STYLE = 1 << 15,
GIMP_LOG_INSTANCES = 1 << 16,
GIMP_LOG_RECTANGLE_TOOL = 1 << 17,
GIMP_LOG_BRUSH_CACHE = 1 << 18
GIMP_LOG_BRUSH_CACHE = 1 << 18,
GIMP_LOG_PROJECTION = 1 << 19
} GimpLogFlags;
......@@ -99,6 +100,7 @@ void gimp_logv (GimpLogFlags flags,
#define INSTANCES GIMP_LOG_INSTANCES
#define RECTANGLE_TOOL GIMP_LOG_RECTANGLE_TOOL
#define BRUSH_CACHE GIMP_LOG_BRUSH_CACHE
#define PROJECTION GIMP_LOG_PROJECTION
#if 0 /* last resort */
# define GIMP_LOG /* nothing => no varargs, no log */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment