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 = fCoverage; | 407 inout.fColor = this->getCoverageColor(); |
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->getProcessor(); | 413 const GrGeometryProcessor* gp = fGeometryProcessor->getProcessor(); |
414 gp->computeInvariantOutput(&inout); | 414 gp->computeInvariantOutput(&inout); |
415 } | 415 } |
| 416 |
416 for (int s = 0; s < this->numCoverageStages(); ++s) { | 417 for (int s = 0; s < this->numCoverageStages(); ++s) { |
417 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); | 418 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); |
418 processor->computeInvariantOutput(&inout); | 419 processor->computeInvariantOutput(&inout); |
419 } | 420 } |
420 return inout.isSolidWhite(); | 421 return inout.isSolidWhite(); |
421 } | 422 } |
422 | 423 |
423 ////////////////////////////////////////////////////////////////////////////// | 424 ////////////////////////////////////////////////////////////////////////////// |
424 | 425 |
425 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { | 426 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS
tate) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 //////////////////////////////////////////////////////////////////////////////// | 634 //////////////////////////////////////////////////////////////////////////////// |
634 | 635 |
635 GrDrawState::~GrDrawState() { | 636 GrDrawState::~GrDrawState() { |
636 SkSafeUnref(fCachedOptState); | 637 SkSafeUnref(fCachedOptState); |
637 SkASSERT(0 == fBlockEffectRemovalCnt); | 638 SkASSERT(0 == fBlockEffectRemovalCnt); |
638 } | 639 } |
639 | 640 |
640 //////////////////////////////////////////////////////////////////////////////// | 641 //////////////////////////////////////////////////////////////////////////////// |
641 | 642 |
642 GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, | 643 GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage, |
643 GrBlendCoeff* srcCoeff, | 644 GrBlendCoeff* srcCoeff, |
644 GrBlendCoeff* dstCoeff)
const { | 645 GrBlendCoeff* dstCoeff) con
st { |
645 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; | 646 GrBlendCoeff bogusSrcCoeff, bogusDstCoeff; |
646 if (NULL == srcCoeff) { | 647 if (NULL == srcCoeff) { |
647 srcCoeff = &bogusSrcCoeff; | 648 srcCoeff = &bogusSrcCoeff; |
648 } | 649 } |
649 if (NULL == dstCoeff) { | 650 if (NULL == dstCoeff) { |
650 dstCoeff = &bogusDstCoeff; | 651 dstCoeff = &bogusDstCoeff; |
651 } | 652 } |
652 | 653 |
653 *srcCoeff = this->getSrcBlendCoeff(); | 654 *srcCoeff = this->getSrcBlendCoeff(); |
654 *dstCoeff = this->getDstBlendCoeff(); | 655 *dstCoeff = this->getDstBlendCoeff(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 } | 777 } |
777 | 778 |
778 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if | 779 // Since the shader will multiply coverage and color, the only way the f
inal A==1 is if |
779 // coverage and color both have A==1. | 780 // coverage and color both have A==1. |
780 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); | 781 return (inoutColor.isOpaque() && inoutCoverage.isOpaque()); |
781 } | 782 } |
782 | 783 |
783 return inoutColor.isOpaque(); | 784 return inoutColor.isOpaque(); |
784 } | 785 } |
785 | 786 |
OLD | NEW |