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 "GrGeometryProcessor.h" | 10 #include "GrGeometryProcessor.h" |
11 | 11 |
12 #include "batches/GrDrawBatch.h" | 12 #include "batches/GrDrawBatch.h" |
13 | 13 |
14 void GrProcOptInfo::calcColorWithBatch(const GrDrawBatch* batch, | |
15 const GrFragmentProcessor* const processo
rs[], | |
16 int cnt) { | |
17 GrInitInvariantOutput out; | |
18 batch->getInvariantOutputColor(&out); | |
19 fInOut.reset(out); | |
20 this->internalCalc(processors, cnt, batch->willReadFragmentPosition()); | |
21 } | |
22 | |
23 void GrProcOptInfo::calcCoverageWithBatch(const GrDrawBatch* batch, | |
24 const GrFragmentProcessor* const proce
ssors[], | |
25 int cnt) { | |
26 GrInitInvariantOutput out; | |
27 batch->getInvariantOutputCoverage(&out); | |
28 fInOut.reset(out); | |
29 this->internalCalc(processors, cnt, batch->willReadFragmentPosition()); | |
30 } | |
31 | |
32 void GrProcOptInfo::calcWithInitialValues(const GrFragmentProcessor * const proc
essors[], | 14 void GrProcOptInfo::calcWithInitialValues(const GrFragmentProcessor * const proc
essors[], |
33 int cnt, | 15 int cnt, |
34 GrColor startColor, | 16 GrColor startColor, |
35 GrColorComponentFlags flags, | 17 GrColorComponentFlags flags, |
36 bool areCoverageStages, | 18 bool areCoverageStages, |
37 bool isLCD) { | 19 bool isLCD) { |
38 GrInitInvariantOutput out; | 20 GrInitInvariantOutput out; |
39 out.fIsSingleComponent = areCoverageStages; | 21 out.fIsSingleComponent = areCoverageStages; |
40 out.fColor = startColor; | 22 out.fColor = startColor; |
41 out.fValidFlags = flags; | 23 out.fValidFlags = flags; |
42 out.fIsLCDCoverage = isLCD; | 24 out.fIsLCDCoverage = isLCD; |
43 fInOut.reset(out); | 25 fInOut.reset(out); |
44 this->internalCalc(processors, cnt, false); | 26 this->internalCalc(processors, cnt, false); |
45 } | 27 } |
46 | 28 |
| 29 void GrProcOptInfo::initUsingInvariantOutput(GrInitInvariantOutput invOutput) { |
| 30 fInOut.reset(invOutput); |
| 31 } |
| 32 |
| 33 void GrProcOptInfo::completeCalculations(const GrFragmentProcessor * const proce
ssors[], int cnt) { |
| 34 this->internalCalc(processors, cnt, false); |
| 35 } |
| 36 |
47 void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[], | 37 void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[], |
48 int cnt, | 38 int cnt, |
49 bool initWillReadFragmentPosition) { | 39 bool initWillReadFragmentPosition) { |
50 fFirstEffectiveProcessorIndex = 0; | 40 fFirstEffectiveProcessorIndex = 0; |
51 fInputColorIsUsed = true; | 41 fInputColorIsUsed = true; |
52 fInputColor = fInOut.color(); | 42 fInputColor = fInOut.color(); |
53 fReadsFragPosition = initWillReadFragmentPosition; | 43 fReadsFragPosition = initWillReadFragmentPosition; |
54 | 44 |
55 for (int i = 0; i < cnt; ++i) { | 45 for (int i = 0; i < cnt; ++i) { |
56 const GrFragmentProcessor* processor = processors[i]; | 46 const GrFragmentProcessor* processor = processors[i]; |
(...skipping 14 matching lines...) Expand all Loading... |
71 fInputColor = fInOut.color(); | 61 fInputColor = fInOut.color(); |
72 fInputColorIsUsed = true; | 62 fInputColorIsUsed = true; |
73 // Since we are clearing all previous color stages we are in a state
where we have found | 63 // Since we are clearing all previous color stages we are in a state
where we have found |
74 // zero stages that don't multiply the inputColor. | 64 // zero stages that don't multiply the inputColor. |
75 fInOut.resetNonMulStageFound(); | 65 fInOut.resetNonMulStageFound(); |
76 // Reset these since we don't care if previous stages read these val
ues | 66 // Reset these since we don't care if previous stages read these val
ues |
77 fReadsFragPosition = initWillReadFragmentPosition; | 67 fReadsFragPosition = initWillReadFragmentPosition; |
78 } | 68 } |
79 } | 69 } |
80 } | 70 } |
OLD | NEW |