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

Unified Diff: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp

Issue 2110903002: Hide more GrBatch Geometry structs. (Closed) Base URL: https://chromium.googlesource.com/skia.git@aabloat
Patch Set: Address comments Created 4 years, 6 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 | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/batches/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index eb6a67dc20c9f32cc73c1c98494854ef6a1b7223..725358ebf161009516051afd22e2d8d09b077956 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -128,17 +128,26 @@ 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});
- 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 +287,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 +495,12 @@ private:
bool fCoverageIgnored;
};
+ struct Geometry {
+ GrColor fColor;
+ GrShape fShape;
+ bool fAntiAlias;
+ };
+
BatchTracker fBatch;
SkSTArray<1, Geometry> fGeoData;
GrBatchAtlas* fAtlas;
@@ -537,15 +531,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 +608,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
« no previous file with comments | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/batches/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698