[gimp/metadata-browser] app: experimental blend speedup code for review, disabled
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] app: experimental blend speedup code for review, disabled
- Date: Thu, 13 Sep 2012 00:21:30 +0000 (UTC)
commit 4d85bbe9ec9cd52b827d7e2de2d000fa0dbfb1d8
Author: Michael Natterer <mitch gimp org>
Date: Mon May 28 22:55:03 2012 +0200
app: experimental blend speedup code for review, disabled
Keeps around a cache of gradient values, instead of calling
gimp_gradient_get_color_at() for each rendered pixel.
app/core/gimpdrawable-blend.c | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c
index bbb21e6..cbbb48c 100644
--- a/app/core/gimpdrawable-blend.c
+++ b/app/core/gimpdrawable-blend.c
@@ -33,6 +33,7 @@
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h"
+#include "gimp-utils.h"
#include "gimp-apply-operation.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
@@ -44,11 +45,18 @@
#include "gimp-intl.h"
+//#define USE_GRADIENT_CACHE 1
+
+
typedef struct
{
GimpGradient *gradient;
GimpContext *context;
gboolean reverse;
+#ifdef USE_GRADIENT_CACHE
+ GimpRGB *gradient_cache;
+ gint gradient_cache_size;
+#endif
gdouble offset;
gdouble sx, sy;
GimpBlendMode blend_mode;
@@ -741,8 +749,12 @@ gradient_render_pixel (gdouble x,
if (rbd->blend_mode == GIMP_CUSTOM_MODE)
{
+#ifdef USE_GRADIENT_CACHE
+ *color = rbd->gradient_cache[(gint) (factor * (rbd->gradient_cache_size - 1))];
+#else
gimp_gradient_get_color_at (rbd->gradient, rbd->context, NULL,
factor, rbd->reverse, color);
+#endif
}
else
{
@@ -822,10 +834,30 @@ gradient_fill_region (GimpImage *image,
{
RenderBlendData rbd = { 0, };
+ GIMP_TIMER_START();
+
rbd.gradient = gimp_context_get_gradient (context);
rbd.context = context;
rbd.reverse = reverse;
+#ifdef USE_GRADIENT_CACHE
+ {
+ gint i;
+
+ rbd.gradient_cache_size = ceil (sqrt (SQR (sx - ex) + SQR (sy - ey)));
+ rbd.gradient_cache = g_new0 (GimpRGB, rbd.gradient_cache_size);
+
+ for (i = 0; i < rbd.gradient_cache_size; i++)
+ {
+ gdouble factor = (gdouble) i / (gdouble) (rbd.gradient_cache_size - 1);
+
+ gimp_gradient_get_color_at (rbd.gradient, rbd.context, NULL,
+ factor, rbd.reverse,
+ rbd.gradient_cache + i);
+ }
+ }
+#endif
+
if (gimp_gradient_has_fg_bg_segments (rbd.gradient))
rbd.gradient = gimp_gradient_flatten (rbd.gradient, context);
else
@@ -1013,8 +1045,14 @@ gradient_fill_region (GimpImage *image,
g_rand_free (rbd.seed);
}
+#ifdef USE_GRADIENT_CACHE
+ g_free (rbd.gradient_cache);
+#endif
+
g_object_unref (rbd.gradient);
if (rbd.dist_buffer)
g_object_unref (rbd.dist_buffer);
+
+ GIMP_TIMER_END("gradient_fill_region");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]