[gimp] app: another optimization in GimpOperationGradient
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: another optimization in GimpOperationGradient
- Date: Wed, 18 Apr 2018 10:48:10 +0000 (UTC)
commit cafb18643f3ae84c9a11564b09fe77da5e931c18
Author: Michael Natterer <mitch gimp org>
Date: Wed Apr 18 12:45:58 2018 +0200
app: another optimization in GimpOperationGradient
Don't reallocate the cache in prepare() but only on demand in
process().
app/operations/gimpoperationgradient.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/app/operations/gimpoperationgradient.c b/app/operations/gimpoperationgradient.c
index 69c5bbe..868591e 100644
--- a/app/operations/gimpoperationgradient.c
+++ b/app/operations/gimpoperationgradient.c
@@ -500,21 +500,9 @@ static void
gimp_operation_gradient_prepare (GeglOperation *operation)
{
GimpOperationGradient *self = GIMP_OPERATION_GRADIENT (operation);
- gint cache_size;
gegl_operation_set_format (operation, "output", babl_format ("R'G'B'A float"));
- cache_size = ceil (sqrt (SQR (self->start_x - self->end_x) +
- SQR (self->start_y - self->end_y))) * 4;
-
- if (cache_size != self->gradient_cache_size)
- {
- g_clear_pointer (&self->gradient_cache, g_free);
-
- self->gradient_cache = g_new0 (GimpRGB, cache_size);
- self->gradient_cache_size = cache_size;
- }
-
self->gradient_cache_valid = FALSE;
}
@@ -1010,8 +998,20 @@ gimp_operation_gradient_process (GeglOperation *operation,
if (! self->gradient_cache_valid)
{
GimpGradientSegment *last_seg = NULL;
+ gint cache_size;
gint i;
+ cache_size = ceil (sqrt (SQR (self->start_x - self->end_x) +
+ SQR (self->start_y - self->end_y))) * 4;
+
+ if (cache_size != self->gradient_cache_size)
+ {
+ g_clear_pointer (&self->gradient_cache, g_free);
+
+ self->gradient_cache = g_new0 (GimpRGB, cache_size);
+ self->gradient_cache_size = cache_size;
+ }
+
for (i = 0; i < self->gradient_cache_size; i++)
{
gdouble factor = (gdouble) i / (gdouble) (self->gradient_cache_size - 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]