| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrDrawState.h" | 8 #include "GrDrawState.h" |
| 9 #include "GrPaint.h" | 9 #include "GrPaint.h" |
| 10 #include "GrDrawTargetCaps.h" | 10 #include "GrDrawTargetCaps.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 fVACount = drawState->fVACount; | 293 fVACount = drawState->fVACount; |
| 294 fVAStride = drawState->fVAStride; | 294 fVAStride = drawState->fVAStride; |
| 295 fDrawState->setDefaultVertexAttribs(); | 295 fDrawState->setDefaultVertexAttribs(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 //////////////////////////////////////////////////////////////////////////////s | 298 //////////////////////////////////////////////////////////////////////////////s |
| 299 | 299 |
| 300 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { | 300 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { |
| 301 if (NULL != fDrawState) { | 301 if (NULL != fDrawState) { |
| 302 // See the big comment on the class definition about GPs. | 302 // See the big comment on the class definition about GPs. |
| 303 if (NULL != fOriginalGP) { | 303 if (SK_InvalidUniqueID == fOriginalGPID) { |
| 304 SkASSERT(fDrawState->getGeometryProcessor()->getEffect() == fOrigina
lGP); | 304 fDrawState->fGeometryProcessor.reset(NULL); |
| 305 fOriginalGP->unref(); | |
| 306 fOriginalGP = NULL; | |
| 307 } else { | 305 } else { |
| 308 fDrawState->fGeometryProcessor.reset(NULL); | 306 SkASSERT(fDrawState->getGeometryProcessor()->getEffect()->getUniqueI
D() == |
| 307 fOriginalGPID); |
| 308 fOriginalGPID = SK_InvalidUniqueID; |
| 309 } | 309 } |
| 310 | 310 |
| 311 int m = fDrawState->numColorStages() - fColorEffectCnt; | 311 int m = fDrawState->numColorStages() - fColorEffectCnt; |
| 312 SkASSERT(m >= 0); | 312 SkASSERT(m >= 0); |
| 313 fDrawState->fColorStages.pop_back_n(m); | 313 fDrawState->fColorStages.pop_back_n(m); |
| 314 | 314 |
| 315 int n = fDrawState->numCoverageStages() - fCoverageEffectCnt; | 315 int n = fDrawState->numCoverageStages() - fCoverageEffectCnt; |
| 316 SkASSERT(n >= 0); | 316 SkASSERT(n >= 0); |
| 317 fDrawState->fCoverageStages.pop_back_n(n); | 317 fDrawState->fCoverageStages.pop_back_n(n); |
| 318 if (m + n > 0) { | 318 if (m + n > 0) { |
| 319 fDrawState->invalidateBlendOptFlags(); | 319 fDrawState->invalidateBlendOptFlags(); |
| 320 } | 320 } |
| 321 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) | 321 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) |
| 322 } | 322 } |
| 323 fDrawState = ds; | 323 fDrawState = ds; |
| 324 if (NULL != ds) { | 324 if (NULL != ds) { |
| 325 SkASSERT(NULL == fOriginalGP); | 325 SkASSERT(SK_InvalidUniqueID == fOriginalGPID); |
| 326 if (NULL != ds->getGeometryProcessor()) { | 326 if (NULL != ds->getGeometryProcessor()) { |
| 327 fOriginalGP = SkRef(ds->getGeometryProcessor()->getEffect()); | 327 fOriginalGPID = ds->getGeometryProcessor()->getEffect()->getUniqueID
(); |
| 328 } | 328 } |
| 329 fColorEffectCnt = ds->numColorStages(); | 329 fColorEffectCnt = ds->numColorStages(); |
| 330 fCoverageEffectCnt = ds->numCoverageStages(); | 330 fCoverageEffectCnt = ds->numCoverageStages(); |
| 331 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) | 331 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 | 334 |
| 335 //////////////////////////////////////////////////////////////////////////////// | 335 //////////////////////////////////////////////////////////////////////////////// |
| 336 | 336 |
| 337 GrRODrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, | 337 GrRODrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 //////////////////////////////////////////////////////////////////////////////// | 603 //////////////////////////////////////////////////////////////////////////////// |
| 604 | 604 |
| 605 bool GrDrawState::canIgnoreColorAttribute() const { | 605 bool GrDrawState::canIgnoreColorAttribute() const { |
| 606 if (fBlendOptFlags & kInvalid_BlendOptFlag) { | 606 if (fBlendOptFlags & kInvalid_BlendOptFlag) { |
| 607 this->getBlendOpts(); | 607 this->getBlendOpts(); |
| 608 } | 608 } |
| 609 return SkToBool(fBlendOptFlags & (GrRODrawState::kEmitTransBlack_BlendOptFla
g | | 609 return SkToBool(fBlendOptFlags & (GrRODrawState::kEmitTransBlack_BlendOptFla
g | |
| 610 GrRODrawState::kEmitCoverage_BlendOptFlag)
); | 610 GrRODrawState::kEmitCoverage_BlendOptFlag)
); |
| 611 } | 611 } |
| 612 | 612 |
| OLD | NEW |