Bug 29296 - cairo_destroy() should not introduce drawing artifacts when omitted
Summary: cairo_destroy() should not introduce drawing artifacts when omitted
Status: RESOLVED WORKSFORME
Alias: None
Product: cairo
Classification: Unclassified
Component: quartz backend (show other bugs)
Version: 1.9.14
Hardware: Other Mac OS X (All)
: medium normal
Assignee: Vladimir Vukicevic
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-29 05:34 UTC by Kristian Rietveld
Modified: 2012-03-03 04:21 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Wannabe testcase (1.00 KB, text/plain)
2010-08-07 07:04 UTC, Andrea Canciani
Details
Image produced by the testcase (151 bytes, text/plain)
2010-08-07 07:06 UTC, Andrea Canciani
Details

Description Kristian Rietveld 2010-07-29 05:34:00 UTC
While debugging GTK+-Quartz it appeared that on several occasions a call to cairo_destroy() is mandatory for the drawing to be done correctly.  Omission of a cairo_destroy() call can lead to the results of later cairo drawing calls to not appear on the screen.  I have been told that a call cairo_destroy() should not be mandatory and that there are likely  flags that are not being properly reset.
Comment 1 Behdad Esfahbod 2010-07-29 11:56:03 UTC
cairo_flush()?
Comment 2 Kristian Rietveld 2010-07-30 03:13:32 UTC
Basically, I was talking about this with Benjamin Otte the other day, and the point is that cairo_destroy() should not introduce drawing artifacts when forgotten.  I will update the title to better reflect this.
Comment 3 Andrea Canciani 2010-08-07 06:46:50 UTC
I need some additional information about the problem you're seeing (a test case reproducing the problem would be great).
Comment 4 Benjamin Otte 2010-08-07 06:52:36 UTC
We need a testcase that reproduces the problem. As I don't have an OS X computer, I cannot do one, but I suspect that something like:

cr = cairo_create (quartz_surface);
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_rectangle (cr, 0, 0, 10, 10);
cairo_clip (cr);
cairo_paint (cr);

cr2 = cairo_create (quartz_surface);
cairo_set_source_rgb (cr2, 0, 1, 0);
cairo_rectangle (cr2, 20, 20, 10, 10);
cairo_clip (cr2);
cairo_paint (cr2);

would reproduce the problem. Or maybe:

cr = cairo_create (quartz_surface);
cr2 = cairo_create (quartz_surface);
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_set_source_rgb (cr2, 0, 1, 0);
cairo_rectangle (cr, 0, 0, 10, 10);
cairo_rectangle (cr2, 20, 20, 10, 10);
cairo_clip (cr);
cairo_clip (cr2);
cairo_paint (cr);
cairo_paint (cr2);
Comment 5 Andrea Canciani 2010-08-07 07:04:37 UTC
Created attachment 37664 [details]
Wannabe testcase

This is a testcase wrapping up Benjamin's code snippets in a "working" appication.
Comment 6 Andrea Canciani 2010-08-07 07:06:45 UTC
Created attachment 37665 [details]
Image produced by the testcase

The image produced by either code snippet is the same (and exactly the expected output).
I assume that some more complicated multiple cairo_t usage is required to trigger the bug.
Comment 7 Chris Wilson 2010-08-07 07:16:56 UTC
Actually cairo_surface_flush(). The decision was made long ago that cairo
should not flush more than is required for its own correct behaviour.
cairo_destroy() is one such point where cairo can not correctly guess the
user's intention and should not flush by itself but leaves it up to the
user to choose the correct point at which to do so (because it more or
less depends upon the interaction with the rest of the windowing system
integration).
Comment 8 Kristian Rietveld 2010-08-08 13:08:44 UTC
I don't have a testcase off head -- I guess we can create something by tracing the cairo calls GTK+ is making ...  Would likely be the most efficient, since I do not have an idea yet what exact pattern is causing this behavior.
Comment 9 Andrea Canciani 2010-11-26 00:55:31 UTC
(In reply to comment #8)
> I don't have a testcase off head -- I guess we can create something by tracing
> the cairo calls GTK+ is making ...  Would likely be the most efficient, since I
> do not have an idea yet what exact pattern is causing this behavior.

Did you manage to create a trace reproducing the wrong behavior?
Comment 10 Kristian Rietveld 2011-11-20 12:08:56 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > I don't have a testcase off head -- I guess we can create something by tracing
> > the cairo calls GTK+ is making ...  Would likely be the most efficient, since I
> > do not have an idea yet what exact pattern is causing this behavior.
> 
> Did you manage to create a trace reproducing the wrong behavior?

Andrea, I've never found the time to hash out a small, working testcase for this, sorry for that.  Ever since we've added the missing calls to cairo_destroy() in GTK+, we've no longer stumbled upon this issue.  For me, this bug can be closed.


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.