blob: 59262f4b11229df0891dd3461476e16e24cb76fe [file] [log] [blame]
bsalomon6bc1b5f2015-02-23 09:06:38 -08001/*
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. */
16class GrRenderTargetPriv {
17public:
18 /**
egdaniel8dc7c3a2015-04-16 11:22:42 -070019 * GrStencilAttachment is not part of the public API.
bsalomon6bc1b5f2015-02-23 09:06:38 -080020 */
egdaniel8dc7c3a2015-04-16 11:22:42 -070021 GrStencilAttachment* getStencilAttachment() const { return fRenderTarget->fStencilAttachment; }
bsalomon6bc1b5f2015-02-23 09:06:38 -080022
23 /**
24 * If this render target already has a stencil buffer, return it. Otherwise attempt to attach
25 * one.
26 */
egdaniel8dc7c3a2015-04-16 11:22:42 -070027 GrStencilAttachment* attachStencilAttachment() const;
bsalomon6bc1b5f2015-02-23 09:06:38 -080028
egdaniel8dc7c3a2015-04-16 11:22:42 -070029 void didAttachStencilAttachment(GrStencilAttachment*);
bsalomon6bc1b5f2015-02-23 09:06:38 -080030
31private:
32 explicit GrRenderTargetPriv(GrRenderTarget* renderTarget) : fRenderTarget(renderTarget) {}
33 GrRenderTargetPriv(const GrRenderTargetPriv&) {} // unimpl
34 GrRenderTargetPriv& operator=(const GrRenderTargetPriv&); // unimpl
35
36 // No taking addresses of this type.
37 const GrRenderTargetPriv* operator&() const;
38 GrRenderTargetPriv* operator&();
39
40 GrRenderTarget* fRenderTarget;
41
42 friend class GrRenderTarget; // to construct/copy this type.
43};
44
45inline GrRenderTargetPriv GrRenderTarget::renderTargetPriv() { return GrRenderTargetPriv(this); }
46
47inline const GrRenderTargetPriv GrRenderTarget::renderTargetPriv () const {
48 return GrRenderTargetPriv(const_cast<GrRenderTarget*>(this));
49}
50
51#endif