[gimp] app: speed up image rendering by removing expose overhead
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: speed up image rendering by removing expose overhead
- Date: Fri, 9 Aug 2013 18:23:23 +0000 (UTC)
commit 40e7ca74425c5c627bf06f716eb00593e0635170
Author: Michael Natterer <mitch gimp org>
Date: Fri Aug 9 20:20:02 2013 +0200
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.
app/core/gimpprojection.c | 30 +++++++++++++++++++++++++-----
app/gimp-log.c | 3 ++-
app/gimp-log.h | 4 +++-
3 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c
index 1e7e072..b6bec74 100644
--- a/app/core/gimpprojection.c
+++ b/app/core/gimpprojection.c
@@ -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
diff --git a/app/gimp-log.c b/app/gimp-log.c
index ca62184..c4bcb29 100644
--- a/app/gimp-log.c
+++ b/app/gimp-log.c
@@ -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 }
};
diff --git a/app/gimp-log.h b/app/gimp-log.h
index 536610a..6b7f2ef 100644
--- a/app/gimp-log.h
+++ b/app/gimp-log.h
@@ -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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]