Simplify ColorFilter in the add-free case.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1938003002

Review-Url: https://codereview.chromium.org/1938003002
This commit is contained in:
djsollen 2016-05-02 09:45:43 -07:00 committed by Commit bot
parent 4b38938db8
commit 0be0a3bb99

View File

@ -17,6 +17,13 @@ static SkScalar byte_to_scale(U8CPU byte) {
}
sk_sp<SkColorFilter> SkColorMatrixFilter::MakeLightingFilter(SkColor mul, SkColor add) {
const SkColor opaqueAlphaMask = SK_ColorBLACK;
// omit the alpha and compare only the RGB values
if (0 == (add & ~opaqueAlphaMask)) {
return SkColorFilter::MakeModeFilter(mul | opaqueAlphaMask,
SkXfermode::Mode::kModulate_Mode);
}
SkColorMatrix matrix;
matrix.setScale(byte_to_scale(SkColorGetR(mul)),
byte_to_scale(SkColorGetG(mul)),