| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 if (this->isCoverageDrawing()) { | 397 if (this->isCoverageDrawing()) { |
| 398 return true; | 398 return true; |
| 399 } | 399 } |
| 400 | 400 |
| 401 GrProcessor::InvariantOutput inout; | 401 GrProcessor::InvariantOutput inout; |
| 402 inout.fIsSingleComponent = false; | 402 inout.fIsSingleComponent = false; |
| 403 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. | 403 // Initialize to an unknown starting coverage if per-vertex coverage is spec
ified. |
| 404 if (this->hasCoverageVertexAttribute()) { | 404 if (this->hasCoverageVertexAttribute()) { |
| 405 inout.fValidFlags = 0; | 405 inout.fValidFlags = 0; |
| 406 } else { | 406 } else { |
| 407 inout.fColor = this->getCoverageColor(); | 407 inout.fColor = fCoverage; |
| 408 inout.fValidFlags = kRGBA_GrColorComponentFlags; | 408 inout.fValidFlags = kRGBA_GrColorComponentFlags; |
| 409 } | 409 } |
| 410 | 410 |
| 411 // Run through the coverage stages and see if the coverage will be all ones
at the end. | 411 // Run through the coverage stages and see if the coverage will be all ones
at the end. |
| 412 if (this->hasGeometryProcessor()) { | 412 if (this->hasGeometryProcessor()) { |
| 413 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor
(); | 413 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor
(); |
| 414 gp->computeInvariantOutput(&inout); | 414 gp->computeInvariantOutput(&inout); |
| 415 } | 415 } |
| 416 | |
| 417 for (int s = 0; s < this->numCoverageStages(); ++s) { | 416 for (int s = 0; s < this->numCoverageStages(); ++s) { |
| 418 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); | 417 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); |
| 419 processor->computeInvariantOutput(&inout); | 418 processor->computeInvariantOutput(&inout); |
| 420 } | 419 } |
| 421 return inout.isSolidWhite(); | 420 return inout.isSolidWhite(); |
| 422 } | 421 } |
| 423 | 422 |
| 424 ////////////////////////////////////////////////////////////////////////////// | 423 ////////////////////////////////////////////////////////////////////////////// |
| 425 | 424 |
| 426 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { | 425 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 //////////////////////////////////////////////////////////////////////////////// | 633 //////////////////////////////////////////////////////////////////////////////// |
| 635 | 634 |
| 636 GrDrawState::~GrDrawState() { | 635 GrDrawState::~GrDrawState() { |
| 637 SkSafeUnref(fCachedOptState); | 636 SkSafeUnref(fCachedOptState); |
| 638 SkASSERT(0 == fBlockEffectRemovalCnt); | 637 SkASSERT(0 == fBlockEffectRemovalCnt); |
| 639 } | 638 } |
| 640 | 639 |
| 641 //////////////////////////////////////////////////////////////////////////////// | 640 //////////////////////////////////////////////////////////////////////////////// |
| 642 | 641 |
| 643 GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, | 642 GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, |
| 644 GrBlendCoeff* srcCoeff, | 643 GrBlendCoeff* srcCoeff, |
| 645 GrBlendCoeff* dstCoeff) con
st { | 644 GrBlendCoeff* dstCoeff)
const { |
| 646 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; | 645 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; |
| 647 if (NULL == srcCoeff) { | 646 if (NULL == srcCoeff) { |
| 648 srcCoeff = &bogusSrcCoeff; | 647 srcCoeff = &bogusSrcCoeff; |
| 649 } | 648 } |
| 650 if (NULL == dstCoeff) { | 649 if (NULL == dstCoeff) { |
| 651 dstCoeff = &bogusDstCoeff; | 650 dstCoeff = &bogusDstCoeff; |
| 652 } | 651 } |
| 653 | 652 |
| 654 *srcCoeff = this->getSrcBlendCoeff(); | 653 *srcCoeff = this->getSrcBlendCoeff(); |
| 655 *dstCoeff = this->getDstBlendCoeff(); | 654 *dstCoeff = this->getDstBlendCoeff(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 } | 776 } |
| 778 | 777 |
| 779 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if | 778 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if |
| 780 // coverage and color both have A==1. | 779 // coverage and color both have A==1. |
| 781 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); | 780 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); |
| 782 } | 781 } |
| 783 | 782 |
| 784 return inoutColor.isOpaque(); | 783 return inoutColor.isOpaque(); |
| 785 } | 784 } |
| 786 | 785 |
| OLD | NEW |