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

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

Issue 25023003: Implement color filter as GrGLEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 9
10 #ifndef GrPaint_DEFINED 10 #ifndef GrPaint_DEFINED
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void setAntiAlias(bool aa) { fAntiAlias = aa; } 78 void setAntiAlias(bool aa) { fAntiAlias = aa; }
79 bool isAntiAlias() const { return fAntiAlias; } 79 bool isAntiAlias() const { return fAntiAlias; }
80 80
81 /** 81 /**
82 * Should dithering be applied. Defaults to false. 82 * Should dithering be applied. Defaults to false.
83 */ 83 */
84 void setDither(bool dither) { fDither = dither; } 84 void setDither(bool dither) { fDither = dither; }
85 bool isDither() const { return fDither; } 85 bool isDither() const { return fDither; }
86 86
87 /** 87 /**
88 * Enables a SkXfermode::Mode-based color filter applied to the primitive co lor. The constant
89 * color passed to this function is considered the "src" color and the primi tive's color is
90 * considered the "dst" color. Defaults to kDst_Mode which equates to simply passing through
91 * the primitive color unmodified.
92 */
93 void setXfermodeColorFilter(SkXfermode::Mode mode, GrColor color) {
94 fColorFilterColor = color;
95 fColorFilterXfermode = mode;
96 }
97 SkXfermode::Mode getColorFilterMode() const { return fColorFilterXfermode; }
98 GrColor getColorFilterColor() const { return fColorFilterColor; }
99
100 /**
101 * Disables the SkXfermode::Mode color filter.
102 */
103 void resetColorFilter() {
104 fColorFilterXfermode = SkXfermode::kDst_Mode;
105 fColorFilterColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff);
106 }
107
108 /**
109 * Appends an additional color effect to the color computation. 88 * Appends an additional color effect to the color computation.
110 */ 89 */
111 const GrEffectRef* addColorEffect(const GrEffectRef* effect, int attr0 = -1, int attr1 = -1) { 90 const GrEffectRef* addColorEffect(const GrEffectRef* effect, int attr0 = -1, int attr1 = -1) {
112 SkASSERT(NULL != effect); 91 SkASSERT(NULL != effect);
92 if (!(*effect)->willUseInputColor()) {
93 fColorStages.reset();
94 }
113 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att r1)); 95 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att r1));
114 return effect; 96 return effect;
115 } 97 }
116 98
117 /** 99 /**
118 * Appends an additional coverage effect to the coverage computation. 100 * Appends an additional coverage effect to the coverage computation.
119 */ 101 */
120 const GrEffectRef* addCoverageEffect(const GrEffectRef* effect, int attr0 = -1, int attr1 = -1) { 102 const GrEffectRef* addCoverageEffect(const GrEffectRef* effect, int attr0 = -1, int attr1 = -1) {
121 SkASSERT(NULL != effect); 103 SkASSERT(NULL != effect);
122 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0, attr1)); 104 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0, attr1));
(...skipping 23 matching lines...) Expand all
146 128
147 GrPaint& operator=(const GrPaint& paint) { 129 GrPaint& operator=(const GrPaint& paint) {
148 fSrcBlendCoeff = paint.fSrcBlendCoeff; 130 fSrcBlendCoeff = paint.fSrcBlendCoeff;
149 fDstBlendCoeff = paint.fDstBlendCoeff; 131 fDstBlendCoeff = paint.fDstBlendCoeff;
150 fAntiAlias = paint.fAntiAlias; 132 fAntiAlias = paint.fAntiAlias;
151 fDither = paint.fDither; 133 fDither = paint.fDither;
152 134
153 fColor = paint.fColor; 135 fColor = paint.fColor;
154 fCoverage = paint.fCoverage; 136 fCoverage = paint.fCoverage;
155 137
156 fColorFilterColor = paint.fColorFilterColor;
157 fColorFilterXfermode = paint.fColorFilterXfermode;
158
159 fColorStages = paint.fColorStages; 138 fColorStages = paint.fColorStages;
160 fCoverageStages = paint.fCoverageStages; 139 fCoverageStages = paint.fCoverageStages;
161 140
162 return *this; 141 return *this;
163 } 142 }
164 143
165 /** 144 /**
166 * Resets the paint to the defaults. 145 * Resets the paint to the defaults.
167 */ 146 */
168 void reset() { 147 void reset() {
169 this->resetBlend(); 148 this->resetBlend();
170 this->resetOptions(); 149 this->resetOptions();
171 this->resetColor(); 150 this->resetColor();
172 this->resetCoverage(); 151 this->resetCoverage();
173 this->resetStages(); 152 this->resetStages();
174 this->resetColorFilter();
175 } 153 }
176 154
177 /** 155 /**
178 * Determines whether the drawing with this paint is opaque with respect to both color blending 156 * Determines whether the drawing with this paint is opaque with respect to both color blending
179 * and fractional coverage. It does not consider whether AA has been enabled on the paint or 157 * and fractional coverage. It does not consider whether AA has been enabled on the paint or
180 * not. Depending upon whether multisampling or coverage-based AA is in use, AA may make the 158 * not. Depending upon whether multisampling or coverage-based AA is in use, AA may make the
181 * result only apply to the interior of primitives. 159 * result only apply to the interior of primitives.
182 * 160 *
183 */ 161 */
184 bool isOpaque() const; 162 bool isOpaque() const;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 SkSTArray<2, GrEffectStage> fCoverageStages; 216 SkSTArray<2, GrEffectStage> fCoverageStages;
239 217
240 GrBlendCoeff fSrcBlendCoeff; 218 GrBlendCoeff fSrcBlendCoeff;
241 GrBlendCoeff fDstBlendCoeff; 219 GrBlendCoeff fDstBlendCoeff;
242 bool fAntiAlias; 220 bool fAntiAlias;
243 bool fDither; 221 bool fDither;
244 222
245 GrColor fColor; 223 GrColor fColor;
246 uint8_t fCoverage; 224 uint8_t fCoverage;
247 225
248 GrColor fColorFilterColor;
249 SkXfermode::Mode fColorFilterXfermode;
250
251 void resetBlend() { 226 void resetBlend() {
252 fSrcBlendCoeff = kOne_GrBlendCoeff; 227 fSrcBlendCoeff = kOne_GrBlendCoeff;
253 fDstBlendCoeff = kZero_GrBlendCoeff; 228 fDstBlendCoeff = kZero_GrBlendCoeff;
254 } 229 }
255 230
256 void resetOptions() { 231 void resetOptions() {
257 fAntiAlias = false; 232 fAntiAlias = false;
258 fDither = false; 233 fDither = false;
259 } 234 }
260 235
261 void resetColor() { 236 void resetColor() {
262 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); 237 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff);
263 } 238 }
264 239
265 void resetCoverage() { 240 void resetCoverage() {
266 fCoverage = 0xff; 241 fCoverage = 0xff;
267 } 242 }
268 243
269 void resetStages() { 244 void resetStages() {
270 fColorStages.reset(); 245 fColorStages.reset();
271 fCoverageStages.reset(); 246 fCoverageStages.reset();
272 } 247 }
273 }; 248 };
274 249
275 #endif 250 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698