[cairo] [PATCH] gl: Draw image surface to fbo gl surface using intermediate texture

Dongyeon Kim dy5.kim at samsung.com
Thu Nov 15 21:45:18 PST 2012


Hello,

When I create an image surface from png, and use this surface as source to paint to cairo gl surface that is created using FBO, the resulting gl surface is just black.
I have spent some time investigating this, and found that cairo was uploading data to the texture that is currently being used as target framebuffer.
To fix this problem, image data should be uploaded to an intermediate texture, and this texture should be rendered into the FBO.
The following patch is a suggested fix for both gl-spans and gl-traps compositors.

Thanks


From cfad0e1ea8e36bc1351c44c2358ef6bb400a0f26 Mon Sep 17 00:00:00 2001
From: Dongyeon Kim <dy5.kim at samsung.com>
Date: Fri, 16 Nov 2012 14:29:50 +0900
Subject: [PATCH] gl: Draw image surface to fbo gl surface using intermediate texture

When gl surface is created using fbo, you cannot upload image data
directly into framebuffer-attached texture.
Image data should be uploaded to an intermediate texture, and
this texture should be rendered into the fbo.
---
 src/cairo-gl-spans-compositor.c |    3 +++
 src/cairo-gl-traps-compositor.c |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/cairo-gl-spans-compositor.c b/src/cairo-gl-spans-compositor.c
index 62da1eb..968bc4c 100644
--- a/src/cairo-gl-spans-compositor.c
+++ b/src/cairo-gl-spans-compositor.c
@@ -291,6 +291,9 @@ draw_image_boxes (void *_dst,
     struct _cairo_boxes_chunk *chunk;
     int i;
 
+    if (_cairo_gl_surface_is_texture (dst))
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+
     for (chunk = &boxes->chunks; chunk; chunk = chunk->next) {
 	for (i = 0; i < chunk->count; i++) {
 	    cairo_box_t *b = &chunk->base[i];
diff --git a/src/cairo-gl-traps-compositor.c b/src/cairo-gl-traps-compositor.c
index 4bae0d1..a1ba69b 100644
--- a/src/cairo-gl-traps-compositor.c
+++ b/src/cairo-gl-traps-compositor.c
@@ -84,6 +84,9 @@ draw_image_boxes (void *_dst,
     struct _cairo_boxes_chunk *chunk;
     int i;
 
+    if (_cairo_gl_surface_is_texture (dst))
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+
     for (chunk = &boxes->chunks; chunk; chunk = chunk->next) {
 	for (i = 0; i < chunk->count; i++) {
 	    cairo_box_t *b = &chunk->base[i];
-- 
1.7.5.4


More information about the cairo mailing list