evas - improve speed of unpremul with redundant pixel data
authorMatvey Konovalov <m.konovalov@samsung.com>
Tue, 15 Apr 2014 10:22:33 +0000 (19:22 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 15 Apr 2014 10:22:58 +0000 (19:22 +0900)
src/lib/evas/common/evas_convert_color.c

index 3399443e447d3ff3439ed64f61fb1b288695f664..e8a6b7254acc3c2e0a511f03e8b989755b8821fe 100644 (file)
@@ -47,17 +47,26 @@ evas_common_convert_argb_premul(DATA32 *data, unsigned int len)
 EAPI void
 evas_common_convert_argb_unpremul(DATA32 *data, unsigned int len)
 {
-   DATA32  *de = data + len;
+   DATA32 *de = data + len;
+   DATA32 p_val = 0x00000000, p_res = 0x00000000;
 
    while (data < de)
      {
-       DATA32  a = (*data >> 24);
-
-       if ((a > 0) && (a < 255))
-          *data = ARGB_JOIN(a,
-                            (R_VAL(data) * 255) / a,
-                            (G_VAL(data) * 255) / a,
-                            (B_VAL(data) * 255) / a);
+       DATA32  a = (*data >> 24) + 1;
+
+        if (p_val == *data) *data = p_res;
+        else
+          {
+             p_val = *data;
+             if ((a > 1) && (a < 256))
+               *data = ARGB_JOIN(a,
+                                 (R_VAL(data) * 255) / a,
+                                 (G_VAL(data) * 255) / a,
+                                 (B_VAL(data) * 255) / a);
+             else if (a == 1)
+               *data = 0x00000000;
+             p_res = *data;
+          }
        data++;
      }