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

Unified Diff: gm/convexpolyeffect.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 | « gm/beziereffects.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/convexpolyeffect.cpp
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index cd9b3d10e55b2efbc56efa0a49b6bf5aa2aaae67..60b73c571d97a067d5b566d2ed0b88570dd65212 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,23 +53,46 @@
}
void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
+ 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(SkPoint));
- QuadHelper helper;
- SkPoint* verts = reinterpret_cast<SkPoint*>(helper.init(batchTarget, vertexStride, 1));
- if (!verts) {
- return;
- }
+ SkPoint* verts = reinterpret_cast<SkPoint*>(vertices);
// Make sure any artifacts around the exterior of path are visible by using overly
// conservative bounding geometry.
fGeometry.fBounds.outset(5.f, 5.f);
fGeometry.fBounds.toQuad(verts);
- 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;
+
+ static const int kVertsPerCubic = 4;
+ static const int kIndicesPerCubic = 6;
typedef GrTestBatch INHERITED;
};
« no previous file with comments | « gm/beziereffects.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698