Re: Calling push_group on unbounded cairo recording surface

Uli Schlachter <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Hi,

On 08.10.2012 12:58, Daniel Kłobuszewski wrote:
> I have an unbounded cairo recording surface, on which I want to draw. 
> Unforntunately, when I start to use cairo_push_group, my whole drawing 
> is gone (ie. cairo_recording_surface_ink_extents gives me only 0s).
[...]

In _cairo_default_gstate_push_group there is a comment about this. Unbounded
groups apparently were never implemented. The attached patch/hack fixes this.
However, it assumes that only recording surfaces are unbounded, which is (half)
incorrect.

Ideas? Adding a new member to cairo_backend_t for this feels wrong.

(Also, the current code uses an uninitialized "cairo_rectangle_int_t extents"
for unbounded surfaces. I guess it is just luck that this results in an 0x0 surface)

Cheers,
Uli
-- 
"Every once in a while, declare peace. It confuses the hell out of your enemies"
 - 79th Rule of Acquisition

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
unbounded-group.patch (text/x-diff, 1.5 KB)
diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c
index 3d828ef..fee08f0 100644
--- a/src/cairo-default-context.c
+++ b/src/cairo-default-context.c
@@ -149,23 +149,28 @@ _cairo_default_context_push_group (void *abstract_cr, cairo_content_t content)
     } else {
 	cairo_surface_t *parent_surface;
 	cairo_rectangle_int_t extents;
-	cairo_bool_t is_empty;
+	cairo_bool_t bounded, is_empty;
 
 	parent_surface = _cairo_gstate_get_target (cr->gstate);
 
 	/* Get the extents that we'll use in creating our new group surface */
-	is_empty = _cairo_surface_get_extents (parent_surface, &extents);
+	bounded = _cairo_surface_get_extents (parent_surface, &extents);
 	if (clip)
+	    /* XXX: This assignment just fixes a compiler warning? */
 	    is_empty = _cairo_rectangle_intersect (&extents,
 						   _cairo_clip_get_extents (clip));
 
-	/* XXX unbounded surface creation */
-
-	group_surface = _cairo_surface_create_similar_solid (parent_surface,
-							     content,
-							     extents.width,
-							     extents.height,
-							     CAIRO_COLOR_TRANSPARENT);
+	if (!bounded) {
+	    /* XXX: Generic solution? */
+	    group_surface = cairo_recording_surface_create (content, NULL);
+	    extents.x = extents.y = 0;
+	} else {
+	    group_surface = _cairo_surface_create_similar_solid (parent_surface,
+								 content,
+								 extents.width,
+								 extents.height,
+								 CAIRO_COLOR_TRANSPARENT);
+	}
 	status = group_surface->status;
 	if (unlikely (status))
 	    goto bail;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.