From 8bf4e672f2c40ef313274f8b79c2c9304f9fff3f Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Mon, 17 Oct 2016 16:54:49 -0400 Subject: [PATCH] Use legacy color filter API when doing legacy paint conversion Matt fixed mode color filter so that the 4f filter uses a linearized version of the stored color. This restores previous behavior, where legacy devices are doing everything in sRGB space. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3581 Change-Id: I6abac176aaeab1242ca74b71ffb7f6df80ad9525 Reviewed-on: https://skia-review.googlesource.com/3581 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- src/gpu/SkGr.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 8f28d70..0eb9ee4 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -665,8 +665,15 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context, SkColorFilter* colorFilter = skPaint.getColorFilter(); if (colorFilter) { if (applyColorFilterToPaintColor) { - grPaint->setColor4f(GrColor4f::FromSkColor4f( - colorFilter->filterColor4f(origColor.toSkColor4f())).premul()); + // If we're in legacy mode, we *must* avoid using the 4f version of the color filter, + // because that will combine with the linearized version of the stored color. + if (dc->isGammaCorrect()) { + grPaint->setColor4f(GrColor4f::FromSkColor4f( + colorFilter->filterColor4f(origColor.toSkColor4f())).premul()); + } else { + grPaint->setColor4f(SkColorToPremulGrColor4f( + colorFilter->filterColor(skPaint.getColor()), false, nullptr)); + } } else { sk_sp cfFP(colorFilter->asFragmentProcessor(context)); if (cfFP) { -- 2.7.4