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

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

Issue 608253002: Add isSingleComponent bool to getConstantColorComponent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update comment and nits 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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrPaint.h" 9 #include "GrPaint.h"
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 } 46 }
47 return false; 47 return false;
48 } 48 }
49 49
50 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, 50 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
51 uint32_t* solidColorKnownComponents) const { 51 uint32_t* solidColorKnownComponents) const {
52 52
53 // TODO: Share this implementation with GrDrawState 53 // TODO: Share this implementation with GrDrawState
54 54
55 GrColor coverage = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverag e); 55 GrProcessor::InvarientOutput invarientOutput;
56 uint32_t coverageComps = kRGBA_GrColorComponentFlags; 56 invarientOutput.color = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCo verage);
57 invarientOutput.validFlags = kRGBA_GrColorComponentFlags;
58 invarientOutput.isSingleComponent = false;
57 int count = fCoverageStages.count(); 59 int count = fCoverageStages.count();
58 for (int i = 0; i < count; ++i) { 60 for (int i = 0; i < count; ++i) {
59 fCoverageStages[i].getProcessor()->getConstantColorComponents(&coverage, &coverageComps); 61 fCoverageStages[i].getProcessor()->computeInvarientOutput(&invarientOutp ut);
60 } 62 }
61 if (kRGBA_GrColorComponentFlags != coverageComps || 0xffffffff != coverage) { 63 if (!invarientOutput.hasOpaqueColor()) {
62 return false; 64 return false;
63 } 65 }
64 66
65 GrColor color = fColor; 67 invarientOutput.color = fColor;
66 uint32_t colorComps = kRGBA_GrColorComponentFlags; 68 invarientOutput.validFlags = kRGBA_GrColorComponentFlags;
69 invarientOutput.isSingleComponent = false;
67 count = fColorStages.count(); 70 count = fColorStages.count();
68 for (int i = 0; i < count; ++i) { 71 for (int i = 0; i < count; ++i) {
69 fColorStages[i].getProcessor()->getConstantColorComponents(&color, &colo rComps); 72 fColorStages[i].getProcessor()->computeInvarientOutput(&invarientOutput) ;
70 } 73 }
71 74
72 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents)); 75 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents));
73 76
74 GrBlendCoeff srcCoeff = fSrcBlendCoeff; 77 GrBlendCoeff srcCoeff = fSrcBlendCoeff;
75 GrBlendCoeff dstCoeff = fDstBlendCoeff; 78 GrBlendCoeff dstCoeff = fDstBlendCoeff;
76 GrSimplifyBlend(&srcCoeff, &dstCoeff, color, colorComps, 0, 0, 0); 79 GrSimplifyBlend(&srcCoeff, &dstCoeff, invarientOutput.color, invarientOutput .validFlags,
80 0, 0, 0);
77 81
78 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef f); 82 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef f);
79 if (solidColor) { 83 if (solidColor) {
80 if (opaque) { 84 if (opaque) {
81 switch (srcCoeff) { 85 switch (srcCoeff) {
82 case kZero_GrBlendCoeff: 86 case kZero_GrBlendCoeff:
83 *solidColor = 0; 87 *solidColor = 0;
84 *solidColorKnownComponents = kRGBA_GrColorComponentFlags; 88 *solidColorKnownComponents = kRGBA_GrColorComponentFlags;
85 break; 89 break;
86 90
87 case kOne_GrBlendCoeff: 91 case kOne_GrBlendCoeff:
88 *solidColor = color; 92 *solidColor = invarientOutput.color;
89 *solidColorKnownComponents = colorComps; 93 *solidColorKnownComponents = invarientOutput.validFlags;
90 break; 94 break;
91 95
92 // The src coeff should never refer to the src and if it refers to dst then opaque 96 // The src coeff should never refer to the src and if it refers to dst then opaque
93 // should have been false. 97 // should have been false.
94 case kSC_GrBlendCoeff: 98 case kSC_GrBlendCoeff:
95 case kISC_GrBlendCoeff: 99 case kISC_GrBlendCoeff:
96 case kDC_GrBlendCoeff: 100 case kDC_GrBlendCoeff:
97 case kIDC_GrBlendCoeff: 101 case kIDC_GrBlendCoeff:
98 case kSA_GrBlendCoeff: 102 case kSA_GrBlendCoeff:
99 case kISA_GrBlendCoeff: 103 case kISA_GrBlendCoeff:
(...skipping 10 matching lines...) Expand all
110 case kIConstA_GrBlendCoeff: 114 case kIConstA_GrBlendCoeff:
111 *solidColorKnownComponents = 0; 115 *solidColorKnownComponents = 0;
112 break; 116 break;
113 } 117 }
114 } else { 118 } else {
115 solidColorKnownComponents = 0; 119 solidColorKnownComponents = 0;
116 } 120 }
117 } 121 }
118 return opaque; 122 return opaque;
119 } 123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698