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

Side by Side Diff: include/gpu/GrInvariantOutput.h

Issue 978713002: Add constant color GrFP. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/effects/GrColorProcessor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 #ifndef GrInvariantOutput_DEFINED 8 #ifndef GrInvariantOutput_DEFINED
9 #define GrInvariantOutput_DEFINED 9 #define GrInvariantOutput_DEFINED
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 void mulByKnownSingleComponent(uint8_t alpha) { 109 void mulByKnownSingleComponent(uint8_t alpha) {
110 if (this->hasZeroAlpha() || 0 == alpha) { 110 if (this->hasZeroAlpha() || 0 == alpha) {
111 this->internalSetToTransparentBlack(); 111 this->internalSetToTransparentBlack();
112 } else { 112 } else {
113 if (alpha != 255) { 113 if (alpha != 255) {
114 // Multiply color by alpha 114 // Multiply color by alpha
115 fColor = GrColorPackRGBA(SkMulDiv255Round(GrColorUnpackR(fColor) , alpha), 115 fColor = GrColorPackRGBA(SkMulDiv255Round(GrColorUnpackR(fColor) , alpha),
116 SkMulDiv255Round(GrColorUnpackG(fColor) , alpha), 116 SkMulDiv255Round(GrColorUnpackG(fColor) , alpha),
117 SkMulDiv255Round(GrColorUnpackB(fColor) , alpha), 117 SkMulDiv255Round(GrColorUnpackB(fColor) , alpha),
118 SkMulDiv255Round(GrColorUnpackA(fColor) , alpha)); 118 SkMulDiv255Round(GrColorUnpackA(fColor) , alpha));
119 // We don't need to change fIsSingleComponent in this case
119 } 120 }
120 } 121 }
121 } 122 }
122 123
124 void mulByKnownFourComponents(GrColor color) {
125 if (0 == color) {
126 this->internalSetToTransparentBlack();
127 } else {
128 if (color != 0xffffffff) {
129 fColor = GrColorPackRGBA(
130 SkMulDiv255Round(GrColorUnpackR(fColor), GrColorUnpackR(colo r)),
131 SkMulDiv255Round(GrColorUnpackG(fColor), GrColorUnpackG(colo r)),
132 SkMulDiv255Round(GrColorUnpackB(fColor), GrColorUnpackB(colo r)),
133 SkMulDiv255Round(GrColorUnpackA(fColor), GrColorUnpackA(colo r)));
134 this->updateIsSingleComponent();
egdaniel 2015/03/04 15:17:03 at least with what is in the updateISC function no
bsalomon 2015/03/04 19:43:36 Done.
135 }
136 }
137 }
138
139 // Ignores the incoming color's RGB and muls its alpha by color.
140 void mulAlphaByKnownFourComponents(GrColor color) {
141 if (0 == color || 0 == this->hasZeroAlpha()) {
142 this->internalSetToTransparentBlack();
143 } else {
144 if (fValidFlags & kA_GrColorComponentFlag) {
145 GrColor alpha = GrColorUnpackA(fColor);
146 fColor = GrColorPackRGBA(
147 SkMulDiv255Round(alpha, GrColorUnpackR(color)),
148 SkMulDiv255Round(alpha, GrColorUnpackG(color)),
149 SkMulDiv255Round(alpha, GrColorUnpackB(color)),
150 SkMulDiv255Round(alpha, GrColorUnpackA(color)));
151 fValidFlags = kRGBA_GrColorComponentFlags;
152 } else {
153 fValidFlags = 0;
154 }
155 // If color is single channel then so are we.
156 GrColor a = GrColorUnpackA(color);
157 fIsSingleComponent = a == GrColorUnpackR(color) && a == GrColorUnpac kG(color) &&
158 a == GrColorUnpackB(color);
159 }
160 }
161
162 // Ignores the incoming color's RGB and muls its alpha by the alpha param.
163 void mulAlphaByKnownSingleComponent(uint8_t alpha) {
164 if (0 == alpha || 0 == this->hasZeroAlpha()) {
165 this->internalSetToTransparentBlack();
166 } else {
167 if (fValidFlags & kA_GrColorComponentFlag) {
168 GrColor a = GrColorUnpackA(fColor);
169 a = SkMulDiv255Round(alpha, a);
170 fColor = GrColorPackRGBA(a, a, a, a);
171 fValidFlags = kRGBA_GrColorComponentFlags;
172 } else {
173 fValidFlags = 0;
174 }
175 fIsSingleComponent = true;
176 }
177 }
178
123 void invalidateComponents(uint8_t invalidateFlags, ReadInput readsInput) { 179 void invalidateComponents(uint8_t invalidateFlags, ReadInput readsInput) {
124 fValidFlags &= ~invalidateFlags; 180 fValidFlags &= ~invalidateFlags;
125 fIsSingleComponent = false; 181 fIsSingleComponent = false;
126 fNonMulStageFound = true; 182 fNonMulStageFound = true;
127 if (kWillNot_ReadInput == readsInput) { 183 if (kWillNot_ReadInput == readsInput) {
128 fWillUseInputColor = false; 184 fWillUseInputColor = false;
129 } 185 }
130 } 186 }
131 187
132 void setToOther(uint8_t validFlags, GrColor color, ReadInput readsInput) { 188 void setToOther(uint8_t validFlags, GrColor color, ReadInput readsInput) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 254 }
199 255
200 bool isOpaque() const { 256 bool isOpaque() const {
201 return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpack A(fColor)); 257 return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpack A(fColor));
202 } 258 }
203 259
204 bool isSolidWhite() const { 260 bool isSolidWhite() const {
205 return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fCol or); 261 return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fCol or);
206 } 262 }
207 263
264 void updateIsSingleComponent() {
egdaniel 2015/03/04 15:17:03 In general I am not a big fan of this function or
265 if (kRGBA_GrColorComponentFlags == fValidFlags) {
266 GrColor a = GrColorUnpackA(fColor);
267 fIsSingleComponent = a == GrColorUnpackR(fColor) && a == GrColorUnpa ckG(fColor) &&
268 a == GrColorUnpackB(fColor);
269 }
270
271 }
208 bool isSingleComponent() const { return fIsSingleComponent; } 272 bool isSingleComponent() const { return fIsSingleComponent; }
209 273
210 bool willUseInputColor() const { return fWillUseInputColor; } 274 bool willUseInputColor() const { return fWillUseInputColor; }
211 void resetWillUseInputColor() { fWillUseInputColor = true; } 275 void resetWillUseInputColor() { fWillUseInputColor = true; }
212 276
213 bool allStagesMulInput() const { return !fNonMulStageFound; } 277 bool allStagesMulInput() const { return !fNonMulStageFound; }
214 void resetNonMulStageFound() { fNonMulStageFound = false; } 278 void resetNonMulStageFound() { fNonMulStageFound = false; }
215 279
216 bool isLCDCoverage() const { return fIsLCDCoverage; } 280 bool isLCDCoverage() const { return fIsLCDCoverage; }
217 281
218 SkDEBUGCODE(bool colorComponentsAllEqual() const;) 282 SkDEBUGCODE(bool colorComponentsAllEqual() const;)
219 /** 283 /**
220 * If alpha is valid, check that any valid R,G,B values are <= A 284 * If alpha is valid, check that any valid R,G,B values are <= A
221 */ 285 */
222 SkDEBUGCODE(bool validPreMulColor() const;) 286 SkDEBUGCODE(bool validPreMulColor() const;)
223 287
224 GrColor fColor; 288 GrColor fColor;
225 uint32_t fValidFlags; 289 uint32_t fValidFlags;
226 bool fIsSingleComponent; 290 bool fIsSingleComponent;
227 bool fNonMulStageFound; 291 bool fNonMulStageFound;
228 bool fWillUseInputColor; 292 bool fWillUseInputColor;
229 bool fIsLCDCoverage; // Temorary data member until texture pixel configs are updated 293 bool fIsLCDCoverage; // Temorary data member until texture pixel configs are updated
230 294
231 }; 295 };
232 296
233 #endif 297 #endif
234 298
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/effects/GrColorProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698