Merge "Handle premultiplication correctly for ColorMatrixColorFilters" into lmp-dev

This commit is contained in:
Chris Craik
2014-09-17 17:01:34 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 1 deletions

View File

@@ -327,8 +327,10 @@ const char* gFS_Main_ApplyColorOp[3] = {
// None
"",
// Matrix
" fragColor.rgb /= (fragColor.a + 0.0019);\n" // un-premultiply
" fragColor *= colorMatrix;\n"
" fragColor += colorMatrixVector;\n",
" fragColor += colorMatrixVector;\n"
" fragColor.rgb *= (fragColor.a + 0.0019);\n", // re-premultiply
// PorterDuff
" fragColor = blendColors(colorBlend, fragColor);\n"
};

View File

@@ -70,6 +70,7 @@ public:
// TODO: move to a method on android:Paint
static inline bool paintWillNotDraw(const SkPaint& paint) {
return paint.getAlpha() == 0
&& !paint.getColorFilter()
&& getXfermode(paint.getXfermode()) != SkXfermode::kClear_Mode;
}
@@ -77,6 +78,7 @@ public:
static inline bool paintWillNotDrawText(const SkPaint& paint) {
return paint.getAlpha() == 0
&& paint.getLooper() == NULL
&& !paint.getColorFilter()
&& getXfermode(paint.getXfermode()) == SkXfermode::kSrcOver_Mode;
}
// ----------------------------------------------------------------------------