diff options
author | Brian Salomon <bsalomon@google.com> | 2016-12-20 14:43:36 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-20 20:43:11 +0000 |
commit | 8c5bad35f5d98040f2db2ffd3ba9a924c7436784 (patch) | |
tree | 5ec1c2ba03d630290bd69e891a5276d4a24d82b2 /src/gpu | |
parent | 721a2c408904619b70ddd228fcaa0908a6da0b4d (diff) |
Remove the last "batch tracker" from AAStrokeRectOp.
Most of the fields weren't really needed.
BUG=skia:
Change-Id: If0dbcb707b3a45d044656cbadbe118aa5583be2e
Reviewed-on: https://skia-review.googlesource.com/6338
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/ops/GrAAStrokeRectOp.cpp | 93 |
1 files changed, 35 insertions, 58 deletions
diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp index 2b68636dee..252889240c 100644 --- a/src/gpu/ops/GrAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrAAStrokeRectOp.cpp @@ -94,16 +94,12 @@ static void compute_rects(SkRect* devOutside, SkRect* devOutsideAssist, SkRect* static sk_sp<GrGeometryProcessor> create_stroke_rect_gp(bool tweakAlphaForCoverage, const SkMatrix& viewMatrix, - bool usesLocalCoords, - bool coverageIgnored) { + bool usesLocalCoords) { using namespace GrDefaultGeoProcFactory; Color color(Color::kAttribute_Type); Coverage::Type coverageType; - // TODO remove coverage if coverage is ignored - /*if (coverageIgnored) { - coverageType = Coverage::kNone_Type; - } else*/ if (tweakAlphaForCoverage) { + if (tweakAlphaForCoverage) { coverageType = Coverage::kSolid_Type; } else { coverageType = Coverage::kAttribute_Type; @@ -124,7 +120,7 @@ public: SkASSERT(!devOutside.isEmpty()); SkASSERT(!devInside.isEmpty()); - fGeoData.emplace_back(Geometry{color, devOutside, devOutside, devInside, false}); + fRects.emplace_back(RectInfo{color, devOutside, devOutside, devInside, false}); this->setBounds(devOutside, HasAABloat::kYes, IsZeroArea::kNo); fMiterStroke = true; } @@ -138,11 +134,11 @@ public: AAStrokeRectOp* op = new AAStrokeRectOp(); op->fMiterStroke = isMiter; - Geometry& geo = op->fGeoData.push_back(); - compute_rects(&geo.fDevOutside, &geo.fDevOutsideAssist, &geo.fDevInside, &geo.fDegenerate, - viewMatrix, rect, stroke.getWidth(), isMiter); - geo.fColor = color; - op->setBounds(geo.fDevOutside, HasAABloat::kYes, IsZeroArea::kNo); + RectInfo& info = op->fRects.push_back(); + compute_rects(&info.fDevOutside, &info.fDevOutsideAssist, &info.fDevInside, + &info.fDegenerate, viewMatrix, rect, stroke.getWidth(), isMiter); + info.fColor = color; + op->setBounds(info.fDevOutside, HasAABloat::kYes, IsZeroArea::kNo); op->fViewMatrix = viewMatrix; return sk_sp<GrDrawOp>(op); } @@ -151,16 +147,16 @@ public: SkString dumpInfo() const override { SkString string; - for (const auto& geo : fGeoData) { + for (const auto& info : fRects) { string.appendf( "Color: 0x%08x, ORect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], " "AssistORect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], " "IRect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], Degen: %d", - geo.fColor, geo.fDevOutside.fLeft, geo.fDevOutside.fTop, geo.fDevOutside.fRight, - geo.fDevOutside.fBottom, geo.fDevOutsideAssist.fLeft, - geo.fDevOutsideAssist.fTop, geo.fDevOutsideAssist.fRight, - geo.fDevOutsideAssist.fBottom, geo.fDevInside.fLeft, geo.fDevInside.fTop, - geo.fDevInside.fRight, geo.fDevInside.fBottom, geo.fDegenerate); + info.fColor, info.fDevOutside.fLeft, info.fDevOutside.fTop, + info.fDevOutside.fRight, info.fDevOutside.fBottom, info.fDevOutsideAssist.fLeft, + info.fDevOutsideAssist.fTop, info.fDevOutsideAssist.fRight, + info.fDevOutsideAssist.fBottom, info.fDevInside.fLeft, info.fDevInside.fTop, + info.fDevInside.fRight, info.fDevInside.fBottom, info.fDegenerate); } string.append(DumpPipelineInfo(*this->pipeline())); string.append(INHERITED::dumpInfo()); @@ -170,8 +166,7 @@ public: void computePipelineOptimizations(GrInitInvariantOutput* color, GrInitInvariantOutput* coverage, GrBatchToXPOverrides* overrides) const override { - // When this is called there is only one rect. - color->setKnownFourComponents(fGeoData[0].fColor); + color->setKnownFourComponents(fRects[0].fColor); coverage->setUnknownSingleComponent(); } @@ -191,11 +186,8 @@ private: static const GrBuffer* GetIndexBuffer(GrResourceProvider* resourceProvider, bool miterStroke); - GrColor color() const { return fBatch.fColor; } - bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } - bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCoverage; } - bool colorIgnored() const { return fBatch.fColorIgnored; } - bool coverageIgnored() const { return fBatch.fCoverageIgnored; } + bool usesLocalCoords() const { return fUsesLocalCoords; } + bool canTweakAlphaForCoverage() const { return fCanTweakAlphaForCoverage; } const SkMatrix& viewMatrix() const { return fViewMatrix; } bool miterStroke() const { return fMiterStroke; } @@ -214,16 +206,8 @@ private: bool degenerate, bool tweakAlphaForCoverage) const; - struct BatchTracker { - GrColor fColor; - bool fUsesLocalCoords; - bool fColorIgnored; - bool fCoverageIgnored; - bool fCanTweakAlphaForCoverage; - }; - // TODO support AA rotated stroke rects by copying around view matrices - struct Geometry { + struct RectInfo { GrColor fColor; SkRect fDevOutside; SkRect fDevOutsideAssist; @@ -231,8 +215,9 @@ private: bool fDegenerate; }; - BatchTracker fBatch; - SkSTArray<1, Geometry, true> fGeoData; + SkSTArray<1, RectInfo, true> fRects; + bool fUsesLocalCoords; + bool fCanTweakAlphaForCoverage; SkMatrix fViewMatrix; bool fMiterStroke; @@ -240,18 +225,14 @@ private: }; void AAStrokeRectOp::initBatchTracker(const GrXPOverridesForBatch& overrides) { - // Handle any color overrides if (!overrides.readsColor()) { - fGeoData[0].fColor = GrColor_ILLEGAL; + fRects[0].fColor = GrColor_ILLEGAL; } - overrides.getOverrideColorIfSet(&fGeoData[0].fColor); + overrides.getOverrideColorIfSet(&fRects[0].fColor); // setup batch properties - fBatch.fColorIgnored = !overrides.readsColor(); - fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); - fBatch.fCoverageIgnored = !overrides.readsCoverage(); - fBatch.fCanTweakAlphaForCoverage = overrides.canTweakAlphaForCoverage(); + fUsesLocalCoords = overrides.readsLocalCoords(); + fCanTweakAlphaForCoverage = overrides.canTweakAlphaForCoverage(); } void AAStrokeRectOp::onPrepareDraws(Target* target) const { @@ -259,8 +240,7 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) const { sk_sp<GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlphaForCoverage, this->viewMatrix(), - this->usesLocalCoords(), - this->coverageIgnored())); + this->usesLocalCoords())); if (!gp) { SkDebugf("Couldn't create GrGeometryProcessor\n"); return; @@ -275,7 +255,7 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) const { int outerVertexNum = this->miterStroke() ? 4 : 8; int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2; int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexCnt; - int instanceCount = fGeoData.count(); + int instanceCount = fRects.count(); const sk_sp<const GrBuffer> indexBuffer( GetIndexBuffer(target->resourceProvider(), this->miterStroke())); @@ -289,18 +269,18 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) const { } for (int i = 0; i < instanceCount; i++) { - const Geometry& args = fGeoData[i]; + const RectInfo& info = fRects[i]; this->generateAAStrokeRectGeometry(vertices, i * verticesPerInstance * vertexStride, vertexStride, outerVertexNum, innerVertexNum, - args.fColor, - args.fDevOutside, - args.fDevOutsideAssist, - args.fDevInside, + info.fColor, + info.fDevOutside, + info.fDevOutsideAssist, + info.fDevInside, fMiterStroke, - args.fDegenerate, + info.fDegenerate, canTweakAlphaForCoverage); } helper.recordDraw(target, gp.get()); @@ -423,13 +403,10 @@ bool AAStrokeRectOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) { // In the event of two ops, one who can tweak, one who cannot, we just fall back to not // tweaking. if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) { - fBatch.fCanTweakAlphaForCoverage = false; + fCanTweakAlphaForCoverage = false; } - if (this->color() != that->color()) { - fBatch.fColor = GrColor_ILLEGAL; - } - fGeoData.push_back_n(that->fGeoData.count(), that->fGeoData.begin()); + fRects.push_back_n(that->fRects.count(), that->fRects.begin()); this->joinBounds(*that); return true; } |