| Index: src/gpu/GrInOrderDrawBuffer.cpp
|
| diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
|
| index cd62c25a9c13526654e708a3d5978f4b8ef94d9e..8190ec0e8a880bc4a6aa696f0c4a5b2f5545080c 100644
|
| --- a/src/gpu/GrInOrderDrawBuffer.cpp
|
| +++ b/src/gpu/GrInOrderDrawBuffer.cpp
|
| @@ -8,6 +8,7 @@
|
| #include "GrInOrderDrawBuffer.h"
|
|
|
| #include "GrDefaultGeoProcFactory.h"
|
| +#include "GrResourceProvider.h"
|
| #include "GrTemplates.h"
|
|
|
| GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context,
|
| @@ -130,49 +131,79 @@
|
| init.fUsesLocalCoords = this->usesLocalCoords();
|
| gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
|
|
|
| - int instanceCount = fGeoData.count();
|
| size_t vertexStride = gp->getVertexStride();
|
| +
|
| SkASSERT(hasExplicitLocalCoords ?
|
| vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr) :
|
| vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
|
| - QuadHelper helper;
|
| - void* vertices = helper.init(batchTarget, vertexStride, instanceCount);
|
| -
|
| - if (!vertices) {
|
| +
|
| + int instanceCount = fGeoData.count();
|
| + SkAutoTUnref<const GrIndexBuffer> indexBuffer(
|
| + batchTarget->resourceProvider()->refQuadIndexBuffer());
|
| +
|
| + int vertexCount = kVertsPerRect * instanceCount;
|
| + const GrVertexBuffer* vertexBuffer;
|
| + int firstVertex;
|
| + void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
|
| + vertexCount,
|
| + &vertexBuffer,
|
| + &firstVertex);
|
| +
|
| + if (!vertices || !indexBuffer) {
|
| + SkDebugf("Could not allocate buffers\n");
|
| return;
|
| }
|
|
|
| -
|
| for (int i = 0; i < instanceCount; i++) {
|
| - const Geometry& geom = fGeoData[i];
|
| -
|
| - intptr_t offset = GrTCast<intptr_t>(vertices) + kVerticesPerQuad * i * vertexStride;
|
| + const Geometry& args = fGeoData[i];
|
| +
|
| + intptr_t offset = GrTCast<intptr_t>(vertices) + kVertsPerRect * i * vertexStride;
|
| SkPoint* positions = GrTCast<SkPoint*>(offset);
|
|
|
| - positions->setRectFan(geom.fRect.fLeft, geom.fRect.fTop,
|
| - geom.fRect.fRight, geom.fRect.fBottom, vertexStride);
|
| - geom.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVerticesPerQuad);
|
| -
|
| - if (geom.fHasLocalRect) {
|
| + positions->setRectFan(args.fRect.fLeft, args.fRect.fTop,
|
| + args.fRect.fRight, args.fRect.fBottom, vertexStride);
|
| + args.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVertsPerRect);
|
| +
|
| + if (args.fHasLocalRect) {
|
| static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
|
| SkPoint* coords = GrTCast<SkPoint*>(offset + kLocalOffset);
|
| - coords->setRectFan(geom.fLocalRect.fLeft, geom.fLocalRect.fTop,
|
| - geom.fLocalRect.fRight, geom.fLocalRect.fBottom,
|
| + coords->setRectFan(args.fLocalRect.fLeft, args.fLocalRect.fTop,
|
| + args.fLocalRect.fRight, args.fLocalRect.fBottom,
|
| vertexStride);
|
| - if (geom.fHasLocalMatrix) {
|
| - geom.fLocalMatrix.mapPointsWithStride(coords, vertexStride, kVerticesPerQuad);
|
| + if (args.fHasLocalMatrix) {
|
| + args.fLocalMatrix.mapPointsWithStride(coords, vertexStride, kVertsPerRect);
|
| }
|
| }
|
|
|
| static const int kColorOffset = sizeof(SkPoint);
|
| GrColor* vertColor = GrTCast<GrColor*>(offset + kColorOffset);
|
| for (int j = 0; j < 4; ++j) {
|
| - *vertColor = geom.fColor;
|
| + *vertColor = args.fColor;
|
| vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
|
| }
|
| }
|
|
|
| - helper.issueDraws(batchTarget);
|
| + GrDrawTarget::DrawInfo drawInfo;
|
| + drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType);
|
| + drawInfo.setStartVertex(0);
|
| + drawInfo.setStartIndex(0);
|
| + drawInfo.setVerticesPerInstance(kVertsPerRect);
|
| + drawInfo.setIndicesPerInstance(kIndicesPerRect);
|
| + drawInfo.adjustStartVertex(firstVertex);
|
| + drawInfo.setVertexBuffer(vertexBuffer);
|
| + drawInfo.setIndexBuffer(indexBuffer);
|
| +
|
| + int maxInstancesPerDraw = indexBuffer->maxQuads();
|
| + 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; }
|
| @@ -230,6 +261,9 @@
|
| bool fColorIgnored;
|
| bool fCoverageIgnored;
|
| };
|
| +
|
| + const static int kVertsPerRect = 4;
|
| + const static int kIndicesPerRect = 6;
|
|
|
| BatchTracker fBatch;
|
| SkSTArray<1, Geometry, true> fGeoData;
|
|
|