From df7bb17b1bbba7b956d9ffb464a790d039ef2c6a Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Thu, 12 Jul 2018 13:53:35 -0400 Subject: Reland "update SkToSRGBColorFilter color management" This is a reland of 8b5092671b1d0802e88b5202f67ceb94c9e5d236 Original change's description: > update SkToSRGBColorFilter color management > > Change-Id: Ia4a8bbc9d983bb5cfa02ba62c922efa1fa879d9b > Reviewed-on: https://skia-review.googlesource.com/141054 > Commit-Queue: Mike Klein > Reviewed-by: Brian Osman Change-Id: Ide55dd34a701a518be11856ecffbacf30954dc64 Reviewed-on: https://skia-review.googlesource.com/143321 Commit-Queue: Mike Klein Reviewed-by: Mike Klein --- src/effects/SkToSRGBColorFilter.cpp | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/effects/SkToSRGBColorFilter.cpp b/src/effects/SkToSRGBColorFilter.cpp index ba01c6b2c4..0bfa40b1d3 100644 --- a/src/effects/SkToSRGBColorFilter.cpp +++ b/src/effects/SkToSRGBColorFilter.cpp @@ -5,6 +5,7 @@ * found in the LICENSE file. */ +#include "SkColorSpaceXformSteps.h" #include "SkPM4fPriv.h" #include "SkRasterPipeline.h" #include "SkReadBuffer.h" @@ -20,30 +21,9 @@ void SkToSRGBColorFilter::onAppendStages(SkRasterPipeline* p, SkColorSpace* /*dst color space*/, SkArenaAlloc* alloc, bool shaderIsOpaque) const { - // Step 1: Linearize by undoing the src transfer function. - // Linear and sRGB will return true to isNumericalTransferFn(), so we check them first. - SkColorSpaceTransferFn srcFn; - if (fSrcColorSpace->gammaIsLinear()) { - // Nothing to do. - } else if (fSrcColorSpace->gammaCloseToSRGB()) { - p->append(SkRasterPipeline::from_srgb); - } else if (fSrcColorSpace->isNumericalTransferFn(&srcFn)) { - auto copy = alloc->make(srcFn); - p->append(SkRasterPipeline::parametric, copy); - } else { - SkDEBUGFAIL("Looks like we got a table transfer function here, quite unexpectedly."); - // TODO: If we really need to handle this, we can, but I don't think Ganesh does. - } - - // Step 2: Transform to sRGB gamut (without clamping). - append_gamut_transform(p, - alloc, - fSrcColorSpace.get(), - SkColorSpace::MakeSRGB().get(), - kPremul_SkAlphaType); - - // Step 3: Back to sRGB encoding. - p->append(SkRasterPipeline::to_srgb); + alloc->make(fSrcColorSpace.get(), kPremul_SkAlphaType, + SkColorSpace::MakeSRGB().get()) + ->apply(p); } sk_sp SkToSRGBColorFilter::Make(sk_sp srcColorSpace) { -- cgit v1.2.3