diff options
Diffstat (limited to 'src/core')
-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) { |