Improve the quality of color matrix filters by using SkPremultiplyARGBInline.
authorsenorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 3 Jan 2012 22:42:26 +0000 (22:42 +0000)
committersenorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 3 Jan 2012 22:42:26 +0000 (22:42 +0000)
This is closer (but not exactly the same as) WebKit's implementation.

Review URL:  http://codereview.appspot.com/5504117/

git-svn-id: http://skia.googlecode.com/svn/trunk@2955 2bbb7eff-a529-9590-31e7-b0007b416f81

src/effects/SkColorMatrixFilter.cpp

index 95f4b0bac4d3a325f8e78ad5adbeab60c7fbc5ab..8a4df66a389448d86454ea7da632b23a402bb5bb 100644 (file)
@@ -270,13 +270,7 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count,
         b = pin(result[2], SK_B32_MASK);
         a = pin(result[3], SK_A32_MASK);
         // re-prepremultiply if needed
-        if (255 != a) {
-            int scale = SkAlpha255To256(a);
-            r = SkAlphaMul(r, scale);
-            g = SkAlphaMul(g, scale);
-            b = SkAlphaMul(b, scale);
-        }
-        dst[i] = SkPackARGB32(a, r, g, b);
+        dst[i] = SkPremultiplyARGBInline(a, r, g, b);
     }
 }