OLD | NEW |
---|---|
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 */ | 44 */ |
45 class GrPaint { | 45 class GrPaint { |
46 public: | 46 public: |
47 GrPaint() { this->reset(); } | 47 GrPaint() { this->reset(); } |
48 | 48 |
49 GrPaint(const GrPaint& paint) { *this = paint; } | 49 GrPaint(const GrPaint& paint) { *this = paint; } |
50 | 50 |
51 ~GrPaint() {} | 51 ~GrPaint() {} |
52 | 52 |
53 /** | 53 /** |
54 * Sets the blending coefficients to use to blend the final primitive color with the | |
bsalomon
2014/12/04 21:54:24
W00000000000000000000000000000000000T
| |
55 * destination color. Defaults to kOne for src and kZero for dst (i.e. src m ode). | |
56 */ | |
57 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { | |
58 fSrcBlendCoeff = srcCoeff; | |
59 fDstBlendCoeff = dstCoeff; | |
60 } | |
61 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlendCoeff; } | |
62 GrBlendCoeff getDstBlendCoeff() const { return fDstBlendCoeff; } | |
63 | |
64 /** | |
65 * The initial color of the drawn primitive. Defaults to solid white. | 54 * The initial color of the drawn primitive. Defaults to solid white. |
66 */ | 55 */ |
67 void setColor(GrColor color) { fColor = color; } | 56 void setColor(GrColor color) { fColor = color; } |
68 GrColor getColor() const { return fColor; } | 57 GrColor getColor() const { return fColor; } |
69 | 58 |
70 /** | 59 /** |
71 * Should primitives be anti-aliased or not. Defaults to false. | 60 * Should primitives be anti-aliased or not. Defaults to false. |
72 */ | 61 */ |
73 void setAntiAlias(bool aa) { fAntiAlias = aa; } | 62 void setAntiAlias(bool aa) { fAntiAlias = aa; } |
74 bool isAntiAlias() const { return fAntiAlias; } | 63 bool isAntiAlias() const { return fAntiAlias; } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 int numColorStages() const { return fColorStages.count(); } | 103 int numColorStages() const { return fColorStages.count(); } |
115 int numCoverageStages() const { return fCoverageStages.count(); } | 104 int numCoverageStages() const { return fCoverageStages.count(); } |
116 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); } | 105 int numTotalStages() const { return this->numColorStages() + this->numCovera geStages(); } |
117 | 106 |
118 const GrXPFactory* getXPFactory() const { return fXPFactory.get(); } | 107 const GrXPFactory* getXPFactory() const { return fXPFactory.get(); } |
119 | 108 |
120 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; } | 109 const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; } |
121 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage s[s]; } | 110 const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStage s[s]; } |
122 | 111 |
123 GrPaint& operator=(const GrPaint& paint) { | 112 GrPaint& operator=(const GrPaint& paint) { |
124 fSrcBlendCoeff = paint.fSrcBlendCoeff; | |
125 fDstBlendCoeff = paint.fDstBlendCoeff; | |
126 fAntiAlias = paint.fAntiAlias; | 113 fAntiAlias = paint.fAntiAlias; |
127 fDither = paint.fDither; | 114 fDither = paint.fDither; |
128 | 115 |
129 fColor = paint.fColor; | 116 fColor = paint.fColor; |
130 | 117 |
131 fColorStages = paint.fColorStages; | 118 fColorStages = paint.fColorStages; |
132 fCoverageStages = paint.fCoverageStages; | 119 fCoverageStages = paint.fCoverageStages; |
133 | 120 |
134 fXPFactory.reset(SkRef(paint.getXPFactory())); | 121 fXPFactory.reset(SkRef(paint.getXPFactory())); |
135 | 122 |
136 return *this; | 123 return *this; |
137 } | 124 } |
138 | 125 |
139 /** | 126 /** |
140 * Resets the paint to the defaults. | 127 * Resets the paint to the defaults. |
141 */ | 128 */ |
142 void reset() { | 129 void reset() { |
143 this->resetBlend(); | |
144 this->resetOptions(); | 130 this->resetOptions(); |
145 this->resetColor(); | 131 this->resetColor(); |
146 this->resetStages(); | 132 this->resetStages(); |
147 } | 133 } |
148 | 134 |
149 /** | 135 /** |
150 * Determines whether the drawing with this paint is opaque with respect to both color blending | 136 * Determines whether the drawing with this paint is opaque with respect to both color blending |
151 * and fractional coverage. It does not consider whether AA has been enabled on the paint or | 137 * and fractional coverage. It does not consider whether AA has been enabled on the paint or |
152 * not. Depending upon whether multisampling or coverage-based AA is in use, AA may make the | 138 * not. Depending upon whether multisampling or coverage-based AA is in use, AA may make the |
153 * result only apply to the interior of primitives. | 139 * result only apply to the interior of primitives. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 return true; | 190 return true; |
205 } | 191 } |
206 | 192 |
207 friend class GrContext; // To access above two functions | 193 friend class GrContext; // To access above two functions |
208 friend class GrStencilAndCoverTextContext; // To access above two functions | 194 friend class GrStencilAndCoverTextContext; // To access above two functions |
209 | 195 |
210 SkAutoTUnref<const GrXPFactory> fXPFactory; | 196 SkAutoTUnref<const GrXPFactory> fXPFactory; |
211 SkSTArray<4, GrFragmentStage> fColorStages; | 197 SkSTArray<4, GrFragmentStage> fColorStages; |
212 SkSTArray<2, GrFragmentStage> fCoverageStages; | 198 SkSTArray<2, GrFragmentStage> fCoverageStages; |
213 | 199 |
214 GrBlendCoeff fSrcBlendCoeff; | |
215 GrBlendCoeff fDstBlendCoeff; | |
216 bool fAntiAlias; | 200 bool fAntiAlias; |
217 bool fDither; | 201 bool fDither; |
218 | 202 |
219 GrColor fColor; | 203 GrColor fColor; |
220 | 204 |
221 void resetBlend() { | |
222 fSrcBlendCoeff = kOne_GrBlendCoeff; | |
223 fDstBlendCoeff = kZero_GrBlendCoeff; | |
224 } | |
225 | |
226 void resetOptions() { | 205 void resetOptions() { |
227 fAntiAlias = false; | 206 fAntiAlias = false; |
228 fDither = false; | 207 fDither = false; |
229 } | 208 } |
230 | 209 |
231 void resetColor() { | 210 void resetColor() { |
232 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); | 211 fColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); |
233 } | 212 } |
234 | 213 |
235 void resetStages(); | 214 void resetStages(); |
236 }; | 215 }; |
237 | 216 |
238 #endif | 217 #endif |
OLD | NEW |