Bug 29501 - cairo_surface_flush() does not undo a clip done on a DirectFB surface
Summary: cairo_surface_flush() does not undo a clip done on a DirectFB surface
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: directfb backend (show other bugs)
Version: 1.8.4
Hardware: Other Linux (All)
: medium normal
Assignee: cairo-bugs mailing list
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-11 03:29 UTC by Allison Newman
Modified: 2012-02-09 14:22 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Allison Newman 2010-08-11 03:29:20 UTC
Take the following code:


    cairo_save(pCairo);
    cairo_rectangle(pCairo, x, y, w, h);
    cairo_clip(pCairo);
    cairo_translate(pCairo, x, y);
    pango_cairo_show_layout(pCairo, pLayout);
    cairo_restore(pCairo);


After the cairo_restore(), if I try to do a DirectFB drawing operation on the surface outside the region specified for the cairo clip, there is no drawing done.

I'm not sure exactly where the bug is though, it may be in pango.  If I remove either the cairo_clip() or the pango_cairo_show_layout(), I can still draw correctly on the surface, but if I have both, the clip remains in effect.

Adding:
    pFBSurface->SetClip(pFBSurface, NULL);

after the cairo_restore() allows me to draw correctly to the surface again.
Comment 1 Bill Spitzak 2010-08-11 11:21:50 UTC
Don't you have to do some sort of sync() call to get the surface to 
actually match? I suspect Cairo is not updating the clip until it needs 
to draw something, which is why removing the show_layout() seems to work 
(because it never applied the clip).

bugzilla-daemon@freedesktop.org wrote:
> https://bugs.freedesktop.org/show_bug.cgi?id=29501
> 
>            Summary: cairo_restore does not undo a clip done on a DirectFB
>                     surface
>            Product: cairo
>            Version: 1.8.4
>           Platform: Other
>         OS/Version: Linux (All)
>             Status: NEW
>           Severity: normal
>           Priority: medium
>          Component: directfb backend
>         AssignedTo: cairo-bugs@cairographics.org
>         ReportedBy: allison.newman@sfr.com
>          QAContact: cairo-bugs@cairographics.org
> 
> 
> Take the following code:
> 
> 
>     cairo_save(pCairo);
>     cairo_rectangle(pCairo, x, y, w, h);
>     cairo_clip(pCairo);
>     cairo_translate(pCairo, x, y);
>     pango_cairo_show_layout(pCairo, pLayout);
>     cairo_restore(pCairo);
> 
> 
> After the cairo_restore(), if I try to do a DirectFB drawing operation on the
> surface outside the region specified for the cairo clip, there is no drawing
> done.
> 
> I'm not sure exactly where the bug is though, it may be in pango.  If I remove
> either the cairo_clip() or the pango_cairo_show_layout(), I can still draw
> correctly on the surface, but if I have both, the clip remains in effect.
> 
> Adding:
>     pFBSurface->SetClip(pFBSurface, NULL);
> 
> after the cairo_restore() allows me to draw correctly to the surface again.
>
Comment 2 Allison Newman 2010-08-12 03:16:46 UTC
You're possibly right, but I would still consider that behaviour as a bug, particularly when it isn't documented anywhere. For example, I don't see any call for synchronising in the API (apart from actually doing a drawing operation).  All I can say is that I find it highly surprising to have the state of my DirectFB surface changed by cairo, and to not have that state restored when I call cairo_restore().  As there isn't a formal spec, and the documentation (both the API reference manual and the comments in the source code) have nothing to say on the subject, I felt that this was more of a bug than anything else.
Comment 3 Benjamin Otte 2010-08-12 04:21:40 UTC
This is a bug in Cairo's DirectFB implementation.

However, it has nothing to do with cairo_restore() but with the way surfaces are handled in Cairo. Cairo surfaces assume full ownership of the given resources when they are created. So they are free to set any clip they like on the DirectFBSurface.

But there is a function that the user can use to make Cairo release its contol of the resource and restore its settings to the original state: cairo_surface_flush(). And that function is not implemented by the DirectFB backend.
Comment 4 Allison Newman 2010-08-12 05:33:51 UTC
Ahhhh.  Thank you Benjamin, yes, that was effectively a bug in my code, although as you have noted, the problem is still present, even with the flush.

I'll have a shot at providing a first attempt at correcting the bug now that I know this is truly a problem, rather than just a bug in my own code!

(In reply to comment #3)
> This is a bug in Cairo's DirectFB implementation.
> 
> However, it has nothing to do with cairo_restore() but with the way surfaces
> are handled in Cairo. Cairo surfaces assume full ownership of the given
> resources when they are created. So they are free to set any clip they like on
> the DirectFBSurface.
> 
> But there is a function that the user can use to make Cairo release its contol
> of the resource and restore its settings to the original state:
> cairo_surface_flush(). And that function is not implemented by the DirectFB
> backend.
Comment 5 Chris Wilson 2012-02-09 14:22:10 UTC
"Fixed" only due to gutting the directfb code not to try and be clever at all.


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.