[Pixman] [PATCH/RFC 1/2] New FAST_PATH_SIMPLE_ROTATE_TRANSFORM flag

Siarhei Siamashka siarhei.siamashka at gmail.com
Fri Jul 30 11:21:27 PDT 2010


From: Siarhei Siamashka <siarhei.siamashka at nokia.com>

This flag is set when the transform is a simple 90/180/270 degrees
rotation.
---
 pixman/pixman-image.c   |   47 ++++++++++++++++++++++++++++++++++++++++-------
 pixman/pixman-private.h |    1 +
 2 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 5c6d415..c7f7c19 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -288,6 +288,22 @@ source_image_needs_out_of_bounds_workaround (bits_image_t *image)
     return FALSE;
 }
 
+static pixman_bool_t
+has_suitable_filter_for_simple_rotate (pixman_image_t *image)
+{
+    if (image->common.filter == PIXMAN_FILTER_NEAREST)
+	return TRUE;
+
+    if (image->common.filter == PIXMAN_FILTER_BILINEAR &&
+	pixman_fixed_frac (image->common.transform->matrix[0][2]) == 0 &&
+	pixman_fixed_frac (image->common.transform->matrix[1][2]) == 0)
+    {
+	return TRUE;
+    }
+
+    return FALSE;
+}
+
 static void
 compute_image_info (pixman_image_t *image)
 {
@@ -299,18 +315,35 @@ compute_image_info (pixman_image_t *image)
     {
 	flags |= (FAST_PATH_ID_TRANSFORM | FAST_PATH_X_UNIT_POSITIVE);
     }
-    else
+    else if (image->common.transform->matrix[2][0] == 0 &&
+	     image->common.transform->matrix[2][1] == 0 &&
+	     image->common.transform->matrix[2][2] == pixman_fixed_1)
     {
-	if (image->common.transform->matrix[0][1] == 0 &&
-	    image->common.transform->matrix[1][0] == 0 &&
-	    image->common.transform->matrix[2][0] == 0 &&
-	    image->common.transform->matrix[2][1] == 0 &&
-	    image->common.transform->matrix[2][2] == pixman_fixed_1)
+	/* affine transform */
+	const pixman_transform_t *t = image->common.transform;
+	if (t->matrix[0][1] == 0 && t->matrix[1][0] == 0)
 	{
+	    if (t->matrix[0][0] == -pixman_fixed_1 &&
+		t->matrix[1][1] == -pixman_fixed_1 &&
+		has_suitable_filter_for_simple_rotate (image))
+	    {
+		/* 180 degrees rotation */
+		flags |= FAST_PATH_SIMPLE_ROTATE_TRANSFORM;
+	    }
 	    flags |= FAST_PATH_SCALE_TRANSFORM;
 	}
+	else if (t->matrix[0][0] == 0 && t->matrix[1][1] == 0 &&
+			((t->matrix[0][1] == pixman_fixed_1 &&
+			 t->matrix[1][0] == -pixman_fixed_1) ||
+			(t->matrix[0][1] == -pixman_fixed_1 &&
+			 t->matrix[1][0] == pixman_fixed_1)) &&
+			has_suitable_filter_for_simple_rotate (image))
+	{
+	    /* 90 or 270 degrees rotation */
+	    flags |= FAST_PATH_SIMPLE_ROTATE_TRANSFORM;
+	}
 
-	if (image->common.transform->matrix[0][0] > 0)
+	if (t->matrix[0][0] > 0)
 	    flags |= FAST_PATH_X_UNIT_POSITIVE;
     }
 
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 8718fcb..d3f9a61 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -579,6 +579,7 @@ _pixman_choose_implementation (void);
 #define FAST_PATH_SAMPLES_COVER_CLIP		(1 << 16)
 #define FAST_PATH_16BIT_SAFE			(1 << 17)
 #define FAST_PATH_X_UNIT_POSITIVE		(1 << 18)
+#define FAST_PATH_SIMPLE_ROTATE_TRANSFORM	(1 << 19)
 
 #define _FAST_PATH_STANDARD_FLAGS					\
     (FAST_PATH_ID_TRANSFORM		|				\
-- 
1.6.4.4



More information about the Pixman mailing list