[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cairo
Subject:    Re: [cairo] Information required for cairo gl backend regarding CAIRO_OPERATOR_SOURCE
From:       "Henry (Yu) Song - SISA" <hsong () sisa ! samsung ! com>
Date:       2012-09-27 19:26:47
Message-ID: 3955FA337689574EB32F94B12A7E6E9E246DF2F9 () sisaex01sj
[Download RAW message or body]

Hi, Yuanhan

If you apply two patcesh I submitted (two patches follow) on cairo upstream, your \
sample works for SOURCE operator.  My guess is right - your driver does not take any \
formats except GL_RGBA/GL_RGB when uploading image to texture.

Thanks

Henry

From 5f5ef3030db287dd2a925b80a22cf3012c5b84d9 Mon Sep 17 00:00:00 2001
From: Henry Song <henry.song@samsung.com>
Date: Thu, 27 Sep 2012 12:19:40 -0700
Subject: [PATCH] gl/traps: we need to create RGBA format image when uploading
 it to texture for GLES2.

---
 src/cairo-gl-traps-compositor.c |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/cairo-gl-traps-compositor.c b/src/cairo-gl-traps-compositor.c
index a87fd16..13b1d4f 100644
--- a/src/cairo-gl-traps-compositor.c
+++ b/src/cairo-gl-traps-compositor.c
@@ -50,6 +50,7 @@
 #include "cairo-image-surface-private.h"
 #include "cairo-spans-compositor-private.h"
 #include "cairo-surface-backend-private.h"
+#include "cairo-surface-offset-private.h"
 
 static cairo_int_status_t
 acquire (void *abstract_dst)
@@ -281,6 +282,8 @@ traps_to_operand (void *_dst,
     pixman_format_code_t pixman_format;
     pixman_image_t *pixman_image;
     cairo_surface_t *image, *mask;
+    cairo_surface_t *orig_image = NULL; 
+    cairo_surface_t *rgba_image = NULL;
     cairo_surface_pattern_t pattern;
     cairo_status_t status;
 
@@ -300,12 +303,43 @@ traps_to_operand (void *_dst,
 	return image->status;
     }
 
+    /* GLES2 only supports RGB/RGBA when uploading */
+    if (_cairo_gl_get_flavor () == CAIRO_GL_FLAVOR_ES) {
+	cairo_pattern_t *pat = cairo_pattern_create_for_surface (image);
+	int image_width = ((cairo_image_surface_t *) image)->width;
+	int image_height = ((cairo_image_surface_t *) image)->height;
+	pixman_format_code_t rgba_format = PIXMAN_r8g8b8a8;
+
+	if (_cairo_is_little_endian ())
+	    rgba_format = PIXMAN_a8b8g8r8;
+
+	rgba_image = 
+	    _cairo_image_surface_create_with_pixman_format (NULL,
+							    rgba_format,
+							    image_width,
+							    image_height,
+							    -1);
+	status = _cairo_surface_offset_paint (rgba_image, 0, 0,
+					      CAIRO_OPERATOR_SOURCE,
+					      pat, NULL);
+	if (unlikely (status)) {
+	    cairo_surface_destroy (image);
+	    cairo_surface_destroy (rgba_image);
+	    return status;
+	}
+	
+	orig_image = image;
+	image = rgba_image;
+    }
+
     mask = _cairo_surface_create_similar_scratch (_dst,
 						  CAIRO_CONTENT_COLOR_ALPHA,
 						  extents->width,
 						  extents->height);
     if (unlikely (mask->status)) {
 	cairo_surface_destroy (image);
+	if (orig_image)
+	    cairo_surface_destroy (orig_image);
 	return mask->status;
     }
 
@@ -315,6 +349,9 @@ traps_to_operand (void *_dst,
 					   extents->width, extents->height,
 					   0, 0);
     cairo_surface_destroy (image);
+    if (orig_image)
+	cairo_surface_destroy (orig_image);
+
     if (unlikely (status))
 	goto error;
 
-- 
1.7.9.5


From 6d6495e7301aefcc19a22bddf82b231fcc73a971 Mon Sep 17 00:00:00 2001
From: Henry Song <henry.song@samsung.com>
Date: Thu, 27 Sep 2012 11:26:27 -0700
Subject: [PATCH] gl: GLES only supports GL_DEPTH24_STENCIL8_OES

---
 src/cairo-gl-device.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
index 9cb0c21..6563b3b 100644
--- a/src/cairo-gl-device.c
+++ b/src/cairo-gl-device.c
@@ -321,7 +321,7 @@ _get_depth_stencil_format (cairo_gl_context_t *ctx)
 
 #if CAIRO_HAS_GLESV2_SURFACE
     if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP)
-       return GL_DEPTH24_STENCIL8;
+       return GL_DEPTH24_STENCIL8_OES;
 #endif
 
 #if CAIRO_HAS_GL_SURFACE
-- 
1.7.9.5



________________________________________
From: cairo-bounces+henry.song=samsung.com@cairographics.org \
[cairo-bounces+henry.song=samsung.com@cairographics.org] on behalf of Henry (Yu) Song \
                - SISA [hsong@sisa.samsung.com]
Sent: Thursday, September 27, 2012 10:54 AM
To: sumit.panwar@samsung.com; Yuanhan Liu
Cc: cairo@cairographics.org
Subject: Re: [cairo] Information required for cairo gl backend regarding \
CAIRO_OPERATOR_SOURCE

Hi, Yuanhan

Which cairo do you use?  The gl/gles backend from cairo upstream is less stable and \
contains more bugs.  I suggest you to use our cairogles backend for cairo.  It is \
available in http://code.google.com/p/cairogles.  It is faster, stable and supports \
MSAA.  If your driver supports MSAA (number of samples > 1 and has \
glFramebufferTexture2DMultisampleEXT), I would suggest to use our cairogles.  We have \
not entirely upstreamed our code yet, but it is in progress.

To use our cairogles

1. set env - export CAIRO_GL_COMPOSITOR=msaa
2. add EGL_SAMPLES, {2 | 4 | 8}, and EGL_SAMPLE_BUFFERS, 1, to your egl attributes - \
recompile your code

I have tested your code under radeon driver (on PC) and my embedded device with \
MSAA-supported driver, they both works with our cairogles (OVER, SOURCE)

The reason that SOURCE fails in upstream gles backend probably is your image_surface \
is BGRA format while your driver only allows RGB/RGBA format when you upload image \
(glTexSubImage2D()) - this is just my guess

More things to point out if you want to optimize your performance.
1. If you application is not multithreading, add cairo_gl_device_set_thread_aware \
(device, FALSE) to your code to reduce context switches 2. Instead of painting an \
image_surface to a gl_surface directly, you should first create a gl_surface same \
size as your image_surface, paint your image to the new gl_surface, and during each \
loop, you paint your new gl_surface to the final gl_surface where you want to show \
result.  The reason is that if you paint image_surface to gl_surface during every \
loop, the image in system memory has to be uploaded to texture every time, You \
definitely want to avoid this that slows down your app.

Please let us know if you have more questions and encouter any problems

Thanks

Henry

________________________________________
From: cairo-bounces+henry.song=samsung.com@cairographics.org \
[cairo-bounces+henry.song=samsung.com@cairographics.org] on behalf of SUMIT PANWAR \
                [sumit.panwar@samsung.com]
Sent: Tuesday, May 29, 2012 2:34 AM
To: Yuanhan Liu
Cc: cairo@cairographics.org
Subject: Re: [cairo] Information required for cairo gl backend regarding \
CAIRO_OPERATOR_SOURCE

Hi,

I have attached the sample code for the issue. It takes command line argument to \
execute for OPERATOR SRC /OPERATOR OVER and to use cairo_paint or cairo_fill like

./sample  ------->>>> EGL_BACKEND, ROP OVER WITH CLIP (works)
./sample  -rop_source ------> ROP_SOURCE  (NOT working)
./sample  -rop_source  -cairo_fill ------> ROP_SOURCE WITH FILL (works)

The attached code uses X window to render the final output.

Please let me know if there is any issue in the sample.



Thanks,

Sumit



------- Original Message -------

Sender : Yuanhan Liu<yuanhan.liu@linux.intel.com>

Date : May 29, 2012 10:51 (GMT+09:00)

Title : Re: [cairo] Information required for cairo gl backend regarding \
CAIRO_OPERATOR_SOURCE



On Mon, May 28, 2012 at 02:05:22PM +0000, SUMIT PANWAR wrote:
> Hi,
> 
> We are writing some test cases to compare cairo gl backend with cairo image
> backend.
> 
> 1) Image clipping does not work for CAIRO_OPERATOR_SOURCE.
> 
> Though it works with bounded rectangle with cairo_fill.
> 
> Below applicaiton code does NOT work. It throws gl error 1282(Invalid
> Operation)
> 
> ---------------------------------------------------------
> cairo_rectangle(m_cr, 0, 0, width,height);
> cairo_clip(m_cr);
> cairo_set_source_surface(m_cr,glSrcSurface, 0 , 0);
> cairo_paint(m_cr);
> ---------------------------------------------------------
> What works is below:
> -------------------------
> cairo_rectangle(m_cr, 0, 0, width,height);
> cairo_set_source_surface(m_cr, glSrcSurface, 0 , 0);
> cairo_fill(m_cr);
> -------------------------

Hi,

It would be good if you attach a full test code that can produce your
issue here.

Thanks,
Yuanhan Liu

> 
> Image clipping with image surface works well.
> 
> Please suggest waht could be the issue.
> 
> Thanks in advance,
> 
> Sumit
> 
> 
> 
> 
> 
> [cid]
> 
> *



> --
> cairo mailing list
> cairo@cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo








[cid:BEI0XT4NZ5JE@namo.co.kr]



-- 
cairo mailing list
cairo@cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic