Bug 55836 - cairo_region cannot be used with CLIP, as NO public API is exposed to use it in cairo_context/surface
Summary: cairo_region cannot be used with CLIP, as NO public API is exposed to use it ...
Status: RESOLVED MOVED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.12.2
Hardware: All Mac OS X (All)
: medium critical
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: cairo-1.16
  Show dependency treegraph
 
Reported: 2012-10-10 10:55 UTC by Adhir
Modified: 2018-08-25 13:49 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Adhir 2012-10-10 10:55:30 UTC
In Cairo release 1.10.0, cairo_region_t data type was added.
However pixman was removed.
Now there is no way to use cairo_region_t in cairo_context. So cairo_region is just a reflection of rectangles.

Setting the CLIP region to the cairo_region is not possible. So if we have a cairo_region_t created after union, subtract, we cannot use it for clipping purposes.

Currently cairo_clip(_preserve) can use ONLY path, but cannot make use all rectangles (obtained from cairo_region_t).

By some or other way, we need to create/expose a function 
cairo_clip_intersect_to_region (cairo_region_t      *region), which would clip according to PATH and INTERSECT with region
Comment 1 Chris Wilson 2012-10-10 11:04:31 UTC
What you want is a cairo_append_region() convenience function:

for (i in cairo_region_num_rectangles())
  cairo_rectangle(cr, cairo_region_get_rectangle(i));
Comment 2 Adhir 2012-10-10 11:14:04 UTC
No, I am looking for function like
cairo_bool_t
cairo_clip_region (cairo_t        *cr,
                   cairo_region_t *region)
as mentioned in http://www.gtkforums.com/viewtopic.php?f=3&t=54873
Thanks to Carlos for giving me the link

(In reply to comment #1)
> What you want is a cairo_append_region() convenience function:
> 
> for (i in cairo_region_num_rectangles())
>   cairo_rectangle(cr, cairo_region_get_rectangle(i));
Comment 3 Chris Wilson 2012-10-10 11:18:15 UTC
What you are looking for and what cairo will provide are two separate things...

Separating the action of adding the path from the operation, provides much greater flexibilty. For example:
  cairo_append_region();
  cairo_clip_preserve();
  cairo_stroke();

And cairo is still free to use the knowledge that we have a region to optimise it path.
Comment 4 Adhir 2012-10-10 11:35:11 UTC
I was looking for direct function to
(1) Use cairo_region_t directly in cairo context OR
(2) Somehow, get the clipping region intersect with cairo_region_t, so
that my drawing occurs only in intersected region.

Assuming that cairoregion already exists, a workaround suggested in
the website states
(1) From Cairo Region, get ALL rectangles via cairo_region_num_rectangles
(2) For each rectangle, actually create rectangle via cairo_rectangle
(3) Use clip_path

(1) - (3) now means that the current path consists of the entire region
(4) Create a new path via cairo_line_to
(5) Clip it

I was looking for direct function which has just steps (4) and (5)
(1) Create a new path via cairo_line etc.
(2) call cairo_clip_intersect(m_cr, region)


On Wed, Oct 10, 2012 at 4:48 PM,  <bugzilla-daemon@freedesktop.org> wrote:
> Comment # 3 on bug 55836 from Chris Wilson
>
> What you are looking for and what cairo will provide are two separate
> things...
>
> Separating the action of adding the path from the operation, provides much
> greater flexibilty. For example:
>   cairo_append_region();
>   cairo_clip_preserve();
>   cairo_stroke();
>
> And cairo is still free to use the knowledge that we have a region to
> optimise
> it path.
>
> ________________________________
> You are receiving this mail because:
>
> You are on the CC list for the bug.
> You reported the bug.
> You are watching the QA Contact of the bug.
Comment 5 Bryce Harrington 2014-09-22 19:20:03 UTC
Moving from 1.14 tracker to 1.16 tracker
Comment 6 GitLab Migration User 2018-08-25 13:49:40 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/214.


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.