| 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 | 9 |
| 10 #include "GrOptDrawState.h" | 10 #include "GrOptDrawState.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 fStencilSettings.setDisabled(); | 184 fStencilSettings.setDisabled(); |
| 185 fCoverage = 0xff; | 185 fCoverage = 0xff; |
| 186 fDrawFace = kBoth_DrawFace; | 186 fDrawFace = kBoth_DrawFace; |
| 187 | 187 |
| 188 fHints = 0; | 188 fHints = 0; |
| 189 | 189 |
| 190 this->invalidateOptState(); | 190 this->invalidateOptState(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool GrDrawState::setIdentityViewMatrix() { | 193 bool GrDrawState::setIdentityViewMatrix() { |
| 194 if (this->numTotalStages()) { | 194 if (this->numFragmentStages()) { |
| 195 SkMatrix invVM; | 195 SkMatrix invVM; |
| 196 if (!fViewMatrix.invert(&invVM)) { | 196 if (!fViewMatrix.invert(&invVM)) { |
| 197 // sad trombone sound | 197 // sad trombone sound |
| 198 return false; | 198 return false; |
| 199 } | 199 } |
| 200 for (int s = 0; s < this->numColorStages(); ++s) { | 200 for (int s = 0; s < this->numColorStages(); ++s) { |
| 201 fColorStages[s].localCoordChange(invVM); | 201 fColorStages[s].localCoordChange(invVM); |
| 202 } | 202 } |
| 203 for (int s = 0; s < this->numCoverageStages(); ++s) { | 203 for (int s = 0; s < this->numCoverageStages(); ++s) { |
| 204 fCoverageStages[s].localCoordChange(invVM); | 204 fCoverageStages[s].localCoordChange(invVM); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 if (NULL == drawState) { | 542 if (NULL == drawState) { |
| 543 return false; | 543 return false; |
| 544 } | 544 } |
| 545 | 545 |
| 546 if (drawState->getViewMatrix().isIdentity()) { | 546 if (drawState->getViewMatrix().isIdentity()) { |
| 547 return true; | 547 return true; |
| 548 } | 548 } |
| 549 | 549 |
| 550 drawState->invalidateOptState(); | 550 drawState->invalidateOptState(); |
| 551 fViewMatrix = drawState->getViewMatrix(); | 551 fViewMatrix = drawState->getViewMatrix(); |
| 552 if (0 == drawState->numTotalStages()) { | 552 if (0 == drawState->numFragmentStages()) { |
| 553 drawState->fViewMatrix.reset(); | 553 drawState->fViewMatrix.reset(); |
| 554 fDrawState = drawState; | 554 fDrawState = drawState; |
| 555 fNumColorStages = 0; | 555 fNumColorStages = 0; |
| 556 fSavedCoordChanges.reset(0); | 556 fSavedCoordChanges.reset(0); |
| 557 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) | 557 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) |
| 558 return true; | 558 return true; |
| 559 } else { | 559 } else { |
| 560 SkMatrix inv; | 560 SkMatrix inv; |
| 561 if (!fViewMatrix.invert(&inv)) { | 561 if (!fViewMatrix.invert(&inv)) { |
| 562 return false; | 562 return false; |
| 563 } | 563 } |
| 564 drawState->fViewMatrix.reset(); | 564 drawState->fViewMatrix.reset(); |
| 565 fDrawState = drawState; | 565 fDrawState = drawState; |
| 566 this->doEffectCoordChanges(inv); | 566 this->doEffectCoordChanges(inv); |
| 567 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) | 567 SkDEBUGCODE(++fDrawState->fBlockEffectRemovalCnt;) |
| 568 return true; | 568 return true; |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 | 571 |
| 572 void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co
ordChangeMatrix) { | 572 void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& co
ordChangeMatrix) { |
| 573 fSavedCoordChanges.reset(fDrawState->numTotalStages()); | 573 fSavedCoordChanges.reset(fDrawState->numFragmentStages()); |
| 574 int i = 0; | 574 int i = 0; |
| 575 | 575 |
| 576 fNumColorStages = fDrawState->numColorStages(); | 576 fNumColorStages = fDrawState->numColorStages(); |
| 577 for (int s = 0; s < fNumColorStages; ++s, ++i) { | 577 for (int s = 0; s < fNumColorStages; ++s, ++i) { |
| 578 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); | 578 fDrawState->getColorStage(s).saveCoordChange(&fSavedCoordChanges[i]); |
| 579 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); | 579 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); |
| 580 } | 580 } |
| 581 | 581 |
| 582 int numCoverageStages = fDrawState->numCoverageStages(); | 582 int numCoverageStages = fDrawState->numCoverageStages(); |
| 583 for (int s = 0; s < numCoverageStages; ++s, ++i) { | 583 for (int s = 0; s < numCoverageStages; ++s, ++i) { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 } | 758 } |
| 759 | 759 |
| 760 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if | 760 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if |
| 761 // coverage and color both have A==1. | 761 // coverage and color both have A==1. |
| 762 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); | 762 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); |
| 763 } | 763 } |
| 764 | 764 |
| 765 return inoutColor.isOpaque(); | 765 return inoutColor.isOpaque(); |
| 766 } | 766 } |
| 767 | 767 |
| OLD | NEW |