Revert of Rework GrPipelineInfo (patchset #7 id:120001 of https://codereview.chromium.org/1213383005/)

Reason for revert:
breaking stuff!

Original issue's description:
> Makes GrPipelineInfo a class with query functions used by GrBatch subclasses.
>
> Committed: https://skia.googlesource.com/skia/+/f5179a4c490bc787190321bd8ffdb0e6a4efa9ac

TBR=joshualitt@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1213013003
This commit is contained in:
bsalomon 2015-07-08 10:20:21 -07:00 committed by Commit bot
parent 60c0475575
commit d07a2793ba
26 changed files with 189 additions and 238 deletions

View File

@ -103,6 +103,10 @@ public:
* Optimizations for blending / coverage that an OptDrawState should apply to itself.
*/
enum OptFlags {
/**
* No optimizations needed
*/
kNone_Opt = 0,
/**
* The draw can be skipped completely.
*/
@ -125,8 +129,6 @@ public:
kCanTweakAlphaForCoverage_OptFlag = 0x20,
};
static const OptFlags kNone_OptFlags = (OptFlags)0;
GR_DECL_BITFIELD_OPS_FRIENDS(OptFlags);
/**

View File

@ -271,7 +271,7 @@ GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations(const GrProcOptInfo&
bool doesStencilWrite,
GrColor* overrideColor,
const GrCaps& caps) {
return GrXferProcessor::kNone_OptFlags;
return GrXferProcessor::kNone_Opt;
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -761,18 +761,19 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSegmentMasks();
fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage();
fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage;
}
void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) {

View File

@ -157,15 +157,16 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fBatch.fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fBatch.fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fBatch.fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
struct FlushInfo {

View File

@ -700,16 +700,17 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
fBatch.fCoverage = fGeoData[0].fCoverage;
}

View File

@ -136,18 +136,19 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSegmentMasks();
fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage();
fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage;
}
void draw(GrBatchTarget* batchTarget, const GrPipeline* pipeline, int vertexCount,

View File

@ -76,16 +76,18 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
fBatch.fColor = GrColor_ILLEGAL;
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fBatch.fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
@ -422,18 +424,19 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
fBatch.fMiterStroke = fGeoData[0].fMiterStroke;
fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage();
fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {

View File

@ -1498,15 +1498,16 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fBatch.fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fBatch.fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fBatch.fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
struct FlushInfo {

View File

@ -24,16 +24,16 @@ public:
GrColor color,
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix,
bool localCoordsWillBeRead,
bool coverageWillBeIgnored,
bool usesLocalCoords,
bool coverageIgnored,
uint8_t coverage) {
return SkNEW_ARGS(DefaultGeoProc, (gpTypeFlags,
color,
viewMatrix,
localMatrix,
coverage,
localCoordsWillBeRead,
coverageWillBeIgnored));
usesLocalCoords,
coverageIgnored));
}
const char* name() const override { return "DefaultGeometryProcessor"; }
@ -47,9 +47,9 @@ public:
bool hasVertexColor() const { return SkToBool(fInColor); }
const SkMatrix& viewMatrix() const { return fViewMatrix; }
const SkMatrix& localMatrix() const { return fLocalMatrix; }
bool localCoordsWillBeRead() const { return fLocalCoordsWillBeRead; }
bool usesLocalCoords() const { return fUsesLocalCoords; }
uint8_t coverage() const { return fCoverage; }
bool coverageWillBeIgnored() const { return fCoverageWillBeIgnored; }
bool coverageIgnored() const { return fCoverageIgnored; }
bool hasVertexCoverage() const { return SkToBool(fInCoverage); }
class GLProcessor : public GrGLGeometryProcessor {
@ -90,7 +90,7 @@ public:
}
// Setup coverage as pass through
if (!gp.coverageWillBeIgnored()) {
if (!gp.coverageIgnored()) {
if (gp.hasVertexCoverage()) {
fs->codeAppendf("float alpha = 1.0;");
args.fPB->addPassThroughAttribute(gp.inCoverage(), "alpha");
@ -116,12 +116,11 @@ public:
const DefaultGeoProc& def = gp.cast<DefaultGeoProc>();
uint32_t key = def.fFlags;
key |= def.colorIgnored() << 8;
key |= def.coverageWillBeIgnored() << 9;
key |= def.coverageIgnored() << 9;
key |= def.hasVertexColor() << 10;
key |= def.hasVertexCoverage() << 11;
key |= def.coverage() == 0xff ? 0x1 << 12 : 0;
key |= def.localCoordsWillBeRead() && def.localMatrix().hasPerspective() ? 0x1 << 24 :
0x0;
key |= def.usesLocalCoords() && def.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0;
key |= ComputePosKey(def.viewMatrix()) << 25;
b->add32(key);
}
@ -145,8 +144,7 @@ public:
fColor = dgp.color();
}
if (!dgp.coverageWillBeIgnored() &&
dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) {
if (!dgp.coverageIgnored() && dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) {
pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverage()));
fCoverage = dgp.coverage();
}
@ -187,8 +185,8 @@ private:
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix,
uint8_t coverage,
bool localCoordsWillBeRead,
bool coverageWillBeIgnored)
bool usesLocalCoords,
bool coverageIgnored)
: fInPosition(NULL)
, fInColor(NULL)
, fInLocalCoords(NULL)
@ -198,8 +196,8 @@ private:
, fLocalMatrix(localMatrix)
, fCoverage(coverage)
, fFlags(gpTypeFlags)
, fLocalCoordsWillBeRead(localCoordsWillBeRead)
, fCoverageWillBeIgnored(coverageWillBeIgnored) {
, fUsesLocalCoords(usesLocalCoords)
, fCoverageIgnored(coverageIgnored) {
this->initClassID<DefaultGeoProc>();
bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_GPType);
bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLocalCoord_GPType);
@ -216,7 +214,7 @@ private:
}
if (hasCoverage) {
fInCoverage = &this->addVertexAttrib(Attribute("inCoverage",
kFloat_GrVertexAttribType));
kFloat_GrVertexAttribType));
}
}
@ -229,8 +227,8 @@ private:
SkMatrix fLocalMatrix;
uint8_t fCoverage;
uint32_t fFlags;
bool fLocalCoordsWillBeRead;
bool fCoverageWillBeIgnored;
bool fUsesLocalCoords;
bool fCoverageIgnored;
GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
@ -265,8 +263,8 @@ GrGeometryProcessor* DefaultGeoProc::TestCreate(SkRandom* random,
const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags,
GrColor color,
bool localCoordsWillBeRead,
bool coverageWillBeIgnored,
bool usesLocalCoords,
bool coverageIgnored,
const SkMatrix& viewMatrix,
const SkMatrix& localMatrix,
uint8_t coverage) {
@ -274,7 +272,7 @@ const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(uint32_t gpTypeFlags,
color,
viewMatrix,
localMatrix,
localCoordsWillBeRead,
coverageWillBeIgnored,
usesLocalCoords,
coverageIgnored,
coverage);
}

View File

@ -74,17 +74,17 @@ public:
};
/*
* The following functions are used to create default GPs. If you just need to create
* attributes separately from creating the default GP, use the SetAttribs function followed
* by the Create function. Otherwise use CreateAndSetAttribs to do both at once.
* The following functions are used to create default GPs. If you just need to create
* attributes seperately from creating the default GP, use the SetAttribs function followed
* by the Create function. Otherwise use CreateAndSetAttribs to do both at once.
*
* You must unref the return from Create.
*/
// TODO clean this up
static const GrGeometryProcessor* Create(uint32_t gpTypeFlags,
GrColor,
bool localCoordsWillBeRead,
bool coverageWillBeIgnored,
bool usesLocalCoords,
bool coverageIgnored,
const SkMatrix& viewMatrix = SkMatrix::I(),
const SkMatrix& localMatrix = SkMatrix::I(),
uint8_t coverage = 0xff);

View File

@ -237,16 +237,17 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {

View File

@ -275,16 +275,17 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
@ -613,16 +614,17 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {

View File

@ -33,7 +33,7 @@ void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch,
return;
}
batch->initBatchTracker(pipeline->infoForPrimitiveProcessor());
batch->initBatchTracker(pipeline->getInitBatchTracker());
fBatchTarget.resetNumberOfDraws();

View File

@ -157,8 +157,8 @@ GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor* prim
return NULL;
}
state->fPrimitiveProcessor->initBatchTracker(
&state->fBatchTracker, state->getPipeline()->infoForPrimitiveProcessor());
state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker,
state->getPipeline()->getInitBatchTracker());
if (fPrevState && fPrevState->fPrimitiveProcessor.get() &&
fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
@ -186,7 +186,7 @@ GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch,
return NULL;
}
batch->initBatchTracker(state->getPipeline()->infoForPrimitiveProcessor());
batch->initBatchTracker(state->getPipeline()->getInitBatchTracker());
if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
fPrevState->getPipeline()->isEqual(*state->getPipeline())) {

View File

@ -661,17 +661,18 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fStroke = fGeoData[0].fStroke;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
@ -875,17 +876,18 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsCoverage()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fStroke = fGeoData[0].fStroke;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
@ -1138,17 +1140,18 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fMode = fGeoData[0].fMode;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
@ -1486,17 +1489,18 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fStroke = fGeoData[0].fStroke;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
@ -1658,17 +1662,18 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fStroke = fGeoData[0].fStroke;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {

View File

@ -32,18 +32,17 @@ void GrPathProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) con
void GrPathProcessor::initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const {
PathBatchTracker* local = bt->cast<PathBatchTracker>();
if (!init.readsColor()) {
if (init.fColorIgnored) {
local->fInputColorType = kIgnored_GrGPInput;
local->fColor = GrColor_ILLEGAL;
} else {
local->fInputColorType = kUniform_GrGPInput;
if (!init.getOverrideColorIfSet(&local->fColor)) {
local->fColor = this->color();
}
local->fColor = GrColor_ILLEGAL == init.fOverrideColor ? this->color() :
init.fOverrideColor;
}
local->fInputCoverageType = init.readsCoverage() ? kAllOnes_GrGPInput : kIgnored_GrGPInput;
local->fUsesLocalCoords = init.readsLocalCoords();
local->fInputCoverageType = init.fCoverageIgnored ? kIgnored_GrGPInput : kAllOnes_GrGPInput;
local->fUsesLocalCoords = init.fUsesLocalCoords;
}
bool GrPathProcessor::canMakeEqual(const GrBatchTracker& m,

View File

@ -30,7 +30,7 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder,
overrideColor = colorPOI.inputColorToEffectiveStage();
}
GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
GrXferProcessor::OptFlags optFlags;
if (xferProcessor) {
fXferProcessor.reset(xferProcessor.get());
@ -41,11 +41,6 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder,
caps);
}
// No need to have an override color if it isn't even going to be used.
if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag)) {
overrideColor = GrColor_ILLEGAL;
}
// When path rendering the stencil settings are not always set on the GrPipelineBuilder
// so we must check the draw type. In cases where we will skip drawing we simply return a
// null GrPipeline.
@ -103,25 +98,13 @@ GrPipeline::GrPipeline(const GrPipelineBuilder& pipelineBuilder,
pipelineBuilder.fCoverageStages[i].processor()->usesLocalCoords();
}
// Setup info we need to pass to GrPrimitiveProcessors that are used with this GrPipeline.
fInfoForPrimitiveProcessor.fFlags = 0;
if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) {
fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsColor_GrPipelineInfoFlag;
}
if (GrColor_ILLEGAL != overrideColor) {
fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kUseOverrideColor_GrPipelineInfoFlag;
fInfoForPrimitiveProcessor.fOverrideColor = overrideColor;
}
if (!SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag)) {
fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsCoverage_GrPipelineInfoFlag;
}
if (usesLocalCoords) {
fInfoForPrimitiveProcessor.fFlags |= GrPipelineInfo::kReadsLocalCoords_GrPipelineInfoFlag;
}
if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag)) {
fInfoForPrimitiveProcessor.fFlags |=
GrPipelineInfo::kCanTweakAlphaForCoverage_GrPipelineInfoFlag;
}
// let the GP init the batch tracker
fInitBT.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag);
fInitBT.fOverrideColor = fInitBT.fColorIgnored ? GrColor_ILLEGAL : overrideColor;
fInitBT.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage_OptFlag);
fInitBT.fUsesLocalCoords = usesLocalCoords;
fInitBT.fCanTweakAlphaForCoverage =
SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag);
}
void GrPipeline::adjustProgramFromOptimizations(const GrPipelineBuilder& pipelineBuilder,

View File

@ -97,9 +97,7 @@ public:
bool readsFragPosition() const { return fReadsFragPosition; }
const GrPipelineInfo& infoForPrimitiveProcessor() const {
return fInfoForPrimitiveProcessor;
}
const GrPipelineInfo& getInitBatchTracker() const { return fInitBT; }
private:
/**
@ -137,7 +135,7 @@ private:
ProgramXferProcessor fXferProcessor;
FragmentStageArray fFragmentStages;
bool fReadsFragPosition;
GrPipelineInfo fInfoForPrimitiveProcessor;
GrPipelineInfo fInitBT;
// This function is equivalent to the offset into fFragmentStages where coverage stages begin.
int fNumColorStages;

View File

@ -72,65 +72,16 @@ class GrGLPrimitiveProcessor;
struct GrInitInvariantOutput;
/*
* This class allows the GrPipeline to communicate information about the pipeline to a
* GrPrimitiveProcessor that will be used in conjunction with the GrPipeline.
* This struct allows the GrPipeline to communicate information about the pipeline. Most of this
* is overrides, but some of it is general information. Logically it should live in GrPipeline.h,
* but this is problematic due to circular dependencies.
*/
class GrPipelineInfo {
public:
/** Does the pipeline require the GrPrimitiveProcessor's color? */
bool readsColor() const { return SkToBool(kReadsColor_GrPipelineInfoFlag & fFlags); }
/** Does the pipeline require the GrPrimitiveProcessor's coverage? */
bool readsCoverage() const { return SkToBool(kReadsCoverage_GrPipelineInfoFlag & fFlags); }
/** Does the pipeline require access to (implicit or explicit) local coordinates? */
bool readsLocalCoords() const {
return SkToBool(kReadsLocalCoords_GrPipelineInfoFlag & fFlags);
}
/** Does the pipeline allow the GrPrimitiveProcessor to combine color and coverage into one
color output ? */
bool canTweakAlphaForCoverage() const {
return SkToBool(kCanTweakAlphaForCoverage_GrPipelineInfoFlag & fFlags);
}
/** Does the pipeline require the GrPrimitiveProcessor to specify a specific color (and if
so get the color)? */
bool getOverrideColorIfSet(GrColor* overrideColor) const {
if (SkToBool(kUseOverrideColor_GrPipelineInfoFlag & fFlags)) {
SkASSERT(SkToBool(kReadsColor_GrPipelineInfoFlag & fFlags));
if (overrideColor) {
*overrideColor = fOverrideColor;
}
return true;
}
return false;
}
private:
enum {
// If this is not set the primitive processor need not produce a color output
kReadsColor_GrPipelineInfoFlag = 0x1,
// If this is not set the primitive processor need not produce a coverage output
kReadsCoverage_GrPipelineInfoFlag = 0x2,
// If this is not set the primitive processor need not produce local coordinates
kReadsLocalCoords_GrPipelineInfoFlag = 0x4,
// If this flag is set then the primitive processor may produce color*coverage as
// its color output (and not output a separate coverage).
kCanTweakAlphaForCoverage_GrPipelineInfoFlag = 0x8,
// If this flag is set the GrPrimitiveProcessor must produce fOverrideColor as its
// output color. If not set fOverrideColor is to be ignored.
kUseOverrideColor_GrPipelineInfoFlag = 0x10,
};
uint32_t fFlags;
GrColor fOverrideColor;
friend class GrPipeline; // To initialize this
struct GrPipelineInfo {
bool fColorIgnored;
bool fCoverageIgnored;
GrColor fOverrideColor;
bool fUsesLocalCoords;
bool fCanTweakAlphaForCoverage;
};
/*

View File

@ -70,16 +70,17 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {

View File

@ -1375,10 +1375,11 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fColor);
fPipelineInfo = init;
}
@ -1411,8 +1412,8 @@ public:
LOG("got %d pts, %d contours\n", maxPts, contourCnt);
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType;
SkAutoTUnref<const GrGeometryProcessor> gp(
GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.readsLocalCoords(),
!fPipelineInfo.readsCoverage(), fViewMatrix,
GrDefaultGeoProcFactory::Create(flags, fColor, fPipelineInfo.fUsesLocalCoords,
fPipelineInfo.fCoverageIgnored, fViewMatrix,
SkMatrix::I()));
batchTarget->initDraw(gp, pipeline);

View File

@ -34,16 +34,17 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
this->geoData(0)->fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
this->geoData(0)->fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&this->geoData(0)->fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = this->geoData(0)->fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {

View File

@ -755,7 +755,7 @@ GrXferProcessor::OptFlags CustomXP::onGetOptimizations(const GrProcOptInfo& colo
= blend(f*Sa, Da)
*/
OptFlags flags = kNone_OptFlags;
OptFlags flags = kNone_Opt;
if (colorPOI.allStagesMultiplyInput()) {
flags |= kCanTweakAlphaForCoverage_OptFlag;
}

View File

@ -274,16 +274,17 @@ public:
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
if (init.fColorIgnored) {
fGeoData[0].fColor = GrColor_ILLEGAL;
} else if (GrColor_ILLEGAL != init.fOverrideColor) {
fGeoData[0].fColor = init.fOverrideColor;
}
init.getOverrideColorIfSet(&fGeoData[0].fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColorIgnored = init.fColorIgnored;
fBatch.fColor = fGeoData[0].fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
fBatch.fCoverageIgnored = init.fCoverageIgnored;
}
struct DashDraw {

View File

@ -428,7 +428,7 @@ PorterDuffXferProcessor::onGetOptimizations(const GrProcOptInfo& colorPOI,
bool doesStencilWrite,
GrColor* overrideColor,
const GrCaps& caps) {
GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_Opt;
if (!fBlendFormula.modifiesDst()) {
if (!doesStencilWrite) {
optFlags |= GrXferProcessor::kSkipDraw_OptFlag;
@ -471,7 +471,7 @@ public:
private:
GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo&, const GrProcOptInfo&,
bool, GrColor*, const GrCaps&) override {
return kNone_OptFlags;
return kNone_Opt;
}
void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;

View File

@ -62,7 +62,7 @@ enum {
};
enum {
kNone_OptFlags = GrXferProcessor::kNone_OptFlags,
kNone_Opt = GrXferProcessor::kNone_Opt,
kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag,
kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag,
kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag,
@ -128,7 +128,7 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
case SkXfermode::kSrc_Mode:
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
TEST_ASSERT((kNone_Opt) == xpi.fOptFlags);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
@ -175,7 +175,7 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
case SkXfermode::kSrcIn_Mode:
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
TEST_ASSERT((kNone_Opt) == xpi.fOptFlags);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
@ -186,7 +186,7 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
case SkXfermode::kDstIn_Mode:
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
TEST_ASSERT((kNone_Opt) == xpi.fOptFlags);
TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
@ -197,7 +197,7 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
case SkXfermode::kSrcOut_Mode:
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
TEST_ASSERT((kNone_Opt) == xpi.fOptFlags);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
@ -230,7 +230,7 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
case SkXfermode::kDstATop_Mode:
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
TEST_ASSERT((kNone_Opt) == xpi.fOptFlags);
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
@ -263,7 +263,7 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
case SkXfermode::kModulate_Mode:
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
TEST_ASSERT((kNone_Opt) == xpi.fOptFlags);
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
@ -663,7 +663,7 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
case SkXfermode::kModulate_Mode:
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
TEST_ASSERT((kNone_Opt) == xpi.fOptFlags);
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);