[gimp] app: cache the GeglBuffer used for display filters in GimpDisplayShell
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: cache the GeglBuffer used for display filters in GimpDisplayShell
- Date: Sat, 2 Nov 2013 19:57:27 +0000 (UTC)
commit 57d291e130674c59a27fe772de72bc7700483a96
Author: Michael Natterer <mitch gimp org>
Date: Sat Nov 2 20:56:25 2013 +0100
app: cache the GeglBuffer used for display filters in GimpDisplayShell
so it is not created and destroyed all the time.
app/display/gimpdisplayshell-render.c | 42 ++++++++++++++++++---------------
app/display/gimpdisplayshell.c | 8 ++++++
app/display/gimpdisplayshell.h | 6 ++++-
3 files changed, 36 insertions(+), 20 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-render.c b/app/display/gimpdisplayshell-render.c
index a50c7e9..7f10009 100644
--- a/app/display/gimpdisplayshell-render.c
+++ b/app/display/gimpdisplayshell-render.c
@@ -114,13 +114,26 @@ gimp_display_shell_render (GimpDisplayShell *shell,
/* apply filters to the rendered projection */
if (shell->filter_stack)
{
- const Babl *tmp_format = babl_format ("R'G'B'A float");
- GeglBuffer *tmp_buffer;
- guchar *tmp_data;
+ const Babl *filter_format = babl_format ("R'G'B'A float");
- tmp_data = gegl_malloc (w * window_scale *
- h * window_scale *
- babl_format_get_bytes_per_pixel (tmp_format));
+ if (! shell->filter_buffer)
+ {
+ gint w = GIMP_DISPLAY_RENDER_BUF_WIDTH * GIMP_DISPLAY_RENDER_MAX_SCALE;
+ gint h = GIMP_DISPLAY_RENDER_BUF_HEIGHT * GIMP_DISPLAY_RENDER_MAX_SCALE;
+
+ shell->filter_data =
+ gegl_malloc (w * h * babl_format_get_bytes_per_pixel (filter_format));
+
+ shell->filter_stride = w * babl_format_get_bytes_per_pixel (filter_format);
+
+ shell->filter_buffer =
+ gegl_buffer_linear_new_from_data (shell->filter_data,
+ filter_format,
+ GEGL_RECTANGLE (0, 0, w, h),
+ GEGL_AUTO_ROWSTRIDE,
+ (GDestroyNotify) gegl_free,
+ shell->filter_data);
+ }
gegl_buffer_get (buffer,
GEGL_RECTANGLE ((x + viewport_offset_x) * window_scale,
@@ -128,24 +141,17 @@ gimp_display_shell_render (GimpDisplayShell *shell,
w * window_scale,
h * window_scale),
shell->scale_x * window_scale,
- tmp_format, tmp_data,
- GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
+ filter_format, shell->filter_data,
+ shell->filter_stride, GEGL_ABYSS_NONE);
- tmp_buffer =
- gegl_buffer_linear_new_from_data (tmp_data, tmp_format,
- GEGL_RECTANGLE (0, 0,
- w * window_scale,
- h * window_scale),
- GEGL_AUTO_ROWSTRIDE,
- (GDestroyNotify) gegl_free, tmp_data);
gimp_color_display_stack_convert_buffer (shell->filter_stack,
- tmp_buffer,
+ shell->filter_buffer,
GEGL_RECTANGLE (0, 0,
w * window_scale,
h * window_scale));
- gegl_buffer_get (tmp_buffer,
+ gegl_buffer_get (shell->filter_buffer,
GEGL_RECTANGLE (0, 0,
w * window_scale,
h * window_scale),
@@ -153,8 +159,6 @@ gimp_display_shell_render (GimpDisplayShell *shell,
babl_format ("cairo-ARGB32"),
data, stride,
GEGL_ABYSS_NONE);
-
- g_object_unref (tmp_buffer);
}
else
{
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 4b94b30..108339a 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -797,6 +797,14 @@ gimp_display_shell_dispose (GObject *object)
shell->checkerboard = NULL;
}
+ if (shell->filter_buffer)
+ {
+ g_object_unref (shell->filter_buffer);
+ shell->filter_buffer = NULL;
+ shell->filter_data = NULL;
+ shell->filter_stride = 0;
+ }
+
if (shell->mask)
{
g_object_unref (shell->mask);
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index ffe04bf..c9b1058 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -108,10 +108,14 @@ struct _GimpDisplayShell
GtkWidget *statusbar; /* statusbar */
- GimpDisplayXfer *xfer; /* managers image buffer transfers */
+ GimpDisplayXfer *xfer; /* manages image buffer transfers */
cairo_surface_t *mask_surface; /* buffer for rendering the mask */
cairo_pattern_t *checkerboard; /* checkerboard pattern */
+ GeglBuffer *filter_buffer; /* buffer for display filters */
+ guchar *filter_data; /* filter_buffer's pixels */
+ gint filter_stride; /* filter_buffer's stride */
+
GimpCanvasItem *canvas_item; /* items drawn on the canvas */
GimpCanvasItem *unrotated_item; /* unrotated items for e.g. cursor */
GimpCanvasItem *passe_partout; /* item for the highlight */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]