diff options
author | Mike Klein <mtklein@chromium.org> | 2017-02-07 11:57:27 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-08 15:38:49 +0000 |
commit | 688ded2ee6c3472986eec2122830667378697577 (patch) | |
tree | 05be1745a9f4f01ad566824c183b294adbc1f1de /src | |
parent | f5759936865d73de3ef715ea228e7dd22eb2dfda (diff) |
Add a blend-wrong mode to SkRasterPipelineBlitter.
This keeps correct linear blending as the only option exericsed,
but it should be easy to see how to turn on blend-wrong mode.
Change-Id: I7d87ef8ed00e8990107bd36b826f8d229d930400
Reviewed-on: https://skia-review.googlesource.com/8125
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBlitter.cpp | 2 | ||||
-rw-r--r-- | src/core/SkCoreBlitters.h | 2 | ||||
-rw-r--r-- | src/core/SkRasterPipelineBlitter.cpp | 24 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index a386904dcd..ec519bdeea 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -847,7 +847,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device, return alloc->make<SkA8_Coverage_Blitter>(device, *paint); } - if (SkBlitter* blitter = SkCreateRasterPipelineBlitter(device, *paint, matrix, alloc)) { + if (SkBlitter* blitter = SkCreateRasterPipelineBlitter(device, *paint, matrix, alloc, true)) { return blitter; } diff --git a/src/core/SkCoreBlitters.h b/src/core/SkCoreBlitters.h index 63ddda9b13..42366cc4b6 100644 --- a/src/core/SkCoreBlitters.h +++ b/src/core/SkCoreBlitters.h @@ -205,6 +205,6 @@ SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint, // Returns nullptr if no SkRasterPipeline blitter can be constructed for this paint. SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap&, const SkPaint&, const SkMatrix& ctm, - SkArenaAlloc*); + SkArenaAlloc*, bool blendCorrectly); #endif diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp index 1a00009734..80e63449a1 100644 --- a/src/core/SkRasterPipelineBlitter.cpp +++ b/src/core/SkRasterPipelineBlitter.cpp @@ -21,12 +21,13 @@ class SkRasterPipelineBlitter : public SkBlitter { public: static SkBlitter* Create(const SkPixmap&, const SkPaint&, const SkMatrix& ctm, - SkArenaAlloc*); + SkArenaAlloc*, bool blendCorrectly); - SkRasterPipelineBlitter(SkPixmap dst, SkBlendMode blend, SkPM4f paintColor) + SkRasterPipelineBlitter(SkPixmap dst, SkBlendMode blend, SkPM4f paintColor, bool blendCorrectly) : fDst(dst) , fBlend(blend) , fPaintColor(paintColor) + , fBlendCorrectly(blendCorrectly) {} void blitH (int x, int y, int w) override; @@ -47,6 +48,7 @@ private: SkBlendMode fBlend; SkPM4f fPaintColor; SkRasterPipeline fShader; + bool fBlendCorrectly; // These functions are compiled lazily when first used. std::function<void(size_t, size_t)> fBlitH = nullptr, @@ -71,8 +73,9 @@ private: SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap& dst, const SkPaint& paint, const SkMatrix& ctm, - SkArenaAlloc* alloc) { - return SkRasterPipelineBlitter::Create(dst, paint, ctm, alloc); + SkArenaAlloc* alloc, + bool blendCorrectly) { + return SkRasterPipelineBlitter::Create(dst, paint, ctm, alloc, blendCorrectly); } static bool supported(const SkImageInfo& info) { @@ -88,11 +91,13 @@ static bool supported(const SkImageInfo& info) { SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst, const SkPaint& paint, const SkMatrix& ctm, - SkArenaAlloc* alloc) { + SkArenaAlloc* alloc, + bool blendCorrectly) { auto blitter = alloc->make<SkRasterPipelineBlitter>( dst, paint.getBlendMode(), - SkPM4f_from_SkColor(paint.getColor(), dst.colorSpace())); + SkPM4f_from_SkColor(paint.getColor(), dst.colorSpace()), + blendCorrectly); SkBlendMode* blend = &blitter->fBlend; @@ -126,6 +131,11 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst, pipeline->append(SkRasterPipeline::constant_color, paintColor); } + // Some people want the rest of the pipeline to operate on sRGB encoded color channels... + if (!blendCorrectly && dst.info().gammaCloseToSRGB()) { + pipeline->append(SkRasterPipeline::to_srgb); + } + if (colorFilter) { if (!colorFilter->appendStages(pipeline, dst.colorSpace(), &blitter->fArena, is_opaque)) { @@ -201,7 +211,7 @@ void SkRasterPipelineBlitter::append_load_d(SkRasterPipeline* p) const { } void SkRasterPipelineBlitter::append_store(SkRasterPipeline* p) const { - if (fDst.info().gammaCloseToSRGB()) { + if (fBlendCorrectly && fDst.info().gammaCloseToSRGB()) { p->append(SkRasterPipeline::to_srgb); } if (fDst.info().colorType() == kBGRA_8888_SkColorType) { |