[PATCH] gl: Fix bug in render_glyphs_via_mask().

Chuanbo Weng <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
If the operator is unbounded and mask is not large enough, the area
affected by _cairo_surface_mask() in render_glyphs_via_mask() will
be too larger, then result in output error. Fixes overlapping-glyphs
and unbounded-operator test cases in cairo-test-suite.
---
 src/cairo-gl-glyphs.c |   41 +++++++++++++++++++++++++++++++++++------
 1 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index c2660ac..b3ec4d1 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -372,6 +372,8 @@ render_glyphs_via_mask (cairo_gl_surface_t *dst,
     if (likely (status == CAIRO_STATUS_SUCCESS)) {
 	cairo_surface_pattern_t mask_pattern;
 	cairo_surface_pattern_t source_pattern;
+	cairo_gl_composite_t setup;
+	cairo_gl_context_t *ctx;
 
 	mask->is_clear = FALSE;
 	_cairo_pattern_init_for_surface (&mask_pattern, mask);
@@ -386,13 +388,40 @@ render_glyphs_via_mask (cairo_gl_surface_t *dst,
 	cairo_matrix_init_translate (&source_pattern.base.matrix,
 		                     dst_x-info->extents.x, dst_y-info->extents.y);
 
-	status = _cairo_surface_mask (&dst->base, op,
-		                      &source_pattern.base,
-				      &mask_pattern.base,
-				      clip);
+	status = _cairo_gl_composite_init (&setup, op, dst, FALSE);
+    	if (unlikely (status))
+            goto FAIL;
+
+	status = _cairo_gl_composite_set_source (&setup,
+						&source_pattern.base,
+						&_cairo_unbounded_rectangle,
+						&_cairo_unbounded_rectangle);
+	if (unlikely (status))
+            goto FAIL;
+
+	 status = _cairo_gl_composite_set_mask (&setup,
+                                               &mask_pattern.base,
+                                               &_cairo_unbounded_rectangle,
+                                               &_cairo_unbounded_rectangle);
+        if (unlikely (status))
+            goto FAIL;
+
+	status = _cairo_gl_composite_begin (&setup, &ctx);
+	if (unlikely (status))
+            goto FAIL;
+
+	_cairo_gl_composite_emit_rect (ctx, info->extents.x-dst_x, info->extents.y-dst_y, 
+				       info->extents.x-dst_x+info->extents.width,
+				       info->extents.y-dst_y+info->extents.height, 0);
+	status = _cairo_gl_context_release (ctx, CAIRO_STATUS_SUCCESS);
+
+	FAIL:
+	    _cairo_gl_composite_fini (&setup);
+	    _cairo_pattern_fini (&mask_pattern.base);
+	    _cairo_pattern_fini (&source_pattern.base);
+	    cairo_surface_destroy (mask);
+            return status;
 
-	_cairo_pattern_fini (&mask_pattern.base);
-	_cairo_pattern_fini (&source_pattern.base);
     }
 
     cairo_surface_destroy (mask);
-- 
1.7.5.4

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.