Chromium Code Reviews| Index: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp |
| diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp |
| index eb6a67dc20c9f32cc73c1c98494854ef6a1b7223..05bf1d633aed2b23a4fb0e8d7a112ed967d0b65b 100644 |
| --- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp |
| +++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp |
| @@ -128,17 +128,27 @@ public: |
| typedef SkTDynamicHash<ShapeData, ShapeData::Key> ShapeCache; |
| typedef GrAADistanceFieldPathRenderer::ShapeDataList ShapeDataList; |
| - struct Geometry { |
| - GrShape fShape; |
| - GrColor fColor; |
| - bool fAntiAlias; |
| - }; |
| + AADistanceFieldPathBatch(GrColor color, |
| + const GrShape& shape, |
| + bool antiAlias, |
| + const SkMatrix& viewMatrix, |
| + GrBatchAtlas* atlas, |
| + ShapeCache* shapeCache, ShapeDataList* shapeList, |
| + bool gammaCorrect) |
| + : INHERITED(ClassID()) { |
| + SkASSERT(shape.hasUnstyledKey()); |
| + fBatch.fViewMatrix = viewMatrix; |
| + fGeoData.emplace_back(Geometry{color, shape, antiAlias}); |
|
robertphillips
2016/06/29 21:07:33
this assert seems redundant with the above one
bsalomon
2016/06/29 21:12:28
Done.
|
| + SkASSERT(fGeoData[0].fShape.hasUnstyledKey()); |
| - static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, |
| - GrBatchAtlas* atlas, ShapeCache* shapeCache, |
| - ShapeDataList* shapeList, bool gammaCorrect) { |
| - return new AADistanceFieldPathBatch(geometry, viewMatrix, atlas, shapeCache, shapeList, |
| - gammaCorrect); |
| + fAtlas = atlas; |
| + fShapeCache = shapeCache; |
| + fShapeList = shapeList; |
| + fGammaCorrect = gammaCorrect; |
| + |
| + // Compute bounds |
| + fBounds = shape.bounds(); |
| + viewMatrix.mapRect(&fBounds); |
| } |
| const char* name() const override { return "AADistanceFieldPathBatch"; } |
| @@ -278,27 +288,6 @@ private: |
| this->flush(target, &flushInfo); |
| } |
| - AADistanceFieldPathBatch(const Geometry& geometry, |
| - const SkMatrix& viewMatrix, |
| - GrBatchAtlas* atlas, |
| - ShapeCache* shapeCache, ShapeDataList* shapeList, |
| - bool gammaCorrect) |
| - : INHERITED(ClassID()) { |
| - SkASSERT(geometry.fShape.hasUnstyledKey()); |
| - fBatch.fViewMatrix = viewMatrix; |
| - fGeoData.push_back(geometry); |
| - SkASSERT(fGeoData[0].fShape.hasUnstyledKey()); |
| - |
| - fAtlas = atlas; |
| - fShapeCache = shapeCache; |
| - fShapeList = shapeList; |
| - fGammaCorrect = gammaCorrect; |
| - |
| - // Compute bounds |
| - fBounds = geometry.fShape.bounds(); |
| - viewMatrix.mapRect(&fBounds); |
| - } |
| - |
| bool addPathToAtlas(GrVertexBatch::Target* target, |
| FlushInfo* flushInfo, |
| GrBatchAtlas* atlas, |
| @@ -507,6 +496,12 @@ private: |
| bool fCoverageIgnored; |
| }; |
| + struct Geometry { |
| + GrColor fColor; |
| + GrShape fShape; |
| + bool fAntiAlias; |
| + }; |
| + |
| BatchTracker fBatch; |
| SkSTArray<1, Geometry> fGeoData; |
| GrBatchAtlas* fAtlas; |
| @@ -537,15 +532,10 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) { |
| } |
| } |
| - AADistanceFieldPathBatch::Geometry geometry; |
| - geometry.fShape = *args.fShape; |
| - geometry.fColor = args.fColor; |
| - geometry.fAntiAlias = args.fAntiAlias; |
| - |
| - SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry, |
| - *args.fViewMatrix, fAtlas, |
| - &fShapeCache, &fShapeList, |
| - args.fGammaCorrect)); |
| + SkAutoTUnref<GrDrawBatch> batch(new AADistanceFieldPathBatch(args.fColor, *args.fShape, |
| + args.fAntiAlias, *args.fViewMatrix, |
| + fAtlas, &fShapeCache, &fShapeList, |
| + args.fGammaCorrect)); |
| GrPipelineBuilder pipelineBuilder(*args.fPaint); |
| pipelineBuilder.setUserStencil(args.fUserStencilSettings); |
| @@ -619,18 +609,18 @@ DRAW_BATCH_TEST_DEFINE(AADistanceFieldPathBatch) { |
| GrColor color = GrRandomColor(random); |
| bool gammaCorrect = random->nextBool(); |
| - AADistanceFieldPathBatch::Geometry geometry; |
| // This path renderer only allows fill styles. |
| GrShape shape(GrTest::TestPath(random), GrStyle::SimpleFill()); |
| - geometry.fShape = shape; |
| - geometry.fColor = color; |
| - geometry.fAntiAlias = random->nextBool(); |
| - |
| - return AADistanceFieldPathBatch::Create(geometry, viewMatrix, |
| - gTestStruct.fAtlas, |
| - &gTestStruct.fShapeCache, |
| - &gTestStruct.fShapeList, |
| - gammaCorrect); |
| + bool antiAlias = random->nextBool(); |
| + |
| + return new AADistanceFieldPathBatch(color, |
| + shape, |
| + antiAlias, |
| + viewMatrix, |
| + gTestStruct.fAtlas, |
| + &gTestStruct.fShapeCache, |
| + &gTestStruct.fShapeList, |
| + gammaCorrect); |
| } |
| #endif |