[Pixman] [PATCH 13/18] Linear: Optimize for horizontal gradients.

Søren Sandmann sandmann at cs.au.dk
Wed Jan 5 18:27:57 PST 2011


From: Søren Sandmann Pedersen <ssp at redhat.com>

If the gradient is horizontal, we can reuse the same scanline over and
over. Add support for this optimization to
_pixman_linear_gradient_iter_init().;
---
 pixman/pixman-linear-gradient.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/pixman/pixman-linear-gradient.c b/pixman/pixman-linear-gradient.c
index e0e6271..20be249 100644
--- a/pixman/pixman-linear-gradient.c
+++ b/pixman/pixman-linear-gradient.c
@@ -243,12 +243,26 @@ _pixman_linear_gradient_iter_init (pixman_image_t *image,
 				   uint8_t        *buffer,
 				   iter_flags_t    flags)
 {
-    if (flags & ITER_NARROW)
-	iter->get_scanline = linear_gradient_get_scanline_narrow;
+    if (linear_gradient_classify (image, x, y, width, height) ==
+	SOURCE_IMAGE_CLASS_HORIZONTAL)
+    {
+	if (flags & ITER_NARROW)
+	    linear_gradient_get_scanline_narrow (iter, NULL);
+	else
+	    linear_gradient_get_scanline_wide (iter, NULL);
+
+	iter->get_scanline = _pixman_iter_get_scanline_noop;
+	iter->next_line = _pixman_iter_next_line_noop;
+    }
     else
-	iter->get_scanline = linear_gradient_get_scanline_wide;
+    {
+	if (flags & ITER_NARROW)
+	    iter->get_scanline = linear_gradient_get_scanline_narrow;
+	else
+	    iter->get_scanline = linear_gradient_get_scanline_wide;
 
-    iter->next_line = _pixman_iter_next_line_regular;
+	iter->next_line = _pixman_iter_next_line_regular;
+    }
 }
 
 PIXMAN_EXPORT pixman_image_t *
-- 
1.6.0.6



More information about the Pixman mailing list