From fe7f70592334390d7f3a7a63f896683c4de91454 Mon Sep 17 00:00:00 2001 From: Joe Drew Date: Fri, 23 Nov 2012 11:57:10 -0500 Subject: [PATCH] Bug 813124 - Make Cairo's image surface correctly handle having multiple clip paths set on the context. r=jrmuizel,roc --- gfx/cairo/README | 2 + gfx/cairo/cairo/src/cairo-image-surface.c | 18 ++----- gfx/cairo/handle-multi-path-clip.patch | 57 +++++++++++++++++++++++ 3 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 gfx/cairo/handle-multi-path-clip.patch diff --git a/gfx/cairo/README b/gfx/cairo/README index ce204912605b..13abbdbd0453 100644 --- a/gfx/cairo/README +++ b/gfx/cairo/README @@ -196,6 +196,8 @@ setlcdfilter_in_tree.patch: bug 790139; force cairo to use FT_Library_SetLcdFilt dwrite-font-match-robustness.patch: bug 717178, don't crash when _name_tables_match is passed a nil scaled-font +handle-multi-path-clip.patch: bug 813124, handle multiple clip paths correctly + ==== pixman patches ==== pixman-android-cpu-detect.patch: Add CPU detection support for Android, where we can't reliably access /proc/self/auxv. diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c index 0e3a98469642..6136d61bd487 100644 --- a/gfx/cairo/cairo/src/cairo-image-surface.c +++ b/gfx/cairo/cairo/src/cairo-image-surface.c @@ -2890,6 +2890,8 @@ _composite_boxes (cairo_image_surface_t *dst, if (clip != NULL) { status = _cairo_clip_get_region (clip, &clip_region); + if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) + return CAIRO_STATUS_SUCCESS; need_clip_mask = status == CAIRO_INT_STATUS_UNSUPPORTED; if (need_clip_mask && (op == CAIRO_OPERATOR_SOURCE || ! extents->is_bounded)) @@ -3205,20 +3207,10 @@ _clip_and_composite_trapezoids (cairo_image_surface_t *dst, static cairo_clip_path_t * _clip_get_single_path (cairo_clip_t *clip) { - cairo_clip_path_t *iter = clip->path; - cairo_clip_path_t *path = NULL; + if (clip->path->prev == NULL) + return clip->path; - do { - if ((iter->flags & CAIRO_CLIP_PATH_IS_BOX) == 0) { - if (path != NULL) - return FALSE; - - path = iter; - } - iter = iter->prev; - } while (iter != NULL); - - return path; + return NULL; } /* high level image interface */ diff --git a/gfx/cairo/handle-multi-path-clip.patch b/gfx/cairo/handle-multi-path-clip.patch new file mode 100644 index 000000000000..fe426888564c --- /dev/null +++ b/gfx/cairo/handle-multi-path-clip.patch @@ -0,0 +1,57 @@ +diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c +--- a/gfx/cairo/cairo/src/cairo-image-surface.c ++++ b/gfx/cairo/cairo/src/cairo-image-surface.c +@@ -2885,16 +2885,18 @@ static cairo_status_t + cairo_bool_t need_clip_mask = FALSE; + cairo_status_t status; + struct _cairo_boxes_chunk *chunk; + uint32_t pixel; + int i; + + if (clip != NULL) { + status = _cairo_clip_get_region (clip, &clip_region); ++ if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) ++ return CAIRO_STATUS_SUCCESS; + need_clip_mask = status == CAIRO_INT_STATUS_UNSUPPORTED; + if (need_clip_mask && + (op == CAIRO_OPERATOR_SOURCE || ! extents->is_bounded)) + { + return CAIRO_INT_STATUS_UNSUPPORTED; + } + + if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1) +@@ -3200,30 +3202,20 @@ static cairo_status_t + return _clip_and_composite (dst, op, src, + _composite_traps, &info, + extents, clip); + } + + static cairo_clip_path_t * + _clip_get_single_path (cairo_clip_t *clip) + { +- cairo_clip_path_t *iter = clip->path; +- cairo_clip_path_t *path = NULL; +- +- do { +- if ((iter->flags & CAIRO_CLIP_PATH_IS_BOX) == 0) { +- if (path != NULL) +- return FALSE; +- +- path = iter; +- } +- iter = iter->prev; +- } while (iter != NULL); +- +- return path; ++ if (clip->path->prev == NULL) ++ return clip->path; ++ ++ return NULL; + } + + /* high level image interface */ + + static cairo_int_status_t + _cairo_image_surface_paint (void *abstract_surface, + cairo_operator_t op, + const cairo_pattern_t *source,