[gimp/gimp-2-6] Make cairo code work with newer cairo backends that actually use caching
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-6] Make cairo code work with newer cairo backends that actually use caching
- Date: Mon, 28 Jun 2010 10:33:10 +0000 (UTC)
commit 8deda13e5f9b5611387dcd1724bfdcac83f07255
Author: Michael Natterer <mitch gimp org>
Date: Mon Jun 28 12:23:31 2010 +0200
Make cairo code work with newer cairo backends that actually use caching
Call cairo_surface_flush() before reading or writing a surface's
pixels directly, and use cairo_surface_mark_dirty() after writing
pixels directly, so we don't read old pixels, and our written pixels
get actually used.
(manually cherry-picked from fad6053643482e222e246c2db828182b4f2a8c7f)
app/widgets/gimpviewrenderer.c | 12 ++++++++++++
app/widgets/gimpviewrenderergradient.c | 4 ++++
app/widgets/gimpviewrendererpalette.c | 4 ++++
libgimpwidgets/gimpcairo-utils.c | 4 ++++
4 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c
index 54bc765..9a91a27 100644
--- a/app/widgets/gimpviewrenderer.c
+++ b/app/widgets/gimpviewrenderer.c
@@ -926,6 +926,16 @@ gimp_view_render_to_surface (TempBuf *temp_buf,
g_return_if_fail (temp_buf != NULL);
g_return_if_fail (surface != NULL);
+ /* In rare cases we can get here while GIMP is exiting, handle that
+ * by checking for availability of the buffers
+ */
+ if (! gimp_render_check_buf ||
+ ! gimp_render_empty_buf ||
+ ! gimp_render_white_buf)
+ return;
+
+ cairo_surface_flush (surface);
+
dest = cairo_image_surface_get_data (surface);
dest_stride = cairo_image_surface_get_stride (surface);
@@ -1078,6 +1088,8 @@ gimp_view_render_to_surface (TempBuf *temp_buf,
dest += dest_stride;
}
+
+ cairo_surface_mark_dirty (surface);
}
void
diff --git a/app/widgets/gimpviewrenderergradient.c b/app/widgets/gimpviewrenderergradient.c
index 563c04d..368f714 100644
--- a/app/widgets/gimpviewrenderergradient.c
+++ b/app/widgets/gimpviewrenderergradient.c
@@ -189,6 +189,8 @@ gimp_view_renderer_gradient_render (GimpViewRenderer *renderer,
renderer->width,
renderer->height);
+ cairo_surface_flush (renderer->surface);
+
dest = cairo_image_surface_get_data (renderer->surface);
dest_stride = cairo_image_surface_get_stride (renderer->surface);
@@ -197,6 +199,8 @@ gimp_view_renderer_gradient_render (GimpViewRenderer *renderer,
memcpy (dest, buf, renderer->width * 4);
}
+ cairo_surface_mark_dirty (renderer->surface);
+
renderer->needs_render = FALSE;
}
diff --git a/app/widgets/gimpviewrendererpalette.c b/app/widgets/gimpviewrendererpalette.c
index 9c9eb8b..eeab3f3 100644
--- a/app/widgets/gimpviewrendererpalette.c
+++ b/app/widgets/gimpviewrendererpalette.c
@@ -139,6 +139,8 @@ gimp_view_renderer_palette_render (GimpViewRenderer *renderer,
renderer->width,
renderer->height);
+ cairo_surface_flush (renderer->surface);
+
row = g_new (guchar, renderer->width * 4);
dest = cairo_image_surface_get_data (renderer->surface);
@@ -202,6 +204,8 @@ gimp_view_renderer_palette_render (GimpViewRenderer *renderer,
g_free (row);
+ cairo_surface_mark_dirty (renderer->surface);
+
renderer->needs_render = FALSE;
}
diff --git a/libgimpwidgets/gimpcairo-utils.c b/libgimpwidgets/gimpcairo-utils.c
index 467c9ce..22cf5cb 100644
--- a/libgimpwidgets/gimpcairo-utils.c
+++ b/libgimpwidgets/gimpcairo-utils.c
@@ -229,6 +229,8 @@ gimp_cairo_surface_create_from_pixbuf (GdkPixbuf *pixbuf)
surface = cairo_image_surface_create (format, width, height);
+ cairo_surface_flush (surface);
+
src = gdk_pixbuf_get_pixels (pixbuf);
src_stride = gdk_pixbuf_get_rowstride (pixbuf);
@@ -281,5 +283,7 @@ gimp_cairo_surface_create_from_pixbuf (GdkPixbuf *pixbuf)
break;
}
+ cairo_surface_mark_dirty (surface);
+
return surface;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]