[cairo] [PATCH] gl: Fix bug in cairo_surface_create_similar().
Chuanbo Weng
strgnm at gmail.com
Mon Dec 5 23:36:06 PST 2011
When use cairo_surface_create_similar() to create a CAIRO_CONTENT_COLOR
surface within gl backend, the result surface is transparent, fail.
Since we use use GL_RGBA when create CAIRO_CONTENT_COLOR surface, we
should make sure the final alpha value is 1.0. So we set alpha value
of solid source operand to be 1.0, then the final surface is black,
fixed.
---
src/cairo-gl-composite.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 777a714..bb28f4d 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -75,8 +75,18 @@ void
_cairo_gl_composite_set_solid_source (cairo_gl_composite_t *setup,
const cairo_color_t *color)
{
+ /* Since we use GL_RGBA Even when the user requests CAIRO_CONTENT_COLOR,
+ * we should make sure that alpha value of surface is 1.0 after doing
+ * CAIRO_OPERATOR_CLEAR. So the alpha value of solid source is set to be
+ * 1.0.
+ */
+ cairo_color_t src_color = *color;
+ if(setup->dst->base.content == CAIRO_CONTENT_COLOR && setup->op == CAIRO_OPERATOR_CLEAR){
+ src_color.alpha = 1.0;
+ src_color.alpha_short = 0xffff;
+ }
_cairo_gl_operand_destroy (&setup->src);
- _cairo_gl_solid_operand_init (&setup->src, color);
+ _cairo_gl_solid_operand_init (&setup->src, &src_color);
}
cairo_int_status_t
--
1.7.5.1
More information about the cairo
mailing list