Bug 1034593 - Backout the cairo clip optimization because it produces incorrect clipping in certain cases. r=jrmuizel

This commit is contained in:
Nicolas Silva 2014-07-10 20:11:01 +02:00
parent c4d263c432
commit 330342a6d9

View File

@ -954,7 +954,6 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
int *tx, int *ty) int *tx, int *ty)
{ {
const cairo_rectangle_int_t *clip_extents = &clip_path->extents; const cairo_rectangle_int_t *clip_extents = &clip_path->extents;
cairo_rectangle_int_t surface_extents;
cairo_bool_t need_translate; cairo_bool_t need_translate;
cairo_surface_t *surface; cairo_surface_t *surface;
cairo_clip_path_t *prev; cairo_clip_path_t *prev;
@ -968,36 +967,27 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
} }
clip_extents = &clip_path->extents; 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 && if (clip_path->surface != NULL &&
clip_path->surface->backend == target->backend) clip_path->surface->backend == target->backend)
{ {
*tx = surface_extents.x; *tx = clip_extents->x;
*ty = surface_extents.y; *ty = clip_extents->y;
return clip_path->surface; return clip_path->surface;
} }
surface = _cairo_surface_create_similar_scratch (target, surface = _cairo_surface_create_similar_scratch (target,
CAIRO_CONTENT_ALPHA, CAIRO_CONTENT_ALPHA,
surface_extents.width, clip_extents->width,
surface_extents.height); clip_extents->height);
if (surface == NULL) { if (surface == NULL) {
surface = cairo_image_surface_create (CAIRO_FORMAT_A8, surface = cairo_image_surface_create (CAIRO_FORMAT_A8,
surface_extents.width, clip_extents->width,
surface_extents.height); clip_extents->height);
} }
if (unlikely (surface->status)) if (unlikely (surface->status))
return surface; return surface;
need_translate = surface_extents.x | surface_extents.y; need_translate = clip_extents->x | clip_extents->y;
if (clip_path->flags & CAIRO_CLIP_PATH_IS_BOX && if (clip_path->flags & CAIRO_CLIP_PATH_IS_BOX &&
clip_path->path.maybe_fill_region) clip_path->path.maybe_fill_region)
{ {
@ -1019,8 +1009,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
if (need_translate) { if (need_translate) {
_cairo_path_fixed_translate (&clip_path->path, _cairo_path_fixed_translate (&clip_path->path,
_cairo_fixed_from_int (-surface_extents.x), _cairo_fixed_from_int (-clip_extents->x),
_cairo_fixed_from_int (-surface_extents.y)); _cairo_fixed_from_int (-clip_extents->y));
} }
status = _cairo_surface_fill (surface, status = _cairo_surface_fill (surface,
CAIRO_OPERATOR_ADD, CAIRO_OPERATOR_ADD,
@ -1032,8 +1022,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
NULL); NULL);
if (need_translate) { if (need_translate) {
_cairo_path_fixed_translate (&clip_path->path, _cairo_path_fixed_translate (&clip_path->path,
_cairo_fixed_from_int (surface_extents.x), _cairo_fixed_from_int (clip_extents->x),
_cairo_fixed_from_int (surface_extents.y)); _cairo_fixed_from_int (clip_extents->y));
} }
if (unlikely (status)) if (unlikely (status))
@ -1053,8 +1043,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
{ {
if (need_translate) { if (need_translate) {
_cairo_path_fixed_translate (&prev->path, _cairo_path_fixed_translate (&prev->path,
_cairo_fixed_from_int (-surface_extents.x), _cairo_fixed_from_int (-clip_extents->x),
_cairo_fixed_from_int (-surface_extents.y)); _cairo_fixed_from_int (-clip_extents->y));
} }
status = _cairo_surface_fill (surface, status = _cairo_surface_fill (surface,
CAIRO_OPERATOR_IN, CAIRO_OPERATOR_IN,
@ -1066,8 +1056,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
NULL); NULL);
if (need_translate) { if (need_translate) {
_cairo_path_fixed_translate (&prev->path, _cairo_path_fixed_translate (&prev->path,
_cairo_fixed_from_int (surface_extents.x), _cairo_fixed_from_int (clip_extents->x),
_cairo_fixed_from_int (surface_extents.y)); _cairo_fixed_from_int (clip_extents->y));
} }
if (unlikely (status)) if (unlikely (status))
@ -1087,8 +1077,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
_cairo_pattern_init_for_surface (&pattern, prev_surface); _cairo_pattern_init_for_surface (&pattern, prev_surface);
pattern.base.filter = CAIRO_FILTER_NEAREST; pattern.base.filter = CAIRO_FILTER_NEAREST;
cairo_matrix_init_translate (&pattern.base.matrix, cairo_matrix_init_translate (&pattern.base.matrix,
surface_extents.x - prev_tx, clip_extents->x - prev_tx,
surface_extents.y - prev_ty); clip_extents->y - prev_ty);
status = _cairo_surface_paint (surface, status = _cairo_surface_paint (surface,
CAIRO_OPERATOR_IN, CAIRO_OPERATOR_IN,
&pattern.base, &pattern.base,
@ -1104,8 +1094,8 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path,
prev = prev->prev; prev = prev->prev;
} }
*tx = surface_extents.x; *tx = clip_extents->x;
*ty = surface_extents.y; *ty = clip_extents->y;
cairo_surface_destroy (clip_path->surface); cairo_surface_destroy (clip_path->surface);
return clip_path->surface = surface; return clip_path->surface = surface;