| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 GrRODrawState::BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dst
Coeff); | 280 GrRODrawState::BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dst
Coeff); |
| 281 return GrRODrawState::kNone_BlendOpt != flag || | 281 return GrRODrawState::kNone_BlendOpt != flag || |
| 282 (this->willEffectReadDstColor() && | 282 (this->willEffectReadDstColor() && |
| 283 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); | 283 kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff); |
| 284 } | 284 } |
| 285 | 285 |
| 286 ////////////////////////////////////////////////////////////////////////////// | 286 ////////////////////////////////////////////////////////////////////////////// |
| 287 | 287 |
| 288 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore( | 288 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore( |
| 289 GrDrawState* drawState) { | 289 GrDrawState* drawState) { |
| 290 SkASSERT(NULL != drawState); | 290 SkASSERT(drawState); |
| 291 fDrawState = drawState; | 291 fDrawState = drawState; |
| 292 fVAPtr = drawState->fVAPtr; | 292 fVAPtr = drawState->fVAPtr; |
| 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 (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 (SK_InvalidUniqueID == fOriginalGPID) { | 303 if (SK_InvalidUniqueID == fOriginalGPID) { |
| 304 fDrawState->fGeometryProcessor.reset(NULL); | 304 fDrawState->fGeometryProcessor.reset(NULL); |
| 305 } else { | 305 } else { |
| 306 SkASSERT(fDrawState->getGeometryProcessor()->getEffect()->getUniqueI
D() == | 306 SkASSERT(fDrawState->getGeometryProcessor()->getEffect()->getUniqueI
D() == |
| 307 fOriginalGPID); | 307 fOriginalGPID); |
| 308 fOriginalGPID = SK_InvalidUniqueID; | 308 fOriginalGPID = SK_InvalidUniqueID; |
| 309 } | 309 } |
| 310 | 310 |
| 311 int m = fDrawState->numColorStages() - fColorEffectCnt; | 311 int m = fDrawState->numColorStages() - fColorEffectCnt; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 return kCoverageAsAlpha_BlendOptFlag; | 440 return kCoverageAsAlpha_BlendOptFlag; |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 | 443 |
| 444 return kNone_BlendOpt; | 444 return kNone_BlendOpt; |
| 445 } | 445 } |
| 446 | 446 |
| 447 //////////////////////////////////////////////////////////////////////////////// | 447 //////////////////////////////////////////////////////////////////////////////// |
| 448 | 448 |
| 449 void GrDrawState::AutoViewMatrixRestore::restore() { | 449 void GrDrawState::AutoViewMatrixRestore::restore() { |
| 450 if (NULL != fDrawState) { | 450 if (fDrawState) { |
| 451 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) | 451 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) |
| 452 fDrawState->fViewMatrix = fViewMatrix; | 452 fDrawState->fViewMatrix = fViewMatrix; |
| 453 SkASSERT(fDrawState->numColorStages() >= fNumColorStages); | 453 SkASSERT(fDrawState->numColorStages() >= fNumColorStages); |
| 454 int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages; | 454 int numCoverageStages = fSavedCoordChanges.count() - fNumColorStages; |
| 455 SkASSERT(fDrawState->numCoverageStages() >= numCoverageStages); | 455 SkASSERT(fDrawState->numCoverageStages() >= numCoverageStages); |
| 456 | 456 |
| 457 int i = 0; | 457 int i = 0; |
| 458 if (fHasGeometryProcessor) { | 458 if (fHasGeometryProcessor) { |
| 459 SkASSERT(fDrawState->hasGeometryProcessor()); | 459 SkASSERT(fDrawState->hasGeometryProcessor()); |
| 460 fDrawState->fGeometryProcessor->restoreCoordChange(fSavedCoordChange
s[i++]); | 460 fDrawState->fGeometryProcessor->restoreCoordChange(fSavedCoordChange
s[i++]); |
| (...skipping 142 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 |