[gimp] app: Make drawable updates happen at fixed framerate
- From: Alexia Death <alexiade src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Make drawable updates happen at fixed framerate
- Date: Sun, 18 Apr 2010 12:53:32 +0000 (UTC)
commit 32aca3c8b68c77d69ef3b8f5facb42d235491638
Author: Alexia Death <alexiadeath gmail com>
Date: Sun Apr 18 15:52:17 2010 +0300
app: Make drawable updates happen at fixed framerate
app/core/gimpdrawable.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
app/core/gimpdrawable.h | 9 +++++++
2 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 887769c..9222036 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -18,6 +18,7 @@
#include "config.h"
#include <gegl.h>
+
#include <gegl-plugin.h>
#include "libgimpbase/gimpbase.h"
@@ -125,6 +126,8 @@ static void gimp_drawable_real_update (GimpDrawable *drawable,
gint width,
gint height);
+static gboolean gimp_drawable_update_timeout (GimpDrawable *drawable);
+
static gint64 gimp_drawable_real_estimate_memsize (const GimpDrawable *drawable,
gint width,
gint height);
@@ -256,6 +259,14 @@ gimp_drawable_init (GimpDrawable *drawable)
drawable->bytes = 0;
drawable->type = -1;
drawable->has_alpha = FALSE;
+
+ drawable->dirty_x1 = 0;
+ drawable->dirty_y1 = 0;
+ drawable->dirty_x2 = 0;
+ drawable->dirty_y2 = 0;
+
+ drawable->update_count = 0;
+ drawable->update_timeout = 0;
}
/* sorry for the evil casts */
@@ -1197,8 +1208,36 @@ gimp_drawable_update (GimpDrawable *drawable,
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
- g_signal_emit (drawable, gimp_drawable_signals[UPDATE], 0,
- x, y, width, height);
+ if (drawable->update_timeout > 0)
+ {
+
+ drawable->dirty_x1 = MIN (x, drawable->dirty_x1);
+ drawable->dirty_y1 = MIN (y, drawable->dirty_y1);
+
+ drawable->dirty_x2 = MAX (x + width, drawable->dirty_x2);
+
+ drawable->dirty_y2 = MAX (y + height, drawable->dirty_y2);
+
+ drawable->update_count = drawable->update_count + 1;
+ }
+ else
+ {
+ g_signal_emit (drawable, gimp_drawable_signals[UPDATE], 0,
+ x, y, width, height);
+
+ drawable->dirty_x1 = drawable->dirty_x2;
+ drawable->dirty_y1 = drawable->dirty_y2;
+ drawable->dirty_x2 = 0;
+ drawable->dirty_y2 = 0;
+
+ drawable->update_count = 0;
+
+ drawable->update_timeout =
+ g_timeout_add_full (G_PRIORITY_HIGH,
+ 40,
+ (GSourceFunc) gimp_drawable_update_timeout,
+ drawable, NULL);
+ }
}
void
@@ -1996,3 +2035,15 @@ gimp_drawable_detach_floating_sel (GimpDrawable *drawable,
gimp_image_set_floating_selection (image, NULL);
}
+
+static gboolean
+gimp_drawable_update_timeout (GimpDrawable *drawable)
+{
+ drawable->update_timeout = 0;
+
+ if (drawable->update_count > 0)
+ gimp_drawable_update(drawable,
+ drawable->dirty_x1, drawable->dirty_y1,
+ drawable->dirty_x2 - drawable->dirty_x1, drawable->dirty_y2 - drawable->dirty_y1);
+ return FALSE;
+}
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index caeed82..00c6dfa 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -41,6 +41,15 @@ struct _GimpDrawable
GimpImageType type; /* type of drawable */
gboolean has_alpha; /* drawable has alpha */
+ gint dirty_x1;
+ gint dirty_y1;
+ gint dirty_x2;
+ gint dirty_y2;
+
+ guint update_timeout; /* update delay timeout ID */
+
+ guint update_count;
+
GimpDrawablePrivate *private;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]