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

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

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: feddback inc Created 6 years, 3 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 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
11 #define GrPaint_DEFINED 11 #define GrPaint_DEFINED
12 12
13 #include "GrColor.h" 13 #include "GrColor.h"
14 #include "GrEffectStage.h" 14 #include "GrProcessorStage.h"
15 15
16 #include "SkXfermode.h" 16 #include "SkXfermode.h"
17 17
18 /** 18 /**
19 * The paint describes how color and coverage are computed at each pixel by GrCo ntext draw 19 * The paint describes how color and coverage are computed at each pixel by GrCo ntext draw
20 * functions and the how color is blended with the destination pixel. 20 * functions and the how color is blended with the destination pixel.
21 * 21 *
22 * The paint allows installation of custom color and coverage stages. New types of stages are 22 * The paint allows installation of custom color and coverage stages. New types of stages are
23 * created by subclassing GrEffect. 23 * created by subclassing GrProcessor.
24 * 24 *
25 * The primitive color computation starts with the color specified by setColor() . This color is the 25 * The primitive color computation starts with the color specified by setColor() . This color is the
26 * input to the first color stage. Each color stage feeds its output to the next color stage. The 26 * input to the first color stage. Each color stage feeds its output to the next color stage. The
27 * final color stage's output color is input to the color filter specified by 27 * final color stage's output color is input to the color filter specified by
28 * setXfermodeColorFilter which produces the final source color, S. 28 * setXfermodeColorFilter which produces the final source color, S.
29 * 29 *
30 * Fractional pixel coverage follows a similar flow. The coverage is initially t he value specified 30 * Fractional pixel coverage follows a similar flow. The coverage is initially t he value specified
31 * by setCoverage(). This is input to the first coverage stage. Coverage stages are chained 31 * by setCoverage(). This is input to the first coverage stage. Coverage stages are chained
32 * together in the same manner as color stages. The output of the last stage is modulated by any 32 * together in the same manner as color stages. The output of the last stage is modulated by any
33 * fractional coverage produced by anti-aliasing. This last step produces the fi nal coverage, C. 33 * fractional coverage produced by anti-aliasing. This last step produces the fi nal coverage, C.
34 * 34 *
35 * setBlendFunc() specifies blending coefficients for S (described above) and D, the initial value 35 * setBlendFunc() specifies blending coefficients for S (described above) and D, the initial value
36 * of the destination pixel, labeled Bs and Bd respectively. The final value of the destination 36 * of the destination pixel, labeled Bs and Bd respectively. The final value of the destination
37 * pixel is then D' = (1-C)*D + C*(Bd*D + Bs*S). 37 * pixel is then D' = (1-C)*D + C*(Bd*D + Bs*S).
38 * 38 *
39 * Note that the coverage is applied after the blend. This is why they are compu ted as distinct 39 * Note that the coverage is applied after the blend. This is why they are compu ted as distinct
40 * values. 40 * values.
41 * 41 *
42 * TODO: Encapsulate setXfermodeColorFilter in a GrEffect and remove from GrPain t. 42 * TODO: Encapsulate setXfermodeColorFilter in a GrProcessor and remove from GrP aint.
43 */ 43 */
44 class GrPaint { 44 class GrPaint {
45 public: 45 public:
46 GrPaint() { this->reset(); } 46 GrPaint() { this->reset(); }
47 47
48 GrPaint(const GrPaint& paint) { *this = paint; } 48 GrPaint(const GrPaint& paint) { *this = paint; }
49 49
50 ~GrPaint() {} 50 ~GrPaint() {}
51 51
52 /** 52 /**
(...skipping 25 matching lines...) Expand all
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 * Appends an additional color effect to the color computation. 88 * Appends an additional color processor to the color computation.
89 */ 89 */
90 const GrEffect* addColorEffect(const GrEffect* effect) { 90 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) {
91 SkASSERT(effect); 91 SkASSERT(fp);
92 SkASSERT(!effect->requiresVertexShader()); 92 if (!fp->willUseInputColor()) {
93 if (!effect->willUseInputColor()) {
94 fColorStages.reset(); 93 fColorStages.reset();
95 } 94 }
96 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect)); 95 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrProcessorStage, (fp));
97 return effect; 96 return fp;
98 } 97 }
99 98
100 /** 99 /**
101 * Appends an additional coverage effect to the coverage computation. 100 * Appends an additional coverage processor to the coverage computation.
102 */ 101 */
103 const GrEffect* addCoverageEffect(const GrEffect* effect) { 102 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* f p) {
104 SkASSERT(effect); 103 SkASSERT(fp);
105 SkASSERT(!effect->requiresVertexShader()); 104 if (!fp->willUseInputColor()) {
106 if (!effect->willUseInputColor()) {
107 fCoverageStages.reset(); 105 fCoverageStages.reset();
108 } 106 }
109 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect)); 107 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrProcessorStage, (fp));
110 return effect; 108 return fp;
111 } 109 }
112 110
113 /** 111 /**
114 * Helpers for adding color or coverage effects that sample a texture. The m atrix is applied 112 * Helpers for adding color or coverage effects that sample a texture. The m atrix is applied
115 * to the src space position to compute texture coordinates. 113 * to the src space position to compute texture coordinates.
116 */ 114 */
117 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix); 115 void addColorTextureProcessor(GrTexture*, const SkMatrix&);
118 void addCoverageTextureEffect(GrTexture* texture, const SkMatrix& matrix); 116 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&);
119 117 void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTexturePa rams&);
120 void addColorTextureEffect(GrTexture* texture, 118 void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextur eParams&);
121 const SkMatrix& matrix,
122 const GrTextureParams& params);
123 void addCoverageTextureEffect(GrTexture* texture,
124 const SkMatrix& matrix,
125 const GrTextureParams& params);
126 119
127 int numColorStages() const { return fColorStages.count(); } 120 int numColorStages() const { return fColorStages.count(); }
128 int numCoverageStages() const { return fCoverageStages.count(); } 121 int numCoverageStages() const { return fCoverageStages.count(); }
129 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); } 122 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); }
130 123
131 const GrEffectStage& getColorStage(int s) const { return fColorStages[s]; } 124 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; }
132 const GrEffectStage& getCoverageStage(int s) const { return fCoverageStages[ s]; } 125 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage s[s]; }
133 126
134 GrPaint& operator=(const GrPaint& paint) { 127 GrPaint& operator=(const GrPaint& paint) {
135 fSrcBlendCoeff = paint.fSrcBlendCoeff; 128 fSrcBlendCoeff = paint.fSrcBlendCoeff;
136 fDstBlendCoeff = paint.fDstBlendCoeff; 129 fDstBlendCoeff = paint.fDstBlendCoeff;
137 fAntiAlias = paint.fAntiAlias; 130 fAntiAlias = paint.fAntiAlias;
138 fDither = paint.fDither; 131 fDither = paint.fDither;
139 132
140 fColor = paint.fColor; 133 fColor = paint.fColor;
141 fCoverage = paint.fCoverage; 134 fCoverage = paint.fCoverage;
142 135
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 computed = true; 204 computed = true;
212 } 205 }
213 fCoverageStages[i].localCoordChange(oldToNew); 206 fCoverageStages[i].localCoordChange(oldToNew);
214 } 207 }
215 return true; 208 return true;
216 } 209 }
217 210
218 friend class GrContext; // To access above two functions 211 friend class GrContext; // To access above two functions
219 friend class GrStencilAndCoverTextContext; // To access above two functions 212 friend class GrStencilAndCoverTextContext; // To access above two functions
220 213
221 SkSTArray<4, GrEffectStage> fColorStages; 214 SkSTArray<4, GrFragmentStage> fColorStages;
222 SkSTArray<2, GrEffectStage> fCoverageStages; 215 SkSTArray<2, GrFragmentStage> fCoverageStages;
223 216
224 GrBlendCoeff fSrcBlendCoeff; 217 GrBlendCoeff fSrcBlendCoeff;
225 GrBlendCoeff fDstBlendCoeff; 218 GrBlendCoeff fDstBlendCoeff;
226 bool fAntiAlias; 219 bool fAntiAlias;
227 bool fDither; 220 bool fDither;
228 221
229 GrColor fColor; 222 GrColor fColor;
230 uint8_t fCoverage; 223 uint8_t fCoverage;
231 224
232 void resetBlend() { 225 void resetBlend() {
(...skipping 14 matching lines...) Expand all
247 fCoverage = 0xff; 240 fCoverage = 0xff;
248 } 241 }
249 242
250 void resetStages() { 243 void resetStages() {
251 fColorStages.reset(); 244 fColorStages.reset();
252 fCoverageStages.reset(); 245 fCoverageStages.reset();
253 } 246 }
254 }; 247 };
255 248
256 #endif 249 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698