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

Unified Diff: src/gpu/GrAARectRenderer.cpp

Issue 1124633003: Revert of Start on simplifying generateGeometry() overrides (Closed) Base URL: https://skia.googlesource.com/skia.git@ibcache
Patch Set: 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 | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/GrAtlasTextContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAARectRenderer.cpp
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 267d970c625cf6d600f72058c4008c26d70a2640..d1c377aa532757ec1b392064026cca09787a067a 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -112,17 +112,22 @@
init.fUsesLocalCoords = this->usesLocalCoords();
gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
+ SkAutoTUnref<const GrIndexBuffer> indexBuffer(this->getIndexBuffer(
+ batchTarget->resourceProvider()));
+
size_t vertexStride = gp->getVertexStride();
SkASSERT(canTweakAlphaForCoverage ?
vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) :
vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr));
int instanceCount = fGeoData.count();
-
- SkAutoTUnref<const GrIndexBuffer> indexBuffer(this->getIndexBuffer(
- batchTarget->resourceProvider()));
- InstancedHelper helper;
- void* vertices = helper.init(batchTarget, vertexStride, indexBuffer, kVertsPerAAFillRect,
- kIndicesPerAAFillRect, instanceCount);
+ int vertexCount = kVertsPerAAFillRect * instanceCount;
+ const GrVertexBuffer* vertexBuffer;
+ int firstVertex;
+ void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
+ vertexCount,
+ &vertexBuffer,
+ &firstVertex);
+
if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
@@ -140,7 +145,28 @@
canTweakAlphaForCoverage);
}
- helper.issueDraws(batchTarget);
+ GrDrawTarget::DrawInfo drawInfo;
+ drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType);
+ drawInfo.setStartVertex(0);
+ drawInfo.setStartIndex(0);
+ drawInfo.setVerticesPerInstance(kVertsPerAAFillRect);
+ drawInfo.setIndicesPerInstance(kIndicesPerAAFillRect);
+ drawInfo.adjustStartVertex(firstVertex);
+ drawInfo.setVertexBuffer(vertexBuffer);
+ drawInfo.setIndexBuffer(indexBuffer);
+
+ int maxInstancesPerDraw = kNumAAFillRectsInIndexBuffer;
+
+ while (instanceCount) {
+ drawInfo.setInstanceCount(SkTMin(instanceCount, maxInstancesPerDraw));
+ drawInfo.setVertexCount(drawInfo.instanceCount() * drawInfo.verticesPerInstance());
+ drawInfo.setIndexCount(drawInfo.instanceCount() * drawInfo.indicesPerInstance());
+
+ batchTarget->draw(drawInfo);
+
+ drawInfo.setStartVertex(drawInfo.startVertex() + drawInfo.vertexCount());
+ instanceCount -= drawInfo.instanceCount();
+ }
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
@@ -459,6 +485,9 @@
batchTarget->initDraw(gp, pipeline);
+ const SkAutoTUnref<const GrIndexBuffer> indexBuffer(
+ GetIndexBuffer(batchTarget->resourceProvider(), this->miterStroke()));
+
// TODO this is hacky, but the only way we have to initialize the GP is to use the
// GrPipelineInfo struct so we can generate the correct shader. Once we have GrBatch
// everywhere we can remove this nastiness
@@ -476,24 +505,28 @@
vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr));
int innerVertexNum = 4;
int outerVertexNum = this->miterStroke() ? 4 : 8;
- int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2;
- int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexCnt;
+ int totalVertexNum = (outerVertexNum + innerVertexNum) * 2;
+
int instanceCount = fGeoData.count();
-
- const SkAutoTUnref<const GrIndexBuffer> indexBuffer(
- GetIndexBuffer(batchTarget->resourceProvider(), this->miterStroke()));
- InstancedHelper helper;
- void* vertices = helper.init(batchTarget, vertexStride, indexBuffer, verticesPerInstance,
- indicesPerInstance, instanceCount);
+ int vertexCount = totalVertexNum * instanceCount;
+
+ const GrVertexBuffer* vertexBuffer;
+ int firstVertex;
+
+ void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
+ vertexCount,
+ &vertexBuffer,
+ &firstVertex);
+
if (!vertices || !indexBuffer) {
- SkDebugf("Could not allocate vertices\n");
- return;
- }
+ SkDebugf("Could not allocate vertices\n");
+ return;
+ }
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];
this->generateAAStrokeRectGeometry(vertices,
- i * verticesPerInstance * vertexStride,
+ i * totalVertexNum * vertexStride,
vertexStride,
outerVertexNum,
innerVertexNum,
@@ -504,7 +537,30 @@
args.fMiterStroke,
canTweakAlphaForCoverage);
}
- helper.issueDraws(batchTarget);
+ int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexCnt;
+ GrDrawTarget::DrawInfo drawInfo;
+ drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType);
+ drawInfo.setStartVertex(0);
+ drawInfo.setStartIndex(0);
+ drawInfo.setVerticesPerInstance(totalVertexNum);
+ drawInfo.setIndicesPerInstance(indicesPerInstance);
+ drawInfo.adjustStartVertex(firstVertex);
+ drawInfo.setVertexBuffer(vertexBuffer);
+ drawInfo.setIndexBuffer(indexBuffer);
+
+ int maxInstancesPerDraw = this->miterStroke() ? kNumMiterRectsInIndexBuffer :
+ kNumBevelRectsInIndexBuffer;
+
+ while (instanceCount) {
+ drawInfo.setInstanceCount(SkTMin(instanceCount, maxInstancesPerDraw));
+ drawInfo.setVertexCount(drawInfo.instanceCount() * drawInfo.verticesPerInstance());
+ drawInfo.setIndexCount(drawInfo.instanceCount() * drawInfo.indicesPerInstance());
+
+ batchTarget->draw(drawInfo);
+
+ drawInfo.setStartVertex(drawInfo.startVertex() + drawInfo.vertexCount());
+ instanceCount -= drawInfo.instanceCount();
+ }
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/GrAtlasTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698