aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-02-22 17:19:04 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-22 17:19:04 -0800
commitd0c4e092d54d281991ecfdc2e4ddd5217e45b42a (patch)
treeb7410292954a9f95bef49d7668adb8d82a07e0f8 /src
parent888934723db64ebecb0d6e577ba7b70689d83dd2 (diff)
Add dest type hint to SkShader::ContextRec
Let SkBlitter decide which dst type is optimal (PMColor vs PM4f), and pass that info to shaders. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1724503002 Review URL: https://codereview.chromium.org/1724503002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBlitter.cpp16
-rw-r--r--src/core/SkBlitter.h2
-rw-r--r--src/core/SkDraw.cpp3
3 files changed, 18 insertions, 3 deletions
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index 804bc813d6..c7c903dc6b 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));
diff --git a/src/core/SkBlitter.h b/src/core/SkBlitter.h
index 5740a5eaed..8711f1a10f 100644
--- a/src/core/SkBlitter.h
+++ b/src/core/SkBlitter.h
@@ -137,6 +137,8 @@ public:
SkTBlitterAllocator*);
///@}
+ static SkShader::ContextRec::DstType PreferredShaderDest(const SkImageInfo&);
+
protected:
SkAutoMalloc fBlitMemory;
};
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index b041df8f7a..0c17c94884 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1896,7 +1896,8 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
if (textures) {
SkMatrix tempM;
if (texture_to_matrix(state, vertices, textures, &tempM)) {
- SkShader::ContextRec rec(p, *fMatrix, &tempM);
+ SkShader::ContextRec rec(p, *fMatrix, &tempM,
+ SkBlitter::PreferredShaderDest(fDst.info()));
if (!blitter->resetShaderContext(rec)) {
continue;
}