aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/batches
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2016-03-16 10:25:58 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-16 10:25:58 -0700
commitaf1e21e7ebb155d2505da0eb974c672953dfefef (patch)
tree6e1fa6b73fd0f559cdb19b05163c3d86c2c49533 /src/gpu/batches
parent3eac8d1b230090e96a408c38b853067860df5f20 (diff)
GrTessellator: don't reuse the previous vertex buffer on a cache miss.
Just let the cache give us the correct entry for the given size. This simplifies the code (no mysterious non-const ref member). I don't see any performance effect from this change, but will watch the bots closely. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1800623002 Review URL: https://codereview.chromium.org/1800623002
Diffstat (limited to 'src/gpu/batches')
-rw-r--r--src/gpu/batches/GrTessellatingPathRenderer.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp
index 85c2ca0738..06f31cd8db 100644
--- a/src/gpu/batches/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp
@@ -61,20 +61,15 @@ bool cache_match(GrVertexBuffer* vertexBuffer, SkScalar tol, int* actualCount) {
class StaticVertexAllocator : public GrTessellator::VertexAllocator {
public:
- StaticVertexAllocator(SkAutoTUnref<GrVertexBuffer>& vertexBuffer,
- GrResourceProvider* resourceProvider,
- bool canMapVB)
- : fVertexBuffer(vertexBuffer)
- , fResourceProvider(resourceProvider)
+ StaticVertexAllocator(GrResourceProvider* resourceProvider, bool canMapVB)
+ : fResourceProvider(resourceProvider)
, fCanMapVB(canMapVB)
, fVertices(nullptr) {
}
SkPoint* lock(int vertexCount) override {
size_t size = vertexCount * sizeof(SkPoint);
- if (!fVertexBuffer.get() || fVertexBuffer->gpuMemorySize() < size) {
- fVertexBuffer.reset(fResourceProvider->createVertexBuffer(
- size, GrResourceProvider::kStatic_BufferUsage, 0));
- }
+ fVertexBuffer.reset(fResourceProvider->createVertexBuffer(
+ size, GrResourceProvider::kStatic_BufferUsage, 0));
if (!fVertexBuffer.get()) {
return nullptr;
}
@@ -94,8 +89,9 @@ public:
}
fVertices = nullptr;
}
+ GrVertexBuffer* vertexBuffer() { return fVertexBuffer.get(); }
private:
- SkAutoTUnref<GrVertexBuffer>& fVertexBuffer;
+ SkAutoTUnref<GrVertexBuffer> fVertexBuffer;
GrResourceProvider* fResourceProvider;
bool fCanMapVB;
SkPoint* fVertices;
@@ -162,13 +158,14 @@ private:
fStroke.asUniqueKeyFragment(&builder[2 + clipBoundsSize32]);
builder.finish();
GrResourceProvider* rp = target->resourceProvider();
- SkAutoTUnref<GrVertexBuffer> vertexBuffer(rp->findAndRefTByUniqueKey<GrVertexBuffer>(key));
+ SkAutoTUnref<GrVertexBuffer> cachedVertexBuffer(
+ rp->findAndRefTByUniqueKey<GrVertexBuffer>(key));
int actualCount;
SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance;
SkScalar tol = GrPathUtils::scaleToleranceToSrc(
screenSpaceTol, fViewMatrix, fPath.getBounds());
- if (cache_match(vertexBuffer.get(), tol, &actualCount)) {
- this->drawVertices(target, gp, vertexBuffer.get(), 0, actualCount);
+ if (cache_match(cachedVertexBuffer.get(), tol, &actualCount)) {
+ this->drawVertices(target, gp, cachedVertexBuffer.get(), 0, actualCount);
return;
}
@@ -190,19 +187,19 @@ private:
}
bool isLinear;
bool canMapVB = GrCaps::kNone_MapFlags != target->caps().mapBufferFlags();
- StaticVertexAllocator allocator(vertexBuffer, target->resourceProvider(), canMapVB);
+ StaticVertexAllocator allocator(rp, canMapVB);
int count = GrTessellator::PathToTriangles(path, tol, fClipBounds, &allocator, &isLinear);
if (count == 0) {
return;
}
- this->drawVertices(target, gp, vertexBuffer.get(), 0, count);
+ this->drawVertices(target, gp, allocator.vertexBuffer(), 0, count);
if (!fPath.isVolatile()) {
TessInfo info;
info.fTolerance = isLinear ? 0 : tol;
info.fCount = count;
SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info)));
key.setCustomData(data.get());
- target->resourceProvider()->assignUniqueKeyToResource(key, vertexBuffer.get());
+ rp->assignUniqueKeyToResource(key, allocator.vertexBuffer());
SkPathPriv::AddGenIDChangeListener(fPath, new PathInvalidator(key));
}
}