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::calcWithInitialValues(const GrFragmentProcessor * const proc
essors[], | 14 void GrProcOptInfo::calcWithInitialValues(const sk_sp<GrFragmentProcessor>* proc
essors, |
15 int cnt, | 15 int cnt, |
16 GrColor startColor, | 16 GrColor startColor, |
17 GrColorComponentFlags flags, | 17 GrColorComponentFlags flags, |
18 bool areCoverageStages, | 18 bool areCoverageStages, |
19 bool isLCD) { | 19 bool isLCD) { |
20 GrInitInvariantOutput out; | 20 GrInitInvariantOutput out; |
21 out.fIsSingleComponent = areCoverageStages; | 21 out.fIsSingleComponent = areCoverageStages; |
22 out.fColor = startColor; | 22 out.fColor = startColor; |
23 out.fValidFlags = flags; | 23 out.fValidFlags = flags; |
24 out.fIsLCDCoverage = isLCD; | 24 out.fIsLCDCoverage = isLCD; |
25 fInOut.reset(out); | 25 fInOut.reset(out); |
26 this->internalCalc(processors, cnt); | 26 this->internalCalc(processors, cnt); |
27 } | 27 } |
28 | 28 |
29 void GrProcOptInfo::initUsingInvariantOutput(GrInitInvariantOutput invOutput) { | 29 void GrProcOptInfo::initUsingInvariantOutput(GrInitInvariantOutput invOutput) { |
30 fInOut.reset(invOutput); | 30 fInOut.reset(invOutput); |
31 } | 31 } |
32 | 32 |
33 void GrProcOptInfo::completeCalculations(const GrFragmentProcessor * const proce
ssors[], int cnt) { | 33 void GrProcOptInfo::completeCalculations(const sk_sp<GrFragmentProcessor>* proce
ssors, int cnt) { |
34 this->internalCalc(processors, cnt); | 34 this->internalCalc(processors, cnt); |
35 } | 35 } |
36 | 36 |
37 void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[],
int cnt) { | 37 void GrProcOptInfo::internalCalc(const sk_sp<GrFragmentProcessor>* processors, i
nt cnt) { |
38 fFirstEffectiveProcessorIndex = 0; | 38 fFirstEffectiveProcessorIndex = 0; |
39 fInputColorIsUsed = true; | 39 fInputColorIsUsed = true; |
40 fInputColor = fInOut.color(); | 40 fInputColor = fInOut.color(); |
41 | 41 |
42 for (int i = 0; i < cnt; ++i) { | 42 for (int i = 0; i < cnt; ++i) { |
43 const GrFragmentProcessor* processor = processors[i]; | 43 const sk_sp<GrFragmentProcessor> processor = processors[i]; |
44 fInOut.resetWillUseInputColor(); | 44 fInOut.resetWillUseInputColor(); |
45 processor->computeInvariantOutput(&fInOut); | 45 processor->computeInvariantOutput(&fInOut); |
46 SkDEBUGCODE(fInOut.validate()); | 46 SkDEBUGCODE(fInOut.validate()); |
47 if (!fInOut.willUseInputColor()) { | 47 if (!fInOut.willUseInputColor()) { |
48 fFirstEffectiveProcessorIndex = i; | 48 fFirstEffectiveProcessorIndex = i; |
49 fInputColorIsUsed = false; | 49 fInputColorIsUsed = false; |
50 } | 50 } |
51 if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) { | 51 if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) { |
52 fFirstEffectiveProcessorIndex = i + 1; | 52 fFirstEffectiveProcessorIndex = i + 1; |
53 fInputColor = fInOut.color(); | 53 fInputColor = fInOut.color(); |
54 fInputColorIsUsed = true; | 54 fInputColorIsUsed = true; |
55 // Since we are clearing all previous color stages we are in a state
where we have found | 55 // Since we are clearing all previous color stages we are in a state
where we have found |
56 // zero stages that don't multiply the inputColor. | 56 // zero stages that don't multiply the inputColor. |
57 fInOut.resetNonMulStageFound(); | 57 fInOut.resetNonMulStageFound(); |
58 } | 58 } |
59 } | 59 } |
60 } | 60 } |
OLD | NEW |