diff options
author | bsalomon <bsalomon@google.com> | 2015-02-23 09:06:38 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-23 09:06:38 -0800 |
commit | 6bc1b5fab8554a9cb643277b4867965dd4535cd6 (patch) | |
tree | 3179261534d7db7a8264735b327daa59593e1dd0 /src/gpu/GrRenderTargetPriv.h | |
parent | 42380174ca509e78ab932fa8c6dae953e1eaaa5a (diff) |
Dynamically create stencil buffer when needed.
Review URL: https://codereview.chromium.org/938383004
Diffstat (limited to 'src/gpu/GrRenderTargetPriv.h')
-rw-r--r-- | src/gpu/GrRenderTargetPriv.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/gpu/GrRenderTargetPriv.h b/src/gpu/GrRenderTargetPriv.h new file mode 100644 index 0000000000..92ee30e49f --- /dev/null +++ b/src/gpu/GrRenderTargetPriv.h @@ -0,0 +1,51 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrRenderTargetPriv_DEFINED +#define GrRenderTargetPriv_DEFINED + +#include "GrRenderTarget.h" + +/** Class that adds methods to GrRenderTarget that are only intended for use internal to Skia. + This class is purely a privileged window into GrRenderTarget. It should never have additional + data members or virtual methods. */ +class GrRenderTargetPriv { +public: + /** + * GrStencilBuffer is not part of the public API. + */ + GrStencilBuffer* getStencilBuffer() const { return fRenderTarget->fStencilBuffer; } + + /** + * If this render target already has a stencil buffer, return it. Otherwise attempt to attach + * one. + */ + GrStencilBuffer* attachStencilBuffer() const; + + void didAttachStencilBuffer(GrStencilBuffer*); + +private: + explicit GrRenderTargetPriv(GrRenderTarget* renderTarget) : fRenderTarget(renderTarget) {} + GrRenderTargetPriv(const GrRenderTargetPriv&) {} // unimpl + GrRenderTargetPriv& operator=(const GrRenderTargetPriv&); // unimpl + + // No taking addresses of this type. + const GrRenderTargetPriv* operator&() const; + GrRenderTargetPriv* operator&(); + + GrRenderTarget* fRenderTarget; + + friend class GrRenderTarget; // to construct/copy this type. +}; + +inline GrRenderTargetPriv GrRenderTarget::renderTargetPriv() { return GrRenderTargetPriv(this); } + +inline const GrRenderTargetPriv GrRenderTarget::renderTargetPriv () const { + return GrRenderTargetPriv(const_cast<GrRenderTarget*>(this)); +} + +#endif |