Re: [patch] quartz: align pixel when source/mask translation is either 1.0 or -1.0

"Henry (Yu) Song - SISA" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <3955FA337689574EB32F94B12A7E6E9E16365147@sisaex01sj>
Thanks Chris


On Mon, 30 Jul 2012 18:18:24 +0000, "Henry (Yu) Song - SISA" <[email protected]> wrote:
> I am not sure whether this should be a considered as a fix, or _cairo_matrix_is_abs_translation() should be moved to cairoint.h instead of in cairo-quartz-surface.c

I think _cairo_matrix_has_unity_scale() is the function you are looking
for.
-Chris

--
Chris Wilson, Intel Open Source Technology Centre


New patch


From d5e97b2e25c78db3567edd854350ecfc712e5560 Mon Sep 17 00:00:00 2001
From: Henry Song <[email protected]>
Date: Mon, 30 Jul 2012 11:06:30 -0700
Subject: [PATCH] quartz: check matrix has unity scale . if filter is
 CAIRO_FILTER_NEAREST and has unity scale, we can align
 pixel for source/mask.  This fixes XFAIL case for
 filter-nearest-transformed

---
 src/cairo-quartz-surface.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 1e2bbec..dc1d804 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -1256,9 +1256,12 @@ _cairo_quartz_setup_state (cairo_quartz_drawing_state_t *state,
 
 	state->image = img;
 
-	if (state->filter == kCGInterpolationNone && _cairo_matrix_is_translation (&m)) {
-	    m.x0 = -ceil (m.x0 - 0.5);
-	    m.y0 = -ceil (m.y0 - 0.5);
+	/* if the filter is CAIRO_FILTER_NEAREST and the transformation
+	 * matrix scale is 1.0 or -1.0, we can align pixel
+	 */
+	if (state->filter == kCGInterpolationNone && _cairo_matrix_has_unity_scale (&m)) {
+	    m.x0 = -ceil (m.x0 - 0.5) * m.xx;
+	    m.y0 = -ceil (m.y0 - 0.5) * m.yy;
 	} else {
 	    cairo_matrix_invert (&m);
 	}
@@ -1756,8 +1759,12 @@ _cairo_quartz_cg_mask (const cairo_compositor_t *compositor,
 	matrix = mask->matrix;
 
 	mask_filter = _cairo_quartz_filter_to_quartz (mask->filter);
+	
+	/* if the filter is CAIRO_FILTER_NEAREST and the transformation
+	 * matrix scale is 1.0 or -1.0, we can align pixel
+	 */
 	if (mask_filter == kCGInterpolationNone) {
-	    simple_transform = _cairo_matrix_is_translation (&matrix);
+	    simple_transform = _cairo_matrix_has_unity_scale (&matrix);
 	    if (simple_transform) {
 		matrix.x0 = ceil (matrix.x0 - 0.5);
 		matrix.y0 = ceil (matrix.y0 - 0.5);
-- 
1.7.11.2
-- 
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.