Bug 29125

Summary: applying a clip can increase the region returned by cairo_copy_clip_rectangle_list
Product: cairo Reporter: Karl Tomlinson <bugs.freedesktop>
Component: generalAssignee: Karl Tomlinson <bugs.freedesktop>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: 1.9.13   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: consider gstate target extents in _cairo_gstate_copy_clip_rectangle_list

Description Karl Tomlinson 2010-07-16 18:09:55 UTC
cairo_copy_clip_rectangle_list(cairo_t*) returns the expected extents of the
target surface until a clip is applied.  When the clip is applied it is not
intersected with the apparent existing clip (of the target extents) because
there is no clip recorded on the context, and cairo_copy_clip_rectangle_list
starts returning the applied clip (even when it is outside the target extents).

This looks like a regression from
http://cgit.freedesktop.org/cairo/commit/?id=bed2701e1c89095878d549cbca8f22d84f3dda3c
where clips were disassociated from surfaces.
Before that _cairo_clip_clip would consider the target extents.

To be consistent with _cairo_gstate_clip_extents, the context's clip should be
intersected with the target surface extents (instead of only using them when
there is no clip).
Comment 1 Karl Tomlinson 2010-07-16 18:15:22 UTC
Created attachment 37145 [details] [review]
consider gstate target extents in _cairo_gstate_copy_clip_rectangle_list

Intersecting the clip path with the target surface extents before getting the
region seems better than trying to get a region and then intersecting with the
target extents.  With the later approach, some portion of the clip path beyond
the target could prevent successful generation of the region (or at least
cause unnecessary conversions to rectangles).

I could have left a fast path for unbounded clips but went with the
less-code approach.

There was some inconsistency where lists with zero-rectangles were returned
both for empty clips and unbounded clips.  The tests expect zero rectangles
for empty clips so unbounded clips (on infinite targets) now return
CAIRO_STATUS_CLIP_NOT_REPRESENTABLE.
Comment 2 Chris Wilson 2010-07-17 03:32:52 UTC
commit 108b1c7825116ed3f93aa57384bbd3290cdc9181
Author: Karl Tomlinson <karlt+@karlt.net>
Date:   Sat Jul 17 13:08:53 2010 +1200

    clip: consider gstate target extents in _cairo_gstate_copy_clip_rectangle_list
    
    Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29125
    
    To be consistent with _cairo_gstate_clip_extents, the context's clip
    should be intersected with the target surface extents (instead of only
    using them when there is no clip).
    
    Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.