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

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

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: more windows fix Created 6 years 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 | « include/gpu/GrFragmentProcessor.h ('k') | include/gpu/GrProcessor.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
11 #include "GrColor.h" 11 #include "GrColor.h"
12 12
13 struct GrInitInvariantOutput {
14 GrInitInvariantOutput()
15 : fValidFlags(0)
16 , fColor(0)
17 , fIsSingleComponent(false)
18 , fIsLCDCoverage(false) {}
19
20 void setKnownFourComponents(GrColor color) {
21 fColor = color;
22 fValidFlags = kRGBA_GrColorComponentFlags;
23 fIsSingleComponent = false;
24 }
25
26 void setUnknownFourComponents() {
27 fValidFlags = 0;
28 fIsSingleComponent = false;
29 }
30
31 void setUnknownOpaqueFourComponents() {
32 fColor = 0xff << GrColor_SHIFT_A;
33 fValidFlags = kA_GrColorComponentFlag;
34 fIsSingleComponent = false;
35 }
36
37 void setKnownSingleComponent(uint8_t alpha) {
38 fColor = GrColorPackRGBA(alpha, alpha, alpha, alpha);
39 fValidFlags = kRGBA_GrColorComponentFlags;
40 fIsSingleComponent = true;
41 }
42
43 void setUnknownSingleComponent() {
44 fValidFlags = 0;
45 fIsSingleComponent = true;
46 }
47
48 void setUsingLCDCoverage() { fIsLCDCoverage = true; }
49
50 uint32_t fValidFlags;
51 GrColor fColor;
52 bool fIsSingleComponent;
53 bool fIsLCDCoverage; // Temorary data member until texture pixel configs are updated
54 };
55
13 class GrInvariantOutput { 56 class GrInvariantOutput {
14 public: 57 public:
15 GrInvariantOutput(GrColor color, GrColorComponentFlags flags, bool isSingleC omponent) 58 GrInvariantOutput(GrColor color, GrColorComponentFlags flags, bool isSingleC omponent)
16 : fColor(color) 59 : fColor(color)
17 , fValidFlags(flags) 60 , fValidFlags(flags)
18 , fIsSingleComponent(isSingleComponent) 61 , fIsSingleComponent(isSingleComponent)
19 , fNonMulStageFound(false) 62 , fNonMulStageFound(false)
20 , fWillUseInputColor(true) 63 , fWillUseInputColor(true)
21 , fIsLCDCoverage(false) {} 64 , fIsLCDCoverage(false) {}
22 65
66 GrInvariantOutput(const GrInitInvariantOutput& io)
67 : fColor(io.fColor)
68 , fValidFlags(io.fValidFlags)
69 , fIsSingleComponent(io.fIsSingleComponent)
70 , fNonMulStageFound(false)
71 , fWillUseInputColor(false)
72 , fIsLCDCoverage(io.fIsLCDCoverage) {}
73
23 virtual ~GrInvariantOutput() {} 74 virtual ~GrInvariantOutput() {}
24 75
25 enum ReadInput { 76 enum ReadInput {
26 kWill_ReadInput, 77 kWill_ReadInput,
27 kWillNot_ReadInput, 78 kWillNot_ReadInput,
28 }; 79 };
29 80
30 void mulByUnknownOpaqueColor() { 81 void mulByUnknownOpaqueFourComponents() {
31 if (this->isOpaque()) { 82 if (this->isOpaque()) {
32 fValidFlags = kA_GrColorComponentFlag; 83 fValidFlags = kA_GrColorComponentFlag;
33 fIsSingleComponent = false; 84 fIsSingleComponent = false;
34 } else { 85 } else {
35 // Since the current state is not opaque we no longer care if the co lor being 86 // Since the current state is not opaque we no longer care if the co lor being
36 // multiplied is opaque. 87 // multiplied is opaque.
37 this->mulByUnknownColor(); 88 this->mulByUnknownFourComponents();
38 } 89 }
39 } 90 }
40 91
41 void mulByUnknownColor() { 92 void mulByUnknownFourComponents() {
42 if (this->hasZeroAlpha()) { 93 if (this->hasZeroAlpha()) {
43 this->internalSetToTransparentBlack(); 94 this->internalSetToTransparentBlack();
44 } else { 95 } else {
45 this->internalSetToUnknown(); 96 this->internalSetToUnknown();
46 } 97 }
47 } 98 }
48 99
49 void mulByUnknownAlpha() { 100 void mulByUnknownSingleComponent() {
50 if (this->hasZeroAlpha()) { 101 if (this->hasZeroAlpha()) {
51 this->internalSetToTransparentBlack(); 102 this->internalSetToTransparentBlack();
52 } else { 103 } else {
53 // We don't need to change fIsSingleComponent in this case 104 // We don't need to change fIsSingleComponent in this case
54 fValidFlags = 0; 105 fValidFlags = 0;
55 } 106 }
56 } 107 }
57 108
58 void mulByKnownAlpha(uint8_t alpha) { 109 void mulByKnownSingleComponent(uint8_t alpha) {
59 if (this->hasZeroAlpha() || 0 == alpha) { 110 if (this->hasZeroAlpha() || 0 == alpha) {
60 this->internalSetToTransparentBlack(); 111 this->internalSetToTransparentBlack();
61 } else { 112 } else {
62 if (alpha != 255) { 113 if (alpha != 255) {
63 // Multiply color by alpha 114 // Multiply color by alpha
64 fColor = GrColorPackRGBA(SkMulDiv255Round(GrColorUnpackR(fColor) , alpha), 115 fColor = GrColorPackRGBA(SkMulDiv255Round(GrColorUnpackR(fColor) , alpha),
65 SkMulDiv255Round(GrColorUnpackG(fColor) , alpha), 116 SkMulDiv255Round(GrColorUnpackG(fColor) , alpha),
66 SkMulDiv255Round(GrColorUnpackB(fColor) , alpha), 117 SkMulDiv255Round(GrColorUnpackB(fColor) , alpha),
67 SkMulDiv255Round(GrColorUnpackA(fColor) , alpha)); 118 SkMulDiv255Round(GrColorUnpackA(fColor) , alpha));
68 } 119 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 friend class GrProcOptInfo; 166 friend class GrProcOptInfo;
116 167
117 void reset(GrColor color, GrColorComponentFlags flags, bool isSingleComponen t) { 168 void reset(GrColor color, GrColorComponentFlags flags, bool isSingleComponen t) {
118 fColor = color; 169 fColor = color;
119 fValidFlags = flags; 170 fValidFlags = flags;
120 fIsSingleComponent = isSingleComponent; 171 fIsSingleComponent = isSingleComponent;
121 fNonMulStageFound = false; 172 fNonMulStageFound = false;
122 fWillUseInputColor = true; 173 fWillUseInputColor = true;
123 } 174 }
124 175
176 void reset(const GrInitInvariantOutput& io) {
177 fColor = io.fColor;
178 fValidFlags = io.fValidFlags;
179 fIsSingleComponent = io.fIsSingleComponent;
180 fNonMulStageFound = false;
181 fWillUseInputColor = true;
182 fIsLCDCoverage = io.fIsLCDCoverage;
183 }
184
125 void internalSetToTransparentBlack() { 185 void internalSetToTransparentBlack() {
126 fValidFlags = kRGBA_GrColorComponentFlags; 186 fValidFlags = kRGBA_GrColorComponentFlags;
127 fColor = 0; 187 fColor = 0;
128 fIsSingleComponent = true; 188 fIsSingleComponent = true;
129 } 189 }
130 190
131 void internalSetToUnknown() { 191 void internalSetToUnknown() {
132 fValidFlags = 0; 192 fValidFlags = 0;
133 fIsSingleComponent = false; 193 fIsSingleComponent = false;
134 } 194 }
(...skipping 29 matching lines...) Expand all
164 uint32_t fValidFlags; 224 uint32_t fValidFlags;
165 bool fIsSingleComponent; 225 bool fIsSingleComponent;
166 bool fNonMulStageFound; 226 bool fNonMulStageFound;
167 bool fWillUseInputColor; 227 bool fWillUseInputColor;
168 bool fIsLCDCoverage; // Temorary data member until texture pixel configs are updated 228 bool fIsLCDCoverage; // Temorary data member until texture pixel configs are updated
169 229
170 }; 230 };
171 231
172 #endif 232 #endif
173 233
OLDNEW
« no previous file with comments | « include/gpu/GrFragmentProcessor.h ('k') | include/gpu/GrProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698