From 25834ffc5a4f6c45830dded7d5d135df157870e6 Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Wed, 15 Feb 2017 15:54:35 -0500 Subject: [PATCH] Use non-linear blending flag in raster pipeline blitter BUG=skia: Change-Id: I00b52e6de3b46b7d26c1df2aa63c521b6c7ece2d Reviewed-on: https://skia-review.googlesource.com/8526 Commit-Queue: Matt Sarett Reviewed-by: Brian Osman Reviewed-by: Mike Klein Reviewed-by: Mike Reed --- include/core/SkColorSpace.h | 5 +++-- src/core/SkBlitter.cpp | 2 +- src/core/SkColorSpace.cpp | 9 +++++---- src/core/SkCoreBlitters.h | 2 +- src/core/SkRasterPipelineBlitter.cpp | 11 +++++------ 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/core/SkColorSpace.h b/include/core/SkColorSpace.h index 86389f2..87ef0ce 100644 --- a/include/core/SkColorSpace.h +++ b/include/core/SkColorSpace.h @@ -91,10 +91,11 @@ public: * Transfer function can be specified as an enum or as the coefficients to an equation. * Gamut can be specified as an enum or as the matrix transformation to XYZ D50. */ - static sk_sp MakeRGB(RenderTargetGamma gamma, Gamut gamut); + static sk_sp MakeRGB(RenderTargetGamma gamma, Gamut gamut, uint32_t flags = 0); static sk_sp MakeRGB(RenderTargetGamma gamma, const SkMatrix44& toXYZD50, uint32_t flags = 0); - static sk_sp MakeRGB(const SkColorSpaceTransferFn& coeffs, Gamut gamut); + static sk_sp MakeRGB(const SkColorSpaceTransferFn& coeffs, Gamut gamut, + uint32_t flags = 0); static sk_sp MakeRGB(const SkColorSpaceTransferFn& coeffs, const SkMatrix44& toXYZD50, uint32_t flags = 0); diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index ec519bd..a386904 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -847,7 +847,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device, return alloc->make(device, *paint); } - if (SkBlitter* blitter = SkCreateRasterPipelineBlitter(device, *paint, matrix, alloc, true)) { + if (SkBlitter* blitter = SkCreateRasterPipelineBlitter(device, *paint, matrix, alloc)) { return blitter; } diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp index 80c5ac1..18eede3 100644 --- a/src/core/SkColorSpace.cpp +++ b/src/core/SkColorSpace.cpp @@ -189,16 +189,17 @@ sk_sp SkColorSpace::MakeRGB(const SkColorSpaceTransferFn& coeffs, std::move(gammas), toXYZD50, nullptr, flags)); } -sk_sp SkColorSpace::MakeRGB(RenderTargetGamma gamma, Gamut gamut) { +sk_sp SkColorSpace::MakeRGB(RenderTargetGamma gamma, Gamut gamut, uint32_t flags) { SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor); to_xyz_d50(&toXYZD50, gamut); - return SkColorSpace::MakeRGB(gamma, toXYZD50); + return SkColorSpace::MakeRGB(gamma, toXYZD50, flags); } -sk_sp SkColorSpace::MakeRGB(const SkColorSpaceTransferFn& coeffs, Gamut gamut) { +sk_sp SkColorSpace::MakeRGB(const SkColorSpaceTransferFn& coeffs, Gamut gamut, + uint32_t flags) { SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor); to_xyz_d50(&toXYZD50, gamut); - return SkColorSpace::MakeRGB(coeffs, toXYZD50); + return SkColorSpace::MakeRGB(coeffs, toXYZD50, flags); } static SkColorSpace* gAdobeRGB; diff --git a/src/core/SkCoreBlitters.h b/src/core/SkCoreBlitters.h index e3256d4..85392dd 100644 --- a/src/core/SkCoreBlitters.h +++ b/src/core/SkCoreBlitters.h @@ -204,6 +204,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*, bool blendCorrectly); + SkArenaAlloc*); #endif diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp index 273f5fe..a994de3 100644 --- a/src/core/SkRasterPipelineBlitter.cpp +++ b/src/core/SkRasterPipelineBlitter.cpp @@ -21,7 +21,7 @@ class SkRasterPipelineBlitter : public SkBlitter { public: static SkBlitter* Create(const SkPixmap&, const SkPaint&, const SkMatrix& ctm, - SkArenaAlloc*, bool blendCorrectly); + SkArenaAlloc*); SkRasterPipelineBlitter(SkPixmap dst, SkBlendMode blend, SkPM4f paintColor, bool blendCorrectly) : fDst(dst) @@ -69,9 +69,8 @@ private: SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap& dst, const SkPaint& paint, const SkMatrix& ctm, - SkArenaAlloc* alloc, - bool blendCorrectly) { - return SkRasterPipelineBlitter::Create(dst, paint, ctm, alloc, blendCorrectly); + SkArenaAlloc* alloc) { + return SkRasterPipelineBlitter::Create(dst, paint, ctm, alloc); } static bool supported(const SkImageInfo& info) { @@ -87,8 +86,8 @@ static bool supported(const SkImageInfo& info) { SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst, const SkPaint& paint, const SkMatrix& ctm, - SkArenaAlloc* alloc, - bool blendCorrectly) { + SkArenaAlloc* alloc) { + bool blendCorrectly = !(dst.colorSpace() && as_CSB(dst.colorSpace())->nonLinearBlending()); auto blitter = alloc->make( dst, paint.getBlendMode(), -- 2.7.4