diff options
author | Mike Klein <mtklein@chromium.org> | 2016-12-14 13:38:24 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-14 13:38:41 +0000 |
commit | d37d5d96493604c12cfaa2d64bcbd32c41b01f3b (patch) | |
tree | 3de3ad9a4a08194c75314b07736170a7150fb5f2 /src/core/SkRasterPipeline.cpp | |
parent | 65115a1b1a5c72b47492dc447d1d282353ae3121 (diff) |
Revert "Revert "clamp to premul when reading premul sRGB""
This reverts commit 2e018f548d76b0688f9873c683cffc681fec40ec.
Reason for revert: doesn't appear to have been the roll problem.
Original change's description:
> Revert "clamp to premul when reading premul sRGB"
>
> This reverts commit 04e10da8362a0dcabd795a4ad53f617719ca0d20.
>
> Reason for revert: roll?
>
> Change-Id: Id0a8dcd62763bd6eddde120c513ca97e098a4268
> Reviewed-on: https://skia-review.googlesource.com/6022
> Commit-Queue: Mike Klein <mtklein@chromium.org>
> Reviewed-by: Mike Klein <mtklein@chromium.org>
>
TBR=mtklein@chromium.org,reviews@skia.org,brianosman@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I399ca5e728ce6766c6707682c4c6b685681ffdeb
Reviewed-on: https://skia-review.googlesource.com/6025
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkRasterPipeline.cpp')
-rw-r--r-- | src/core/SkRasterPipeline.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp index 4c1dbc762e..00ba81e6f3 100644 --- a/src/core/SkRasterPipeline.cpp +++ b/src/core/SkRasterPipeline.cpp @@ -11,6 +11,14 @@ SkRasterPipeline::SkRasterPipeline() {} void SkRasterPipeline::append(StockStage stage, void* ctx) { +#ifdef SK_DEBUG + switch (stage) { + case from_srgb: + case from_srgb_d: + SkDEBUGFAIL("Please use append_srgb[_d]() instead."); + default: break; + } +#endif fStages.push_back({stage, ctx}); } @@ -42,3 +50,29 @@ void SkRasterPipeline::dump() const { } SkDebugf("\n"); } + +// It's pretty easy to start with sound premultiplied linear floats, pack those +// to sRGB encoded bytes, then read them back to linear floats and find them not +// quite premultiplied, with a color channel just a smidge greater than the alpha +// channel. This can happen basically any time we have different transfer +// functions for alpha and colors... sRGB being the only one we draw into. + +// This is an annoying problem with no known good solution. So apply the clamp hammer. + +void SkRasterPipeline::append_from_srgb(SkAlphaType at) { + //this->append(from_srgb); + fStages.push_back({from_srgb, nullptr}); + + if (at == kPremul_SkAlphaType) { + this->append(SkRasterPipeline::clamp_a); + } +} + +void SkRasterPipeline::append_from_srgb_d(SkAlphaType at) { + //this->append(from_srgb_d); + fStages.push_back({from_srgb_d, nullptr}); + + if (at == kPremul_SkAlphaType) { + this->append(SkRasterPipeline::clamp_a_d); + } +} |