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" |
cdalton | 28f45b9 | 2016-03-07 13:58:26 -0800 | [diff] [blame] | 12 | #include "GrGpu.h" |
| 13 | |
| 14 | class GrStencilSettings; |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 15 | |
| 16 | /** Class that adds methods to GrRenderTarget that are only intended for use internal to Skia. |
| 17 | This class is purely a privileged window into GrRenderTarget. It should never have additional |
| 18 | data members or virtual methods. */ |
| 19 | class GrRenderTargetPriv { |
| 20 | public: |
| 21 | /** |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 22 | * GrStencilAttachment is not part of the public API. |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 23 | */ |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 24 | GrStencilAttachment* getStencilAttachment() const { return fRenderTarget->fStencilAttachment; } |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 25 | |
| 26 | /** |
egdaniel | ec00d94 | 2015-09-14 12:56:10 -0700 | [diff] [blame] | 27 | * Attaches the GrStencilAttachment onto the render target. If stencil is a nullptr then the |
| 28 | * currently attached GrStencilAttachment will be removed if one was previously attached. This |
| 29 | * function returns false if there were any failure in attaching the GrStencilAttachment. |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 30 | */ |
egdaniel | ec00d94 | 2015-09-14 12:56:10 -0700 | [diff] [blame] | 31 | bool attachStencilAttachment(GrStencilAttachment* stencil); |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 32 | |
cdalton | 28f45b9 | 2016-03-07 13:58:26 -0800 | [diff] [blame] | 33 | const GrGpu::MultisampleSpecs& getMultisampleSpecs(const GrStencilSettings& stencil) const; |
| 34 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame^] | 35 | GrRenderTarget::SampleConfig sampleConfig() const { return fRenderTarget->fSampleConfig; } |
| 36 | |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 37 | private: |
| 38 | explicit GrRenderTargetPriv(GrRenderTarget* renderTarget) : fRenderTarget(renderTarget) {} |
| 39 | GrRenderTargetPriv(const GrRenderTargetPriv&) {} // unimpl |
| 40 | GrRenderTargetPriv& operator=(const GrRenderTargetPriv&); // unimpl |
| 41 | |
| 42 | // No taking addresses of this type. |
| 43 | const GrRenderTargetPriv* operator&() const; |
| 44 | GrRenderTargetPriv* operator&(); |
| 45 | |
| 46 | GrRenderTarget* fRenderTarget; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 47 | |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 48 | friend class GrRenderTarget; // to construct/copy this type. |
| 49 | }; |
| 50 | |
| 51 | inline GrRenderTargetPriv GrRenderTarget::renderTargetPriv() { return GrRenderTargetPriv(this); } |
| 52 | |
| 53 | inline const GrRenderTargetPriv GrRenderTarget::renderTargetPriv () const { |
| 54 | return GrRenderTargetPriv(const_cast<GrRenderTarget*>(this)); |
| 55 | } |
| 56 | |
| 57 | #endif |