[cairo] [PATCH] gl: Fix creation of the source operand for text rendering

Martin Robinson mrobinson at igalia.com
Fri Nov 4 13:29:11 PDT 2011


Subject: [PATCH] gl: Fix creation of the source operand for text rendering

Support both cairo_pattern_t and cairo_surface_t arguments to
_render_glyphs. The latter is for rendering directly via the
traps compositor and the former is for rendering that happens
through render_glyphs_via_mask.
---
 src/cairo-gl-glyphs.c           |   36 +++++++++++++++++++++---------------
 src/cairo-gl-private.h          |    6 ++++++
 src/cairo-gl-spans-compositor.c |    6 ------
 src/cairo-gl-traps-compositor.c |    6 ------
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index ee5c543..2324922 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -214,12 +214,13 @@ _cairo_gl_font_fini (cairo_scaled_font_private_t *_priv,
 }
 
 static cairo_status_t
-render_glyphs (cairo_gl_surface_t	*dst,
+render_glyphs (cairo_gl_surface_t *dst,
 	       int dst_x, int dst_y,
-	       cairo_operator_t	 op,
-	       const cairo_pattern_t	*source,
+	       cairo_operator_t op,
+	       const cairo_pattern_t *source_pattern,
+	       const cairo_surface_t *source_surface,
 	       cairo_composite_glyphs_info_t *info,
-	       cairo_bool_t		*has_component_alpha)
+	       cairo_bool_t *has_component_alpha)
 {
     cairo_format_t last_format = CAIRO_FORMAT_INVALID;
     cairo_gl_glyph_cache_t *cache = NULL;
@@ -238,15 +239,20 @@ render_glyphs (cairo_gl_surface_t	*dst,
     if (unlikely (status))
 	goto FINISH;
 
-    status = _cairo_gl_composite_set_source (&setup, source,
-                                             info->extents.x,
-					     info->extents.y,
-                                             dst_x, dst_y,
-                                             info->extents.width,
-                                             info->extents.height);
-    if (unlikely (status))
-	goto FINISH;
-
+    if (source_pattern) {
+	status = _cairo_gl_composite_set_source (&setup,
+						 source_pattern,
+						 info->extents.x,
+						 info->extents.y,
+						 dst_x, dst_y,
+						 info->extents.width,
+						 info->extents.height);
+	if (unlikely (status))
+	    goto FINISH;
+    } else {
+	_cairo_gl_composite_set_source_operand (&setup,
+	    &((cairo_gl_source_t *) source_surface)->operand);
+    }
 
     //_cairo_gl_composite_set_clip_region (&setup, _cairo_clip_get_region (extents->clip));
 
@@ -368,7 +374,7 @@ render_glyphs_via_mask (cairo_gl_surface_t	*dst,
 
     status = render_glyphs ((cairo_gl_surface_t *) mask, 0, 0,
 			    CAIRO_OPERATOR_ADD,
-			    &_cairo_pattern_white.base,
+			    &_cairo_pattern_white.base, NULL,
 			    info, &has_component_alpha);
     if (likely (status == CAIRO_STATUS_SUCCESS)) {
 	/* XXX composite */
@@ -449,7 +455,7 @@ _cairo_gl_composite_glyphs (void			*_dst,
 	return render_glyphs_via_mask (dst, op, _src, info);
     } else {
 	return render_glyphs (dst, dst_x, dst_y,
-			      op, _src, info,
+			      op, NULL, _src, info,
 			      &has_component_alpha);
     }
 }
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index cd7c8ae..758f33e 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -333,6 +333,12 @@ typedef struct _cairo_gl_font {
     cairo_list_t			link;
 } cairo_gl_font_t;
 
+typedef struct cairo_gl_source {
+    cairo_surface_t base;
+
+    cairo_gl_operand_t operand;
+} cairo_gl_source_t;
+
 cairo_private extern const cairo_surface_backend_t _cairo_gl_surface_backend;
 
 static cairo_always_inline GLenum
diff --git a/src/cairo-gl-spans-compositor.c b/src/cairo-gl-spans-compositor.c
index 3e52f28..ba89dbd 100644
--- a/src/cairo-gl-spans-compositor.c
+++ b/src/cairo-gl-spans-compositor.c
@@ -279,12 +279,6 @@ FAIL:
     return status;
 }
 
-typedef struct cairo_gl_source {
-    cairo_surface_t base;
-
-    cairo_gl_operand_t operand;
-} cairo_gl_source_t;
-
 static cairo_status_t
 _cairo_gl_source_finish (void *abstract_surface)
 {
diff --git a/src/cairo-gl-traps-compositor.c b/src/cairo-gl-traps-compositor.c
index afc74d0..d999959 100644
--- a/src/cairo-gl-traps-compositor.c
+++ b/src/cairo-gl-traps-compositor.c
@@ -150,12 +150,6 @@ FAIL:
     return status;
 }
 
-typedef struct cairo_gl_source {
-    cairo_surface_t base;
-
-    cairo_gl_operand_t operand;
-} cairo_gl_source_t;
-
 static cairo_status_t
 _cairo_gl_source_finish (void *abstract_surface)
 {
-- 
1.7.5.4



More information about the cairo mailing list