[PATCH] Optimization to reduce fetching calls in scaled up or =

Antoine Azar cairo at antoineazar.com
Wed Apr 23 18:33:48 PDT 2008


bilinear cases=0A=
=0A=
---=0A=
 pixman/pixman-transformed.c |  160 =
+++++++++++++++++++++++++++++++++----------=0A=
 1 files changed, 124 insertions(+), 36 deletions(-)=0A=
=0A=
diff --git a/pixman/pixman-transformed.c b/pixman/pixman-transformed.c=0A=
index e3ef17e..27927d9 100644=0A=
--- a/pixman/pixman-transformed.c=0A=
+++ b/pixman/pixman-transformed.c=0A=
@@ -70,6 +70,8 @@ fbFetchTransformed_Nearest_Normal(bits_image_t * pict, =
int width, uint32_t *buff=0A=
     fetchPixelProc   fetch;=0A=
     fetchFromRegionProc fetchFromRegion;=0A=
     int x, y, i;=0A=
+    int oldX =3D -2147483648;=0A=
+    int oldY =3D oldX;=0A=
 =0A=
     /* initialize the two function pointers */=0A=
     fetch =3D ACCESS(pixman_fetchPixelProcForPicture)(pict);=0A=
@@ -99,8 +101,18 @@ fbFetchTransformed_Nearest_Normal(bits_image_t * =
pict, int width, uint32_t *buff=0A=
                     y =3D MOD(v.vector[1]>>16, pict->height);=0A=
                     x =3D MOD(v.vector[0]>>16, pict->width);=0A=
                 }=0A=
+=0A=
+                if(x !=3D oldX || y !=3D oldY)=0A=
+                {=0A=
+                    oldX =3D x;=0A=
+                    oldY =3D y;=0A=
                 *(buffer + i) =3D fetchFromRegion(pict, x, y, buffer, =
fetch, box);=0A=
             }=0A=
+                else=0A=
+                {=0A=
+                    *(buffer + i) =3D *(buffer + i - 1);=0A=
+                }=0A=
+            }=0A=
         }=0A=
 =0A=
         v.vector[0] +=3D unit.vector[0];=0A=
@@ -116,6 +128,8 @@ fbFetchTransformed_Nearest_Pad(bits_image_t * pict, =
int width, uint32_t *buffer,=0A=
     fetchPixelProc   fetch;=0A=
     fetchFromRegionProc fetchFromRegion;=0A=
     int x, y, i;=0A=
+    int oldX =3D -2147483648;=0A=
+    int oldY =3D oldX;=0A=
 =0A=
     /* initialize the two function pointers */=0A=
     fetch =3D ACCESS(pixman_fetchPixelProcForPicture)(pict);=0A=
@@ -146,8 +160,17 @@ fbFetchTransformed_Nearest_Pad(bits_image_t * pict, =
int width, uint32_t *buffer,=0A=
                     x =3D CLIP(v.vector[0]>>16, 0, pict->width-1);=0A=
                 }=0A=
 =0A=
+                if(x !=3D oldX || y !=3D oldY)=0A=
+                {=0A=
+                    oldX =3D x;=0A=
+                    oldY =3D y;=0A=
                 *(buffer + i) =3D fetchFromRegion(pict, x, y, buffer, =
fetch, box);=0A=
             }=0A=
+                else=0A=
+                {=0A=
+                    *(buffer + i) =3D *(buffer + i - 1);=0A=
+                }=0A=
+            }=0A=
         }=0A=
 =0A=
         v.vector[0] +=3D unit.vector[0];=0A=
@@ -163,6 +186,8 @@ fbFetchTransformed_Nearest_General(bits_image_t * =
pict, int width, uint32_t *buf=0A=
     fetchPixelProc   fetch;=0A=
     fetchFromRegionProc fetchFromRegion;=0A=
     int x, y, i;=0A=
+    int oldX =3D -2147483648;=0A=
+    int oldY =3D oldX;=0A=
 =0A=
     /* initialize the two function pointers */=0A=
     fetch =3D ACCESS(pixman_fetchPixelProcForPicture)(pict);=0A=
@@ -190,8 +215,18 @@ fbFetchTransformed_Nearest_General(bits_image_t * =
pict, int width, uint32_t *buf=0A=
                     y =3D v.vector[1]>>16;=0A=
                     x =3D v.vector[0]>>16;=0A=
                 }=0A=
+=0A=
+                if(x !=3D oldX || y !=3D oldY)=0A=
+                {=0A=
+                    oldX =3D x;=0A=
+                    oldY =3D y;=0A=
                 *(buffer + i) =3D fetchFromRegion(pict, x, y, buffer, =
fetch, box);=0A=
             }=0A=
+                else=0A=
+                {=0A=
+                    *(buffer + i) =3D *(buffer + i - 1);=0A=
+                }=0A=
+            }=0A=
         }=0A=
         v.vector[0] +=3D unit.vector[0];=0A=
         v.vector[1] +=3D unit.vector[1];=0A=
@@ -205,7 +240,11 @@ fbFetchTransformed_Bilinear_Normal(bits_image_t * =
pict, int width, uint32_t *buf=0A=
     pixman_box16_t *box =3D NULL;=0A=
     fetchPixelProc   fetch;=0A=
     fetchFromRegionProc fetchFromRegion;=0A=
-    int i;=0A=
+    int i, j;=0A=
+    int oldX1 =3D -2147483648;=0A=
+    int oldY1 =3D oldX1;=0A=
+    uint32_t tl, tr, bl, br, r;=0A=
+    uint16_t tlVec[4], trVec[4], blVec[4], brVec[4];=0A=
 =0A=
     /* initialize the two function pointers */=0A=
     fetch =3D ACCESS(pixman_fetchPixelProcForPicture)(pict);=0A=
@@ -222,7 +261,6 @@ fbFetchTransformed_Bilinear_Normal(bits_image_t * =
pict, int width, uint32_t *buf=0A=
                 *(buffer + i) =3D 0;=0A=
             } else {=0A=
                 int x1, x2, y1, y2, distx, idistx, disty, idisty;=0A=
-                uint32_t tl, tr, bl, br, r;=0A=
                 uint32_t ft, fb;=0A=
 =0A=
                 if (!affine) {=0A=
@@ -239,12 +277,18 @@ fbFetchTransformed_Bilinear_Normal(bits_image_t * =
pict, int width, uint32_t *buf=0A=
                     y1 =3D v.vector[1] >> 16;=0A=
                     disty =3D (v.vector[1] >> 8) & 0xff;=0A=
                 }=0A=
-                x2 =3D x1 + 1;=0A=
-                y2 =3D y1 + 1;=0A=
 =0A=
                 idistx =3D 256 - distx;=0A=
                 idisty =3D 256 - disty;=0A=
 =0A=
+                if(x1 !=3D oldX1 || y1 !=3D oldY1)=0A=
+                {=0A=
+                    oldX1 =3D x1;=0A=
+                    oldY1 =3D y1;=0A=
+=0A=
+                    x2 =3D x1 + 1;=0A=
+                    y2 =3D y1 + 1;=0A=
+=0A=
                 x1 =3D MOD (x1, pict->width);=0A=
                 x2 =3D MOD (x2, pict->width);=0A=
                 y1 =3D MOD (y1, pict->height);=0A=
@@ -255,19 +299,29 @@ fbFetchTransformed_Bilinear_Normal(bits_image_t * =
pict, int width, uint32_t *buf=0A=
                 bl =3D fetchFromRegion(pict, x1, y2, buffer, fetch, =
box);=0A=
                 br =3D fetchFromRegion(pict, x2, y2, buffer, fetch, =
box);=0A=
 =0A=
-                ft =3D FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;=0A=
-                fb =3D FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;=0A=
+                    for(j =3D 0; j < 4; j++)=0A=
+                    {=0A=
+                        tlVec[j] =3D FbGet8(tl,j*8);=0A=
+                        trVec[j] =3D FbGet8(tr,j*8);=0A=
+                        blVec[j] =3D FbGet8(bl,j*8);=0A=
+                        brVec[j] =3D FbGet8(br,j*8);=0A=
+                    }=0A=
+                }=0A=
+=0A=
+                ft =3D tlVec[0] * idistx + trVec[0] * distx;=0A=
+                fb =3D blVec[0] * idistx + brVec[0] * distx;=0A=
                 r =3D (((ft * idisty + fb * disty) >> 16) & 0xff);=0A=
-                ft =3D FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;=0A=
-                fb =3D FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;=0A=
+                ft =3D tlVec[1] * idistx + trVec[1] * distx;=0A=
+                fb =3D blVec[1] * idistx + brVec[1] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty) >> 8) & 0xff00);=0A=
-                ft =3D FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;=0A=
-                fb =3D FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;=0A=
+                ft =3D tlVec[2] * idistx + trVec[2] * distx;=0A=
+                fb =3D blVec[2] * idistx + brVec[2] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty)) & 0xff0000);=0A=
-                ft =3D FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;=0A=
-                fb =3D FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;=0A=
+                ft =3D tlVec[3] * idistx + trVec[3] * distx;=0A=
+                fb =3D blVec[3] * idistx + brVec[3] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty) << 8) & 0xff000000);=0A=
                 *(buffer + i) =3D r;=0A=
+=0A=
             }=0A=
         }=0A=
         v.vector[0] +=3D unit.vector[0];=0A=
@@ -282,7 +336,11 @@ fbFetchTransformed_Bilinear_Pad(bits_image_t * =
pict, int width, uint32_t *buffer=0A=
     pixman_box16_t *box =3D NULL;=0A=
     fetchPixelProc   fetch;=0A=
     fetchFromRegionProc fetchFromRegion;=0A=
-    int i;=0A=
+    int i, j;=0A=
+    int oldX1 =3D -2147483648;=0A=
+    int oldY1 =3D oldX1;=0A=
+    uint32_t tl, tr, bl, br, r;=0A=
+    uint16_t tlVec[4], trVec[4], blVec[4], brVec[4];=0A=
 =0A=
     /* initialize the two function pointers */=0A=
     fetch =3D ACCESS(pixman_fetchPixelProcForPicture)(pict);=0A=
@@ -299,7 +357,6 @@ fbFetchTransformed_Bilinear_Pad(bits_image_t * pict, =
int width, uint32_t *buffer=0A=
                 *(buffer + i) =3D 0;=0A=
             } else {=0A=
                 int x1, x2, y1, y2, distx, idistx, disty, idisty;=0A=
-                uint32_t tl, tr, bl, br, r;=0A=
                 uint32_t ft, fb;=0A=
 =0A=
                 if (!affine) {=0A=
@@ -316,12 +373,15 @@ fbFetchTransformed_Bilinear_Pad(bits_image_t * =
pict, int width, uint32_t *buffer=0A=
                     y1 =3D v.vector[1] >> 16;=0A=
                     disty =3D (v.vector[1] >> 8) & 0xff;=0A=
                 }=0A=
-                x2 =3D x1 + 1;=0A=
-                y2 =3D y1 + 1;=0A=
 =0A=
                 idistx =3D 256 - distx;=0A=
                 idisty =3D 256 - disty;=0A=
 =0A=
+                if(x1 !=3D oldX1 || y1 !=3D oldY1)=0A=
+                {=0A=
+                    x2 =3D x1 + 1;=0A=
+                    y2 =3D y1 + 1;=0A=
+=0A=
                 x1 =3D CLIP (x1, 0, pict->width-1);=0A=
                 x2 =3D CLIP (x2, 0, pict->width-1);=0A=
                 y1 =3D CLIP (y1, 0, pict->height-1);=0A=
@@ -332,17 +392,26 @@ fbFetchTransformed_Bilinear_Pad(bits_image_t * =
pict, int width, uint32_t *buffer=0A=
                 bl =3D fetchFromRegion(pict, x1, y2, buffer, fetch, =
box);=0A=
                 br =3D fetchFromRegion(pict, x2, y2, buffer, fetch, =
box);=0A=
 =0A=
-                ft =3D FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;=0A=
-                fb =3D FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;=0A=
+                    for(j =3D 0; j < 4; j++)=0A=
+                    {=0A=
+                        tlVec[j] =3D FbGet8(tl,j*8);=0A=
+                        trVec[j] =3D FbGet8(tr,j*8);=0A=
+                        blVec[j] =3D FbGet8(bl,j*8);=0A=
+                        brVec[j] =3D FbGet8(br,j*8);=0A=
+                    }=0A=
+                }=0A=
+=0A=
+                ft =3D tlVec[0] * idistx + trVec[0] * distx;=0A=
+                fb =3D blVec[0] * idistx + brVec[0] * distx;=0A=
                 r =3D (((ft * idisty + fb * disty) >> 16) & 0xff);=0A=
-                ft =3D FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;=0A=
-                fb =3D FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;=0A=
+                ft =3D tlVec[1] * idistx + trVec[1] * distx;=0A=
+                fb =3D blVec[1] * idistx + brVec[1] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty) >> 8) & 0xff00);=0A=
-                ft =3D FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;=0A=
-                fb =3D FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;=0A=
+                ft =3D tlVec[2] * idistx + trVec[2] * distx;=0A=
+                fb =3D blVec[2] * idistx + brVec[2] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty)) & 0xff0000);=0A=
-                ft =3D FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;=0A=
-                fb =3D FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;=0A=
+                ft =3D tlVec[3] * idistx + trVec[3] * distx;=0A=
+                fb =3D blVec[3] * idistx + brVec[3] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty) << 8) & 0xff000000);=0A=
                 *(buffer + i) =3D r;=0A=
             }=0A=
@@ -359,7 +428,11 @@ fbFetchTransformed_Bilinear_General(bits_image_t * =
pict, int width, uint32_t *bu=0A=
     pixman_box16_t *box =3D NULL;=0A=
     fetchPixelProc   fetch;=0A=
     fetchFromRegionProc fetchFromRegion;=0A=
-    int i;=0A=
+    int i, j;=0A=
+    int oldX1 =3D -2147483648;=0A=
+    int oldY1 =3D oldX1;=0A=
+    uint32_t tl, tr, bl, br, r;=0A=
+    uint16_t tlVec[4], trVec[4], blVec[4], brVec[4];=0A=
 =0A=
     /* initialize the two function pointers */=0A=
     fetch =3D ACCESS(pixman_fetchPixelProcForPicture)(pict);=0A=
@@ -382,7 +455,6 @@ fbFetchTransformed_Bilinear_General(bits_image_t * =
pict, int width, uint32_t *bu=0A=
                 *(buffer + i) =3D 0;=0A=
             } else {=0A=
                 int x1, x2, y1, y2, distx, idistx, disty, idisty;=0A=
-                uint32_t tl, tr, bl, br, r;=0A=
                 uint32_t ft, fb;=0A=
 =0A=
                 if (!affine) {=0A=
@@ -399,28 +471,44 @@ fbFetchTransformed_Bilinear_General(bits_image_t * =
pict, int width, uint32_t *bu=0A=
                     y1 =3D v.vector[1] >> 16;=0A=
                     disty =3D (v.vector[1] >> 8) & 0xff;=0A=
                 }=0A=
-                x2 =3D x1 + 1;=0A=
-                y2 =3D y1 + 1;=0A=
 =0A=
                 idistx =3D 256 - distx;=0A=
                 idisty =3D 256 - disty;=0A=
 =0A=
+                if(x1 !=3D oldX1 || y1 !=3D oldY1)=0A=
+                {=0A=
+                    oldX1 =3D x1;=0A=
+                    oldY1 =3D y1;=0A=
+=0A=
+                    x2 =3D x1 + 1;=0A=
+                    y2 =3D y1 + 1;=0A=
+=0A=
                 tl =3D fetchFromRegion(pict, x1, y1, buffer, fetch, =
box);=0A=
                 tr =3D fetchFromRegion(pict, x2, y1, buffer, fetch, =
box);=0A=
                 bl =3D fetchFromRegion(pict, x1, y2, buffer, fetch, =
box);=0A=
                 br =3D fetchFromRegion(pict, x2, y2, buffer, fetch, =
box);=0A=
 =0A=
-                ft =3D FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;=0A=
-                fb =3D FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;=0A=
+                    for(j =3D 0; j < 4; j++)=0A=
+                    {=0A=
+                        tlVec[j] =3D FbGet8(tl,j*8);=0A=
+                        trVec[j] =3D FbGet8(tr,j*8);=0A=
+                        blVec[j] =3D FbGet8(bl,j*8);=0A=
+                        brVec[j] =3D FbGet8(br,j*8);=0A=
+                    }=0A=
+=0A=
+                }=0A=
+=0A=
+                ft =3D tlVec[0] * idistx + trVec[0] * distx;=0A=
+                fb =3D blVec[0] * idistx + brVec[0] * distx;=0A=
                 r =3D (((ft * idisty + fb * disty) >> 16) & 0xff);=0A=
-                ft =3D FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;=0A=
-                fb =3D FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;=0A=
+                ft =3D tlVec[1] * idistx + trVec[1] * distx;=0A=
+                fb =3D blVec[1] * idistx + brVec[1] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty) >> 8) & 0xff00);=0A=
-                ft =3D FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;=0A=
-                fb =3D FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;=0A=
+                ft =3D tlVec[2] * idistx + trVec[2] * distx;=0A=
+                fb =3D blVec[2] * idistx + brVec[2] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty)) & 0xff0000);=0A=
-                ft =3D FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;=0A=
-                fb =3D FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;=0A=
+                ft =3D tlVec[3] * idistx + trVec[3] * distx;=0A=
+                fb =3D blVec[3] * idistx + brVec[3] * distx;=0A=
                 r |=3D (((ft * idisty + fb * disty) << 8) & 0xff000000);=0A=
                 *(buffer + i) =3D r;=0A=
             }=0A=
-- =0A=
1.5.4.rc3.941.gebb79=0A=
=0A=

--Boundary_(ID_KPQ30WNncd0JJqg60P3FOQ)--


More information about the cairo mailing list