Index: gm/beziereffects.cpp |
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp |
index d543c149c715a0c53274c89f2a2aa53a9ef2406f..656842289867710a072b6ae1456d409d0cbd9a93 100644 |
--- a/gm/beziereffects.cpp |
+++ b/gm/beziereffects.cpp |
@@ -16,6 +16,7 @@ |
#include "GrBufferAllocPool.h" |
#include "GrContext.h" |
#include "GrPathUtils.h" |
+#include "GrResourceProvider.h" |
#include "GrTest.h" |
#include "GrTestBatch.h" |
#include "SkColorPriv.h" |
@@ -66,13 +67,24 @@ |
} |
void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { |
- QuadHelper helper; |
+ SkAutoTUnref<const GrIndexBuffer> indexBuffer( |
+ batchTarget->resourceProvider()->refQuadIndexBuffer()); |
+ |
size_t vertexStride = this->geometryProcessor()->getVertexStride(); |
+ const GrVertexBuffer* vertexBuffer; |
+ int firstVertex; |
+ void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
+ kVertsPerCubic, |
+ &vertexBuffer, |
+ &firstVertex); |
+ |
+ if (!vertices || !indexBuffer) { |
+ SkDebugf("Could not allocate buffers\n"); |
+ return; |
+ } |
+ |
SkASSERT(vertexStride == sizeof(Vertex)); |
- Vertex* verts = reinterpret_cast<Vertex*>(helper.init(batchTarget, vertexStride, 1)); |
- if (!verts) { |
- return; |
- } |
+ Vertex* verts = reinterpret_cast<Vertex*>(vertices); |
verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds.fTop, |
fGeometry.fBounds.fRight, fGeometry.fBounds.fBottom, |
@@ -82,7 +94,16 @@ |
verts[v].fKLM[1] = eval_line(verts[v].fPosition, fKlmEqs + 3, fSign); |
verts[v].fKLM[2] = eval_line(verts[v].fPosition, fKlmEqs + 6, 1.f); |
} |
- helper.issueDraws(batchTarget); |
+ |
+ GrDrawTarget::DrawInfo drawInfo; |
+ drawInfo.setPrimitiveType(kTriangleFan_GrPrimitiveType); |
+ drawInfo.setVertexBuffer(vertexBuffer); |
+ drawInfo.setStartVertex(firstVertex); |
+ drawInfo.setVertexCount(kVertsPerCubic); |
+ drawInfo.setStartIndex(0); |
+ drawInfo.setIndexCount(kIndicesPerCubic); |
+ drawInfo.setIndexBuffer(indexBuffer); |
+ batchTarget->draw(drawInfo); |
} |
Geometry fGeometry; |
@@ -454,19 +475,42 @@ |
} |
void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override { |
- QuadHelper helper; |
+ SkAutoTUnref<const GrIndexBuffer> indexBuffer( |
+ batchTarget->resourceProvider()->refQuadIndexBuffer()); |
+ |
size_t vertexStride = this->geometryProcessor()->getVertexStride(); |
+ const GrVertexBuffer* vertexBuffer; |
+ int firstVertex; |
+ |
+ void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
+ kVertsPerCubic, |
+ &vertexBuffer, |
+ &firstVertex); |
+ |
+ if (!vertices || !indexBuffer) { |
+ SkDebugf("Could not allocate buffers\n"); |
+ return; |
+ } |
+ |
SkASSERT(vertexStride == sizeof(Vertex)); |
- GrDrawTarget::DrawInfo drawInfo; |
- Vertex* verts = reinterpret_cast<Vertex*>(helper.init(batchTarget, vertexStride, 1)); |
- if (!verts) { |
- return; |
- } |
+ Vertex* verts = reinterpret_cast<Vertex*>(vertices); |
+ |
verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds.fTop, |
fGeometry.fBounds.fRight, fGeometry.fBounds.fBottom, |
sizeof(Vertex)); |
+ |
fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); |
- helper.issueDraws(batchTarget); |
+ |
+ |
+ GrDrawTarget::DrawInfo drawInfo; |
+ drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType); |
+ drawInfo.setVertexBuffer(vertexBuffer); |
+ drawInfo.setStartVertex(firstVertex); |
+ drawInfo.setVertexCount(kVertsPerCubic); |
+ drawInfo.setStartIndex(0); |
+ drawInfo.setIndexCount(kIndicesPerCubic); |
+ drawInfo.setIndexBuffer(indexBuffer); |
+ batchTarget->draw(drawInfo); |
} |
Geometry fGeometry; |