aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/convexpolyeffect.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@google.com>2015-02-11 13:03:15 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-11 13:03:16 -0800
commit94dff15404a6c82873f3f5092023426937274cc1 (patch)
tree2edf58b5dc200a3cf969a05ac6d7686f21c0a75a /gm/convexpolyeffect.cpp
parentb48e08e03a7573c6917d9932a60af5822c009abd (diff)
Revert of GMs now use batch (patchset #3 id:40001 of https://codereview.chromium.org/865313004/)
Reason for revert: missing hairlines on gms Original issue's description: > GMs now use batch > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/3f284d7758d7f35b59d93a22d126f7cd8423be44 TBR=bsalomon@google.com,joshualitt@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/913153003
Diffstat (limited to 'gm/convexpolyeffect.cpp')
-rw-r--r--gm/convexpolyeffect.cpp105
1 files changed, 26 insertions, 79 deletions
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 0a3be28c73..281ddca77e 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -12,13 +12,10 @@
#if SK_SUPPORT_GPU
-#include "GrBatchTarget.h"
-#include "GrBufferAllocPool.h"
#include "GrContext.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrPathUtils.h"
#include "GrTest.h"
-#include "GrTestBatch.h"
#include "SkColorPriv.h"
#include "SkDevice.h"
#include "SkGeometry.h"
@@ -27,68 +24,6 @@
#include "effects/GrConvexPolyEffect.h"
namespace skiagm {
-
-class ConvexPolyTestBatch : public GrTestBatch {
-public:
- struct Geometry : public GrTestBatch::Geometry {
- SkRect fBounds;
- };
-
- const char* name() const SK_OVERRIDE { return "ConvexPolyTestBatch"; }
-
- static GrBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo) {
- return SkNEW_ARGS(ConvexPolyTestBatch, (gp, geo));
- }
-
-private:
- ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo)
- : INHERITED(gp)
- , fGeometry(geo) {
- }
-
- Geometry* geoData(int index) SK_OVERRIDE {
- SkASSERT(0 == index);
- return &fGeometry;
- }
-
- void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) SK_OVERRIDE {
- size_t vertexStride = this->geometryProcessor()->getVertexStride();
-
- const GrVertexBuffer* vertexBuffer;
- int firstVertex;
-
- void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
- kVertsPerCubic,
- &vertexBuffer,
- &firstVertex);
-
- SkASSERT(vertexStride == sizeof(SkPoint));
- 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);
-
- GrDrawTarget::DrawInfo drawInfo;
- drawInfo.setPrimitiveType(kTriangleFan_GrPrimitiveType);
- drawInfo.setVertexBuffer(vertexBuffer);
- drawInfo.setStartVertex(firstVertex);
- drawInfo.setVertexCount(kVertsPerCubic);
- drawInfo.setStartIndex(0);
- drawInfo.setIndexCount(kIndicesPerCubic);
- drawInfo.setIndexBuffer(batchTarget->quadIndexBuffer());
- batchTarget->draw(drawInfo);
- }
-
- Geometry fGeometry;
-
- static const int kVertsPerCubic = 4;
- static const int kIndicesPerCubic = 6;
-
- typedef GrTestBatch INHERITED;
-};
-
/**
* This GM directly exercises a GrProcessor that draws convex polygons.
*/
@@ -168,10 +103,6 @@ protected:
return;
}
- SkAutoTUnref<const GrGeometryProcessor> gp(
- GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
- 0xff000000));
-
SkScalar y = 0;
for (SkTLList<SkPath>::Iter iter(fPaths, SkTLList<SkPath>::Iter::kHead_IterStart);
iter.get();
@@ -198,16 +129,25 @@ protected:
}
GrPipelineBuilder pipelineBuilder;
+ SkAutoTUnref<const GrGeometryProcessor> gp(
+ GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
+ 0xff000000));
pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
- ConvexPolyTestBatch::Geometry geometry;
- geometry.fColor = gp->color();
- geometry.fBounds = p.getBounds();
+ GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVertexStride(), 0);
+ SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
+ SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices());
- SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
+ SkRect bounds = p.getBounds();
+ // Make sure any artifacts around the exterior of path are visible by using overly
+ // conservative bounding geometry.
+ bounds.outset(5.f, 5.f);
+ bounds.toQuad(verts);
- tt.target()->drawBatch(&pipelineBuilder, batch, NULL);
+ tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer());
+ tt.target()->drawIndexed(&pipelineBuilder, gp, kTriangleFan_GrPrimitiveType,
+ 0, 0, 4, 6);
x += SkScalarCeilToScalar(path->getBounds().width() + 10.f);
}
@@ -247,16 +187,23 @@ protected:
}
GrPipelineBuilder pipelineBuilder;
+ SkAutoTUnref<const GrGeometryProcessor> gp(
+ GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPosition_GPType,
+ 0xff000000));
pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
- ConvexPolyTestBatch::Geometry geometry;
- geometry.fColor = gp->color();
- geometry.fBounds = rect;
+ GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVertexStride(), 0);
+ SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
+ SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices());
- SkAutoTUnref<GrBatch> batch(ConvexPolyTestBatch::Create(gp, geometry));
+ SkRect bounds = rect;
+ bounds.outset(5.f, 5.f);
+ bounds.toQuad(verts);
- tt.target()->drawBatch(&pipelineBuilder, batch, NULL);
+ tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer());
+ tt.target()->drawIndexed(&pipelineBuilder, gp, kTriangleFan_GrPrimitiveType,
+ 0, 0, 4, 6);
x += SkScalarCeilToScalar(rect.width() + 10.f);
}