[cairo] Recording surfaces fail to replay onto SVG surfaces
Antony Lee
antony.lee at berkeley.edu
Wed Oct 4 22:04:58 UTC 2017
Thank you for the quick reply. It turns out there is probably another bug
somewhere in my real program that is still causing the recording surface
not to end up on the SVG surface, but at least this workaround should help
me move forward.
I don't have a minimal example, but I have some suspicion that the same
issue also affects the X11 surface (or again it could be due to the
"other", still unknown issue).
In any case, should I report this to the cairo bug tracker, or is the
previous email enough?
Antony
2017-10-04 5:19 GMT-07:00 Adrian Johnson <ajohnson at redneon.com>:
> Seems to be a bug with unbounded recording surfaces and SVG. As a
> workaround if you specify an extents for the recording surface it works.
>
>
> On 04/10/17 08:39, Antony Lee wrote:
> > Hi all,
> >
> > I am having an issue with replaying a recording surface onto an SVG
> > surface. A minimal example is included at the end of the email.
> >
> > Briefly, the example sets up a recording surface and two 100x100
> > surfaces -- one IMAGE and one SVG. It then draws a 10x10 rectangle on
> > each of them at position (10, 10) and saves the results (the IMAGE to a
> > PNG). Both resulting files display the box at the correct position.
> >
> > The example then tries to replay the recording surface onto a separate
> > 100x100 SVG surface, and also save that surface. Unfortunately, this
> > results in a blank SVG. Note that if, instead, the recording surface is
> > played onto a separate 100x100 IMAGE surface (code not included for
> > simplicity), this works perfectly well (the resulting PNG also displays
> > the box); so the basic setup of the recording surface seems correct.
> >
> > I am using cairo 1.15.8 from Arch Linux.
> >
> > Any help would be very welcome. Thanks!
> >
> > Antony Lee
> >
> >
> >
> > === Example program; compile and run with:
> > gcc main.c $(pkg-config --cflags --libs cairo) -o main && ./main
> >
> > #include <stddef.h>
> > #include <cairo/cairo.h>
> > #include <cairo/cairo-svg.h>
> >
> > int main() {
> > cairo_surface_t* rec_surf =
> > cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, NULL);
> > cairo_t* rec_ctx = cairo_create(rec_surf);
> >
> > cairo_surface_t* img_surf =
> > cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 100);
> > cairo_t* img_ctx = cairo_create(img_surf);
> >
> > cairo_surface_t* svg_surf = cairo_svg_surface_create("/tmp/test.svg",
> > 100, 100);
> > cairo_t* svg_ctx = cairo_create(svg_surf);
> >
> > cairo_t* ctxs[3] = {rec_ctx, img_ctx, svg_ctx};
> >
> > for (unsigned i = 0; i < 3; ++i) {
> > cairo_rectangle(ctxs[i], 10, 10, 10, 10);
> > cairo_fill(ctxs[i]);
> > }
> >
> > // Dump image to png.
> > cairo_surface_write_to_png(img_surf, "/tmp/test.png");
> >
> > // Transfer recording surface to SVG.
> > cairo_surface_t* svg1_surf =
> > cairo_svg_surface_create("/tmp/test1.svg", 100, 100);
> > cairo_t* svg1_ctx = cairo_create(svg1_surf);
> > cairo_set_source_surface(svg1_ctx, rec_surf, 0, 0);
> > cairo_paint(svg1_ctx);
> >
> > // Done.
> > for (unsigned i = 0; i < 3; ++i) {
> > if (cairo_status(ctxs[i])) {
> > return 1;
> > }
> > }
> > cairo_surface_finish(svg_surf);
> > cairo_surface_finish(svg1_surf);
> > for (unsigned i = 0; i < 3; ++i) {
> > cairo_surface_destroy(cairo_get_target(ctxs[i]));
> > cairo_destroy(ctxs[i]);
> > }
> > cairo_surface_destroy(svg1_surf);
> > cairo_destroy(svg1_ctx);
> > }
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20171004/754945f5/attachment.html>
More information about the cairo
mailing list