| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 inout.fValidFlags = kA_GrColorComponentFlag; | 237 inout.fValidFlags = kA_GrColorComponentFlag; |
| 238 } else { | 238 } else { |
| 239 inout.fValidFlags = 0; | 239 inout.fValidFlags = 0; |
| 240 // not strictly necessary but we get false alarms from tools about u
ninit. | 240 // not strictly necessary but we get false alarms from tools about u
ninit. |
| 241 inout.fColor = 0; | 241 inout.fColor = 0; |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 for (int i = 0; i < ds.numColorStages(); ++i) { | 245 for (int i = 0; i < ds.numColorStages(); ++i) { |
| 246 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor(); | 246 const GrFragmentProcessor* fp = ds.getColorStage(i).getProcessor(); |
| 247 if (!fp->willUseInputColor()) { | 247 fp->computeInvariantOutput(&inout); |
| 248 if (!inout.fWillUseInputColor) { |
| 248 *firstColorStageIdx = i; | 249 *firstColorStageIdx = i; |
| 249 fInputColorIsUsed = false; | 250 fInputColorIsUsed = false; |
| 250 } | 251 } |
| 251 fp->computeInvariantOutput(&inout); | |
| 252 if (kRGBA_GrColorComponentFlags == inout.fValidFlags) { | 252 if (kRGBA_GrColorComponentFlags == inout.fValidFlags) { |
| 253 *firstColorStageIdx = i + 1; | 253 *firstColorStageIdx = i + 1; |
| 254 fColor = inout.fColor; | 254 fColor = inout.fColor; |
| 255 fInputColorIsUsed = true; | 255 fInputColorIsUsed = true; |
| 256 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; | 256 *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; |
| 257 // Since we are clearing all previous color stages we are in a state
where we have found |
| 258 // zero stages that don't multiply the inputColor. |
| 259 inout.fNonMulStageFound = false; |
| 257 } | 260 } |
| 258 } | 261 } |
| 259 } | 262 } |
| 260 | 263 |
| 261 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds, | 264 void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds, |
| 262 int* firstCoverageStageIdx)
{ | 265 int* firstCoverageStageIdx)
{ |
| 263 // We do not try to optimize out constantColor coverage effects here. It is
extremely rare | 266 // We do not try to optimize out constantColor coverage effects here. It is
extremely rare |
| 264 // to have a coverage effect that returns a constant value for all four chan
nels. Thus we | 267 // to have a coverage effect that returns a constant value for all four chan
nels. Thus we |
| 265 // save having to make extra virtual calls by not checking for it. | 268 // save having to make extra virtual calls by not checking for it. |
| 266 | 269 |
| 267 // Don't do any optimizations on coverage stages. It should not be the case
where we do not use | 270 // Don't do any optimizations on coverage stages. It should not be the case
where we do not use |
| 268 // input coverage in an effect | 271 // input coverage in an effect |
| 269 #ifdef OptCoverageStages | 272 #ifdef OptCoverageStages |
| 273 GrProcessor::InvariantOutput inout; |
| 270 for (int i = 0; i < ds.numCoverageStages(); ++i) { | 274 for (int i = 0; i < ds.numCoverageStages(); ++i) { |
| 271 const GrProcessor* processor = ds.getCoverageStage(i).getProcessor(); | 275 const GrFragmentProcessor* fp = ds.getCoverageStage(i).getProcessor(); |
| 272 if (!processor->willUseInputColor()) { | 276 fp->computeInvariantOutput(&inout); |
| 277 if (!inout.fWillUseInputColor) { |
| 273 *firstCoverageStageIdx = i; | 278 *firstCoverageStageIdx = i; |
| 274 fInputCoverageIsUsed = false; | 279 fInputCoverageIsUsed = false; |
| 275 } | 280 } |
| 276 } | 281 } |
| 277 #endif | 282 #endif |
| 278 } | 283 } |
| 279 | 284 |
| 280 static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool*
readsFragPosition) { | 285 static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool*
readsFragPosition) { |
| 281 if (stage.getProcessor()->willReadDstColor()) { | 286 if (stage.getProcessor()->willReadDstColor()) { |
| 282 *readsDst = true; | 287 *readsDst = true; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 373 } |
| 369 } | 374 } |
| 370 | 375 |
| 371 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices, | 376 SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices, |
| 372 that.fFixedFunctionVertexAttribIndices, | 377 that.fFixedFunctionVertexAttribIndices, |
| 373 sizeof(this->fFixedFunctionVertexAttribIndices))); | 378 sizeof(this->fFixedFunctionVertexAttribIndices))); |
| 374 | 379 |
| 375 return true; | 380 return true; |
| 376 } | 381 } |
| 377 | 382 |
| OLD | NEW |