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 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 if (drawState.hasGeometryProcessor()) { | 38 if (drawState.hasGeometryProcessor()) { |
39 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*drawState.getGeomet ryProcessor()))); | 39 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*drawState.getGeomet ryProcessor()))); |
40 } else { | 40 } else { |
41 fGeometryProcessor.reset(NULL); | 41 fGeometryProcessor.reset(NULL); |
42 } | 42 } |
43 | 43 |
44 this->copyEffectiveColorStages(drawState); | 44 this->copyEffectiveColorStages(drawState); |
45 this->copyEffectiveCoverageStages(drawState); | 45 this->copyEffectiveCoverageStages(drawState); |
46 this->adjustFromBlendOpts(); | 46 this->adjustFromBlendOpts(); |
47 this->getStageStats(); | |
47 }; | 48 }; |
48 | 49 |
49 void GrOptDrawState::adjustFromBlendOpts() { | 50 void GrOptDrawState::adjustFromBlendOpts() { |
50 | 51 |
51 switch (fBlendOptFlags) { | 52 switch (fBlendOptFlags) { |
52 case kNone_BlendOpt: | 53 case kNone_BlendOpt: |
53 case kSkipDraw_BlendOptFlag: | 54 case kSkipDraw_BlendOptFlag: |
54 break; | 55 break; |
55 case kCoverageAsAlpha_BlendOptFlag: | 56 case kCoverageAsAlpha_BlendOptFlag: |
56 fFlagBits |= kCoverageDrawing_StateBit; | 57 fFlagBits |= kCoverageDrawing_StateBit; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 } | 173 } |
173 #endif | 174 #endif |
174 if (ds.numCoverageStages() > 0) { | 175 if (ds.numCoverageStages() > 0) { |
175 fCoverageStages.reset(&ds.getCoverageStage(firstCoverageStage), | 176 fCoverageStages.reset(&ds.getCoverageStage(firstCoverageStage), |
176 ds.numCoverageStages() - firstCoverageStage); | 177 ds.numCoverageStages() - firstCoverageStage); |
177 } else { | 178 } else { |
178 fCoverageStages.reset(); | 179 fCoverageStages.reset(); |
179 } | 180 } |
180 } | 181 } |
181 | 182 |
183 static void get_stage_stats(const GrEffectStage& stage, bool* readsDst, bool* re adsFragPosition) { | |
184 if (stage.getEffect()->willReadDstColor()) { | |
185 *readsDst = true; | |
186 } | |
187 if (stage.getEffect()->willReadFragmentPosition()) { | |
188 *readsFragPosition = true; | |
189 } | |
190 } | |
191 void GrOptDrawState::getStageStats() { | |
192 // We will need a local coord attrib if there is one currently set on the op tState and we are | |
193 // actually generating some effect code | |
194 fRequiresLocalCoordAttrib = this->hasLocalCoordAttribute() && this->numTotal Stages() > 0; | |
195 | |
196 // if 1 == fVACount then that VA must be position, otherwise it contains som e attribute which | |
197 // will requires a vertexShader | |
bsalomon
2014/09/17 15:11:26
requires->require
| |
198 fRequiresVertexShader = fVACount > 1; | |
199 | |
200 fReadsDst = false; | |
201 fReadsFragPosition = false; | |
202 | |
203 for (int s = 0; s < this->numColorStages(); ++s) { | |
204 const GrEffectStage& stage = this->getColorStage(s); | |
205 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); | |
206 } | |
207 for (int s = 0; s < this->numCoverageStages(); ++s) { | |
208 const GrEffectStage& stage = this->getCoverageStage(s); | |
209 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); | |
210 } | |
211 if (this->hasGeometryProcessor()) { | |
212 const GrEffectStage& stage = *this->getGeometryProcessor(); | |
213 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition); | |
214 SkASSERT(fRequiresVertexShader); | |
215 } | |
216 } | |
217 | |
182 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { | 218 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { |
183 return this->isEqual(that); | 219 return this->isEqual(that); |
184 } | 220 } |
185 | 221 |
OLD | NEW |