Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: src/core/SkBlitter.cpp

Issue 1724503002: Add dest type hint to SkShader::ContextRec (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBlitter.h ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBlitter.cpp
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index 804bc813d6054a64b75407d1a590288571968733..c7c903dc6bcff4e2a305c13911abb7bda8a1bc58 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -789,6 +789,16 @@ private:
#include "SkCoreBlitters.h"
+SkShader::ContextRec::DstType SkBlitter::PreferredShaderDest(const SkImageInfo& dstInfo) {
+#ifdef SK_FORCE_PM4f_FOR_L32_BLITS
+ return SkShader::ContextRec::kPM4f_DstType;
+#else
+ return (dstInfo.isSRGB() || dstInfo.colorType() == kRGBA_F16_SkColorType)
+ ? SkShader::ContextRec::kPM4f_DstType
+ : SkShader::ContextRec::kPMColor_DstType;
+#endif
+}
+
SkBlitter* SkBlitter::Choose(const SkPixmap& device,
const SkMatrix& matrix,
const SkPaint& origPaint,
@@ -875,7 +885,8 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
*/
SkShader::Context* shaderContext = nullptr;
if (shader) {
- SkShader::ContextRec rec(*paint, matrix, nullptr);
+ const SkShader::ContextRec rec(*paint, matrix, nullptr,
+ PreferredShaderDest(device.info()));
size_t contextSize = shader->contextSize(rec);
if (contextSize) {
// Try to create the ShaderContext
@@ -961,7 +972,8 @@ class SkZeroShaderContext : public SkShader::Context {
public:
SkZeroShaderContext(const SkShader& shader, const SkShader::ContextRec& rec)
// Override rec with the identity matrix, so it is guaranteed to be invertible.
- : INHERITED(shader, SkShader::ContextRec(*rec.fPaint, SkMatrix::I(), nullptr)) {}
+ : INHERITED(shader, SkShader::ContextRec(*rec.fPaint, SkMatrix::I(), nullptr,
+ rec.fPreferredDstType)) {}
void shadeSpan(int x, int y, SkPMColor colors[], int count) override {
sk_bzero(colors, count * sizeof(SkPMColor));
« no previous file with comments | « src/core/SkBlitter.h ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698