Chromium Code Reviews| Index: src/gpu/batches/GrMSAAPathRenderer.cpp |
| diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp |
| index c4b8835f6ed5e543f64c084b3aef40b05b667f42..f63f9a515585e383f25f64b6081f48dd71929f84 100644 |
| --- a/src/gpu/batches/GrMSAAPathRenderer.cpp |
| +++ b/src/gpu/batches/GrMSAAPathRenderer.cpp |
| @@ -225,15 +225,18 @@ class MSAAPathBatch : public GrVertexBatch { |
| public: |
| DEFINE_BATCH_CLASS_ID |
|
robertphillips
2016/06/30 17:10:41
The usage of 'tolerance', 'kTolerance' & 'fToleran
|
| - struct Geometry { |
| - GrColor fColor; |
| - SkPath fPath; |
| - SkScalar fTolerance; |
| - }; |
| - |
| - static MSAAPathBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, |
| - const SkRect& devBounds) { |
| - return new MSAAPathBatch(geometry, viewMatrix, devBounds); |
| + MSAAPathBatch(GrColor color, const SkPath& path, SkScalar tolerance, const SkMatrix& viewMatrix, |
| + const SkRect& devBounds) |
| + : INHERITED(ClassID()) |
| + , fViewMatrix(viewMatrix) { |
| + fPaths.emplace_back(PathInfo{color, path, tolerance}); |
| + this->setBounds(devBounds); |
| + int contourCount; |
| + this->computeWorstCasePointCount(path, &contourCount, kTolerance, |
| + &fMaxLineVertices, &fMaxQuadVertices); |
| + fMaxLineIndices = fMaxLineVertices * 3; |
| + fMaxQuadIndices = fMaxQuadVertices * 3; |
| + fIsIndexed = contourCount > 1; |
| } |
| const char* name() const override { return "MSAAPathBatch"; } |
| @@ -241,8 +244,8 @@ public: |
| void computePipelineOptimizations(GrInitInvariantOutput* color, |
| GrInitInvariantOutput* coverage, |
| GrBatchToXPOverrides* overrides) const override { |
| - // When this is called on a batch, there is only one geometry bundle |
| - color->setKnownFourComponents(fGeoData[0].fColor); |
| + // When this is called on a batch, there is only one path |
| + color->setKnownFourComponents(fPaths[0].fColor); |
| coverage->setKnownSingleComponent(0xff); |
| } |
| @@ -254,9 +257,9 @@ private: |
| void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| // Handle any color overrides |
| if (!overrides.readsColor()) { |
| - fGeoData[0].fColor = GrColor_ILLEGAL; |
| + fPaths[0].fColor = GrColor_ILLEGAL; |
| } |
| - overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| + overrides.getOverrideColorIfSet(&fPaths[0].fColor); |
| } |
| void computeWorstCasePointCount(const SkPath& path, int* subpaths, SkScalar tol, |
| @@ -370,15 +373,15 @@ private: |
| } |
| // fill buffers |
| - for (int i = 0; i < fGeoData.count(); i++) { |
| - const Geometry& args = fGeoData[i]; |
| + for (int i = 0; i < fPaths.count(); i++) { |
| + const PathInfo& pathInfo = fPaths[i]; |
| if (!this->createGeom(lines, |
| quads, |
| - args.fPath, |
| - args.fTolerance, |
| + pathInfo.fPath, |
| + pathInfo.fTolerance, |
| fViewMatrix, |
| - args.fColor, |
| + pathInfo.fColor, |
| fIsIndexed)) { |
| return; |
| } |
| @@ -442,21 +445,6 @@ private: |
| } |
| } |
| - SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| - |
| - MSAAPathBatch(const Geometry& geometry, const SkMatrix& viewMatrix, const SkRect& devBounds) |
| - : INHERITED(ClassID()) |
| - , fViewMatrix(viewMatrix) { |
| - fGeoData.push_back(geometry); |
| - this->setBounds(devBounds); |
| - int contourCount; |
| - this->computeWorstCasePointCount(geometry.fPath, &contourCount, kTolerance, |
| - &fMaxLineVertices, &fMaxQuadVertices); |
| - fMaxLineIndices = fMaxLineVertices * 3; |
| - fMaxQuadIndices = fMaxQuadVertices * 3; |
| - fIsIndexed = contourCount > 1; |
| - } |
| - |
| bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| MSAAPathBatch* that = t->cast<MSAAPathBatch>(); |
| if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(), |
| @@ -473,7 +461,7 @@ private: |
| return false; |
| } |
| - fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()); |
| + fPaths.push_back_n(that->fPaths.count(), that->fPaths.begin()); |
| this->joinBounds(that->bounds()); |
| fIsIndexed = true; |
| fMaxLineVertices += that->fMaxLineVertices; |
| @@ -555,7 +543,13 @@ private: |
| return true; |
| } |
| - SkSTArray<1, Geometry, true> fGeoData; |
| + struct PathInfo { |
| + GrColor fColor; |
| + SkPath fPath; |
| + SkScalar fTolerance; |
| + }; |
| + |
| + SkSTArray<1, PathInfo, true> fPaths; |
| SkMatrix fViewMatrix; |
| int fMaxLineVertices; |
| @@ -680,13 +674,8 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawContext* drawContext, |
| drawContext->drawBatch(pipelineBuilder, clip, batch); |
| } else { |
| - MSAAPathBatch::Geometry geometry; |
| - geometry.fColor = color; |
| - geometry.fPath = path; |
| - geometry.fTolerance = kTolerance; |
| - |
| - SkAutoTUnref<MSAAPathBatch> batch(MSAAPathBatch::Create(geometry, viewMatrix, |
| - devBounds)); |
| + SkAutoTUnref<MSAAPathBatch> batch(new MSAAPathBatch(color, path, kTolerance, viewMatrix, |
| + devBounds)); |
| if (!batch->isValid()) { |
| return false; |
| } |