[gimp/soc-2010-cage] Make cairo code work with newer cairo backends that actually use caching



commit 613ce67710704aac0ece742795c716ad91192c7a
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.

 app/text/gimptextlayer.c               |    2 ++
 app/widgets/gimpviewrenderer.c         |    4 ++++
 app/widgets/gimpviewrenderergradient.c |    4 ++++
 app/widgets/gimpviewrendererpalette.c  |    4 ++++
 libgimpwidgets/gimpcairo-utils.c       |    4 ++++
 5 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c
index 433395b..779af21 100644
--- a/app/text/gimptextlayer.c
+++ b/app/text/gimptextlayer.c
@@ -662,6 +662,8 @@ gimp_text_layer_render_layout (GimpTextLayer  *layer,
   mask = tile_manager_new ( width, height, 1);
   pixel_region_init (&maskPR, mask, 0, 0, width, height, TRUE);
 
+  cairo_surface_flush (surface);
+
   data      = cairo_image_surface_get_data (surface);
   rowstride = cairo_image_surface_get_stride (surface);
 
diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c
index 927721d..2171932 100644
--- a/app/widgets/gimpviewrenderer.c
+++ b/app/widgets/gimpviewrenderer.c
@@ -933,6 +933,8 @@ gimp_view_render_to_surface (TempBuf         *temp_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);
 
@@ -1085,6 +1087,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 d987789..a0ff120 100644
--- a/app/widgets/gimpviewrenderergradient.c
+++ b/app/widgets/gimpviewrenderergradient.c
@@ -188,6 +188,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);
 
@@ -196,6 +198,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 9713481..3f02b26 100644
--- a/app/widgets/gimpviewrendererpalette.c
+++ b/app/widgets/gimpviewrendererpalette.c
@@ -138,6 +138,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);
@@ -201,6 +203,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 b2c0c6b..9bb72e7 100644
--- a/libgimpwidgets/gimpcairo-utils.c
+++ b/libgimpwidgets/gimpcairo-utils.c
@@ -228,6 +228,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);
 
@@ -280,5 +282,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]