Move instanced index buffer creation to flush time
Committed: https://skia.googlesource.com/skia/+/ab622c7b8cc8c39f0a594e4392b9e31b7e1ddb26
Review URL: https://codereview.chromium.org/1116943004
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 07d5fc2..60b73c5 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -17,6 +17,7 @@
#include "GrContext.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrPathUtils.h"
+#include "GrResourceProvider.h"
#include "GrTest.h"
#include "GrTestBatch.h"
#include "SkColorPriv.h"
@@ -52,8 +53,10 @@
}
void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
- size_t vertexStride = this->geometryProcessor()->getVertexStride();
+ SkAutoTUnref<const GrIndexBuffer> indexBuffer(
+ batchTarget->resourceProvider()->refQuadIndexBuffer());
+ size_t vertexStride = this->geometryProcessor()->getVertexStride();
const GrVertexBuffer* vertexBuffer;
int firstVertex;
@@ -62,7 +65,7 @@
&vertexBuffer,
&firstVertex);
- if (!vertices || !batchTarget->quadIndexBuffer()) {
+ if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate buffers\n");
return;
}
@@ -82,7 +85,7 @@
drawInfo.setVertexCount(kVertsPerCubic);
drawInfo.setStartIndex(0);
drawInfo.setIndexCount(kIndicesPerCubic);
- drawInfo.setIndexBuffer(batchTarget->quadIndexBuffer());
+ drawInfo.setIndexBuffer(indexBuffer);
batchTarget->draw(drawInfo);
}