[cairo] [patch] gl: fix bug when mask/source surface are not created within a same context as dst surface

Henry (Yu) Song - SISA hsong at sisa.samsung.com
Tue Jul 24 17:24:14 PDT 2012


commit 3bf82304fda6a9e2a09753f2b3c5ac66baa02140
Author: Henry Song <henry.song at samsung.com>
Date:   Tue Jul 24 17:13:46 2012 -0700

    gl: when mask/source and dst are all GL surfaces, and they do not have a same
    device (they are created from different context/display), we cannot use
    mask/source texture directly.
    
    This fixes bug for gl-surface-source test case in GL backend.  Ideally,
    instead of falling back, we should download the texture from mask/source and
    then upload it to a texture that is created in the same context as the dst.
    However, this requires release the current dst's device and acquire it again
    once we finish downloading.  Given the device might be recursively locked and 
    a single release does not do the job, so let's fallback.

diff --git a/src/cairo-mask-compositor.c b/src/cairo-mask-compositor.c
index 7976a79..acfb01a 100644
--- a/src/cairo-mask-compositor.c
+++ b/src/cairo-mask-compositor.c
@@ -813,6 +813,11 @@ upload_boxes (const cairo_mask_compositor_t *compositor,
     if (!(src->type == CAIRO_SURFACE_TYPE_IMAGE || src->type == dst->type))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
+    if (src->type == CAIRO_SURFACE_TYPE_GL && extents->surface->type == CAIRO_SURFACE_TYPE_GL) {
+	if (src->device != extents->surface->device)
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+    }
+
     if (! _cairo_matrix_is_integer_translation (&source->matrix, &tx, &ty))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
diff --git a/src/cairo-spans-compositor.c b/src/cairo-spans-compositor.c
index 602d6a6..5f1ce38 100644
--- a/src/cairo-spans-compositor.c
+++ b/src/cairo-spans-compositor.c
@@ -493,6 +493,11 @@ upload_boxes (const cairo_spans_compositor_t *compositor,
     src = _cairo_pattern_get_source(source, &limit);
     if (!(src->type == CAIRO_SURFACE_TYPE_IMAGE || src->type == dst->type))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
+    
+    if (src->type == CAIRO_SURFACE_TYPE_GL && extents->surface->type == CAIRO_SURFACE_TYPE_GL) {
+	if (src->device != extents->surface->device)
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+    }
 
     if (! _cairo_matrix_is_integer_translation (&source->base.matrix, &tx, &ty))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
diff --git a/src/cairo-traps-compositor.c b/src/cairo-traps-compositor.c
index eeee20c..5d24996 100644
--- a/src/cairo-traps-compositor.c
+++ b/src/cairo-traps-compositor.c
@@ -1312,6 +1312,11 @@ upload_boxes (const cairo_traps_compositor_t *compositor,
 				    &limit);
     if (!(src->type == CAIRO_SURFACE_TYPE_IMAGE || src->type == dst->type))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
+    
+    if (src->type == CAIRO_SURFACE_TYPE_GL && extents->surface->type == CAIRO_SURFACE_TYPE_GL) {
+	if (src->device != extents->surface->device)
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+    }
 
     if (! _cairo_matrix_is_integer_translation (&source->matrix, &tx, &ty))
 	return CAIRO_INT_STATUS_UNSUPPORTED;


More information about the cairo mailing list