| 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 /// @name Render Target | 373 /// @name Render Target |
| 374 //// | 374 //// |
| 375 | 375 |
| 376 /** | 376 /** |
| 377 * Sets the render-target used at the next drawing call | 377 * Sets the render-target used at the next drawing call |
| 378 * | 378 * |
| 379 * @param target The render target to set. | 379 * @param target The render target to set. |
| 380 */ | 380 */ |
| 381 void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef
(target)); } | 381 void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef
(target)); } |
| 382 | 382 |
| 383 class AutoRenderTargetRestore : public ::SkNoncopyable { | |
| 384 public: | |
| 385 AutoRenderTargetRestore() : fDrawState(NULL), fSavedTarget(NULL) {} | |
| 386 AutoRenderTargetRestore(GrDrawState* ds, GrRenderTarget* newTarget) { | |
| 387 fDrawState = NULL; | |
| 388 fSavedTarget = NULL; | |
| 389 this->set(ds, newTarget); | |
| 390 } | |
| 391 ~AutoRenderTargetRestore() { this->restore(); } | |
| 392 | |
| 393 void restore() { | |
| 394 if (NULL != fDrawState) { | |
| 395 fDrawState->setRenderTarget(fSavedTarget); | |
| 396 fDrawState = NULL; | |
| 397 } | |
| 398 SkSafeSetNull(fSavedTarget); | |
| 399 } | |
| 400 | |
| 401 void set(GrDrawState* ds, GrRenderTarget* newTarget) { | |
| 402 this->restore(); | |
| 403 | |
| 404 if (NULL != ds) { | |
| 405 SkASSERT(NULL == fSavedTarget); | |
| 406 fSavedTarget = ds->getRenderTarget(); | |
| 407 SkSafeRef(fSavedTarget); | |
| 408 ds->setRenderTarget(newTarget); | |
| 409 fDrawState = ds; | |
| 410 } | |
| 411 } | |
| 412 private: | |
| 413 GrDrawState* fDrawState; | |
| 414 GrRenderTarget* fSavedTarget; | |
| 415 }; | |
| 416 | |
| 417 /// @} | 383 /// @} |
| 418 | 384 |
| 419 /////////////////////////////////////////////////////////////////////////// | 385 /////////////////////////////////////////////////////////////////////////// |
| 420 /// @name Stencil | 386 /// @name Stencil |
| 421 //// | 387 //// |
| 422 | 388 |
| 423 /** | 389 /** |
| 424 * Sets the stencil settings to use for the next draw. | 390 * Sets the stencil settings to use for the next draw. |
| 425 * Changing the clip has the side-effect of possibly zeroing | 391 * Changing the clip has the side-effect of possibly zeroing |
| 426 * out the client settable stencil bits. So multipass algorithms | 392 * out the client settable stencil bits. So multipass algorithms |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 528 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
| 563 // This is used to assert that this condition holds. | 529 // This is used to assert that this condition holds. |
| 564 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 530 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
| 565 | 531 |
| 566 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); | 532 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); |
| 567 | 533 |
| 568 typedef GrRODrawState INHERITED; | 534 typedef GrRODrawState INHERITED; |
| 569 }; | 535 }; |
| 570 | 536 |
| 571 #endif | 537 #endif |
| OLD | NEW |