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

Unified Diff: src/gpu/GrAADistanceFieldPathRenderer.cpp

Issue 1116943004: Move instanced index buffer creation to flush time (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix missing assignment of keys to index buffers Created 5 years, 8 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 | « include/gpu/GrTextureProvider.h ('k') | src/gpu/GrAAHairLinePathRenderer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAADistanceFieldPathRenderer.cpp
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index 669ec09d97ae02ab629204199a5f22fc38500390..ca8c52fa348289ad62ad95f0d530c46857f55db0 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -15,6 +15,7 @@
#include "GrPipelineBuilder.h"
#include "GrSurfacePriv.h"
#include "GrSWMaskHelper.h"
+#include "GrResourceProvider.h"
#include "GrTexturePriv.h"
#include "GrVertexBuffer.h"
#include "effects/GrDistanceFieldGeoProc.h"
@@ -194,13 +195,17 @@ public:
this->initDraw(batchTarget, dfProcessor, pipeline);
+ static const int kVertsPerQuad = 4;
+ static const int kIndicesPerQuad = 6;
+
+ SkAutoTUnref<const GrIndexBuffer> indexBuffer(
+ batchTarget->resourceProvider()->refQuadIndexBuffer());
+
// allocate vertices
size_t vertexStride = dfProcessor->getVertexStride();
SkASSERT(vertexStride == 2 * sizeof(SkPoint));
-
- int vertexCount = GrBatchTarget::kVertsPerRect * instanceCount;
-
const GrVertexBuffer* vertexBuffer;
+ int vertexCount = kVertsPerQuad * instanceCount;
int firstVertex;
void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
@@ -208,24 +213,23 @@ public:
&vertexBuffer,
&firstVertex);
- if (!vertices) {
+ if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
// We may have to flush while uploading path data to the atlas, so we set up the draw here
- const GrIndexBuffer* quadIndexBuffer = batchTarget->quadIndexBuffer();
- int maxInstancesPerDraw = quadIndexBuffer->maxQuads();
+ int maxInstancesPerDraw = indexBuffer->maxQuads();
GrDrawTarget::DrawInfo drawInfo;
drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType);
drawInfo.setStartVertex(0);
drawInfo.setStartIndex(0);
- drawInfo.setVerticesPerInstance(GrBatchTarget::kVertsPerRect);
- drawInfo.setIndicesPerInstance(GrBatchTarget::kIndicesPerRect);
+ drawInfo.setVerticesPerInstance(kVertsPerQuad);
+ drawInfo.setIndicesPerInstance(kIndicesPerQuad);
drawInfo.adjustStartVertex(firstVertex);
drawInfo.setVertexBuffer(vertexBuffer);
- drawInfo.setIndexBuffer(quadIndexBuffer);
+ drawInfo.setIndexBuffer(indexBuffer);
int instancesToFlush = 0;
for (int i = 0; i < instanceCount; i++) {
@@ -280,7 +284,7 @@ public:
// Now set vertices
intptr_t offset = reinterpret_cast<intptr_t>(vertices);
- offset += i * GrBatchTarget::kVertsPerRect * vertexStride;
+ offset += i * kVertsPerQuad * vertexStride;
SkPoint* positions = reinterpret_cast<SkPoint*>(offset);
this->drawPath(batchTarget,
atlas,
« no previous file with comments | « include/gpu/GrTextureProvider.h ('k') | src/gpu/GrAAHairLinePathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698