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

Side by Side Diff: include/gpu/GrRenderTarget.h

Issue 2225303002: Add flag for window rectangles to GrRenderTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add GrRenderTarget flag for window rectangles Created 4 years, 4 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/GrDrawContext.h ('k') | include/gpu/GrTypes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrRenderTarget_DEFINED 8 #ifndef GrRenderTarget_DEFINED
9 #define GrRenderTarget_DEFINED 9 #define GrRenderTarget_DEFINED
10 10
(...skipping 12 matching lines...) Expand all
23 * Additionally, GrContext provides methods for creating GrRenderTargets 23 * Additionally, GrContext provides methods for creating GrRenderTargets
24 * that wrap externally created render targets. 24 * that wrap externally created render targets.
25 */ 25 */
26 class GrRenderTarget : virtual public GrSurface { 26 class GrRenderTarget : virtual public GrSurface {
27 public: 27 public:
28 // GrSurface overrides 28 // GrSurface overrides
29 GrRenderTarget* asRenderTarget() override { return this; } 29 GrRenderTarget* asRenderTarget() override { return this; }
30 const GrRenderTarget* asRenderTarget() const override { return this; } 30 const GrRenderTarget* asRenderTarget() const override { return this; }
31 31
32 // GrRenderTarget 32 // GrRenderTarget
33 /** 33 bool isStencilBufferMultisampled() const { return fDesc.fSampleCnt > 0; }
34 * On some hardware it is possible for a render target to have multisampling
35 * only in certain buffers.
36 * Enforce only two legal sample configs.
37 * kUnified_SampleConfig signifies multisampling in both color and stencil
38 * buffers and is available across all hardware.
39 * kStencil_SampleConfig means multisampling is present in stencil buffer
40 * only; this config requires hardware support of
41 * NV_framebuffer_mixed_samples.
42 */
43 enum SampleConfig {
44 kUnified_SampleConfig = 0,
45 kStencil_SampleConfig = 1
46 };
47 34
48 /** 35 /**
49 * @return true if the surface is multisampled in all buffers, 36 * For our purposes, "Mixed Sampled" means the stencil buffer is multisample d but the color
50 * false otherwise 37 * buffer is not.
51 */ 38 */
52 bool isUnifiedMultisampled() const { 39 bool isMixedSampled() const { return fFlags & Flags::kMixedSampled; }
53 if (fSampleConfig != kUnified_SampleConfig) {
54 return false;
55 }
56 return 0 != fDesc.fSampleCnt;
57 }
58 40
59 /** 41 /**
60 * @return true if the surface is multisampled in the stencil buffer, 42 * "Unified Sampled" means the stencil and color buffers are both multisampl ed.
61 * false otherwise
62 */ 43 */
63 bool isStencilBufferMultisampled() const { 44 bool isUnifiedMultisampled() const { return fDesc.fSampleCnt > 0 && !this->i sMixedSampled(); }
64 return 0 != fDesc.fSampleCnt;
65 }
66 45
67 /** 46 /**
68 * @return the number of color samples-per-pixel, or zero if non-MSAA or 47 * Returns the number of samples/pixel in the stencil buffer (Zero if non-MS AA).
69 * multisampled in the stencil buffer only.
70 */ 48 */
71 int numColorSamples() const { 49 int numStencilSamples() const { return fDesc.fSampleCnt; }
72 if (fSampleConfig == kUnified_SampleConfig) {
73 return fDesc.fSampleCnt;
74 }
75 return 0;
76 }
77 50
78 /** 51 /**
79 * @return the number of stencil samples-per-pixel, or zero if non-MSAA. 52 * Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled).
80 */ 53 */
81 int numStencilSamples() const { 54 int numColorSamples() const { return this->isMixedSampled() ? 0 : fDesc.fSam pleCnt; }
82 return fDesc.fSampleCnt;
83 }
84
85 /**
86 * @return true if the surface is mixed sampled, false otherwise.
87 */
88 bool hasMixedSamples() const {
89 SkASSERT(kStencil_SampleConfig != fSampleConfig ||
90 this->isStencilBufferMultisampled());
91 return kStencil_SampleConfig == fSampleConfig;
92 }
93 55
94 /** 56 /**
95 * Call to indicate the multisample contents were modified such that the 57 * Call to indicate the multisample contents were modified such that the
96 * render target needs to be resolved before it can be used as texture. Gr 58 * render target needs to be resolved before it can be used as texture. Gr
97 * tracks this for its own drawing and thus this only needs to be called 59 * tracks this for its own drawing and thus this only needs to be called
98 * when the render target has been modified outside of Gr. This has no 60 * when the render target has been modified outside of Gr. This has no
99 * effect on wrapped backend render targets. 61 * effect on wrapped backend render targets.
100 * 62 *
101 * @param rect a rect bounding the area needing resolve. NULL indicates 63 * @param rect a rect bounding the area needing resolve. NULL indicates
102 * the whole RT needs resolving. 64 * the whole RT needs resolving.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Checked when this object is asked to attach a stencil buffer. 111 // Checked when this object is asked to attach a stencil buffer.
150 virtual bool canAttemptStencilAttachment() const = 0; 112 virtual bool canAttemptStencilAttachment() const = 0;
151 113
152 // Provides access to functions that aren't part of the public API. 114 // Provides access to functions that aren't part of the public API.
153 GrRenderTargetPriv renderTargetPriv(); 115 GrRenderTargetPriv renderTargetPriv();
154 const GrRenderTargetPriv renderTargetPriv() const; 116 const GrRenderTargetPriv renderTargetPriv() const;
155 117
156 void setLastDrawTarget(GrDrawTarget* dt); 118 void setLastDrawTarget(GrDrawTarget* dt);
157 GrDrawTarget* getLastDrawTarget() { return fLastDrawTarget; } 119 GrDrawTarget* getLastDrawTarget() { return fLastDrawTarget; }
158 120
159 static SampleConfig ComputeSampleConfig(const GrCaps& caps, int sampleCnt); 121 protected:
122 enum class Flags {
123 kNone = 0,
124 kMixedSampled = 1 << 0,
125 kWindowRectsSupport = 1 << 1
126 };
160 127
161 protected: 128 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(Flags);
162 GrRenderTarget(GrGpu* gpu, const GrSurfaceDesc& desc,
163 SampleConfig sampleConfig, GrStencilAttachment* stencil = nul lptr)
164 : INHERITED(gpu, desc)
165 , fStencilAttachment(stencil)
166 , fMultisampleSpecsID(0)
167 , fSampleConfig(sampleConfig)
168 , fLastDrawTarget(nullptr) {
169 fResolveRect.setLargestInverted();
170 }
171 129
130 GrRenderTarget(GrGpu*, const GrSurfaceDesc&, Flags = Flags::kNone,
131 GrStencilAttachment* = nullptr);
172 ~GrRenderTarget() override; 132 ~GrRenderTarget() override;
173 133
174 // override of GrResource 134 // override of GrResource
175 void onAbandon() override; 135 void onAbandon() override;
176 void onRelease() override; 136 void onRelease() override;
177 137
178 private: 138 private:
179 // Allows the backends to perform any additional work that is required for a ttaching a 139 // Allows the backends to perform any additional work that is required for a ttaching a
180 // GrStencilAttachment. When this is called, the GrStencilAttachment has alr eady been put onto 140 // GrStencilAttachment. When this is called, the GrStencilAttachment has alr eady been put onto
181 // the GrRenderTarget. This function must return false if any failures occur when completing the 141 // the GrRenderTarget. This function must return false if any failures occur when completing the
182 // stencil attachment. 142 // stencil attachment.
183 virtual bool completeStencilAttachment() = 0; 143 virtual bool completeStencilAttachment() = 0;
184 144
185 friend class GrRenderTargetPriv; 145 friend class GrRenderTargetPriv;
186 146
187 GrStencilAttachment* fStencilAttachment; 147 GrStencilAttachment* fStencilAttachment;
188 uint8_t fMultisampleSpecsID; 148 uint8_t fMultisampleSpecsID;
189 SampleConfig fSampleConfig; 149 Flags fFlags;
190 150
191 SkIRect fResolveRect; 151 SkIRect fResolveRect;
192 152
193 // The last drawTarget that wrote to or is currently going to write to this renderTarget 153 // The last drawTarget that wrote to or is currently going to write to this renderTarget
194 // The drawTarget can be closed (e.g., no draw context is currently bound 154 // The drawTarget can be closed (e.g., no draw context is currently bound
195 // to this renderTarget). 155 // to this renderTarget).
196 // This back-pointer is required so that we can add a dependancy between 156 // This back-pointer is required so that we can add a dependancy between
197 // the drawTarget used to create the current contents of this renderTarget 157 // the drawTarget used to create the current contents of this renderTarget
198 // and the drawTarget of a destination renderTarget to which this one is bei ng drawn. 158 // and the drawTarget of a destination renderTarget to which this one is bei ng drawn.
199 GrDrawTarget* fLastDrawTarget; 159 GrDrawTarget* fLastDrawTarget;
200 160
201 typedef GrSurface INHERITED; 161 typedef GrSurface INHERITED;
202 }; 162 };
203 163
164 GR_MAKE_BITFIELD_CLASS_OPS(GrRenderTarget::Flags);
204 165
205 #endif 166 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | include/gpu/GrTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698