diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-08-02 22:31:49 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-08-15 00:16:09 +0100 |
commit | 2220693a40a4f8d13603b3fb29273ec59fd433bc (patch) | |
tree | aec5bf4af07b2a2c2c0d96069e028bdcdec953e9 /util | |
parent | eed1f2efdf36173e23b7177bb34ab9a5f015fb2a (diff) |
Introduce cairo_mime_surface_t
The mime surface is a user-callback surface designed for interfacing
cairo with an opaque data source. For instance, in a web browser, the
incoming page may be laid out and rendered to a recording surface before
all the image data has finished being downloaded. In this circumstance
we need to pass a place holder to cairo and to supply the image data
later upon demand.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'util')
-rw-r--r-- | util/cairo-trace/trace.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c index 614783c67..1b42bed30 100644 --- a/util/cairo-trace/trace.c +++ b/util/cairo-trace/trace.c @@ -3496,6 +3496,55 @@ cairo_image_surface_create_for_data (unsigned char *data, cairo_format_t format, } cairo_surface_t * +cairo_mime_surface_create (void *data, cairo_content_t content, int width, int height) +{ + cairo_surface_t *ret; + + _enter_trace (); + + ret = DLCALL (cairo_mime_surface_create, data, content, width, height); + + _emit_line_info (); + if (_write_lock ()) { + Object *obj = _create_surface (ret); + cairo_format_t format; + cairo_surface_t *image; + cairo_t *cr; + + /* Impossible to accurately record the interaction with a mime-surface + * so just suck all the data into an image upfront */ + switch (content) { + case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break; + case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break; + default: + case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break; + } + + _trace_printf ("%% mime-surface\n"); + + image = DLCALL (cairo_image_surface_create, format, width, height); + cr = DLCALL (cairo_create, image); + DLCALL (cairo_set_source_surface, cr, ret, 0, 0); + DLCALL (cairo_paint, cr); + DLCALL (cairo_destroy, cr); + + _emit_image (image, NULL); + DLCALL (cairo_surface_destroy, image); + _trace_printf (" dup /s%ld exch def\n", + obj->token); + + obj->width = width; + obj->height = height; + obj->defined = TRUE; + _push_object (obj); + _write_unlock (); + } + + _exit_trace (); + return ret; +} + +cairo_surface_t * cairo_surface_create_similar (cairo_surface_t *other, cairo_content_t content, int width, int height) |