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;
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;
}
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);
}
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());
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();
}
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; }
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;
bool fDegenerate;
};
- BatchTracker fBatch;
- SkSTArray<1, Geometry, true> fGeoData;
+ SkSTArray<1, RectInfo, true> fRects;
+ bool fUsesLocalCoords;
+ bool fCanTweakAlphaForCoverage;
SkMatrix fViewMatrix;
bool fMiterStroke;
};
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 {
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;
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()));
}
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());
// 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;
}