Bug 7079 - New surface: cairo_combined_surface_t
Summary: New surface: cairo_combined_surface_t
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.1.7
Hardware: x86 (IA32) Linux (All)
: high enhancement
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-30 21:22 UTC by Kouhei Sutou
Modified: 2008-10-08 05:55 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
An implementation of this idea. (29.89 KB, patch)
2006-05-30 21:22 UTC, Kouhei Sutou
Details | Splinter Review

Description Kouhei Sutou 2006-05-30 21:22:22 UTC
Even if we want to write same contents to different serfaces, we must make
cairo_t for each cairo_surface_t. For example, if we wants to output PS and PDF
with same contents, we write the following code:

static void
render(cairo_surface_t *surface)
{
  cairo_t *cr;

  cr = cairo_create(surface);
  ...
  cairo_rectangle(cr, ...);
  cairo_fill(cr);
  ...
  cairo_show_page(cr);
  ...
  cairo_surface_finish(cairo_get_target(cr));
}

static void
output(void)
{
  cairo_surface_t *ps_surface, *pdf_surface;
  ...
  render(ps_surface);
  render(pdf_surface);
}

There is some problems:
* If render() loads a image each time, the image is loaded twice.
* We must define a function to render. (Yes, we can use "copy and paste" but
this is a bad manner.)
* ...

To solve those problems, I suggeste that cairo provides a surface can combine
some surfaces and show those surfaces as a surface to cairo_t. And then, we can
write the above code as the following:

static void
output(void)
{
  cairo_t *cr;
  cairo_surface_t *ps_surface, *pdf_surface, *combined_surface;

  ...
  combined_surface = cairo_combined_surface(ps_surface, pdf_surface, NULL);

  cr = cairo_create(combined_surface);
  ...
  cairo_rectangle(cr, ...);
  cairo_fill(cr);
  ...
  cairo_show_page(cr);
  ...
  cairo_surface_finish(cairo_get_target(cr));
}
Comment 1 Kouhei Sutou 2006-05-30 21:22:57 UTC
Created attachment 5764 [details] [review]
An implementation of this idea.
Comment 2 Chris Wilson 2008-10-08 05:55:51 UTC
Moved to todo.


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.