Calling push_group on unbounded cairo recording surface

Daniel Kłobuszewski <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Hello,

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).

While actual usage in my app is quite complicated, I managed to narrow 
the problem to this:

#include <cairo/cairo.h>
#include <cairo/cairo-pdf.h>

void dump_to_file(cairo_surface_t* src)
{
     double imgw = 50, imgh = 50;
     cairo_surface_t* dst = cairo_pdf_surface_create("test.pdf", imgw, 
imgh);
     cairo_t* c = cairo_create(dst);
     double x,y,w,h;
     cairo_recording_surface_ink_extents(src,&x,&y,&w,&h);
     cairo_scale(c, imgw/w, imgh/h);
     cairo_set_source_surface(c, src, -x, -y);
     cairo_paint(c);
     cairo_destroy(c);
     cairo_surface_destroy(dst);
}

void draw(cairo_t *ctx)
{
     cairo_set_source_rgb(ctx, 0, 0.8, 0);
     cairo_set_line_width(ctx, 1);
     cairo_move_to(ctx, 5,5);
     cairo_line_to(ctx, 10, 10);
     cairo_stroke(ctx);
}

int main(int argc, char**argv)
{
     cairo_surface_t* s = 
cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, nullptr);
     cairo_t* ctx = cairo_create(s);

     //cairo_push_group(ctx);
     draw(ctx);
     //cairo_pop_group_to_source(ctx);
     //cairo_paint(ctx);

     dump_to_file(s);
     cairo_destroy(ctx);
     cairo_surface_destroy(s);

     return 0;
}

Above code works until I uncomment lines around the call to draw(...). 
But if I provide (big enough) bounding rectangle instead of nullptr, 
then uncommenting push/pop lines makes no difference. So I can either 
have a stack of bounded surfaces or single unbounded surface. How do I 
get a stack of unbounded surfaces? Is there a bug in cairo (I am using 
version 2.12.2 at the moment), or is it a bug in my understanding?

Kind regards,
Daniel
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
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.