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

Unified Diff: src/gpu/batches/GrAAHairLinePathRenderer.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/GrAADistanceFieldPathRenderer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAAHairLinePathRenderer.cpp
diff --git a/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
index 1f7407c5f633dc4731b10cf304051830c7524c0d..1a5e6971e7f5c22e740b9e7cb1161ec9a0dcca31 100644
--- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
@@ -676,15 +676,21 @@ class AAHairlineBatch : public GrVertexBatch {
public:
DEFINE_BATCH_CLASS_ID
- struct Geometry {
- GrColor fColor;
- uint8_t fCoverage;
- SkMatrix fViewMatrix;
- SkPath fPath;
- SkIRect fDevClipBounds;
- };
+ AAHairlineBatch(GrColor color,
+ uint8_t coverage,
+ const SkMatrix& viewMatrix,
+ const SkPath& path,
+ SkIRect devClipBounds) : INHERITED(ClassID()) {
+ fGeoData.emplace_back(Geometry{color, coverage, viewMatrix, path, devClipBounds});
+
+ // compute bounds
+ fBounds = path.getBounds();
+ viewMatrix.mapRect(&fBounds);
- static GrDrawBatch* Create(const Geometry& geometry) { return new AAHairlineBatch(geometry); }
+ // This is b.c. hairlines are notionally infinitely thin so without expansion
+ // two overlapping lines could be reordered even though they hit the same pixels.
+ fBounds.outset(0.5f, 0.5f);
+ }
const char* name() const override { return "AAHairlineBatch"; }
@@ -712,26 +718,12 @@ private:
fBatch.fCoverage = fGeoData[0].fCoverage;
}
- SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
-
void onPrepareDraws(Target*) const override;
typedef SkTArray<SkPoint, true> PtArray;
typedef SkTArray<int, true> IntArray;
typedef SkTArray<float, true> FloatArray;
- AAHairlineBatch(const Geometry& geometry) : INHERITED(ClassID()) {
- fGeoData.push_back(geometry);
-
- // compute bounds
- fBounds = geometry.fPath.getBounds();
- geometry.fViewMatrix.mapRect(&fBounds);
-
- // This is b.c. hairlines are notionally infinitely thin so without expansion
- // two overlapping lines could be reordered even though they hit the same pixels.
- fBounds.outset(0.5f, 0.5f);
- }
-
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
AAHairlineBatch* that = t->cast<AAHairlineBatch>();
@@ -766,7 +758,7 @@ private:
return false;
}
- fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
+ fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin());
this->joinBounds(that->bounds());
return true;
}
@@ -777,6 +769,15 @@ private:
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
+
+ struct Geometry {
+ GrColor fColor;
+ uint8_t fCoverage;
+ SkMatrix fViewMatrix;
+ SkPath fPath;
+ SkIRect fDevClipBounds;
+ };
+
struct BatchTracker {
GrColor fColor;
uint8_t fCoverage;
@@ -953,14 +954,7 @@ static GrDrawBatch* create_hairline_batch(GrColor color,
newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff);
}
- AAHairlineBatch::Geometry geometry;
- geometry.fColor = color;
- geometry.fCoverage = newCoverage;
- geometry.fViewMatrix = viewMatrix;
- geometry.fPath = path;
- geometry.fDevClipBounds = devClipBounds;
-
- return AAHairlineBatch::Create(geometry);
+ return new AAHairlineBatch(color, newCoverage, viewMatrix, path, devClipBounds);
}
bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
« no previous file with comments | « src/gpu/batches/GrAADistanceFieldPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698