Bug 612846 - Part 2: Make cairo_tee_surface support flush. r=roc a=blocking-betan
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 28 Jan 2011 06:34:27 +0100
changeset 61471 99c20fdff1c2cd3a539b3bb98fad8c9cfd013922
parent 61470 bbee61de7173e2031ebaccea0e6dba737647b08a
child 61472 4b4ea122f4231377cfa2b30f4bbadf16e8c51d8b
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersroc, blocking-betan
bugs612846
milestone2.0b11pre
Bug 612846 - Part 2: Make cairo_tee_surface support flush. r=roc a=blocking-betan
gfx/cairo/cairo/src/cairo-surface-wrapper-private.h
gfx/cairo/cairo/src/cairo-surface-wrapper.c
gfx/cairo/cairo/src/cairo-tee-surface.c
--- a/gfx/cairo/cairo/src/cairo-surface-wrapper-private.h
+++ b/gfx/cairo/cairo/src/cairo-surface-wrapper-private.h
@@ -147,16 +147,19 @@ cairo_private void
 					 cairo_font_options_t	    *options);
 
 cairo_private cairo_surface_t *
 _cairo_surface_wrapper_snapshot (cairo_surface_wrapper_t *wrapper);
 
 cairo_private cairo_bool_t
 _cairo_surface_wrapper_has_show_text_glyphs (cairo_surface_wrapper_t *wrapper);
 
+cairo_private cairo_status_t
+_cairo_surface_wrapper_flush (cairo_surface_wrapper_t *wrapper);
+
 static inline cairo_bool_t
 _cairo_surface_wrapper_is_active (cairo_surface_wrapper_t *wrapper)
 {
     return wrapper->target != (cairo_surface_t *) 0;
 }
 
 CAIRO_END_DECLS
 
--- a/gfx/cairo/cairo/src/cairo-surface-wrapper.c
+++ b/gfx/cairo/cairo/src/cairo-surface-wrapper.c
@@ -519,8 +519,16 @@ void
     wrapper->target = cairo_surface_reference (target);
 }
 
 void
 _cairo_surface_wrapper_fini (cairo_surface_wrapper_t *wrapper)
 {
     cairo_surface_destroy (wrapper->target);
 }
+
+cairo_status_t
+_cairo_surface_wrapper_flush (cairo_surface_wrapper_t *wrapper)
+{
+    if (wrapper->target->backend->flush) {
+	return wrapper->target->backend->flush(wrapper->target);
+    }
+}
--- a/gfx/cairo/cairo/src/cairo-tee-surface.c
+++ b/gfx/cairo/cairo/src/cairo-tee-surface.c
@@ -462,16 +462,39 @@ static cairo_int_status_t
 	    goto CLEANUP;
     }
 
   CLEANUP:
     free (glyphs_copy);
     return status;
 }
 
+static cairo_status_t
+_cairo_tee_surface_flush (void *abstract_surface)
+{
+    cairo_tee_surface_t *surface = abstract_surface;
+    cairo_surface_wrapper_t *slaves;
+    int n, num_slaves;
+    cairo_status_t status;
+
+    status = _cairo_surface_wrapper_flush(&surface->master);
+    if (unlikely (status))
+	return status;
+
+    num_slaves = _cairo_array_num_elements (&surface->slaves);
+    slaves = _cairo_array_index (&surface->slaves, 0);
+    for (n = 0; n < num_slaves; n++) {
+	status = _cairo_surface_wrapper_flush(&slaves[n]);
+	if (unlikely (status))
+	    return status;
+    }
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
 static const cairo_surface_backend_t cairo_tee_surface_backend = {
     CAIRO_SURFACE_TYPE_TEE,
     _cairo_tee_surface_create_similar,
     _cairo_tee_surface_finish,
     _cairo_tee_surface_acquire_source_image,
     _cairo_tee_surface_release_source_image,
     NULL, NULL, /* dest_image */
     NULL, /* clone_similar */
@@ -480,17 +503,17 @@ static const cairo_surface_backend_t cai
     NULL, /* composite_trapezoids */
     NULL, /* create_span_renderer */
     NULL, /* check_span_renderer */
     NULL, /* copy_page */
     NULL, /* show_page */
     _cairo_tee_surface_get_extents,
     NULL, /* old_show_glyphs */
     _cairo_tee_surface_get_font_options,
-    NULL, /* flush */
+    _cairo_tee_surface_flush,
     NULL, /* mark_dirty_rectangle */
     NULL, /* scaled_font_fini */
     NULL, /* scaled_glyph_fini */
 
     _cairo_tee_surface_paint,
     _cairo_tee_surface_mask,
     _cairo_tee_surface_stroke,
     _cairo_tee_surface_fill,