diff options
author | Brian Osman <brianosman@google.com> | 2017-04-12 17:07:22 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-13 13:57:50 +0000 |
commit | 2d2da4f9ee4932720c71348d0aff0cd75ebd956b (patch) | |
tree | 8f797504fd8638ae492dd4745042a8edd3c6283a /src | |
parent | 59163ba06c42e2bb2e7c87c8f3564f0bfd9df327 (diff) |
Do sRGB premul/unpremul on the GPU
Previously, the early check would decide that sRGB pixel configs were okay
(because they're 8888-unorm). Then we'd go to make the effect and decide
that we didn't want them to work. This led to the software fallback.
The software fallback was obviously slower, but also doing non-linear
premul/unpremul operations. Eventually, whether or not the premul is
linear should be dictated by the destination color space, but for now,
this is an improvement (and only affects the one GM that tests this
feature).
Bug: skia:
Change-Id: I0cf1ad5a7f552135ac1da728c6db2977652a433b
Reviewed-on: https://skia-review.googlesource.com/13321
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrContext.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 31f1787d56..7ea4abd0c0 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -919,16 +919,20 @@ sk_sp<GrFragmentProcessor> GrContext::createPMToUPMEffect(sk_sp<GrFragmentProces ASSERT_SINGLE_OWNER // We should have already called this->testPMConversionsIfNecessary(). SkASSERT(fDidTestPMConversions); - if (kRGBA_half_GrPixelConfig == config) { - return GrFragmentProcessor::UnpremulOutput(std::move(fp)); - } else if (kRGBA_8888_GrPixelConfig == config || kBGRA_8888_GrPixelConfig == config) { + // We have specialized effects that guarantee round-trip conversion for these formats + if (kRGBA_8888_GrPixelConfig == config || kBGRA_8888_GrPixelConfig == config) { GrConfigConversionEffect::PMConversion pmToUPM = static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion); if (GrConfigConversionEffect::kPMConversionCnt != pmToUPM) { return GrConfigConversionEffect::Make(std::move(fp), pmToUPM); + } else { + return nullptr; } + } else { + // For everything else (sRGB, half-float, etc...), it doesn't make sense to try and + // explicitly round the results. Just do the obvious, naive thing in the shader. + return GrFragmentProcessor::UnpremulOutput(std::move(fp)); } - return nullptr; } sk_sp<GrFragmentProcessor> GrContext::createUPMToPMEffect(sk_sp<GrFragmentProcessor> fp, @@ -936,16 +940,20 @@ sk_sp<GrFragmentProcessor> GrContext::createUPMToPMEffect(sk_sp<GrFragmentProces ASSERT_SINGLE_OWNER // We should have already called this->testPMConversionsIfNecessary(). SkASSERT(fDidTestPMConversions); - if (kRGBA_half_GrPixelConfig == config) { - return GrFragmentProcessor::PremulOutput(std::move(fp)); - } else if (kRGBA_8888_GrPixelConfig == config || kBGRA_8888_GrPixelConfig == config) { + // We have specialized effects that guarantee round-trip conversion for these formats + if (kRGBA_8888_GrPixelConfig == config || kBGRA_8888_GrPixelConfig == config) { GrConfigConversionEffect::PMConversion upmToPM = static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion); if (GrConfigConversionEffect::kPMConversionCnt != upmToPM) { return GrConfigConversionEffect::Make(std::move(fp), upmToPM); + } else { + return nullptr; } + } else { + // For everything else (sRGB, half-float, etc...), it doesn't make sense to try and + // explicitly round the results. Just do the obvious, naive thing in the shader. + return GrFragmentProcessor::PremulOutput(std::move(fp)); } - return nullptr; } bool GrContext::validPMUPMConversionExists(GrPixelConfig config) const { |