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 "GrOptDrawState.h" | 8 #include "GrOptDrawState.h" |
9 | 9 |
10 #include "GrDrawState.h" | 10 #include "GrDrawState.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 int firstCoverageStageIdx = 0; | 103 int firstCoverageStageIdx = 0; |
104 | 104 |
105 GrXferProcessor::BlendInfo blendInfo; | 105 GrXferProcessor::BlendInfo blendInfo; |
106 fXferProcessor->getBlendInfo(&blendInfo); | 106 fXferProcessor->getBlendInfo(&blendInfo); |
107 | 107 |
108 this->adjustProgramFromOptimizations(drawState, optFlags, colorPOI, coverage
POI, | 108 this->adjustProgramFromOptimizations(drawState, optFlags, colorPOI, coverage
POI, |
109 &firstColorStageIdx, &firstCoverageStag
eIdx); | 109 &firstColorStageIdx, &firstCoverageStag
eIdx); |
110 | 110 |
111 fDescInfo.fRequiresLocalCoordAttrib = hasLocalCoords; | 111 fDescInfo.fRequiresLocalCoordAttrib = hasLocalCoords; |
112 | 112 |
| 113 bool usesLocalCoords = false; |
| 114 |
113 // Copy Stages from DS to ODS | 115 // Copy Stages from DS to ODS |
114 for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) { | 116 for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) { |
115 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 117 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
116 GrPendingFragmentStage, | 118 GrPendingFragmentStage, |
117 (drawState.fColorStages[i], hasLocalCoords)); | 119 (drawState.fColorStages[i], hasLocalCoords)); |
| 120 usesLocalCoords = usesLocalCoords || |
| 121 drawState.fColorStages[i].getProcessor()->usesLocalCoo
rds(); |
118 } | 122 } |
119 | 123 |
120 fNumColorStages = fFragmentStages.count(); | 124 fNumColorStages = fFragmentStages.count(); |
121 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i)
{ | 125 for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i)
{ |
122 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, | 126 SkNEW_APPEND_TO_TARRAY(&fFragmentStages, |
123 GrPendingFragmentStage, | 127 GrPendingFragmentStage, |
124 (drawState.fCoverageStages[i], hasLocalCoords)); | 128 (drawState.fCoverageStages[i], hasLocalCoords)); |
| 129 usesLocalCoords = usesLocalCoords || |
| 130 drawState.fCoverageStages[i].getProcessor()->usesLocal
Coords(); |
125 } | 131 } |
126 | 132 |
127 // let the GP init the batch tracker | 133 // let the GP init the batch tracker |
128 GrGeometryProcessor::InitBT init; | 134 GrGeometryProcessor::InitBT init; |
129 init.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFl
ag); | 135 init.fColorIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFl
ag); |
130 init.fOverrideColor = init.fColorIgnored ? GrColor_ILLEGAL : overrideColor; | 136 init.fOverrideColor = init.fColorIgnored ? GrColor_ILLEGAL : overrideColor; |
131 init.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage
_OptFlag); | 137 init.fCoverageIgnored = SkToBool(optFlags & GrXferProcessor::kIgnoreCoverage
_OptFlag); |
| 138 init.fUsesLocalCoords = usesLocalCoords; |
132 fPrimitiveProcessor->initBatchTracker(&fBatchTracker, init); | 139 fPrimitiveProcessor->initBatchTracker(&fBatchTracker, init); |
133 } | 140 } |
134 | 141 |
135 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, | 142 void GrOptDrawState::adjustProgramFromOptimizations(const GrDrawState& ds, |
136 GrXferProcessor::OptFlags fl
ags, | 143 GrXferProcessor::OptFlags fl
ags, |
137 const GrProcOptInfo& colorPO
I, | 144 const GrProcOptInfo& colorPO
I, |
138 const GrProcOptInfo& coverag
ePOI, | 145 const GrProcOptInfo& coverag
ePOI, |
139 int* firstColorStageIdx, | 146 int* firstColorStageIdx, |
140 int* firstCoverageStageIdx)
{ | 147 int* firstCoverageStageIdx)
{ |
141 fDescInfo.fReadsDst = false; | 148 fDescInfo.fReadsDst = false; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { | 210 if (this->getFragmentStage(i) != that.getFragmentStage(i)) { |
204 return false; | 211 return false; |
205 } | 212 } |
206 } | 213 } |
207 | 214 |
208 // Now update the GrPrimitiveProcessor's batch tracker | 215 // Now update the GrPrimitiveProcessor's batch tracker |
209 fPrimitiveProcessor->makeEqual(&fBatchTracker, that.getBatchTracker()); | 216 fPrimitiveProcessor->makeEqual(&fBatchTracker, that.getBatchTracker()); |
210 return true; | 217 return true; |
211 } | 218 } |
212 | 219 |
OLD | NEW |