bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrRenderTargetPriv_DEFINED |
| 9 | #define GrRenderTargetPriv_DEFINED |
| 10 | |
| 11 | #include "GrRenderTarget.h" |
| 12 | |
| 13 | /** Class that adds methods to GrRenderTarget that are only intended for use internal to Skia. |
| 14 | This class is purely a privileged window into GrRenderTarget. It should never have additional |
| 15 | data members or virtual methods. */ |
| 16 | class GrRenderTargetPriv { |
| 17 | public: |
| 18 | /** |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 19 | * GrStencilAttachment is not part of the public API. |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 20 | */ |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 21 | GrStencilAttachment* getStencilAttachment() const { return fRenderTarget->fStencilAttachment; } |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 22 | |
| 23 | /** |
Tom Hudson | 2880df2 | 2015-10-29 09:55:42 -0400 | [diff] [blame] | 24 | * Attaches the GrStencilAttachment onto the render target. If stencil is a nullptr then the |
| 25 | * currently attached GrStencilAttachment will be removed if one was previously attached. This |
| 26 | * function returns false if there were any failure in attaching the GrStencilAttachment. |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 27 | */ |
Tom Hudson | 2880df2 | 2015-10-29 09:55:42 -0400 | [diff] [blame] | 28 | bool attachStencilAttachment(GrStencilAttachment* stencil); |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 29 | |
| 30 | private: |
| 31 | explicit GrRenderTargetPriv(GrRenderTarget* renderTarget) : fRenderTarget(renderTarget) {} |
| 32 | GrRenderTargetPriv(const GrRenderTargetPriv&) {} // unimpl |
| 33 | GrRenderTargetPriv& operator=(const GrRenderTargetPriv&); // unimpl |
| 34 | |
| 35 | // No taking addresses of this type. |
| 36 | const GrRenderTargetPriv* operator&() const; |
| 37 | GrRenderTargetPriv* operator&(); |
| 38 | |
| 39 | GrRenderTarget* fRenderTarget; |
| 40 | |
| 41 | friend class GrRenderTarget; // to construct/copy this type. |
| 42 | }; |
| 43 | |
| 44 | inline GrRenderTargetPriv GrRenderTarget::renderTargetPriv() { return GrRenderTargetPriv(this); } |
| 45 | |
| 46 | inline const GrRenderTargetPriv GrRenderTarget::renderTargetPriv () const { |
| 47 | return GrRenderTargetPriv(const_cast<GrRenderTarget*>(this)); |
| 48 | } |
| 49 | |
| 50 | #endif |