[Pixman] [PATCH] bits: optimise fetching width==1 repeats

Chris Wilson chris at chris-wilson.co.uk
Sat Aug 20 05:47:53 PDT 2011


Profiling ign.com, 20% of the entire render time was absorbed in this
single operation:

<< /content //COLOR_ALPHA /width 480 /height 800 >> surface context
<< /width 1 /height 677 /format //ARGB32 /source <|!!!@jGb!m5gD']#$jFHGWtZcK&2i)Up=!TuR9`G<8;ZQp[FQk;emL9ibhbEL&NTh-j63LhHo$E=mSG,0p71`cRJHcget4%<S\X+~> >> image pattern
  //EXTEND_REPEAT set-extend
  set-source
n 0 0 480 677 rectangle
fill+
pop

which is a simple composition of a single pixel wide image. Sadly this
is a workaround for lack of independent repeat-x/y handling in cairo and
pixman. Worse still is that this is the worst-case behaviour of the
general repeat path is for width 1 images...

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 pixman/pixman-bits-image.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 4e9ed14..a762c27 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -1149,7 +1149,34 @@ bits_image_fetch_untransformed_repeat_normal (bits_image_t *image,
     while (y >= image->height)
 	y -= image->height;
 
-    while (width)
+    if (image->width == 1)
+    {
+	    /* XXX duplication from fetch solid */
+	    if (wide)
+	    {
+		    uint64_t color;
+		    uint64_t *b = (uint64_t *)buffer;
+		    uint64_t *end;
+
+		    color = image->fetch_pixel_64 (image, 0, y);
+
+		    end = b + width;
+		    while (b < end)
+			    *(b++) = color;
+	    }
+	    else
+	    {
+		    uint32_t color;
+		    uint32_t *end;
+
+		    color = image->fetch_pixel_32 (image, 0, y);
+
+		    end = buffer + width;
+		    while (buffer < end)
+			    *(buffer++) = color;
+	    }
+    }
+    else while (width)
     {
 	while (x < 0)
 	    x += image->width;
-- 
1.7.5.4



More information about the Pixman mailing list