[cairo] [PATCH] gl: Create a new image surface if necessary in upload_boxes().

Chuanbo Weng strgnm at gmail.com
Fri Jul 6 00:52:28 PDT 2012


When the source surface type is gl-window in upload_boxes(), we should
create a image surface for it to do compositing. Fixes 6 fails in
cairo-test-suite, for example, subsurface-image-repeat.
---
 src/cairo-gl-surface.c       |    5 ++++-
 src/cairo-spans-compositor.c |   17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 6b9bc67..4fee7f5 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -1136,7 +1136,10 @@ _cairo_gl_surface_source (void		       *abstract_surface,
 	extents->height = surface->height;
     }
 
-    return &surface->base;
+    if (!_cairo_gl_surface_is_texture (surface))
+        return NULL;
+    else
+        return &surface->base;
 }
 
 static cairo_status_t
diff --git a/src/cairo-spans-compositor.c b/src/cairo-spans-compositor.c
index 602d6a6..53bde9b 100644
--- a/src/cairo-spans-compositor.c
+++ b/src/cairo-spans-compositor.c
@@ -487,10 +487,25 @@ upload_boxes (const cairo_spans_compositor_t *compositor,
     cairo_rectangle_int_t limit;
     cairo_int_status_t status;
     int tx, ty;
+    cairo_image_surface_t *image;
+    void *image_extra;
+    cairo_bool_t aq_src_img = FALSE;
 
     TRACE ((stderr, "%s\n", __FUNCTION__));
 
     src = _cairo_pattern_get_source(source, &limit);
+    if (!src){
+        status = _cairo_surface_acquire_source_image (source->surface,
+                                                      &image,
+                                                      &image_extra);
+
+        if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+            return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+        else if (unlikely (status))
+            return status;
+        src = &image->base;
+        aq_src_img = TRUE;
+    }
     if (!(src->type == CAIRO_SURFACE_TYPE_IMAGE || src->type == dst->type))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
@@ -515,6 +530,8 @@ upload_boxes (const cairo_spans_compositor_t *compositor,
     else
 	status = compositor->copy_boxes (dst, src, boxes, &extents->bounded,
 					 tx, ty);
+    if (aq_src_img)
+        _cairo_surface_release_source_image (source->surface, image, image_extra);
 
     return status;
 }
-- 
1.7.5.4



More information about the cairo mailing list