| Index: src/gpu/GrOptDrawState.cpp
|
| diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
|
| index 5f352966b8a3441d5faf603c6234788dc2e23db6..cb03d2d683005dfe063bbedf49cf0cd53b8e933a 100644
|
| --- a/src/gpu/GrOptDrawState.cpp
|
| +++ b/src/gpu/GrOptDrawState.cpp
|
| @@ -44,6 +44,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
| this->copyEffectiveColorStages(drawState);
|
| this->copyEffectiveCoverageStages(drawState);
|
| this->adjustFromBlendOpts();
|
| + this->getStageStats();
|
| };
|
|
|
| void GrOptDrawState::adjustFromBlendOpts() {
|
| @@ -179,6 +180,41 @@ void GrOptDrawState::copyEffectiveCoverageStages(const GrDrawState& ds) {
|
| }
|
| }
|
|
|
| +static void get_stage_stats(const GrEffectStage& stage, bool* readsDst, bool* readsFragPosition) {
|
| + if (stage.getEffect()->willReadDstColor()) {
|
| + *readsDst = true;
|
| + }
|
| + if (stage.getEffect()->willReadFragmentPosition()) {
|
| + *readsFragPosition = true;
|
| + }
|
| +}
|
| +void GrOptDrawState::getStageStats() {
|
| + // We will need a local coord attrib if there is one currently set on the optState and we are
|
| + // actually generating some effect code
|
| + fRequiresLocalCoordAttrib = this->hasLocalCoordAttribute() && this->numTotalStages() > 0;
|
| +
|
| + // if 1 == fVACount then that VA must be position, otherwise it contains some attribute which
|
| + // will require a vertexShader
|
| + fRequiresVertexShader = fVACount > 1;
|
| +
|
| + fReadsDst = false;
|
| + fReadsFragPosition = false;
|
| +
|
| + for (int s = 0; s < this->numColorStages(); ++s) {
|
| + const GrEffectStage& stage = this->getColorStage(s);
|
| + get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
|
| + }
|
| + for (int s = 0; s < this->numCoverageStages(); ++s) {
|
| + const GrEffectStage& stage = this->getCoverageStage(s);
|
| + get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
|
| + }
|
| + if (this->hasGeometryProcessor()) {
|
| + const GrEffectStage& stage = *this->getGeometryProcessor();
|
| + get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
|
| + SkASSERT(fRequiresVertexShader);
|
| + }
|
| +}
|
| +
|
| bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
|
| return this->isEqual(that);
|
| }
|
|
|