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

Bryce W. Harrington b.harrington at samsung.com
Tue Jul 8 14:43:57 PDT 2014


On Tue, May 20, 2014 at 06:16:23PM +0200, z wrote:
> 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)

Here's a document with some directions on how to properly format
patches:

  http://wiki.x.org/wiki/Development/Documentation/SubmittingPatches/

Basically, you should generate them via `git format-patch`

> --- 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 */

Leave out all the /* z-one */ comments.  The patch itself indicates all
the lines you changed, we don't need to markup the source itself.

Why not call 'tmpextents' just 'rect', to match the chunk of code at
line 562?

> @@ -467,3 +468,4 @@
>               surface->win32.dc,
> -             0, 0,
> +/* z-one removed: 0, 0, */

Similarly, no need to document lines removed, that will just add
clutter.  People can refer to git log to see what got changed.

> +             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,

Probably better to add the win32 offsets to the rect structure before
the BitBlt.  rect isn't used anywhere else.
 
> -- 
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list