Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: src/gpu/GrDrawState.cpp

Issue 608253002: Add isSingleComponent bool to getConstantColorComponent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 416 }
417 417
418 bool GrDrawState::hasSolidCoverage() const { 418 bool GrDrawState::hasSolidCoverage() const {
419 // If we're drawing coverage directly then coverage is effectively treated a s color. 419 // If we're drawing coverage directly then coverage is effectively treated a s color.
420 if (this->isCoverageDrawing()) { 420 if (this->isCoverageDrawing()) {
421 return true; 421 return true;
422 } 422 }
423 423
424 GrColor coverage; 424 GrColor coverage;
425 uint32_t validComponentFlags; 425 uint32_t validComponentFlags;
426 bool isSingleComponent = false;
426 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified. 427 // Initialize to an unknown starting coverage if per-vertex coverage is spec ified.
427 if (this->hasCoverageVertexAttribute()) { 428 if (this->hasCoverageVertexAttribute()) {
428 validComponentFlags = 0; 429 validComponentFlags = 0;
429 } else { 430 } else {
430 coverage = fCoverage; 431 coverage = fCoverage;
431 validComponentFlags = kRGBA_GrColorComponentFlags; 432 validComponentFlags = kRGBA_GrColorComponentFlags;
432 } 433 }
433 434
434 // Run through the coverage stages and see if the coverage will be all ones at the end. 435 // Run through the coverage stages and see if the coverage will be all ones at the end.
435 if (this->hasGeometryProcessor()) { 436 if (this->hasGeometryProcessor()) {
436 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor (); 437 const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor ();
437 gp->getConstantColorComponents(&coverage, &validComponentFlags); 438 gp->getConstantColorComponents(&coverage, &validComponentFlags, &isSingl eComponent);
438 } 439 }
439 for (int s = 0; s < this->numCoverageStages(); ++s) { 440 for (int s = 0; s < this->numCoverageStages(); ++s) {
440 const GrProcessor* processor = this->getCoverageStage(s).getProcessor(); 441 const GrProcessor* processor = this->getCoverageStage(s).getProcessor();
441 processor->getConstantColorComponents(&coverage, &validComponentFlags); 442 processor->getConstantColorComponents(&coverage, &validComponentFlags, & isSingleComponent);
442 } 443 }
443 return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff = = coverage); 444 return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff = = coverage);
444 } 445 }
445 446
446 ////////////////////////////////////////////////////////////////////////////// 447 //////////////////////////////////////////////////////////////////////////////
447 448
448 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) { 449 GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(GrDrawState* drawS tate) {
449 SkASSERT(drawState); 450 SkASSERT(drawState);
450 fDrawState = drawState; 451 fDrawState = drawState;
451 fVAPtr = drawState->fVAPtr; 452 fVAPtr = drawState->fVAPtr;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 751 }
751 } 752 }
752 753
753 return kNone_BlendOpt; 754 return kNone_BlendOpt;
754 } 755 }
755 756
756 757
757 bool GrDrawState::srcAlphaWillBeOne() const { 758 bool GrDrawState::srcAlphaWillBeOne() const {
758 uint32_t validComponentFlags; 759 uint32_t validComponentFlags;
759 GrColor color; 760 GrColor color;
761 bool isSingleComponent = false;
760 // Check if per-vertex or constant color may have partial alpha 762 // Check if per-vertex or constant color may have partial alpha
761 if (this->hasColorVertexAttribute()) { 763 if (this->hasColorVertexAttribute()) {
762 if (fHints & kVertexColorsAreOpaque_Hint) { 764 if (fHints & kVertexColorsAreOpaque_Hint) {
763 validComponentFlags = kA_GrColorComponentFlag; 765 validComponentFlags = kA_GrColorComponentFlag;
764 color = 0xFF << GrColor_SHIFT_A; 766 color = 0xFF << GrColor_SHIFT_A;
765 } else { 767 } else {
766 validComponentFlags = 0; 768 validComponentFlags = 0;
767 color = 0; // not strictly necessary but we get false alarms from to ols about uninit. 769 color = 0; // not strictly necessary but we get false alarms from to ols about uninit.
768 } 770 }
769 } else { 771 } else {
770 validComponentFlags = kRGBA_GrColorComponentFlags; 772 validComponentFlags = kRGBA_GrColorComponentFlags;
771 color = this->getColor(); 773 color = this->getColor();
772 } 774 }
773 775
774 // Run through the color stages 776 // Run through the color stages
775 for (int s = 0; s < this->numColorStages(); ++s) { 777 for (int s = 0; s < this->numColorStages(); ++s) {
776 const GrProcessor* processor = this->getColorStage(s).getProcessor(); 778 const GrProcessor* processor = this->getColorStage(s).getProcessor();
777 processor->getConstantColorComponents(&color, &validComponentFlags); 779 processor->getConstantColorComponents(&color, &validComponentFlags, &isS ingleComponent);
778 } 780 }
779 781
780 // Check whether coverage is treated as color. If so we run through the cove rage computation. 782 // Check whether coverage is treated as color. If so we run through the cove rage computation.
781 if (this->isCoverageDrawing()) { 783 if (this->isCoverageDrawing()) {
782 // The shader generated for coverage drawing runs the full coverage comp utation and then 784 // The shader generated for coverage drawing runs the full coverage comp utation and then
783 // makes the shader output be the multiplication of color and coverage. We mirror that here. 785 // makes the shader output be the multiplication of color and coverage. We mirror that here.
784 GrColor coverage; 786 GrColor coverage;
785 uint32_t coverageComponentFlags; 787 uint32_t coverageComponentFlags;
786 if (this->hasCoverageVertexAttribute()) { 788 if (this->hasCoverageVertexAttribute()) {
787 coverageComponentFlags = 0; 789 coverageComponentFlags = 0;
788 coverage = 0; // suppresses any warnings. 790 coverage = 0; // suppresses any warnings.
789 } else { 791 } else {
790 coverageComponentFlags = kRGBA_GrColorComponentFlags; 792 coverageComponentFlags = kRGBA_GrColorComponentFlags;
791 coverage = this->getCoverageColor(); 793 coverage = this->getCoverageColor();
792 } 794 }
793 795
794 // Run through the coverage stages 796 // Run through the coverage stages
795 for (int s = 0; s < this->numCoverageStages(); ++s) { 797 for (int s = 0; s < this->numCoverageStages(); ++s) {
796 const GrProcessor* processor = this->getCoverageStage(s).getProcesso r(); 798 const GrProcessor* processor = this->getCoverageStage(s).getProcesso r();
797 processor->getConstantColorComponents(&coverage, &coverageComponentF lags); 799 processor->getConstantColorComponents(&coverage, &coverageComponentF lags, &isSingleComponent);
joshua.litt 2014/09/29 15:22:08 Newline
egdaniel 2014/09/29 15:50:20 Done.
798 } 800 }
799 801
800 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if 802 // Since the shader will multiply coverage and color, the only way the f inal A==1 is if
801 // coverage and color both have A==1. 803 // coverage and color both have A==1.
802 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen tFlags) && 804 return (kA_GrColorComponentFlag & validComponentFlags & coverageComponen tFlags) &&
803 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage ); 805 0xFF == GrColorUnpackA(color) && 0xFF == GrColorUnpackA(coverage );
804 806
805 } 807 }
806 808
807 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp ackA(color); 809 return (kA_GrColorComponentFlag & validComponentFlags) && 0xFF == GrColorUnp ackA(color);
808 } 810 }
809 811
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698