[cairo] [PATCH] gl: Do correct translation and lerp in gl-traps-compositor.

Chuanbo Weng strgnm at gmail.com
Wed May 30 07:51:03 PDT 2012


Coordinate translation is necessary in composite_boxes(), composite()
and composite_traps(). The translation value should set to correct
value in traps_to_operand(). Also fix the bug in lerp().
---
 src/cairo-gl-traps-compositor.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/cairo-gl-traps-compositor.c b/src/cairo-gl-traps-compositor.c
index 776b74c..a87fd16 100644
--- a/src/cairo-gl-traps-compositor.c
+++ b/src/cairo-gl-traps-compositor.c
@@ -174,9 +174,11 @@ composite_boxes (void			*_dst,
 
     _cairo_gl_composite_set_source_operand (&setup,
 					    source_to_operand (abstract_src));
+    _cairo_gl_operand_translate (&setup.src, dst_x-src_x, dst_y-src_y);
 
     _cairo_gl_composite_set_mask_operand (&setup,
 					  source_to_operand (abstract_mask));
+    _cairo_gl_operand_translate (&setup.mask, dst_x-mask_x, dst_y-mask_y);
 
     status = _cairo_gl_composite_begin (&setup, &ctx);
     if (unlikely (status))
@@ -214,9 +216,11 @@ composite (void			*_dst,
 
     _cairo_gl_composite_set_source_operand (&setup,
 					    source_to_operand (abstract_src));
+    _cairo_gl_operand_translate (&setup.src, dst_x-src_x, dst_y-src_y);
 
     _cairo_gl_composite_set_mask_operand (&setup,
 					  source_to_operand (abstract_mask));
+    _cairo_gl_operand_translate (&setup.mask, dst_x-mask_x, dst_y-mask_y);
 
     status = _cairo_gl_composite_begin (&setup, &ctx);
     if (unlikely (status))
@@ -247,9 +251,9 @@ lerp (void			*dst,
     cairo_int_status_t status;
 
     /* we could avoid some repetition... */
-    status = composite (dst, CAIRO_OPERATOR_DEST_OUT, src, mask,
-			src_x, src_y,
+    status = composite (dst, CAIRO_OPERATOR_DEST_OUT, mask, NULL,
 			mask_x, mask_y,
+			0, 0,
 			dst_x, dst_y,
 			width, height);
     if (unlikely (status))
@@ -271,7 +275,8 @@ traps_to_operand (void *_dst,
 		  const cairo_rectangle_int_t *extents,
 		  cairo_antialias_t	antialias,
 		  cairo_traps_t		*traps,
-		  cairo_gl_operand_t	*operand)
+		  cairo_gl_operand_t	*operand,
+		  int dst_x, int dst_y)
 {
     pixman_format_code_t pixman_format;
     pixman_image_t *pixman_image;
@@ -315,7 +320,7 @@ traps_to_operand (void *_dst,
 
     _cairo_pattern_init_for_surface (&pattern, mask);
     cairo_matrix_init_translate (&pattern.base.matrix,
-				 -extents->x, -extents->y);
+				 -extents->x+dst_x, -extents->y+dst_y);
     pattern.base.filter = CAIRO_FILTER_NEAREST;
     pattern.base.extend = CAIRO_EXTEND_NONE;
     status = _cairo_gl_operand_init (operand, &pattern.base, _dst,
@@ -356,7 +361,8 @@ composite_traps (void			*_dst,
 
     _cairo_gl_composite_set_source_operand (&setup,
 					    source_to_operand (abstract_src));
-    status = traps_to_operand (_dst, extents, antialias, traps, &setup.mask);
+    _cairo_gl_operand_translate (&setup.src, -src_x-dst_x, -src_y-dst_y);
+    status = traps_to_operand (_dst, extents, antialias, traps, &setup.mask, dst_x, dst_y);
     if (unlikely (status))
 	goto FAIL;
 
@@ -366,9 +372,9 @@ composite_traps (void			*_dst,
 
     /* XXX clip */
     _cairo_gl_composite_emit_rect (ctx,
-				   dst_x, dst_y,
-				   dst_x+extents->width,
-				   dst_y+extents->height, 0);
+				   extents->x-dst_x, extents->y-dst_y,
+				   extents->x-dst_x+extents->width,
+				   extents->y-dst_y+extents->height, 0);
     status = _cairo_gl_context_release (ctx, CAIRO_STATUS_SUCCESS);
 
 FAIL:
-- 
1.7.5.4



More information about the cairo mailing list