diff options
Diffstat (limited to 'src/gpu/GrDrawState.cpp')
-rw-r--r-- | src/gpu/GrDrawState.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp index e1fa6da877..288fa12730 100644 --- a/src/gpu/GrDrawState.cpp +++ b/src/gpu/GrDrawState.cpp @@ -43,7 +43,9 @@ bool GrDrawState::isEqual(const GrDrawState& that) const { if (this->hasGeometryProcessor()) { if (!that.hasGeometryProcessor()) { return false; - } else if (!this->getGeometryProcessor()->isEqual(*that.getGeometryProcessor())) { + } else if (!GrProcessorStage::AreCompatible(*this->getGeometryProcessor(), + *that.getGeometryProcessor(), + explicitLocalCoords)) { return false; } } else if (that.hasGeometryProcessor()) { @@ -51,13 +53,13 @@ bool GrDrawState::isEqual(const GrDrawState& that) const { } for (int i = 0; i < this->numColorStages(); i++) { - if (!GrFragmentStage::AreCompatible(this->getColorStage(i), that.getColorStage(i), + if (!GrProcessorStage::AreCompatible(this->getColorStage(i), that.getColorStage(i), explicitLocalCoords)) { return false; } } for (int i = 0; i < this->numCoverageStages(); i++) { - if (!GrFragmentStage::AreCompatible(this->getCoverageStage(i), that.getCoverageStage(i), + if (!GrProcessorStage::AreCompatible(this->getCoverageStage(i), that.getCoverageStage(i), explicitLocalCoords)) { return false; } @@ -114,6 +116,9 @@ GrDrawState::GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatr SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) *this = state; if (!preConcatMatrix.isIdentity()) { + if (this->hasGeometryProcessor()) { + fGeometryProcessor->localCoordChange(preConcatMatrix); + } for (int i = 0; i < this->numColorStages(); ++i) { fColorStages[i].localCoordChange(preConcatMatrix); } @@ -142,7 +147,7 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) { fCoverage = that.fCoverage; fDrawFace = that.fDrawFace; if (that.hasGeometryProcessor()) { - fGeometryProcessor.initAndRef(that.fGeometryProcessor); + fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*that.fGeometryProcessor.get()))); } else { fGeometryProcessor.reset(NULL); } @@ -197,6 +202,9 @@ bool GrDrawState::setIdentityViewMatrix() { // sad trombone sound return false; } + if (this->hasGeometryProcessor()) { + fGeometryProcessor->localCoordChange(invVM); + } for (int s = 0; s < this->numColorStages(); ++s) { fColorStages[s].localCoordChange(invVM); } @@ -257,7 +265,9 @@ bool GrDrawState::validateVertexAttribs() const { } if (this->hasGeometryProcessor()) { - const GrGeometryProcessor* gp = this->getGeometryProcessor(); + const GrGeometryStage& stage = *this->getGeometryProcessor(); + const GrGeometryProcessor* gp = stage.getProcessor(); + SkASSERT(gp); // make sure that any attribute indices have the correct binding type, that the attrib // type and effect's shader lang type are compatible, and that attributes shared by // multiple effects use the same shader lang type. @@ -400,7 +410,8 @@ bool GrDrawState::hasSolidCoverage() const { // Run through the coverage stages and see if the coverage will be all ones at the end. if (this->hasGeometryProcessor()) { - fGeometryProcessor->computeInvariantOutput(&inout); + const GrGeometryProcessor* gp = fGeometryProcessor->getProcessor(); + gp->computeInvariantOutput(&inout); } for (int s = 0; s < this->numCoverageStages(); ++s) { @@ -445,7 +456,7 @@ void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { if (SK_InvalidUniqueID == fOriginalGPID) { fDrawState->fGeometryProcessor.reset(NULL); } else { - SkASSERT(fDrawState->getGeometryProcessor()->getUniqueID() == + SkASSERT(fDrawState->getGeometryProcessor()->getProcessor()->getUniqueID() == fOriginalGPID); fOriginalGPID = SK_InvalidUniqueID; } @@ -466,7 +477,7 @@ void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { if (NULL != ds) { SkASSERT(SK_InvalidUniqueID == fOriginalGPID); if (NULL != ds->getGeometryProcessor()) { - fOriginalGPID = ds->getGeometryProcessor()->getUniqueID(); + fOriginalGPID = ds->getGeometryProcessor()->getProcessor()->getUniqueID(); } fColorEffectCnt = ds->numColorStages(); fCoverageEffectCnt = ds->numCoverageStages(); @@ -504,9 +515,14 @@ void GrDrawState::AutoViewMatrixRestore::restore() { fDrawState->fViewMatrix = fViewMatrix; SkASSERT(fDrawState->numColorStages() >= fNumColorStages); int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages; + numCoverageStages -= fHasGeometryProcessor ? 1 : 0; SkASSERT(fDrawState->numCoverageStages() >= numCoverageStages); int i = 0; + if (fHasGeometryProcessor) { + SkASSERT(fDrawState->hasGeometryProcessor()); + fDrawState->fGeometryProcessor->restoreCoordChange(fSavedCoordChanges[i++]); + } for (int s = 0; s < fNumColorStages; ++s, ++i) { fDrawState->fColorStages[s].restoreCoordChange(fSavedCoordChanges[i]); } @@ -552,6 +568,7 @@ bool GrDrawState::AutoViewMatrixRestore::setIdentity(GrDrawState* drawState) { if (0 == drawState->numTotalStages()) { drawState->fViewMatrix.reset(); fDrawState = drawState; + fHasGeometryProcessor = false; fNumColorStages = 0; fSavedCoordChanges.reset(0); SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) @@ -573,6 +590,13 @@ void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co fSavedCoordChanges.reset(fDrawState->numTotalStages()); int i = 0; + fHasGeometryProcessor = false; + if (fDrawState->hasGeometryProcessor()) { + fDrawState->fGeometryProcessor->saveCoordChange(&fSavedCoordChanges[i++]); + fDrawState->fGeometryProcessor->localCoordChange(coordChangeMatrix); + fHasGeometryProcessor = true; + } + fNumColorStages = fDrawState->numColorStages(); for (int s = 0; s < fNumColorStages; ++s, ++i) { fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); @@ -595,7 +619,7 @@ void GrDrawState::convertToPendingExec() { fColorStages[i].convertToPendingExec(); } if (fGeometryProcessor) { - fGeometryProcessor.convertToPendingExec(); + fGeometryProcessor->convertToPendingExec(); } for (int i = 0; i < fCoverageStages.count(); ++i) { fCoverageStages[i].convertToPendingExec(); |