This is being stored and passed in places where it is unneeded or only 1 or 2 of its flags are needed.
Change-Id: Ifded9e645c0380e792708064ad69449653668acf
Reviewed-on: https://skia-review.googlesource.com/6583
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
};
GrPathProcessor::GrPathProcessor(GrColor color,
- const GrPipelineOptimizations& optimizations,
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix)
: fColor(color)
, fViewMatrix(viewMatrix)
- , fLocalMatrix(localMatrix)
- , fOptimizations(optimizations) {
+ , fLocalMatrix(localMatrix) {
this->initClassID<GrPathProcessor>();
}
class GrPathProcessor : public GrPrimitiveProcessor {
public:
static GrPathProcessor* Create(GrColor color,
- const GrPipelineOptimizations& optimizations,
const SkMatrix& viewMatrix = SkMatrix::I(),
const SkMatrix& localMatrix = SkMatrix::I()) {
- return new GrPathProcessor(color, optimizations, viewMatrix, localMatrix);
+ return new GrPathProcessor(color, viewMatrix, localMatrix);
}
const char* name() const override { return "PathProcessor"; }
virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
- const GrPipelineOptimizations& optimizations() const { return fOptimizations; }
-
virtual bool isPathRendering() const override { return true; }
private:
- GrPathProcessor(GrColor, const GrPipelineOptimizations&, const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix);
+ GrPathProcessor(GrColor, const SkMatrix& viewMatrix, const SkMatrix& localMatrix);
bool hasExplicitLocalCoords() const override { return false; }
GrColor fColor;
const SkMatrix fViewMatrix;
const SkMatrix fLocalMatrix;
- GrPipelineOptimizations fOptimizations;
typedef GrPrimitiveProcessor INHERITED;
};
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect,
- const GrPipelineOptimizations& optimizations,
+ bool tweakAlphaForCoverage,
const SkMatrix* localMatrix) {
SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride);
localCoordMatrix.mapPointsWithStride(fan0Loc, fan0Pos, vertexStride, 8);
}
- bool tweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage();
-
// Make verts point to vertex color and then set all the color and coverage vertex attrs
// values.
verts += sizeof(SkPoint);
if (optimizations.getOverrideColorIfSet(&color)) {
this->first()->setColor(color);
}
- fOptimizations = optimizations;
+ fCanTweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage();
+ fNeedsLocalCoords = optimizations.readsLocalCoords();
}
private:
}
void onPrepareDraws(Target* target) const override {
- bool needLocalCoords = fOptimizations.readsLocalCoords();
using namespace GrDefaultGeoProcFactory;
Color color(Color::kAttribute_Type);
Coverage::Type coverageType;
- if (fOptimizations.canTweakAlphaForCoverage()) {
+ if (fCanTweakAlphaForCoverage) {
coverageType = Coverage::kSolid_Type;
} else {
coverageType = Coverage::kAttribute_Type;
}
LocalCoords lc =
- needLocalCoords ? LocalCoords::kHasExplicit_Type : LocalCoords::kUnused_Type;
+ fNeedsLocalCoords ? LocalCoords::kHasExplicit_Type : LocalCoords::kUnused_Type;
sk_sp<GrGeometryProcessor> gp =
GrDefaultGeoProcFactory::Make(color, coverageType, lc, SkMatrix::I());
if (!gp) {
for (int i = 0; i < fRectCnt; i++) {
intptr_t verts =
reinterpret_cast<intptr_t>(vertices) + i * kVertsPerAAFillRect * vertexStride;
- if (needLocalCoords) {
+ if (fNeedsLocalCoords) {
if (info->hasLocalMatrix()) {
localMatrix = &static_cast<const RectWithLocalMatrixInfo*>(info)->localMatrix();
} else {
}
}
generate_aa_fill_rect_geometry(verts, vertexStride, info->color(), info->viewMatrix(),
- info->rect(), info->devRect(), fOptimizations,
+ info->rect(), info->devRect(), fCanTweakAlphaForCoverage,
localMatrix);
info = this->next(info);
}
return false;
}
+ SkASSERT(fNeedsLocalCoords == that->fNeedsLocalCoords);
+
// In the event of two ops, one who can tweak, one who cannot, we just fall back to not
// tweaking.
- if (fOptimizations.canTweakAlphaForCoverage() &&
- !that->fOptimizations.canTweakAlphaForCoverage()) {
- fOptimizations = that->fOptimizations;
+ if (fCanTweakAlphaForCoverage && !that->fCanTweakAlphaForCoverage) {
+ fCanTweakAlphaForCoverage = false;
}
fRectData.push_back_n(that->fRectData.count(), that->fRectData.begin());
return reinterpret_cast<const RectInfo*>(next);
}
- GrPipelineOptimizations fOptimizations;
+ bool fNeedsLocalCoords;
+ bool fCanTweakAlphaForCoverage;
SkSTArray<4 * sizeof(RectWithLocalMatrixInfo), uint8_t, true> fRectData;
int fRectCnt;
GrProgramDesc desc;
sk_sp<GrPathProcessor> pathProc(
- GrPathProcessor::Create(this->color(), this->optimizations(), this->viewMatrix()));
+ GrPathProcessor::Create(this->color(), this->viewMatrix()));
state->gpu()->pathRendering()->drawPath(*this->pipeline(), *pathProc,
this->stencilPassSettings(), fPath.get());
}
// combined. (Glyphs in the same font tend to wind the same direction so it works out OK.)
if (GrPathRendering::kWinding_FillType != this->fillType() ||
GrPathRendering::kWinding_FillType != that->fillType() ||
- this->optimizations().willColorBlendWithDst()) {
+ this->blendsWithDst()) {
return false;
}
- SkASSERT(!that->optimizations().willColorBlendWithDst());
+ SkASSERT(!that->blendsWithDst());
fTotalPathCount += that->fTotalPathCount;
while (Draw* head = that->fDraws.head()) {
Draw* draw = fDraws.addToTail();
localMatrix.preTranslate(head.fX, head.fY);
sk_sp<GrPathProcessor> pathProc(
- GrPathProcessor::Create(this->color(), this->optimizations(), drawMatrix, localMatrix));
+ GrPathProcessor::Create(this->color(), drawMatrix, localMatrix));
if (fDraws.count() == 1) {
const InstanceData& instances = *head.fInstanceData;
}
protected:
- const GrPipelineOptimizations& optimizations() const { return fOptimizations; }
const SkMatrix& viewMatrix() const { return fViewMatrix; }
GrColor color() const { return fColor; }
GrPathRendering::FillType fillType() const { return fFillType; }
+ bool blendsWithDst() const { return fBlendsWithDst; }
private:
void getPipelineAnalysisInput(GrPipelineAnalysisDrawOpInput* input) const override {
void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
- fOptimizations = optimizations;
+ fBlendsWithDst = optimizations.willColorBlendWithDst();
}
void onPrepare(GrOpFlushState*) override; // Initializes fStencilPassSettings.
GrColor fColor;
GrPathRendering::FillType fFillType;
GrStencilSettings fStencilPassSettings;
- GrPipelineOptimizations fOptimizations;
+ bool fBlendsWithDst;
typedef GrDrawOp INHERITED;
};
void applyPipelineOptimizations(const GrPipelineOptimizations& analysioptimizations) override {
analysioptimizations.getOverrideColorIfSet(&fPatches[0].fColor);
- fOptimizations = analysioptimizations;
}
void onPrepareDraws(Target* target) const override {
SkASSERT(this->fImageWidth == that->fImageWidth &&
this->fImageHeight == that->fImageHeight);
- // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
- // tweaking.
- if (fOptimizations.canTweakAlphaForCoverage() &&
- !that->fOptimizations.canTweakAlphaForCoverage()) {
- fOptimizations = that->fOptimizations;
- }
-
fPatches.move_back_n(that->fPatches.count(), that->fPatches.begin());
this->joinBounds(*that);
return true;
GrColor fColor;
};
- GrPipelineOptimizations fOptimizations;
int fImageWidth;
int fImageHeight;
SkSTArray<1, Patch, true> fPatches;
void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fRects[0].fColor);
- fOptimizations = optimizations;
}
void onPrepareDraws(Target* target) const override {
return false;
}
- // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
- // tweaking.
- if (fOptimizations.canTweakAlphaForCoverage() &&
- !that->fOptimizations.canTweakAlphaForCoverage()) {
- fOptimizations = that->fOptimizations;
- }
-
fRects.push_back_n(that->fRects.count(), that->fRects.begin());
this->joinBounds(*that);
return true;
GrQuad fLocalQuad;
};
- GrPipelineOptimizations fOptimizations;
SkSTArray<1, RectInfo, true> fRects;
typedef GrMeshDrawOp INHERITED;
void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fRects[0].fColor);
- fOptimizations = optimizations;
}
void onPrepareDraws(Target* target) const override {
return false;
}
- // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
- // tweaking.
- if (fOptimizations.canTweakAlphaForCoverage() &&
- !that->fOptimizations.canTweakAlphaForCoverage()) {
- fOptimizations = that->fOptimizations;
- }
-
fRects.push_back_n(that->fRects.count(), that->fRects.begin());
this->joinBounds(*that);
return true;
SkRect fLocalRect;
};
- GrPipelineOptimizations fOptimizations;
SkSTArray<1, RectInfo, true> fRects;
bool fHasLocalMatrix;
bool fHasLocalRect;
{
using namespace GrDefaultGeoProcFactory;
Color color(fColor);
- LocalCoords::Type localCoordsType = fOptimizations.readsLocalCoords()
+ LocalCoords::Type localCoordsType = fNeedsLocalCoords
? LocalCoords::kUsePosition_Type
: LocalCoords::kUnused_Type;
gp = GrDefaultGeoProcFactory::Make(color, Coverage::kSolid_Type, localCoordsType,
void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
- fOptimizations = optimizations;
+ fNeedsLocalCoords = optimizations.readsLocalCoords();
}
bool onCombineIfPossible(GrOp* t, const GrCaps&) override {
SkMatrix fViewMatrix;
SkRect fRect;
SkScalar fStrokeWidth;
- GrPipelineOptimizations fOptimizations;
+ bool fNeedsLocalCoords;
const static int kVertsPerHairlineRect = 5;
const static int kVertsPerStrokeRect = 10;
void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fRegions[0].fColor);
- fOptimizations = optimizations;
}
void onPrepareDraws(Target* target) const override {
};
SkMatrix fViewMatrix;
- GrPipelineOptimizations fOptimizations;
SkSTArray<1, RegionInfo, true> fRegions;
typedef GrMeshDrawOp INHERITED;
void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
- fOptimizations = optimizations;
+ fCanTweakAlphaForCoverage = optimizations.canTweakAlphaForCoverage();
+ fNeedsLocalCoords = optimizations.readsLocalCoords();
}
SkPath getPath() const {
SkScalar tol = GrPathUtils::kDefaultTolerance;
bool isLinear;
DynamicVertexAllocator allocator(gp->getVertexStride(), target);
- bool canTweakAlphaForCoverage = fOptimizations.canTweakAlphaForCoverage();
int count = GrTessellator::PathToTriangles(path, tol, clipBounds, &allocator,
- true, fColor, canTweakAlphaForCoverage,
+ true, fColor, fCanTweakAlphaForCoverage,
&isLinear);
if (count == 0) {
return;
using namespace GrDefaultGeoProcFactory;
Color color(fColor);
- LocalCoords::Type localCoordsType = fOptimizations.readsLocalCoords()
+ LocalCoords::Type localCoordsType = fNeedsLocalCoords
? LocalCoords::kUsePosition_Type
: LocalCoords::kUnused_Type;
Coverage::Type coverageType;
if (fAntiAlias) {
color = Color(Color::kAttribute_Type);
- if (fOptimizations.canTweakAlphaForCoverage()) {
+ if (fCanTweakAlphaForCoverage) {
coverageType = Coverage::kSolid_Type;
} else {
coverageType = Coverage::kAttribute_Type;
SkMatrix fViewMatrix;
SkIRect fDevClipBounds;
bool fAntiAlias;
- GrPipelineOptimizations fOptimizations;
+ bool fCanTweakAlphaForCoverage;
+ bool fNeedsLocalCoords;
typedef GrMeshDrawOp INHERITED;
};