| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrProcOptInfo.h" | 8 #include "GrProcOptInfo.h" |
| 9 | 9 |
| 10 #include "GrFragmentProcessor.h" | 10 #include "GrGeometryProcessor.h" |
| 11 #include "GrFragmentStage.h" | 11 #include "GrFragmentStage.h" |
| 12 #include "GrGeometryProcessor.h" | |
| 13 | 12 |
| 14 void GrProcOptInfo::calcWithInitialValues(const GrFragmentStage* stages, | 13 void GrProcOptInfo::calcWithInitialValues(const GrFragmentStage* stages, |
| 15 int stageCount, | 14 int stageCount, |
| 16 GrColor startColor, | 15 GrColor startColor, |
| 17 GrColorComponentFlags flags, | 16 GrColorComponentFlags flags, |
| 18 bool areCoverageStages, | 17 bool areCoverageStages, |
| 19 const GrGeometryProcessor* gp) { | 18 const GrGeometryProcessor* gp) { |
| 20 fInOut.reset(startColor, flags, areCoverageStages); | 19 fInOut.reset(startColor, flags, areCoverageStages); |
| 21 fFirstEffectStageIndex = 0; | 20 fFirstEffectStageIndex = 0; |
| 22 fInputColorIsUsed = true; | 21 fInputColorIsUsed = true; |
| 23 fInputColor = startColor; | 22 fInputColor = startColor; |
| 24 fRemoveVertexAttrib = false; | 23 fRemoveVertexAttrib = false; |
| 25 fReadsDst = false; | 24 fReadsDst = false; |
| 26 fReadsFragPosition = false; | |
| 27 | 25 |
| 28 if (areCoverageStages && gp) { | 26 if (areCoverageStages && gp) { |
| 29 gp->computeInvariantOutput(&fInOut); | 27 gp->computeInvariantOutput(&fInOut); |
| 30 } | 28 } |
| 31 | 29 |
| 32 for (int i = 0; i < stageCount; ++i) { | 30 for (int i = 0; i < stageCount; ++i) { |
| 33 const GrFragmentProcessor* processor = stages[i].getProcessor(); | 31 const GrFragmentProcessor* processor = stages[i].getProcessor(); |
| 34 fInOut.resetWillUseInputColor(); | 32 fInOut.resetWillUseInputColor(); |
| 35 processor->computeInvariantOutput(&fInOut); | 33 processor->computeInvariantOutput(&fInOut); |
| 36 #ifdef SK_DEBUG | 34 #ifdef SK_DEBUG |
| 37 fInOut.validate(); | 35 fInOut.validate(); |
| 38 #endif | 36 #endif |
| 39 if (!fInOut.willUseInputColor()) { | 37 if (!fInOut.willUseInputColor()) { |
| 40 fFirstEffectStageIndex = i; | 38 fFirstEffectStageIndex = i; |
| 41 fInputColorIsUsed = false; | 39 fInputColorIsUsed = false; |
| 42 // Reset these since we don't care if previous stages read these val
ues | 40 fReadsDst = false; // Reset this since we don't care if previous sta
ges read dst |
| 43 fReadsDst = false; | |
| 44 fReadsFragPosition = false; | |
| 45 } | 41 } |
| 46 if (processor->willReadDstColor()) { | 42 if (processor->willReadDstColor()) { |
| 47 fReadsDst = true; | 43 fReadsDst = true; |
| 48 } | 44 } |
| 49 if (processor->willReadFragmentPosition()) { | |
| 50 fReadsFragPosition = true; | |
| 51 } | |
| 52 if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) { | 45 if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) { |
| 53 fFirstEffectStageIndex = i + 1; | 46 fFirstEffectStageIndex = i + 1; |
| 54 fInputColor = fInOut.color(); | 47 fInputColor = fInOut.color(); |
| 55 fInputColorIsUsed = true; | 48 fInputColorIsUsed = true; |
| 56 fRemoveVertexAttrib = true; | 49 fRemoveVertexAttrib = true; |
| 57 // Since we are clearing all previous color stages we are in a state
where we have found | 50 // Since we are clearing all previous color stages we are in a state
where we have found |
| 58 // zero stages that don't multiply the inputColor. | 51 // zero stages that don't multiply the inputColor. |
| 59 fInOut.resetNonMulStageFound(); | 52 fInOut.resetNonMulStageFound(); |
| 60 // Reset these since we don't care if previous stages read these val
ues | 53 fReadsDst = false; // Reset this since we don't care if previous sta
ges read dst |
| 61 fReadsDst = false; | |
| 62 fReadsFragPosition = false; | |
| 63 } | 54 } |
| 64 } | 55 } |
| 65 } | 56 } |
| 66 | |
| OLD | NEW |