mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 1034593 - Teach cairo to not fail at creating oversized masks in case of huge clips. r=jrmuizel
This commit is contained in:
parent
9cf8d7b48d
commit
d0a4b176b1
@ -954,6 +954,7 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
|
||||
int *tx, int *ty)
|
||||
{
|
||||
const cairo_rectangle_int_t *clip_extents = &clip_path->extents;
|
||||
cairo_rectangle_int_t surface_extents;
|
||||
cairo_bool_t need_translate;
|
||||
cairo_surface_t *surface;
|
||||
cairo_clip_path_t *prev;
|
||||
@ -967,27 +968,36 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
|
||||
}
|
||||
|
||||
clip_extents = &clip_path->extents;
|
||||
if (_cairo_surface_get_extents (target, &surface_extents))
|
||||
{
|
||||
_cairo_rectangle_intersect(&surface_extents, clip_extents);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface_extents = *clip_extents;
|
||||
}
|
||||
|
||||
if (clip_path->surface != NULL &&
|
||||
clip_path->surface->backend == target->backend)
|
||||
{
|
||||
*tx = clip_extents->x;
|
||||
*ty = clip_extents->y;
|
||||
*tx = surface_extents.x;
|
||||
*ty = surface_extents.y;
|
||||
return clip_path->surface;
|
||||
}
|
||||
|
||||
surface = _cairo_surface_create_similar_scratch (target,
|
||||
CAIRO_CONTENT_ALPHA,
|
||||
clip_extents->width,
|
||||
clip_extents->height);
|
||||
surface_extents.width,
|
||||
surface_extents.height);
|
||||
if (surface == NULL) {
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_A8,
|
||||
clip_extents->width,
|
||||
clip_extents->height);
|
||||
surface_extents.width,
|
||||
surface_extents.height);
|
||||
}
|
||||
if (unlikely (surface->status))
|
||||
return surface;
|
||||
|
||||
need_translate = clip_extents->x | clip_extents->y;
|
||||
need_translate = surface_extents.x | surface_extents.y;
|
||||
if (clip_path->flags & CAIRO_CLIP_PATH_IS_BOX &&
|
||||
clip_path->path.maybe_fill_region)
|
||||
{
|
||||
@ -1009,8 +1019,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
|
||||
|
||||
if (need_translate) {
|
||||
_cairo_path_fixed_translate (&clip_path->path,
|
||||
_cairo_fixed_from_int (-clip_extents->x),
|
||||
_cairo_fixed_from_int (-clip_extents->y));
|
||||
_cairo_fixed_from_int (-surface_extents.x),
|
||||
_cairo_fixed_from_int (-surface_extents.y));
|
||||
}
|
||||
status = _cairo_surface_fill (surface,
|
||||
CAIRO_OPERATOR_ADD,
|
||||
@ -1022,8 +1032,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
|
||||
NULL);
|
||||
if (need_translate) {
|
||||
_cairo_path_fixed_translate (&clip_path->path,
|
||||
_cairo_fixed_from_int (clip_extents->x),
|
||||
_cairo_fixed_from_int (clip_extents->y));
|
||||
_cairo_fixed_from_int (surface_extents.x),
|
||||
_cairo_fixed_from_int (surface_extents.y));
|
||||
}
|
||||
|
||||
if (unlikely (status))
|
||||
@ -1043,8 +1053,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
|
||||
{
|
||||
if (need_translate) {
|
||||
_cairo_path_fixed_translate (&prev->path,
|
||||
_cairo_fixed_from_int (-clip_extents->x),
|
||||
_cairo_fixed_from_int (-clip_extents->y));
|
||||
_cairo_fixed_from_int (-surface_extents.x),
|
||||
_cairo_fixed_from_int (-surface_extents.y));
|
||||
}
|
||||
status = _cairo_surface_fill (surface,
|
||||
CAIRO_OPERATOR_IN,
|
||||
@ -1056,8 +1066,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
|
||||
NULL);
|
||||
if (need_translate) {
|
||||
_cairo_path_fixed_translate (&prev->path,
|
||||
_cairo_fixed_from_int (clip_extents->x),
|
||||
_cairo_fixed_from_int (clip_extents->y));
|
||||
_cairo_fixed_from_int (surface_extents.x),
|
||||
_cairo_fixed_from_int (surface_extents.y));
|
||||
}
|
||||
|
||||
if (unlikely (status))
|
||||
@ -1077,8 +1087,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
|
||||
_cairo_pattern_init_for_surface (&pattern, prev_surface);
|
||||
pattern.base.filter = CAIRO_FILTER_NEAREST;
|
||||
cairo_matrix_init_translate (&pattern.base.matrix,
|
||||
clip_extents->x - prev_tx,
|
||||
clip_extents->y - prev_ty);
|
||||
surface_extents.x - prev_tx,
|
||||
surface_extents.y - prev_ty);
|
||||
status = _cairo_surface_paint (surface,
|
||||
CAIRO_OPERATOR_IN,
|
||||
&pattern.base,
|
||||
@ -1094,8 +1104,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
|
||||
prev = prev->prev;
|
||||
}
|
||||
|
||||
*tx = clip_extents->x;
|
||||
*ty = clip_extents->y;
|
||||
*tx = surface_extents.x;
|
||||
*ty = surface_extents.y;
|
||||
cairo_surface_destroy (clip_path->surface);
|
||||
return clip_path->surface = surface;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user