aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-01-27 12:05:27 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-27 17:48:08 +0000
commit00dca8cb09aaeca067cac022e97c4af31e656b37 (patch)
treeb70e85179fae8f5c1815131c8fbf8e8e5bae5715 /src/core
parenta6f6f77566f210788f83a531067f1b5222d2d33a (diff)
Remove SkBlitter:resetShaderContext()
Refactor SkDraw::drawVertices() to reset the whole blitter instead. No noticeable bench diff. out/Release/nanobench --config 8888 -m patch_grid_colors_tex Before: 9/9 MB 1 9.24ms 11.4ms 11.5ms 15ms 16% █▆▅▄▄▃▂▂▁▁ 8888 patch_grid_colors_texs_big 9/9 MB 1 5.2ms 5.2ms 5.2ms 5.21ms 0% █▃▂▁▂▂▃▂▂▁ 8888 patch_grid_colors_texs_medium 9/9 MB 2 378µs 380µs 380µs 382µs 0% █▆▅▄▄▁▄▄▆▄ 8888 patch_grid_colors_texs_small After: 9/9 MB 1 9.29ms 11.5ms 11.6ms 15.3ms 17% █▇▅▄▄▃▂▂▁▁ 8888 patch_grid_colors_texs_big 9/9 MB 1 5.15ms 5.16ms 5.16ms 5.18ms 0% █▄▁▁▄▂▁▂▃▂ 8888 patch_grid_colors_texs_medium 9/9 MB 2 378µs 380µs 380µs 382µs 0% █▅▄▃▁▄▄▄▃▄ 8888 patch_grid_colors_texs_small R=reed@google.com,mtklein@google.com,herb@google.com BUG=skia:6168 Change-Id: I0b6b7d1297323681d8d2838040450c4e1afabc17 Reviewed-on: https://skia-review.googlesource.com/7626 Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBlitter.cpp21
-rw-r--r--src/core/SkBlitter.h5
-rw-r--r--src/core/SkCoreBlitters.h7
-rw-r--r--src/core/SkDraw.cpp22
4 files changed, 15 insertions, 40 deletions
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index d3c60b7739..d8e3dfd664 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -25,10 +25,6 @@ SkBlitter::~SkBlitter() {}
bool SkBlitter::isNullBlitter() const { return false; }
-bool SkBlitter::resetShaderContext(const SkShader::ContextRec&) {
- return true;
-}
-
const SkPixmap* SkBlitter::justAnOpaqueColor(uint32_t* value) {
return nullptr;
}
@@ -1005,23 +1001,6 @@ SkShaderBlitter::~SkShaderBlitter() {
fShader->unref();
}
-bool SkShaderBlitter::resetShaderContext(const SkShader::ContextRec& rec) {
- // Only destroy the old context if we have a new one. We need to ensure to have a
- // live context in fShaderContext because the storage is owned by an SkSmallAllocator
- // outside of this class.
- // The new context will be of the same size as the old one because we use the same
- // shader to create it. It is therefore safe to re-use the storage.
- fShaderContext->~Context();
- SkShader::Context* ctx = fShader->createContext(rec, (void*)fShaderContext);
- if (nullptr == ctx) {
- // Need a valid context in fShaderContext's storage, so we can later (or our caller) call
- // the in-place destructor.
- new (fShaderContext) SkZeroShaderContext(*fShader, rec);
- return false;
- }
- return true;
-}
-
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef SK_DEBUG
diff --git a/src/core/SkBlitter.h b/src/core/SkBlitter.h
index ac4712ed48..cab2afc974 100644
--- a/src/core/SkBlitter.h
+++ b/src/core/SkBlitter.h
@@ -108,11 +108,6 @@ public:
virtual bool isNullBlitter() const;
/**
- * Special methods for SkShaderBlitter. On all other classes this is a no-op.
- */
- virtual bool resetShaderContext(const SkShader::ContextRec&);
-
- /**
* Special methods for blitters that can blit more than one row at a time.
* This function returns the number of rows that this blitter could optimally
* process at a time. It is still required to support blitting one scanline
diff --git a/src/core/SkCoreBlitters.h b/src/core/SkCoreBlitters.h
index 3ff1e1df18..62bf73e6a2 100644
--- a/src/core/SkCoreBlitters.h
+++ b/src/core/SkCoreBlitters.h
@@ -37,13 +37,6 @@ public:
SkShader::Context* shaderContext);
virtual ~SkShaderBlitter();
- /**
- * Create a new shader context and uses it instead of the old one if successful.
- * Will create the context at the same location as the old one (this is safe
- * because the shader itself is unchanged).
- */
- bool resetShaderContext(const SkShader::ContextRec&) override;
-
protected:
uint32_t fShaderFlags;
const SkShader* fShader;
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index f9f9a28aeb..d63abd3c88 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -15,6 +15,7 @@
#include "SkDeviceLooper.h"
#include "SkFindAndPlaceGlyph.h"
#include "SkFixed.h"
+#include "SkLocalMatrixShader.h"
#include "SkMaskFilter.h"
#include "SkMatrix.h"
#include "SkPaint.h"
@@ -24,7 +25,6 @@
#include "SkRRect.h"
#include "SkScan.h"
#include "SkShader.h"
-#include "SkSmallAllocator.h"
#include "SkString.h"
#include "SkStroke.h"
#include "SkStrokeRec.h"
@@ -1952,13 +1952,21 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
SkTriColorShader::TriColorShaderData verticesSetup = { vertices, colors, &state };
while (vertProc(&state)) {
+ auto* blitterPtr = blitter.get();
+
+ SkTLazy<SkLocalMatrixShader> localShader;
+ SkTLazy<SkAutoBlitterChoose> localBlitter;
+
if (textures) {
SkMatrix tempM;
if (texture_to_matrix(state, vertices, textures, &tempM)) {
- SkShader::ContextRec rec(p, *fMatrix, &tempM,
- SkBlitter::PreferredShaderDest(fDst.info()),
- fDst.colorSpace());
- if (!blitter->resetShaderContext(rec)) {
+ localShader.init(p.refShader(), tempM);
+
+ SkPaint localPaint(p);
+ localPaint.setShader(sk_ref_sp(localShader.get()));
+
+ blitterPtr = localBlitter.init(fDst, *fMatrix, localPaint)->get();
+ if (blitterPtr->isNullBlitter()) {
continue;
}
}
@@ -1970,8 +1978,8 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
SkPoint tmp[] = {
devVerts[state.f0], devVerts[state.f1], devVerts[state.f2]
};
- SkScan::FillTriangle(tmp, *fRC, blitter.get());
- triShader->bindSetupData(NULL);
+ SkScan::FillTriangle(tmp, *fRC, blitterPtr);
+ triShader->bindSetupData(nullptr);
}
} else {
// no colors[] and no texture, stroke hairlines with paint's color.