OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrDrawState_DEFINED | 8 #ifndef GrDrawState_DEFINED |
9 #define GrDrawState_DEFINED | 9 #define GrDrawState_DEFINED |
10 | 10 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix, para
ms))->unref(); | 230 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix, para
ms))->unref(); |
231 } | 231 } |
232 | 232 |
233 void addCoverageTextureEffect(GrTexture* texture, | 233 void addCoverageTextureEffect(GrTexture* texture, |
234 const SkMatrix& matrix, | 234 const SkMatrix& matrix, |
235 const GrTextureParams& params) { | 235 const GrTextureParams& params) { |
236 this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix, p
arams))->unref(); | 236 this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix, p
arams))->unref(); |
237 } | 237 } |
238 | 238 |
239 /** | 239 /** |
240 * When this object is destroyed it will remove any effects from the draw st
ate that were added | 240 * When this object is destroyed it will remove any color/coverage effects f
rom the draw state |
241 * after its constructor. | 241 * that were added after its constructor. |
| 242 * |
| 243 * This class has strange behavior around geometry processor. If there is a
GP on the draw state |
| 244 * it will assert that the GP is not modified until after the destructor of
the ARE. If the |
| 245 * draw state has a NULL GP when the ARE is constructed then it will reset i
t to null in the |
| 246 * destructor. |
| 247 * |
| 248 * TODO: We'd prefer for the ARE to just save and restore the GP. However, t
his would add |
| 249 * significant complexity to the multi-ref architecture for deferred drawing
. Once GrDrawState |
| 250 * and GrOptDrawState are fully separated then GrDrawState will never be in
the deferred |
| 251 * execution state and GrOptDrawState always will be (and will be immutable
and therefore |
| 252 * unable to have an ARE). At this point we can restore sanity and have the
ARE save and restore |
| 253 * the GP. |
242 */ | 254 */ |
243 class AutoRestoreEffects : public ::SkNoncopyable { | 255 class AutoRestoreEffects : public ::SkNoncopyable { |
244 public: | 256 public: |
245 AutoRestoreEffects() : fDrawState(NULL), fColorEffectCnt(0), fCoverageEf
fectCnt(0) {} | 257 AutoRestoreEffects() |
| 258 : fDrawState(NULL) |
| 259 , fOriginalGP(NULL) |
| 260 , fColorEffectCnt(0) |
| 261 , fCoverageEffectCnt(0) {} |
246 | 262 |
247 AutoRestoreEffects(GrDrawState* ds) : fDrawState(NULL), fColorEffectCnt(
0), fCoverageEffectCnt(0) { | 263 AutoRestoreEffects(GrDrawState* ds) |
| 264 : fDrawState(NULL) |
| 265 , fOriginalGP(NULL) |
| 266 , fColorEffectCnt(0) |
| 267 , fCoverageEffectCnt(0) { |
248 this->set(ds); | 268 this->set(ds); |
249 } | 269 } |
250 | 270 |
251 ~AutoRestoreEffects() { this->set(NULL); } | 271 ~AutoRestoreEffects() { this->set(NULL); } |
252 | 272 |
253 void set(GrDrawState* ds); | 273 void set(GrDrawState* ds); |
254 | 274 |
255 bool isSet() const { return NULL != fDrawState; } | 275 bool isSet() const { return NULL != fDrawState; } |
256 | 276 |
257 private: | 277 private: |
258 GrDrawState* fDrawState; | 278 GrDrawState* fDrawState; |
259 SkAutoTDelete<GrEffectStage> fGeometryProcessor; | 279 const GrEffect* fOriginalGP; |
260 int fColorEffectCnt; | 280 int fColorEffectCnt; |
261 int fCoverageEffectCnt; | 281 int fCoverageEffectCnt; |
262 }; | 282 }; |
263 | 283 |
264 /// @} | 284 /// @} |
265 | 285 |
266 /////////////////////////////////////////////////////////////////////////// | 286 /////////////////////////////////////////////////////////////////////////// |
267 /// @name Blending | 287 /// @name Blending |
268 //// | 288 //// |
269 | 289 |
270 /** | 290 /** |
271 * Sets the blending function coefficients. | 291 * Sets the blending function coefficients. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 564 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
545 // This is used to assert that this condition holds. | 565 // This is used to assert that this condition holds. |
546 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 566 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
547 | 567 |
548 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); | 568 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); |
549 | 569 |
550 typedef GrRODrawState INHERITED; | 570 typedef GrRODrawState INHERITED; |
551 }; | 571 }; |
552 | 572 |
553 #endif | 573 #endif |
OLD | NEW |