Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: include/private/GrRenderTargetProxy.h

Issue 1937553002: Add Gr*Proxy classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix memory bugs Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrRenderTarget.h ('k') | include/private/GrSurfaceProxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 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 GrRenderTargetProxy_DEFINED
9 #define GrRenderTargetProxy_DEFINED
10
11 #include "GrRenderTarget.h"
12 #include "GrSurfaceProxy.h"
13 #include "GrTypes.h"
14
15 class GrTextureProvider;
16
17 // This class delays the acquisition of RenderTargets until they are actually
18 // required
19 // Beware: the uniqueID of the RenderTargetProxy will usually be different than
20 // the uniqueID of the RenderTarget it represents!
21 class GrRenderTargetProxy : public GrSurfaceProxy {
22 public:
23 /**
24 * The caller gets the creation ref.
25 */
26 static sk_sp<GrRenderTargetProxy> Make(const GrCaps&, const GrSurfaceDesc&,
27 SkBackingFit, SkBudgeted);
28 static sk_sp<GrRenderTargetProxy> Make(sk_sp<GrRenderTarget> rt);
29
30 ~GrRenderTargetProxy() override;
31
32 // TODO: add asTextureProxy variants
33 GrRenderTargetProxy* asRenderTargetProxy() override { return this; }
34 const GrRenderTargetProxy* asRenderTargetProxy() const override { return thi s; }
35
36 // Actually instantiate the backing rendertarget, if necessary.
37 GrRenderTarget* instantiate(GrTextureProvider* texProvider);
38
39 /**
40 * @return true if the surface is multisampled in all buffers,
41 * false otherwise
42 */
43 bool isUnifiedMultisampled() const {
44 if (fSampleConfig != GrRenderTarget::kUnified_SampleConfig) {
45 return false;
46 }
47 return 0 != fDesc.fSampleCnt;
48 }
49
50 /**
51 * @return true if the surface is multisampled in the stencil buffer,
52 * false otherwise
53 */
54 bool isStencilBufferMultisampled() const {
55 return 0 != fDesc.fSampleCnt;
56 }
57
58 /**
59 * @return the number of color samples-per-pixel, or zero if non-MSAA or
60 * multisampled in the stencil buffer only.
61 */
62 int numColorSamples() const {
63 if (fSampleConfig == GrRenderTarget::kUnified_SampleConfig) {
64 return fDesc.fSampleCnt;
65 }
66 return 0;
67 }
68
69 /**
70 * @return the number of stencil samples-per-pixel, or zero if non-MSAA.
71 */
72 int numStencilSamples() const {
73 return fDesc.fSampleCnt;
74 }
75
76 /**
77 * @return true if the surface is mixed sampled, false otherwise.
78 */
79 bool hasMixedSamples() const {
80 SkASSERT(GrRenderTarget::kStencil_SampleConfig != fSampleConfig ||
81 this->isStencilBufferMultisampled());
82 return GrRenderTarget::kStencil_SampleConfig == fSampleConfig;
83 }
84
85 void setLastDrawTarget(GrDrawTarget* dt);
86 GrDrawTarget* getLastDrawTarget() { return fLastDrawTarget; }
87
88 private:
89 // TODO: we can probably munge the 'desc' in both the wrapped and deferred
90 // cases to make the sampleConfig/numSamples stuff more rational.
91 GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc& desc,
92 SkBackingFit fit, SkBudgeted budgeted)
93 : INHERITED(desc, fit, budgeted)
94 , fTarget(nullptr)
95 , fSampleConfig(GrRenderTarget::ComputeSampleConfig(caps, desc.fSampleCn t))
96 , fLastDrawTarget(nullptr) {
97 }
98
99 // Wrapped version
100 GrRenderTargetProxy(sk_sp<GrRenderTarget> rt);
101
102 // For wrapped render targets we store it here.
103 // For deferred proxies we will fill this in when we need to instantiate the deferred resource
104 sk_sp<GrRenderTarget> fTarget;
105
106 // The sample config doesn't usually get computed until the render target is instantiated but
107 // the render target proxy may need to answer queries about it before then. For this reason
108 // we precompute it in the deferred case. In the wrapped case we just copy t he wrapped
109 // rendertarget's info here.
110 GrRenderTarget::SampleConfig fSampleConfig;
111
112 // The last drawTarget that wrote to or is currently going to write to this renderTarget
113 // The drawTarget can be closed (e.g., no draw context is currently bound
114 // to this renderTarget).
115 // This back-pointer is required so that we can add a dependancy between
116 // the drawTarget used to create the current contents of this renderTarget
117 // and the drawTarget of a destination renderTarget to which this one is bei ng drawn.
118 GrDrawTarget* fLastDrawTarget;
119
120 typedef GrSurfaceProxy INHERITED;
121 };
122
123 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrRenderTarget.h ('k') | include/private/GrSurfaceProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698