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

Unified Diff: src/gpu/GrAAConvexPathRenderer.cpp

Issue 1139723004: Preliminary attempt to remove batch tracker (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanup5
Patch Set: tweaks Created 5 years, 7 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 | « gm/convexpolyeffect.cpp ('k') | src/gpu/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAAConvexPathRenderer.cpp
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 0d909b1dc6bd2b419431e84e5b4c99b5700180c4..1b7efefd07fc3888fd717d0d55fa4f3f4538aa9a 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -525,8 +525,9 @@ static void create_vertices(const SegmentArray& segments,
class QuadEdgeEffect : public GrGeometryProcessor {
public:
- static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatrix) {
- return SkNEW_ARGS(QuadEdgeEffect, (color, localMatrix));
+ static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatrix,
+ bool usesLocalCoords) {
+ return SkNEW_ARGS(QuadEdgeEffect, (color, localMatrix, usesLocalCoords));
}
virtual ~QuadEdgeEffect() {}
@@ -536,7 +537,9 @@ public:
const Attribute* inPosition() const { return fInPosition; }
const Attribute* inQuadEdge() const { return fInQuadEdge; }
GrColor color() const { return fColor; }
+ bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
const SkMatrix& localMatrix() const { return fLocalMatrix; }
+ bool usesLocalCoords() const { return fUsesLocalCoords; }
class GLProcessor : public GrGLGeometryProcessor {
public:
@@ -556,11 +559,10 @@ public:
args.fPB->addVarying("QuadEdge", &v);
vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName);
- const BatchTracker& local = args.fBT.cast<BatchTracker>();
-
// Setup pass through color
- this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NULL,
- &fColorUniform);
+ if (!qe.colorIgnored()) {
+ this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
+ }
// Setup position
this->setupPosition(pb, gpArgs, qe.inPosition()->fName);
@@ -598,22 +600,22 @@ public:
const GrBatchTracker& bt,
const GrGLSLCaps&,
GrProcessorKeyBuilder* b) {
- const BatchTracker& local = bt.cast<BatchTracker>();
const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>();
- uint32_t key = local.fInputColorType << 16;
- key |= local.fUsesLocalCoords && qee.localMatrix().hasPerspective() ? 0x1 : 0x0;
+ uint32_t key = 0;
+ key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ? 0x1 : 0x0;
+ key |= qee.colorIgnored() ? 0x2 : 0x0;
b->add32(key);
}
virtual void setData(const GrGLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp,
const GrBatchTracker& bt) override {
- const BatchTracker& local = bt.cast<BatchTracker>();
- if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
+ const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>();
+ if (qe.color() != fColor) {
GrGLfloat c[4];
- GrColorToRGBAFloat(local.fColor, c);
+ GrColorToRGBAFloat(qe.color(), c);
pdman.set4fv(fColorUniform, 1, c);
- fColor = local.fColor;
+ fColor = qe.color();
}
}
@@ -642,31 +644,21 @@ public:
return SkNEW_ARGS(GLProcessor, (*this, bt));
}
- void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const override {
- BatchTracker* local = bt->cast<BatchTracker>();
- local->fInputColorType = GetColorInputType(&local->fColor, this->color(), init, false);
- local->fUsesLocalCoords = init.fUsesLocalCoords;
- }
-
private:
- QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix)
+ QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix, bool usesLocalCoords)
: fColor(color)
- , fLocalMatrix(localMatrix) {
+ , fLocalMatrix(localMatrix)
+ , fUsesLocalCoords(usesLocalCoords) {
this->initClassID<QuadEdgeEffect>();
fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType));
fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVertexAttribType));
}
- struct BatchTracker {
- GrGPInput fInputColorType;
- GrColor fColor;
- bool fUsesLocalCoords;
- };
-
const Attribute* fInPosition;
const Attribute* fInQuadEdge;
GrColor fColor;
SkMatrix fLocalMatrix;
+ bool fUsesLocalCoords;
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
@@ -682,7 +674,8 @@ GrGeometryProcessor* QuadEdgeEffect::TestCreate(SkRandom* random,
// Doesn't work without derivative instructions.
return caps.shaderCaps()->shaderDerivativeSupport() ?
QuadEdgeEffect::Create(GrRandomColor(random),
- GrTest::TestMatrix(random)) : NULL;
+ GrTest::TestMatrix(random),
+ random->nextBool()) : NULL;
}
///////////////////////////////////////////////////////////////////////////////
@@ -732,13 +725,16 @@ static void extract_verts(const GrAAConvexTessellator& tess,
}
static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage,
- const SkMatrix& localMatrix) {
+ const SkMatrix& localMatrix,
+ bool usesLocalCoords,
+ bool coverageIgnored) {
uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType;
if (!tweakAlphaForCoverage) {
flags |= GrDefaultGeoProcFactory::kCoverage_GPType;
}
- return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, SkMatrix::I(), localMatrix);
+ return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords, coverageIgnored,
+ SkMatrix::I(), localMatrix);
}
class AAConvexPathBatch : public GrBatch {
@@ -791,18 +787,12 @@ public:
// Setup GrGeometryProcessor
SkAutoTUnref<const GrGeometryProcessor> gp(
- create_fill_gp(canTweakAlphaForCoverage, invert));
+ create_fill_gp(canTweakAlphaForCoverage, invert,
+ this->usesLocalCoords(),
+ this->coverageIgnored()));
batchTarget->initDraw(gp, pipeline);
- // TODO remove this when batch is everywhere
- GrPipelineInfo init;
- init.fColorIgnored = fBatch.fColorIgnored;
- init.fOverrideColor = GrColor_ILLEGAL;
- init.fCoverageIgnored = fBatch.fCoverageIgnored;
- init.fUsesLocalCoords = this->usesLocalCoords();
- gp->initBatchTracker(batchTarget->currentBatchTracker(), init);
-
size_t vertexStride = gp->getVertexStride();
SkASSERT(canTweakAlphaForCoverage ?
@@ -870,19 +860,11 @@ public:
}
// Setup GrGeometryProcessor
- SkAutoTUnref<GrGeometryProcessor> quadProcessor(QuadEdgeEffect::Create(this->color(),
- invert));
+ SkAutoTUnref<GrGeometryProcessor> quadProcessor(
+ QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoords()));
batchTarget->initDraw(quadProcessor, pipeline);
- // TODO remove this when batch is everywhere
- GrPipelineInfo init;
- init.fColorIgnored = fBatch.fColorIgnored;
- init.fOverrideColor = GrColor_ILLEGAL;
- init.fCoverageIgnored = fBatch.fCoverageIgnored;
- init.fUsesLocalCoords = this->usesLocalCoords();
- quadProcessor->initBatchTracker(batchTarget->currentBatchTracker(), init);
-
// TODO generate all segments for all paths and use one vertex buffer
for (int i = 0; i < instanceCount; i++) {
Geometry& args = fGeoData[i];
@@ -991,6 +973,7 @@ private:
bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCoverage; }
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
+ bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
struct BatchTracker {
GrColor fColor;
« no previous file with comments | « gm/convexpolyeffect.cpp ('k') | src/gpu/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698