Bug 14945 - cairo_write_func_t isn't called when a call to cairo_show_page/cairo_copy_page is done
Summary: cairo_write_func_t isn't called when a call to cairo_show_page/cairo_copy_pag...
Status: RESOLVED MOVED
Alias: None
Product: cairo
Classification: Unclassified
Component: svg backend (show other bugs)
Version: 1.5.13
Hardware: x86 (IA32) Linux (All)
: medium enhancement
Assignee: Emmanuel Pacaud
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-10 14:22 UTC by Carlos Eduardo Rodrigues Diógenes
Modified: 2018-08-25 13:53 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Carlos Eduardo Rodrigues Diógenes 2008-03-10 14:22:03 UTC
Sometime ago, talking in #cairo, Carl Worth tell me that the cairo_write_func_t used in cairo_svg_surface_create_for_stream must be called when a call to cairo_show_page/cairo_copy_page or cairo_surface_show_page/cairo_surface_copy_page is called, but this isn't what actually happen.

The cairo_write_func_t is only called when the surface is destroyed, what's a problem, since some applications only destroy the surface when it's terminate, so we can't send progress throw the stream.
Comment 1 Emmanuel Pacaud 2008-03-11 01:11:23 UTC
I guess it should be possible, by having a defs element before each page.
Comment 2 oliver.terbu 2013-05-22 09:54:44 UTC
(In reply to comment #1)
> I guess it should be possible, by having a defs element before each page.

I ran into the same issue. Can you please explain your solution and how to implement it?

cairo_status_t writeSvg(void *closure, const unsigned char *data, unsigned int length)
{
  ...
}
...
void main() {
  cairo_surface_t *surface=0;
  cairo_t *cr=0;

  surface = cairo_svg_surface_create_for_stream(writeSvg, &truncated, 390, 60);
  cr = cairo_create(surface);

  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size(cr, 40.0);

  cairo_move_to(cr, 10.0, 50.0);
  cairo_show_text(cr, "Hello World.");
  
  cairo_show_page(cr); // writeSvg not invoked here!

  cairo_move_to(cr, 10.0, 50.0);
  cairo_show_text(cr, "Knowledge is Power.");

  cairo_surface_destroy(surface);
  cairo_destroy(cr); // writeSvg invoked here!

  ...
}
Comment 3 GitLab Migration User 2018-08-25 13:53:22 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/250.


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.