[cairo] Patch for win32 clipping crash + Visual Studio project file

z z-one at freemail.hu
Tue May 20 09:16:23 PDT 2014


Hi, I'm new here, please tell me if I write anything inappropriate to 
this list.

As others before me I also met a crash using cairo with a win32 dc when 
it has clipping. For example:
http://lists.cairographics.org/archives/cairo/2012-October/023683.html

It took me a few hours but I figured out what the problem is. I don't 
know how to post patches (i.e. just add attachment or something) so let 
me paste in the diff output.
(it was done with the source of the latest stable release, 1.12.16)

The original code could be optimized to work faster with smaller memory 
usage as it is currently not really optimal, but I don't have the time 
to do it. If anyone wants to, I might be able to help after I spent so 
much time reading this code to make the patch. (Currently it is better 
to just allocate some memory and let cairo write to it directly.)

I also made a project file that works with Visual Studio 2012 (and 
presumably 2013) and compiles the pixman 0.32.4  / cairo 1.12.16 into a 
static library without having to install other tools:
http://sourceforge.net/projects/cairosolutionvs2012/

Here's the patch: (I don't know if the format is good, I used winmerge 
to make it, but looks very similar to other patches)

--- 
C:/Projects/cairo/cairo-1.12.16/src/win32/cairo-win32-display-surface.c 
Mon Aug 26 17:07:21 2013
+++ 
C:/Projects/vs2012/cairo/cairo-1.12.16/src/win32/cairo-win32-display-surface.c 
Tue May 20 18:03:39 2014
@@ -446,2 +446,3 @@
      cairo_status_t status;
+    cairo_rectangle_int_t tmpextents; /* z-one */

@@ -467,3 +468,4 @@
               surface->win32.dc,
-             0, 0,
+/* z-one removed: 0, 0, */
+             surface->win32.extents.x, surface->win32.extents.y, /* 
z-one */
               SRCCOPY)) {
@@ -474,2 +476,6 @@

+    tmpextents.x = extents->x - surface->win32.extents.x; /* z-one */
+    tmpextents.y = extents->y - surface->win32.extents.y; /* z-one */
+    tmpextents.width = extents->width; /* z-one */
+    tmpextents.height = extents->height; /* z-one */
      surface = to_win32_display_surface (surface->fallback);
@@ -477,4 +483,4 @@
      GdiFlush();
-    return _cairo_surface_map_to_image (surface->image, extents);
-
+    /* z-one removed: return _cairo_surface_map_to_image 
(surface->image, extents); */
+    return _cairo_surface_map_to_image (surface->image, &tmpextents); 
/* z-one */
  err:
@@ -545,3 +551,4 @@
          if (!BitBlt (surface->win32.dc,
-             0, 0,
+/* z-one removed: 0, 0, */
+             surface->win32.extents.x, surface->win32.extents.y,  /* 
z-one */
               surface->win32.extents.width,
@@ -562,3 +569,4 @@
          if (!BitBlt (surface->win32.dc,
-                 rect.x, rect.y,
+/* z-one removed: rect.x, rext.y, */
+                 rect.x + surface->win32.extents.x, rect.y + 
surface->win32.extents.y,  /* z-one */
                   rect.width, rect.height,



More information about the cairo mailing list