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

Side by Side Diff: src/gpu/GrDrawState.h

Issue 533883004: Remove GrDrawTarget::AutoRenderTargetRestore. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pass rt to clearStencilClip 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 * 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
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
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
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrGpu.h » ('j') | src/gpu/gl/GrGpuGL.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698