OLD | NEW |
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 | 8 |
9 #ifndef GrGLRenderTarget_DEFINED | 9 #ifndef GrGLRenderTarget_DEFINED |
10 #define GrGLRenderTarget_DEFINED | 10 #define GrGLRenderTarget_DEFINED |
11 | 11 |
12 #include "GrGpu.h" | |
13 #include "GrGLIRect.h" | 12 #include "GrGLIRect.h" |
14 #include "GrRenderTarget.h" | 13 #include "GrRenderTarget.h" |
15 #include "SkScalar.h" | 14 #include "SkScalar.h" |
16 | 15 |
17 class GrGLGpu; | 16 class GrGLGpu; |
18 class GrGLStencilAttachment; | 17 class GrGLStencilAttachment; |
19 | 18 |
20 class GrGLRenderTarget : public GrRenderTarget { | 19 class GrGLRenderTarget : public GrRenderTarget { |
21 public: | 20 public: |
22 // set fTexFBOID to this value to indicate that it is multisampled but | 21 // set fTexFBOID to this value to indicate that it is multisampled but |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 63 |
65 /** When we don't own the FBO ID we don't attempt to modify its attachments.
*/ | 64 /** When we don't own the FBO ID we don't attempt to modify its attachments.
*/ |
66 bool canAttemptStencilAttachment() const override { | 65 bool canAttemptStencilAttachment() const override { |
67 return kCached_LifeCycle == fRTLifecycle || kUncached_LifeCycle == fRTLi
fecycle; | 66 return kCached_LifeCycle == fRTLifecycle || kUncached_LifeCycle == fRTLi
fecycle; |
68 } | 67 } |
69 | 68 |
70 // GrGLRenderTarget overrides dumpMemoryStatistics so it can log its texture
and renderbuffer | 69 // GrGLRenderTarget overrides dumpMemoryStatistics so it can log its texture
and renderbuffer |
71 // components seperately. | 70 // components seperately. |
72 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override
; | 71 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override
; |
73 | 72 |
74 bool getCachedCoCenteredSamplesState(GrGpu::ResetTimestamp* stamp) const { | 73 /** |
75 *stamp = fHasCoCenteredSamplesTimestamp; | 74 * @return true if sample locations colocated at pixel center have been set
for this |
76 return fHasCoCenteredSamples; | 75 * render target. Requires support for NV_sample_locations. |
| 76 */ |
| 77 bool usesColocatedSampleLocations() const { |
| 78 return fUsesColocatedSampleLocations; |
77 } | 79 } |
78 | 80 |
79 void setCachedCoCenteredSamplesState(bool hasCoCenteredSamples, GrGpu::Reset
Timestamp stamp) { | 81 /** |
80 fHasCoCenteredSamples = hasCoCenteredSamples; | 82 * Flag render target as using or not using sample locations colocated at pi
xel center. |
81 fHasCoCenteredSamplesTimestamp = stamp; | 83 */ |
| 84 void flagAsUsingColocatedSampleLocations(bool useColocatedSampleLocations) { |
| 85 fUsesColocatedSampleLocations = useColocatedSampleLocations; |
82 } | 86 } |
83 | 87 |
84 protected: | 88 protected: |
85 // The public constructor registers this object with the cache. However, onl
y the most derived | 89 // The public constructor registers this object with the cache. However, onl
y the most derived |
86 // class should register with the cache. This constructor does not do the re
gistration and | 90 // class should register with the cache. This constructor does not do the re
gistration and |
87 // rather moves that burden onto the derived class. | 91 // rather moves that burden onto the derived class. |
88 enum Derived { kDerived }; | 92 enum Derived { kDerived }; |
89 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, Derived); | 93 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, Derived); |
90 | 94 |
91 void init(const GrSurfaceDesc&, const IDDesc&); | 95 void init(const GrSurfaceDesc&, const IDDesc&); |
(...skipping 11 matching lines...) Expand all Loading... |
103 | 107 |
104 GrGLGpu* getGLGpu() const; | 108 GrGLGpu* getGLGpu() const; |
105 bool completeStencilAttachment() override; | 109 bool completeStencilAttachment() override; |
106 | 110 |
107 // The total size of the resource (including all pixels) for a single sample
. | 111 // The total size of the resource (including all pixels) for a single sample
. |
108 size_t totalBytesPerSample() const; | 112 size_t totalBytesPerSample() const; |
109 int msaaSamples() const; | 113 int msaaSamples() const; |
110 // The number total number of samples, including both MSAA and resolve textu
re samples. | 114 // The number total number of samples, including both MSAA and resolve textu
re samples. |
111 int totalSamples() const; | 115 int totalSamples() const; |
112 | 116 |
113 GrGLuint fRTFBOID; | 117 GrGLuint fRTFBOID; |
114 GrGLuint fTexFBOID; | 118 GrGLuint fTexFBOID; |
115 GrGLuint fMSColorRenderbufferID; | 119 GrGLuint fMSColorRenderbufferID; |
116 bool fHasCoCenteredSamples; | |
117 GrGpu::ResetTimestamp fHasCoCenteredSamplesTimestamp; | |
118 | 120 |
119 // We track this separately from GrGpuResource because this may be both a te
xture and a render | 121 // We track this separately from GrGpuResource because this may be both a te
xture and a render |
120 // target, and the texture may be wrapped while the render target is not. | 122 // target, and the texture may be wrapped while the render target is not. |
121 LifeCycle fRTLifecycle; | 123 LifeCycle fRTLifecycle; |
122 | 124 |
123 // when we switch to this render target we want to set the viewport to | 125 // when we switch to this render target we want to set the viewport to |
124 // only render to content area (as opposed to the whole allocation) and | 126 // only render to content area (as opposed to the whole allocation) and |
125 // we want the rendering to be at top left (GL has origin in bottom left) | 127 // we want the rendering to be at top left (GL has origin in bottom left) |
126 GrGLIRect fViewport; | 128 GrGLIRect fViewport; |
127 | 129 |
128 // onGpuMemorySize() needs to know the VRAM footprint of the FBO(s). However
, abandon and | 130 // onGpuMemorySize() needs to know the VRAM footprint of the FBO(s). However
, abandon and |
129 // release zero out the IDs and the cache needs to know the size even after
those actions. | 131 // release zero out the IDs and the cache needs to know the size even after
those actions. |
130 size_t fGpuMemorySize; | 132 size_t fGpuMemorySize; |
| 133 |
| 134 // True if sample locations colocated at pixel center are currently in use,
false if default |
| 135 // sample locations are currently in use. |
| 136 bool fUsesColocatedSampleLocations; |
131 | 137 |
132 typedef GrRenderTarget INHERITED; | 138 typedef GrRenderTarget INHERITED; |
133 }; | 139 }; |
134 | 140 |
135 #endif | 141 #endif |
OLD | NEW |