From d75ce8aee317356ec4ef676531d61433492d4a9f Mon Sep 17 00:00:00 2001 From: "vladimir%pobox.com" Date: Wed, 18 Jan 2006 22:15:25 +0000 Subject: [PATCH] Import a bunch of more up to date local cairo patches, notably fixes to win32 clipping. --- gfx/cairo/README | 15 ++ gfx/cairo/cairo-debug-helpers.patch | 76 +++++-- gfx/cairo/cairo-win32-clip.patch | 235 ++++++++++++++++++++++ gfx/cairo/cairo/src/cairo-debug.c | 41 ++++ gfx/cairo/cairo/src/cairo-debug.h | 4 + gfx/cairo/cairo/src/cairo-surface.c | 18 +- gfx/cairo/cairo/src/cairo-win32-private.h | 2 +- gfx/cairo/cairo/src/cairo-win32-surface.c | 92 ++++----- gfx/cairo/device-offset-scale.patch | 66 +++--- gfx/cairo/mozilla-misc.patch | 53 ++++- gfx/cairo/push-pop-group.patch | 22 +- 11 files changed, 500 insertions(+), 124 deletions(-) create mode 100644 gfx/cairo/cairo-win32-clip.patch diff --git a/gfx/cairo/README b/gfx/cairo/README index 2e39869fa07a..f8f2cfc866ce 100644 --- a/gfx/cairo/README +++ b/gfx/cairo/README @@ -23,10 +23,25 @@ if cairo is enabled. Please upgrade to VC7.1/8. mozilla-misc.patch - Misc compilation fixes for pixman (submitted upstream) - temporary moz_cairo_set_target API (not for upstream) + - mac compilation fix for cairo-atsui-font.c for 10.2 SDK (maybe should + be upstream?) + - cairo-features.h.in - add cairo-platform.h include and hard-code the + cairo version (not for upstream) + - #if 0'ing out DllMain in win32-surface.c -- not needed, since + we don't use cairo multithreaded, and DllMain interferes + with libxul's DllMain. (not for usptream) + - #if 0'ing out bits to get rid of multithreaded stuff in cairoint.h + (not for upstream) cairo-debug-helpers.patch - some stuff for cairo-debug.[ch] +cairo-win32-clip.patch + - Make mark_dirty() reset a surface's clip, so that we can call it + when we RestoreDC() after native win32 drawing (submitted upstream) + - Rework win32 surface clip and extents handling for correctness + (submitted upstream) + device-offset-scale.path - Move device offset/scale handling into surface layer; large rework of device offset/scale. (submitted upstream) diff --git a/gfx/cairo/cairo-debug-helpers.patch b/gfx/cairo/cairo-debug-helpers.patch index 357381cc7a5f..6812071584b2 100644 --- a/gfx/cairo/cairo-debug-helpers.patch +++ b/gfx/cairo/cairo-debug-helpers.patch @@ -1,19 +1,59 @@ Index: src/cairo-debug.c =================================================================== -RCS file: /cvs/cairo/cairo/src/cairo-debug.c,v -retrieving revision 1.2 -diff -u -8 -p -r1.2 cairo-debug.c ---- src/cairo-debug.c 31 Aug 2005 22:08:02 -0000 1.2 -+++ src/cairo-debug.c 10 Jan 2006 21:15:50 -0000 -@@ -65,8 +65,158 @@ cairo_debug_reset_static_data (void) +--- src/cairo-debug.c.orig ++++ src/cairo-debug.c +@@ -35,6 +35,8 @@ - _cairo_font_reset_static_data (); + #include "cairoint.h" - #if CAIRO_HAS_FT_FONT - _cairo_ft_font_reset_static_data (); ++#include "cairo-clip-private.h" ++ + /** + * cairo_debug_reset_static_data: + * +@@ -70,3 +72,192 @@ cairo_debug_reset_static_data (void) #endif } ++/* ++ * clip dumper ++ */ ++void ++cairo_debug_dump_clip (struct _cairo_clip *clip, ++ FILE *fp) ++{ ++ fprintf (fp, "clip %p: %s ", (clip->mode == CAIRO_CLIP_MODE_PATH ? "PATH" : ++ clip->mode == CAIRO_CLIP_MODE_REGION ? "REGION" : ++ clip->mode == CAIRO_CLIP_MODE_MASK ? "MASK" : ++ "INVALID?!")); ++ if (clip->mode == CAIRO_CLIP_MODE_PATH) { ++ fprintf (fp, "\n=== clip path ===\n"); ++ } else if (clip->mode == CAIRO_CLIP_MODE_REGION) { ++ if (!clip->region) { ++ fprintf (fp, "region = NULL"); ++ } else if (pixman_region_num_rects (clip->region) == 1) { ++ pixman_box16_t *rects = pixman_region_rects (clip->region); ++ fprintf (fp, "region [%d %d %d %d]", ++ rects[0].x1, rects[0].y1, ++ rects[0].x2, rects[0].y2); ++ } else { ++ pixman_box16_t *rects = pixman_region_rects (clip->region); ++ int i, nr = pixman_region_num_rects(clip->region); ++ fprintf (fp, "region (%d rects)\n", nr); ++ for (i = 0; i < nr; i++) { ++ fprintf (fp, "rect %d: [%d %d %d %d]", i, ++ rects[nr].x1, rects[nr].y1, ++ rects[nr].x2, rects[nr].y2); ++ } ++ } ++ } else if (clip->mode == CAIRO_CLIP_MODE_MASK) { ++ fprintf (fp, "mask, surface: %p rect: [%d %d %d %d]", clip->surface, ++ clip->surface_rect.x, clip->surface_rect.y, clip->surface_rect.width, clip->surface_rect.height); ++ } ++ ++ fprintf (fp, "\n"); ++} ++ +/* + * path dumper + */ @@ -166,17 +206,9 @@ diff -u -8 -p -r1.2 cairo-debug.c + Index: src/cairo-debug.h =================================================================== -RCS file: /cvs/cairo/cairo/src/cairo-debug.h,v -retrieving revision 1.1 -diff -u -8 -p -r1.1 cairo-debug.h ---- src/cairo-debug.h 1 Aug 2005 20:33:47 -0000 1.1 -+++ src/cairo-debug.h 10 Jan 2006 21:15:50 -0000 -@@ -32,17 +32,35 @@ - * Contributor(s): - * Carl D. Worth - */ - - #ifndef CAIRO_DEBUG_H +--- src/cairo-debug.h.orig ++++ src/cairo-debug.h +@@ -37,12 +37,34 @@ #define CAIRO_DEBUG_H #include @@ -187,10 +219,14 @@ diff -u -8 -p -r1.1 cairo-debug.h +struct _cairo_path_fixed; +struct _cairo_traps; +struct _cairo_trapezoid; ++struct _cairo_clip; + void cairo_debug_reset_static_data (void); ++void ++cairo_debug_dump_clip (struct _cairo_clip *clip, ++ FILE *fp); +void +cairo_debug_dump_path (struct _cairo_path_fixed *path, + FILE *fp); diff --git a/gfx/cairo/cairo-win32-clip.patch b/gfx/cairo/cairo-win32-clip.patch new file mode 100644 index 000000000000..91a10c60cdf0 --- /dev/null +++ b/gfx/cairo/cairo-win32-clip.patch @@ -0,0 +1,235 @@ +Index: cairo-glitz/src/cairo-surface.c +=================================================================== +--- cairo-glitz.orig/src/cairo-surface.c ++++ cairo-glitz/src/cairo-surface.c +@@ -502,6 +502,10 @@ cairo_surface_mark_dirty (cairo_surface_ + * Like cairo_surface_mark_dirty(), but drawing has been done only to + * the specified rectangle, so that cairo can retain cached contents + * for other parts of the surface. ++ * ++ * Any cached clip set on the surface will be reset by this function, ++ * to make sure that future cairo calls have the clip set that they ++ * expect. + */ + void + cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface, +@@ -520,6 +524,12 @@ cairo_surface_mark_dirty_rectangle (cair + return; + } + ++ /* Always reset the clip here, to avoid having a SaveDC/RestoreDC around ++ * cairo calls that update the surface clip resulting in a desync between ++ * the cairo clip and the backend clip. ++ */ ++ surface->current_clip_serial = -1; ++ + if (surface->backend->mark_dirty_rectangle) { + cairo_status_t status; + +@@ -1329,6 +1339,12 @@ _cairo_surface_set_clip (cairo_surface_t + if (!surface) + return CAIRO_STATUS_NULL_POINTER; + ++ if (surface->status) ++ return surface->status; ++ ++ if (surface->finished) ++ return CAIRO_STATUS_SURFACE_FINISHED; ++ + if (clip) { + serial = clip->serial; + if (serial == 0) +@@ -1336,7 +1352,7 @@ _cairo_surface_set_clip (cairo_surface_t + } + + surface->clip = clip; +- ++ + if (serial == _cairo_surface_get_current_clip_serial (surface)) + return CAIRO_STATUS_SUCCESS; + +Index: cairo-glitz/src/cairo-win32-private.h +=================================================================== +--- cairo-glitz.orig/src/cairo-win32-private.h ++++ cairo-glitz/src/cairo-win32-private.h +@@ -62,9 +62,9 @@ typedef struct _cairo_win32_surface { + + cairo_rectangle_t clip_rect; + +- int set_clip; + HRGN saved_clip; + ++ cairo_rectangle_t extents; + } cairo_win32_surface_t; + + cairo_status_t +Index: cairo-glitz/src/cairo-win32-surface.c +=================================================================== +--- cairo-glitz.orig/src/cairo-win32-surface.c ++++ cairo-glitz/src/cairo-win32-surface.c +@@ -274,9 +274,14 @@ _cairo_win32_surface_create_for_dc (HDC + surface->clip_rect.width = width; + surface->clip_rect.height = height; + +- surface->set_clip = 0; +- surface->saved_clip = NULL; +- ++ surface->saved_clip = CreateRectRgn (0, 0, 0, 0); ++ if (GetClipRgn (surface->dc, surface->saved_clip) == 0) { ++ DeleteObject(surface->saved_clip); ++ surface->saved_clip = NULL; ++ } ++ ++ surface->extents = surface->clip_rect; ++ + _cairo_surface_init (&surface->base, &cairo_win32_surface_backend); + + return (cairo_surface_t *)surface; +@@ -340,9 +345,8 @@ _cairo_win32_surface_finish (void *abstr + if (surface->image) + cairo_surface_destroy (surface->image); + +- if (surface->saved_clip) { ++ if (surface->saved_clip) + DeleteObject (surface->saved_clip); +- } + + /* If we created the Bitmap and DC, destroy them */ + if (surface->bitmap) { +@@ -403,7 +407,7 @@ _cairo_win32_surface_acquire_source_imag + cairo_win32_surface_t *surface = abstract_surface; + cairo_win32_surface_t *local = NULL; + cairo_status_t status; +- ++ + if (surface->image) { + *image_out = (cairo_image_surface_t *)surface->image; + *image_extra = NULL; +@@ -446,7 +450,7 @@ _cairo_win32_surface_acquire_dest_image + cairo_status_t status; + RECT clip_box; + int x1, y1, x2, y2; +- ++ + if (surface->image) { + image_rect->x = 0; + image_rect->y = 0; +@@ -461,12 +465,12 @@ _cairo_win32_surface_acquire_dest_image + + if (GetClipBox (surface->dc, &clip_box) == ERROR) + return _cairo_win32_print_gdi_error ("_cairo_win3_surface_acquire_dest_image"); +- ++ + x1 = clip_box.left; + x2 = clip_box.right; + y1 = clip_box.top; + y2 = clip_box.bottom; +- ++ + if (interest_rect->x > x1) + x1 = interest_rect->x; + if (interest_rect->y > y1) +@@ -855,19 +859,9 @@ _cairo_win32_surface_set_clip_region (vo + + if (region == NULL) { + /* Clear any clip set by cairo, return to the original */ +- +- if (surface->set_clip) { +- if (SelectClipRgn (surface->dc, surface->saved_clip) == ERROR) +- return _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region"); +- +- if (surface->saved_clip) { +- DeleteObject (surface->saved_clip); +- surface->saved_clip = NULL; +- } ++ if (SelectClipRgn (surface->dc, surface->saved_clip) == ERROR) ++ return _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region (reset)"); + +- surface->set_clip = 0; +- } +- + return CAIRO_STATUS_SUCCESS; + + } else { +@@ -910,36 +904,16 @@ _cairo_win32_surface_set_clip_region (vo + if (!gdi_region) + return CAIRO_STATUS_NO_MEMORY; + +- if (surface->set_clip) { +- /* Combine the new region with the original clip */ ++ /* Combine the new region with the original clip */ + +- if (surface->saved_clip) { +- if (CombineRgn (gdi_region, gdi_region, surface->saved_clip, RGN_AND) == ERROR) +- goto FAIL; +- } +- +- if (SelectClipRgn (surface->dc, gdi_region) == ERROR) ++ if (surface->saved_clip) { ++ if (CombineRgn (gdi_region, gdi_region, surface->saved_clip, RGN_AND) == ERROR) + goto FAIL; +- +- } else { +- /* Save the the current region */ +- +- surface->saved_clip = CreateRectRgn (0, 0, 0, 0); +- if (!surface->saved_clip) { +- goto FAIL; } +- +- /* This function has no error return! */ +- if (GetClipRgn (surface->dc, surface->saved_clip) == 0) { /* No clip */ +- DeleteObject (surface->saved_clip); +- surface->saved_clip = NULL; +- } +- +- if (ExtSelectClipRgn (surface->dc, gdi_region, RGN_AND) == ERROR) +- goto FAIL; +- +- surface->set_clip = 1; + } + ++ if (SelectClipRgn (surface->dc, gdi_region) == ERROR) ++ goto FAIL; ++ + DeleteObject (gdi_region); + return CAIRO_STATUS_SUCCESS; + +@@ -955,15 +929,8 @@ _cairo_win32_surface_get_extents (void + cairo_rectangle_t *rectangle) + { + cairo_win32_surface_t *surface = abstract_surface; +- RECT clip_box; + +- if (GetClipBox (surface->dc, &clip_box) == ERROR) +- return _cairo_win32_print_gdi_error ("_cairo_win3_surface_acquire_dest_image"); +- +- rectangle->x = clip_box.left; +- rectangle->y = clip_box.top; +- rectangle->width = clip_box.right - clip_box.left; +- rectangle->height = clip_box.bottom - clip_box.top; ++ *rectangle = surface->extents; + + return CAIRO_STATUS_SUCCESS; + } +@@ -1007,8 +974,19 @@ cairo_win32_surface_create (HDC hdc) + surface->clip_rect.width = rect.right - rect.left; + surface->clip_rect.height = rect.bottom - rect.top; + +- surface->set_clip = 0; +- surface->saved_clip = NULL; ++ if (surface->clip_rect.width == 0 || ++ surface->clip_rect.height == 0) ++ { ++ surface->saved_clip = NULL; ++ } else { ++ surface->saved_clip = CreateRectRgn (0, 0, 0, 0); ++ if (GetClipRgn (hdc, surface->saved_clip) == 0) { ++ DeleteObject(surface->saved_clip); ++ surface->saved_clip = NULL; ++ } ++ } ++ ++ surface->extents = surface->clip_rect; + + _cairo_surface_init (&surface->base, &cairo_win32_surface_backend); + diff --git a/gfx/cairo/cairo/src/cairo-debug.c b/gfx/cairo/cairo/src/cairo-debug.c index 8cdb39167000..524de78663a5 100644 --- a/gfx/cairo/cairo/src/cairo-debug.c +++ b/gfx/cairo/cairo/src/cairo-debug.c @@ -35,6 +35,8 @@ #include "cairoint.h" +#include "cairo-clip-private.h" + /** * cairo_debug_reset_static_data: * @@ -70,6 +72,45 @@ cairo_debug_reset_static_data (void) #endif } +/* + * clip dumper + */ +void +cairo_debug_dump_clip (struct _cairo_clip *clip, + FILE *fp) +{ + fprintf (fp, "clip %p: %s ", (clip->mode == CAIRO_CLIP_MODE_PATH ? "PATH" : + clip->mode == CAIRO_CLIP_MODE_REGION ? "REGION" : + clip->mode == CAIRO_CLIP_MODE_MASK ? "MASK" : + "INVALID?!")); + if (clip->mode == CAIRO_CLIP_MODE_PATH) { + fprintf (fp, "\n=== clip path ===\n"); + } else if (clip->mode == CAIRO_CLIP_MODE_REGION) { + if (!clip->region) { + fprintf (fp, "region = NULL"); + } else if (pixman_region_num_rects (clip->region) == 1) { + pixman_box16_t *rects = pixman_region_rects (clip->region); + fprintf (fp, "region [%d %d %d %d]", + rects[0].x1, rects[0].y1, + rects[0].x2, rects[0].y2); + } else { + pixman_box16_t *rects = pixman_region_rects (clip->region); + int i, nr = pixman_region_num_rects(clip->region); + fprintf (fp, "region (%d rects)\n", nr); + for (i = 0; i < nr; i++) { + fprintf (fp, "rect %d: [%d %d %d %d]", i, + rects[nr].x1, rects[nr].y1, + rects[nr].x2, rects[nr].y2); + } + } + } else if (clip->mode == CAIRO_CLIP_MODE_MASK) { + fprintf (fp, "mask, surface: %p rect: [%d %d %d %d]", clip->surface, + clip->surface_rect.x, clip->surface_rect.y, clip->surface_rect.width, clip->surface_rect.height); + } + + fprintf (fp, "\n"); +} + /* * path dumper */ diff --git a/gfx/cairo/cairo/src/cairo-debug.h b/gfx/cairo/cairo/src/cairo-debug.h index e9595490752a..2a7c3af88a49 100644 --- a/gfx/cairo/cairo/src/cairo-debug.h +++ b/gfx/cairo/cairo/src/cairo-debug.h @@ -44,10 +44,14 @@ CAIRO_BEGIN_DECLS struct _cairo_path_fixed; struct _cairo_traps; struct _cairo_trapezoid; +struct _cairo_clip; void cairo_debug_reset_static_data (void); +void +cairo_debug_dump_clip (struct _cairo_clip *clip, + FILE *fp); void cairo_debug_dump_path (struct _cairo_path_fixed *path, FILE *fp); diff --git a/gfx/cairo/cairo/src/cairo-surface.c b/gfx/cairo/cairo/src/cairo-surface.c index 377a84f7c8d0..3eea708d6188 100644 --- a/gfx/cairo/cairo/src/cairo-surface.c +++ b/gfx/cairo/cairo/src/cairo-surface.c @@ -518,6 +518,10 @@ cairo_surface_mark_dirty (cairo_surface_t *surface) * Like cairo_surface_mark_dirty(), but drawing has been done only to * the specified rectangle, so that cairo can retain cached contents * for other parts of the surface. + * + * Any cached clip set on the surface will be reset by this function, + * to make sure that future cairo calls have the clip set that they + * expect. */ void cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface, @@ -536,6 +540,12 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface, return; } + /* Always reset the clip here, to avoid having a SaveDC/RestoreDC around + * cairo calls that update the surface clip resulting in a desync between + * the cairo clip and the backend clip. + */ + surface->current_clip_serial = -1; + if (surface->backend->mark_dirty_rectangle) { cairo_status_t status; @@ -1542,6 +1552,12 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip) if (!surface) return CAIRO_STATUS_NULL_POINTER; + if (surface->status) + return surface->status; + + if (surface->finished) + return CAIRO_STATUS_SURFACE_FINISHED; + if (clip) { serial = clip->serial; if (serial == 0) @@ -1549,7 +1565,7 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip) } surface->clip = clip; - + if (serial == _cairo_surface_get_current_clip_serial (surface)) return CAIRO_STATUS_SUCCESS; diff --git a/gfx/cairo/cairo/src/cairo-win32-private.h b/gfx/cairo/cairo/src/cairo-win32-private.h index a229147c7dc0..b3143c96fcb4 100644 --- a/gfx/cairo/cairo/src/cairo-win32-private.h +++ b/gfx/cairo/cairo/src/cairo-win32-private.h @@ -62,9 +62,9 @@ typedef struct _cairo_win32_surface { cairo_rectangle_t clip_rect; - int set_clip; HRGN saved_clip; + cairo_rectangle_t extents; } cairo_win32_surface_t; cairo_status_t diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c index 69621b446878..a8b3f0989c39 100644 --- a/gfx/cairo/cairo/src/cairo-win32-surface.c +++ b/gfx/cairo/cairo/src/cairo-win32-surface.c @@ -274,9 +274,14 @@ _cairo_win32_surface_create_for_dc (HDC original_dc, surface->clip_rect.width = width; surface->clip_rect.height = height; - surface->set_clip = 0; - surface->saved_clip = NULL; - + surface->saved_clip = CreateRectRgn (0, 0, 0, 0); + if (GetClipRgn (surface->dc, surface->saved_clip) == 0) { + DeleteObject(surface->saved_clip); + surface->saved_clip = NULL; + } + + surface->extents = surface->clip_rect; + _cairo_surface_init (&surface->base, &cairo_win32_surface_backend); return (cairo_surface_t *)surface; @@ -340,9 +345,8 @@ _cairo_win32_surface_finish (void *abstract_surface) if (surface->image) cairo_surface_destroy (surface->image); - if (surface->saved_clip) { + if (surface->saved_clip) DeleteObject (surface->saved_clip); - } /* If we created the Bitmap and DC, destroy them */ if (surface->bitmap) { @@ -403,7 +407,7 @@ _cairo_win32_surface_acquire_source_image (void *abstract_sur cairo_win32_surface_t *surface = abstract_surface; cairo_win32_surface_t *local = NULL; cairo_status_t status; - + if (surface->image) { *image_out = (cairo_image_surface_t *)surface->image; *image_extra = NULL; @@ -446,7 +450,7 @@ _cairo_win32_surface_acquire_dest_image (void *abstract_surfa cairo_status_t status; RECT clip_box; int x1, y1, x2, y2; - + if (surface->image) { image_rect->x = 0; image_rect->y = 0; @@ -461,12 +465,12 @@ _cairo_win32_surface_acquire_dest_image (void *abstract_surfa if (GetClipBox (surface->dc, &clip_box) == ERROR) return _cairo_win32_print_gdi_error ("_cairo_win3_surface_acquire_dest_image"); - + x1 = clip_box.left; x2 = clip_box.right; y1 = clip_box.top; y2 = clip_box.bottom; - + if (interest_rect->x > x1) x1 = interest_rect->x; if (interest_rect->y > y1) @@ -855,19 +859,9 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface, if (region == NULL) { /* Clear any clip set by cairo, return to the original */ - - if (surface->set_clip) { - if (SelectClipRgn (surface->dc, surface->saved_clip) == ERROR) - return _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region"); + if (SelectClipRgn (surface->dc, surface->saved_clip) == ERROR) + return _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region (reset)"); - if (surface->saved_clip) { - DeleteObject (surface->saved_clip); - surface->saved_clip = NULL; - } - - surface->set_clip = 0; - } - return CAIRO_STATUS_SUCCESS; } else { @@ -910,36 +904,16 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface, if (!gdi_region) return CAIRO_STATUS_NO_MEMORY; - if (surface->set_clip) { - /* Combine the new region with the original clip */ + /* Combine the new region with the original clip */ - if (surface->saved_clip) { - if (CombineRgn (gdi_region, gdi_region, surface->saved_clip, RGN_AND) == ERROR) - goto FAIL; - } - - if (SelectClipRgn (surface->dc, gdi_region) == ERROR) + if (surface->saved_clip) { + if (CombineRgn (gdi_region, gdi_region, surface->saved_clip, RGN_AND) == ERROR) goto FAIL; - - } else { - /* Save the the current region */ - - surface->saved_clip = CreateRectRgn (0, 0, 0, 0); - if (!surface->saved_clip) { - goto FAIL; } - - /* This function has no error return! */ - if (GetClipRgn (surface->dc, surface->saved_clip) == 0) { /* No clip */ - DeleteObject (surface->saved_clip); - surface->saved_clip = NULL; - } - - if (ExtSelectClipRgn (surface->dc, gdi_region, RGN_AND) == ERROR) - goto FAIL; - - surface->set_clip = 1; } + if (SelectClipRgn (surface->dc, gdi_region) == ERROR) + goto FAIL; + DeleteObject (gdi_region); return CAIRO_STATUS_SUCCESS; @@ -955,15 +929,8 @@ _cairo_win32_surface_get_extents (void *abstract_surface, cairo_rectangle_t *rectangle) { cairo_win32_surface_t *surface = abstract_surface; - RECT clip_box; - if (GetClipBox (surface->dc, &clip_box) == ERROR) - return _cairo_win32_print_gdi_error ("_cairo_win3_surface_acquire_dest_image"); - - rectangle->x = clip_box.left; - rectangle->y = clip_box.top; - rectangle->width = clip_box.right - clip_box.left; - rectangle->height = clip_box.bottom - clip_box.top; + *rectangle = surface->extents; return CAIRO_STATUS_SUCCESS; } @@ -1007,8 +974,19 @@ cairo_win32_surface_create (HDC hdc) surface->clip_rect.width = rect.right - rect.left; surface->clip_rect.height = rect.bottom - rect.top; - surface->set_clip = 0; - surface->saved_clip = NULL; + if (surface->clip_rect.width == 0 || + surface->clip_rect.height == 0) + { + surface->saved_clip = NULL; + } else { + surface->saved_clip = CreateRectRgn (0, 0, 0, 0); + if (GetClipRgn (hdc, surface->saved_clip) == 0) { + DeleteObject(surface->saved_clip); + surface->saved_clip = NULL; + } + } + + surface->extents = surface->clip_rect; _cairo_surface_init (&surface->base, &cairo_win32_surface_backend); diff --git a/gfx/cairo/device-offset-scale.patch b/gfx/cairo/device-offset-scale.patch index ca343216da03..b9423b1e5f2e 100644 --- a/gfx/cairo/device-offset-scale.patch +++ b/gfx/cairo/device-offset-scale.patch @@ -2,7 +2,7 @@ Index: src/cairo-gstate.c =================================================================== --- src/cairo-gstate.c.orig +++ src/cairo-gstate.c -@@ -501,37 +501,10 @@ _cairo_gstate_get_miter_limit (cairo_gst +@@ -508,37 +508,10 @@ _cairo_gstate_get_miter_limit (cairo_gst return gstate->stroke_style.miter_limit; } @@ -40,7 +40,7 @@ Index: src/cairo-gstate.c } cairo_status_t -@@ -617,9 +590,6 @@ _cairo_gstate_set_matrix (cairo_gstate_t +@@ -624,9 +597,6 @@ _cairo_gstate_set_matrix (cairo_gstate_t if (status) return status; @@ -50,7 +50,7 @@ Index: src/cairo-gstate.c return CAIRO_STATUS_SUCCESS; } -@@ -631,9 +601,6 @@ _cairo_gstate_identity_matrix (cairo_gst +@@ -638,9 +608,6 @@ _cairo_gstate_identity_matrix (cairo_gst cairo_matrix_init_identity (&gstate->ctm); cairo_matrix_init_identity (&gstate->ctm_inverse); @@ -60,7 +60,7 @@ Index: src/cairo-gstate.c return CAIRO_STATUS_SUCCESS; } -@@ -675,15 +642,11 @@ void +@@ -682,15 +649,11 @@ void _cairo_gstate_user_to_backend (cairo_gstate_t *gstate, double *x, double *y) { cairo_matrix_transform_point (&gstate->ctm, x, y); @@ -76,7 +76,7 @@ Index: src/cairo-gstate.c cairo_matrix_transform_point (&gstate->ctm_inverse, x, y); } -@@ -704,16 +667,8 @@ _cairo_gstate_copy_transformed_pattern ( +@@ -711,16 +674,8 @@ _cairo_gstate_copy_transformed_pattern ( cairo_pattern_t *original, cairo_matrix_t *ctm_inverse) { @@ -237,7 +237,7 @@ Index: src/cairo-surface.c /** * _cairo_surface_set_error: * @surface: a surface -@@ -523,7 +539,10 @@ cairo_surface_mark_dirty_rectangle (cair +@@ -533,7 +549,10 @@ cairo_surface_mark_dirty_rectangle (cair if (surface->backend->mark_dirty_rectangle) { cairo_status_t status; @@ -249,7 +249,7 @@ Index: src/cairo-surface.c if (status) _cairo_surface_set_error (surface, status); -@@ -618,6 +637,7 @@ _cairo_surface_release_source_image (cai +@@ -628,6 +647,7 @@ _cairo_surface_release_source_image (cai * @surface: a #cairo_surface_t * @interest_rect: area of @surface for which fallback drawing is being done. * A value of %NULL indicates that the entire surface is desired. @@ -257,7 +257,7 @@ Index: src/cairo-surface.c * @image_out: location to store a pointer to an image surface that includes at least * the intersection of @interest_rect with the visible area of @surface. * This surface could be @surface itself, a surface held internal to @surface, -@@ -650,10 +670,26 @@ _cairo_surface_acquire_dest_image (cairo +@@ -660,10 +680,26 @@ _cairo_surface_acquire_dest_image (cairo cairo_rectangle_t *image_rect, void **image_extra) { @@ -286,7 +286,7 @@ Index: src/cairo-surface.c } /** -@@ -675,10 +711,22 @@ _cairo_surface_release_dest_image (cairo +@@ -685,10 +721,22 @@ _cairo_surface_release_dest_image (cairo cairo_rectangle_t *image_rect, void *image_extra) { @@ -310,7 +310,7 @@ Index: src/cairo-surface.c image, image_rect, image_extra); } -@@ -714,6 +762,13 @@ _cairo_surface_clone_similar (cairo_surf +@@ -724,6 +772,13 @@ _cairo_surface_clone_similar (cairo_surf return CAIRO_INT_STATUS_UNSUPPORTED; status = surface->backend->clone_similar (surface, src, clone_out); @@ -324,7 +324,7 @@ Index: src/cairo-surface.c if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; -@@ -722,6 +777,12 @@ _cairo_surface_clone_similar (cairo_surf +@@ -732,6 +787,12 @@ _cairo_surface_clone_similar (cairo_surf return status; status = surface->backend->clone_similar (surface, &image->base, clone_out); @@ -337,7 +337,7 @@ Index: src/cairo-surface.c /* If the above failed point, we could implement a full fallback * using acquire_dest_image, but that's going to be very -@@ -798,7 +859,8 @@ _cairo_surface_composite (cairo_operator +@@ -808,7 +869,8 @@ _cairo_surface_composite (cairo_operator src, mask, dst, src_x, src_y, mask_x, mask_y, @@ -347,7 +347,7 @@ Index: src/cairo-surface.c width, height); if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; -@@ -927,6 +989,8 @@ _cairo_surface_fill_rectangles (cairo_su +@@ -937,6 +999,8 @@ _cairo_surface_fill_rectangles (cairo_su int num_rects) { cairo_int_status_t status; @@ -356,7 +356,7 @@ Index: src/cairo-surface.c assert (! surface->is_snapshot); -@@ -940,8 +1004,26 @@ _cairo_surface_fill_rectangles (cairo_su +@@ -950,8 +1014,26 @@ _cairo_surface_fill_rectangles (cairo_su return CAIRO_STATUS_SUCCESS; if (surface->backend->fill_rectangles) { @@ -385,7 +385,7 @@ Index: src/cairo-surface.c if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; } -@@ -1002,10 +1084,31 @@ _cairo_surface_stroke (cairo_surface_t +@@ -1012,10 +1094,31 @@ _cairo_surface_stroke (cairo_surface_t if (surface->backend->stroke) { cairo_status_t status; @@ -418,7 +418,7 @@ Index: src/cairo-surface.c if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; } -@@ -1026,13 +1129,33 @@ _cairo_surface_fill (cairo_surface_t *su +@@ -1036,13 +1139,33 @@ _cairo_surface_fill (cairo_surface_t *su cairo_antialias_t antialias) { cairo_status_t status; @@ -453,7 +453,7 @@ Index: src/cairo-surface.c if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; } -@@ -1057,6 +1180,7 @@ _cairo_surface_composite_trapezoids (cai +@@ -1067,6 +1190,7 @@ _cairo_surface_composite_trapezoids (cai int num_traps) { cairo_int_status_t status; @@ -461,7 +461,7 @@ Index: src/cairo-surface.c assert (! dst->is_snapshot); -@@ -1072,13 +1196,36 @@ _cairo_surface_composite_trapezoids (cai +@@ -1082,13 +1206,36 @@ _cairo_surface_composite_trapezoids (cai return CAIRO_STATUS_SURFACE_FINISHED; if (dst->backend->composite_trapezoids) { @@ -500,7 +500,7 @@ Index: src/cairo-surface.c if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; } -@@ -1225,6 +1372,9 @@ _cairo_surface_set_clip_region (cairo_su +@@ -1235,6 +1382,9 @@ _cairo_surface_set_clip_region (cairo_su pixman_region16_t *region, unsigned int serial) { @@ -510,7 +510,7 @@ Index: src/cairo-surface.c if (surface->status) return surface->status; -@@ -1232,10 +1382,48 @@ _cairo_surface_set_clip_region (cairo_su +@@ -1242,10 +1392,50 @@ _cairo_surface_set_clip_region (cairo_su return CAIRO_STATUS_SURFACE_FINISHED; assert (surface->backend->set_clip_region != NULL); @@ -532,12 +532,14 @@ Index: src/cairo-surface.c + pixman_box16_t *rects = pixman_region_rects (region); + for (i = 0; i < nr; i++) { + pixman_box16_t tmpb; ++ pixman_region16_t *tmpr; ++ + tmpb.x1 = BACKEND_X(surface, rects[i].x1); + tmpb.y1 = BACKEND_Y(surface, rects[i].y1); + tmpb.x2 = BACKEND_X(surface, rects[i].x2); + tmpb.y2 = BACKEND_Y(surface, rects[i].y2); + -+ pixman_region16_t *tmpr = pixman_region_create_simple (&tmpb); ++ tmpr = pixman_region_create_simple (&tmpb); + + pixman_region_append (dev_region, tmpr); + pixman_region_destroy (tmpr); @@ -561,7 +563,7 @@ Index: src/cairo-surface.c } cairo_int_status_t -@@ -1245,6 +1433,10 @@ _cairo_surface_intersect_clip_path (cair +@@ -1255,6 +1445,10 @@ _cairo_surface_intersect_clip_path (cair double tolerance, cairo_antialias_t antialias) { @@ -572,7 +574,7 @@ Index: src/cairo-surface.c if (surface->status) return surface->status; -@@ -1253,11 +1445,30 @@ _cairo_surface_intersect_clip_path (cair +@@ -1263,11 +1457,30 @@ _cairo_surface_intersect_clip_path (cair assert (surface->backend->intersect_clip_path != NULL); @@ -608,7 +610,7 @@ Index: src/cairo-surface.c } static cairo_status_t -@@ -1273,11 +1484,11 @@ _cairo_surface_set_clip_path_recursive ( +@@ -1283,11 +1496,11 @@ _cairo_surface_set_clip_path_recursive ( if (status) return status; @@ -625,7 +627,7 @@ Index: src/cairo-surface.c } /** -@@ -1374,13 +1585,20 @@ cairo_status_t +@@ -1390,13 +1603,20 @@ cairo_status_t _cairo_surface_get_extents (cairo_surface_t *surface, cairo_rectangle_t *rectangle) { @@ -647,7 +649,7 @@ Index: src/cairo-surface.c } cairo_status_t -@@ -1392,13 +1610,34 @@ _cairo_surface_show_glyphs (cairo_surfac +@@ -1408,13 +1628,34 @@ _cairo_surface_show_glyphs (cairo_surfac cairo_scaled_font_t *scaled_font) { cairo_status_t status; @@ -684,7 +686,7 @@ Index: src/cairo-surface.c if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; } -@@ -1428,6 +1667,7 @@ _cairo_surface_old_show_glyphs (cairo_sc +@@ -1444,6 +1685,7 @@ _cairo_surface_old_show_glyphs (cairo_sc int num_glyphs) { cairo_status_t status; @@ -692,7 +694,7 @@ Index: src/cairo-surface.c assert (! dst->is_snapshot); -@@ -1437,14 +1677,35 @@ _cairo_surface_old_show_glyphs (cairo_sc +@@ -1453,14 +1695,35 @@ _cairo_surface_old_show_glyphs (cairo_sc if (dst->finished) return CAIRO_STATUS_SURFACE_FINISHED; @@ -731,7 +733,7 @@ Index: src/cairo-surface.c status = CAIRO_INT_STATUS_UNSUPPORTED; return status; -@@ -1554,7 +1815,15 @@ _cairo_surface_composite_fixup_unbounded +@@ -1570,7 +1833,15 @@ _cairo_surface_composite_fixup_unbounded cairo_rectangle_t *mask_rectangle = NULL; assert (! dst->is_snapshot); @@ -748,7 +750,7 @@ Index: src/cairo-surface.c /* The RENDER/libpixman operators are clipped to the bounds of the untransformed, * non-repeating sources and masks. Other sources and masks can be ignored. */ -@@ -1629,6 +1898,10 @@ _cairo_surface_composite_shape_fixup_unb +@@ -1645,6 +1916,10 @@ _cairo_surface_composite_shape_fixup_unb cairo_rectangle_t *mask_rectangle = NULL; assert (! dst->is_snapshot); @@ -827,7 +829,7 @@ Index: src/cairoint.h =================================================================== --- src/cairoint.h.orig +++ src/cairoint.h -@@ -1460,6 +1460,13 @@ _cairo_path_fixed_bounds (cairo_path_fix +@@ -1466,6 +1466,13 @@ _cairo_path_fixed_bounds (cairo_path_fix double *x1, double *y1, double *x2, double *y2); @@ -841,7 +843,7 @@ Index: src/cairoint.h /* cairo_path_fill.c */ cairo_private cairo_status_t _cairo_path_fixed_fill_to_traps (cairo_path_fixed_t *path, -@@ -1978,6 +1985,13 @@ cairo_private cairo_status_t +@@ -1984,6 +1991,13 @@ cairo_private cairo_status_t _cairo_traps_extract_region (cairo_traps_t *tr, pixman_region16_t **region); diff --git a/gfx/cairo/mozilla-misc.patch b/gfx/cairo/mozilla-misc.patch index 3f058b7d54f0..b0f0cd409dd4 100644 --- a/gfx/cairo/mozilla-misc.patch +++ b/gfx/cairo/mozilla-misc.patch @@ -167,13 +167,14 @@ Index: pixman/src/fbcompose.c =================================================================== --- pixman/src/fbcompose.c.orig +++ pixman/src/fbcompose.c -@@ -33,8 +33,15 @@ +@@ -33,8 +33,16 @@ #include "pixregionint.h" +#ifdef _MSC_VER +#define _USE_MATH_DEFINES +#endif ++ #include +#ifndef M_PI @@ -204,3 +205,53 @@ Index: src/cairo-atsui-font.c typedef struct _cairo_atsui_font_face cairo_atsui_font_face_t; typedef struct _cairo_atsui_font cairo_atsui_font_t; +Index: src/cairo-features.h.in +=================================================================== +--- src/cairo-features.h.in.orig ++++ src/cairo-features.h.in +@@ -37,6 +37,8 @@ + #ifndef CAIRO_FEATURES_H + #define CAIRO_FEATURES_H + ++#include "cairo-platform.h" ++ + #ifdef __cplusplus + # define CAIRO_BEGIN_DECLS extern "C" { + # define CAIRO_END_DECLS } +@@ -49,11 +51,11 @@ + # define cairo_public + #endif + +-#define CAIRO_VERSION_MAJOR @CAIRO_VERSION_MAJOR@ +-#define CAIRO_VERSION_MINOR @CAIRO_VERSION_MINOR@ +-#define CAIRO_VERSION_MICRO @CAIRO_VERSION_MICRO@ ++#define CAIRO_VERSION_MAJOR 1 ++#define CAIRO_VERSION_MINOR 1 ++#define CAIRO_VERSION_MICRO 1 + +-#define CAIRO_VERSION_STRING "@CAIRO_VERSION_MAJOR@.@CAIRO_VERSION_MINOR@.@CAIRO_VERSION_MICRO@" ++#define CAIRO_VERSION_STRING "1.1.1" + + @PS_SURFACE_FEATURE@ + +Index: src/cairo-win32-surface.c +=================================================================== +--- src/cairo-win32-surface.c.orig ++++ src/cairo-win32-surface.c +@@ -1062,6 +1062,9 @@ CRITICAL_SECTION cairo_toy_font_face_has + CRITICAL_SECTION cairo_scaled_font_map_mutex; + CRITICAL_SECTION cairo_ft_unscaled_font_map_mutex; + ++#if 0 ++// Mozilla doesn't use the mutexes, and this definition of DllMain ++// conflicts with libxul. + BOOL WINAPI + DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, +@@ -1083,4 +1086,6 @@ DllMain (HINSTANCE hinstDLL, + } + return TRUE; + } ++#endif // 0 ++ + #endif diff --git a/gfx/cairo/push-pop-group.patch b/gfx/cairo/push-pop-group.patch index d42ec08ef38b..8a22d6d75779 100644 --- a/gfx/cairo/push-pop-group.patch +++ b/gfx/cairo/push-pop-group.patch @@ -151,25 +151,23 @@ Index: src/cairo-gstate.c - 0, 0, - _cairo_surface_get_width (gstate->target), - _cairo_surface_get_height (gstate->target)); -- ++ /* If this gstate is already redirected, this is an error; we need a ++ * new gstate to be able to redirect */ ++ assert (gstate->parent_target == NULL); + - _cairo_surface_fini (&mask); - - pix = _cairo_surface_get_drawable (gstate->target); - XFreePixmap (gstate->dpy, pix); -- -- cairo_surface_destroy (gstate->target); -- gstate->target = gstate->parent_surface; -- gstate->parent_surface = NULL; -+ /* If this gstate is already redirected, this is an error; we need a -+ * new gstate to be able to redirect */ -+ assert (gstate->parent_target == NULL); -+ + /* Set up our new parent_target based on our current target; + * gstate->parent_target will take the ref that is held by gstate->target + */ + cairo_surface_destroy (gstate->parent_target); + gstate->parent_target = gstate->target; -+ + +- cairo_surface_destroy (gstate->target); +- gstate->target = gstate->parent_surface; +- gstate->parent_surface = NULL; + /* Now set up our new target; we overwrite gstate->target directly, + * since its ref is now owned by gstate->parent_target */ + gstate->target = cairo_surface_reference (child); @@ -449,7 +447,7 @@ Index: src/cairoint.h =================================================================== --- src/cairoint.h.orig +++ src/cairoint.h -@@ -1073,9 +1073,24 @@ _cairo_gstate_clone (cairo_gstate_t *gst +@@ -1077,9 +1077,24 @@ _cairo_gstate_clone (cairo_gstate_t *gst cairo_private void _moz_cairo_gstate_set_target (cairo_gstate_t *gstate, cairo_surface_t *target); @@ -474,7 +472,7 @@ Index: src/cairoint.h cairo_private cairo_status_t _cairo_gstate_set_source (cairo_gstate_t *gstate, cairo_pattern_t *source); -@@ -2173,6 +2188,9 @@ slim_hidden_proto(cairo_restore) +@@ -2177,6 +2192,9 @@ slim_hidden_proto(cairo_restore) slim_hidden_proto(cairo_save) slim_hidden_proto(cairo_stroke_preserve) slim_hidden_proto(cairo_surface_destroy)