blob: 89f4d5289ec6212061eb89cc5f66d0b058db48dc [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"
cdalton28f45b92016-03-07 13:58:26 -080012#include "GrGpu.h"
13
14class GrStencilSettings;
bsalomon6bc1b5f2015-02-23 09:06:38 -080015
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. */
19class GrRenderTargetPriv {
20public:
21 /**
egdaniel8dc7c3a2015-04-16 11:22:42 -070022 * GrStencilAttachment is not part of the public API.
bsalomon6bc1b5f2015-02-23 09:06:38 -080023 */
egdaniel8dc7c3a2015-04-16 11:22:42 -070024 GrStencilAttachment* getStencilAttachment() const { return fRenderTarget->fStencilAttachment; }
bsalomon6bc1b5f2015-02-23 09:06:38 -080025
26 /**
egdanielec00d942015-09-14 12:56:10 -070027 * 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.
bsalomon6bc1b5f2015-02-23 09:06:38 -080030 */
egdanielec00d942015-09-14 12:56:10 -070031 bool attachStencilAttachment(GrStencilAttachment* stencil);
bsalomon6bc1b5f2015-02-23 09:06:38 -080032
cdalton193d9cf2016-05-12 11:52:02 -070033 int numStencilBits() const;
34
csmartdaltonc633abb2016-11-01 08:55:55 -070035 // Finds a render target's multisample specs. The pipeline is only needed in case the info isn't
36 // cached and we need to flush the draw state in order to query it. The pipeline is not expected
37 // to affect the multisample information itself.
38 const GrGpu::MultisampleSpecs& getMultisampleSpecs(const GrPipeline&) const;
cdalton28f45b92016-03-07 13:58:26 -080039
csmartdaltonf9635992016-08-10 11:09:07 -070040 typedef GrRenderTarget::Flags Flags;
41
42 Flags flags() const { return fRenderTarget->fFlags; }
robertphillips76948d42016-05-04 12:47:41 -070043
bsalomon6bc1b5f2015-02-23 09:06:38 -080044private:
45 explicit GrRenderTargetPriv(GrRenderTarget* renderTarget) : fRenderTarget(renderTarget) {}
46 GrRenderTargetPriv(const GrRenderTargetPriv&) {} // unimpl
47 GrRenderTargetPriv& operator=(const GrRenderTargetPriv&); // unimpl
48
49 // No taking addresses of this type.
50 const GrRenderTargetPriv* operator&() const;
51 GrRenderTargetPriv* operator&();
52
53 GrRenderTarget* fRenderTarget;
halcanary9d524f22016-03-29 09:03:52 -070054
bsalomon6bc1b5f2015-02-23 09:06:38 -080055 friend class GrRenderTarget; // to construct/copy this type.
56};
57
58inline GrRenderTargetPriv GrRenderTarget::renderTargetPriv() { return GrRenderTargetPriv(this); }
59
60inline const GrRenderTargetPriv GrRenderTarget::renderTargetPriv () const {
61 return GrRenderTargetPriv(const_cast<GrRenderTarget*>(this));
62}
63
64#endif