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

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

Issue 1001503002: Implement support for mixed sampled render targets (Closed) Base URL: https://skia.googlesource.com/skia.git@mix1
Patch Set: Fix build error related to isMultisamped renaming Created 5 years, 6 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 | « no previous file | samplecode/SampleApp.cpp » ('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 13 matching lines...) Expand all
24 class GrRenderTarget : virtual public GrSurface { 24 class GrRenderTarget : virtual public GrSurface {
25 public: 25 public:
26 SK_DECLARE_INST_COUNT(GrRenderTarget) 26 SK_DECLARE_INST_COUNT(GrRenderTarget)
27 27
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 /**
34 * @return true if the surface is multisampled, false otherwise 34 * On some hardware it is possible for a render target to have multisampling
35 */ 35 * only in certain buffers.
36 bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } 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 };
37 47
38 /** 48 /**
39 * @return the number of samples-per-pixel or zero if non-MSAA. 49 * @return true if the surface is multisampled in all buffers,
50 * false otherwise
40 */ 51 */
41 int numSamples() const { return fDesc.fSampleCnt; } 52 bool isUnifiedMultisampled() const {
53 if (fSampleConfig != kUnified_SampleConfig) {
54 return false;
55 }
56 return 0 != fDesc.fSampleCnt;
57 }
58
59 /**
60 * @return true if the surface is multisampled in the stencil buffer,
61 * false otherwise
62 */
63 bool isStencilBufferMultisampled() const {
64 return 0 != fDesc.fSampleCnt;
65 }
66
67 /**
68 * @return the number of color samples-per-pixel, or zero if non-MSAA or
69 * multisampled in the stencil buffer only.
70 */
71 int numColorSamples() const {
72 if (fSampleConfig == kUnified_SampleConfig) {
73 return fDesc.fSampleCnt;
74 }
75 return 0;
76 }
77
78 /**
79 * @return the number of stencil samples-per-pixel, or zero if non-MSAA.
80 */
81 int numStencilSamples() const {
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 }
42 93
43 /** 94 /**
44 * Call to indicate the multisample contents were modified such that the 95 * Call to indicate the multisample contents were modified such that the
45 * render target needs to be resolved before it can be used as texture. Gr 96 * render target needs to be resolved before it can be used as texture. Gr
46 * tracks this for its own drawing and thus this only needs to be called 97 * tracks this for its own drawing and thus this only needs to be called
47 * when the render target has been modified outside of Gr. This has no 98 * when the render target has been modified outside of Gr. This has no
48 * effect on wrapped backend render targets. 99 * effect on wrapped backend render targets.
49 * 100 *
50 * @param rect a rect bounding the area needing resolve. NULL indicates 101 * @param rect a rect bounding the area needing resolve. NULL indicates
51 * the whole RT needs resolving. 102 * the whole RT needs resolving.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 kAutoResolves_ResolveType, 138 kAutoResolves_ResolveType,
88 kCantResolve_ResolveType, 139 kCantResolve_ResolveType,
89 }; 140 };
90 virtual ResolveType getResolveType() const = 0; 141 virtual ResolveType getResolveType() const = 0;
91 142
92 // Provides access to functions that aren't part of the public API. 143 // Provides access to functions that aren't part of the public API.
93 GrRenderTargetPriv renderTargetPriv(); 144 GrRenderTargetPriv renderTargetPriv();
94 const GrRenderTargetPriv renderTargetPriv() const; 145 const GrRenderTargetPriv renderTargetPriv() const;
95 146
96 protected: 147 protected:
97 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) 148 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc,
149 SampleConfig sampleConfig)
98 : INHERITED(gpu, lifeCycle, desc) 150 : INHERITED(gpu, lifeCycle, desc)
99 , fStencilAttachment(NULL) { 151 , fStencilAttachment(NULL)
152 , fSampleConfig(sampleConfig) {
100 fResolveRect.setLargestInverted(); 153 fResolveRect.setLargestInverted();
101 } 154 }
102 155
103 // override of GrResource 156 // override of GrResource
104 void onAbandon() override; 157 void onAbandon() override;
105 void onRelease() override; 158 void onRelease() override;
106 159
107 private: 160 private:
108 // Checked when this object is asked to attach a stencil buffer. 161 // Checked when this object is asked to attach a stencil buffer.
109 virtual bool canAttemptStencilAttachment() const = 0; 162 virtual bool canAttemptStencilAttachment() const = 0;
110 163
111 friend class GrRenderTargetPriv; 164 friend class GrRenderTargetPriv;
112 165
113 GrStencilAttachment* fStencilAttachment; 166 GrStencilAttachment* fStencilAttachment;
167 SampleConfig fSampleConfig;
114 168
115 SkIRect fResolveRect; 169 SkIRect fResolveRect;
116 170
117 typedef GrSurface INHERITED; 171 typedef GrSurface INHERITED;
118 }; 172 };
119 173
174
120 #endif 175 #endif
OLDNEW
« no previous file with comments | « no previous file | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698