OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/framebuffer_manager.h" | 5 #include "gpu/command_buffer/service/framebuffer_manager.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
9 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 9 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
10 #include "gpu/command_buffer/service/texture_manager.h" | 10 #include "gpu/command_buffer/service/texture_manager.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 class RenderbufferAttachment | 43 class RenderbufferAttachment |
44 : public Framebuffer::Attachment { | 44 : public Framebuffer::Attachment { |
45 public: | 45 public: |
46 explicit RenderbufferAttachment( | 46 explicit RenderbufferAttachment( |
47 Renderbuffer* renderbuffer) | 47 Renderbuffer* renderbuffer) |
48 : renderbuffer_(renderbuffer) { | 48 : renderbuffer_(renderbuffer) { |
49 } | 49 } |
50 | 50 |
51 virtual GLsizei width() const OVERRIDE { | 51 virtual GLsizei width() const override { |
52 return renderbuffer_->width(); | 52 return renderbuffer_->width(); |
53 } | 53 } |
54 | 54 |
55 virtual GLsizei height() const OVERRIDE { | 55 virtual GLsizei height() const override { |
56 return renderbuffer_->height(); | 56 return renderbuffer_->height(); |
57 } | 57 } |
58 | 58 |
59 virtual GLenum internal_format() const OVERRIDE { | 59 virtual GLenum internal_format() const override { |
60 return renderbuffer_->internal_format(); | 60 return renderbuffer_->internal_format(); |
61 } | 61 } |
62 | 62 |
63 virtual GLenum texture_type() const OVERRIDE { | 63 virtual GLenum texture_type() const override { |
64 return 0; | 64 return 0; |
65 } | 65 } |
66 | 66 |
67 virtual GLsizei samples() const OVERRIDE { | 67 virtual GLsizei samples() const override { |
68 return renderbuffer_->samples(); | 68 return renderbuffer_->samples(); |
69 } | 69 } |
70 | 70 |
71 virtual GLuint object_name() const OVERRIDE { | 71 virtual GLuint object_name() const override { |
72 return renderbuffer_->client_id(); | 72 return renderbuffer_->client_id(); |
73 } | 73 } |
74 | 74 |
75 virtual bool cleared() const OVERRIDE { | 75 virtual bool cleared() const override { |
76 return renderbuffer_->cleared(); | 76 return renderbuffer_->cleared(); |
77 } | 77 } |
78 | 78 |
79 virtual void SetCleared( | 79 virtual void SetCleared( |
80 RenderbufferManager* renderbuffer_manager, | 80 RenderbufferManager* renderbuffer_manager, |
81 TextureManager* /* texture_manager */, | 81 TextureManager* /* texture_manager */, |
82 bool cleared) OVERRIDE { | 82 bool cleared) override { |
83 renderbuffer_manager->SetCleared(renderbuffer_.get(), cleared); | 83 renderbuffer_manager->SetCleared(renderbuffer_.get(), cleared); |
84 } | 84 } |
85 | 85 |
86 virtual bool IsTexture( | 86 virtual bool IsTexture( |
87 TextureRef* /* texture */) const OVERRIDE { | 87 TextureRef* /* texture */) const override { |
88 return false; | 88 return false; |
89 } | 89 } |
90 | 90 |
91 virtual bool IsRenderbuffer( | 91 virtual bool IsRenderbuffer( |
92 Renderbuffer* renderbuffer) const OVERRIDE { | 92 Renderbuffer* renderbuffer) const override { |
93 return renderbuffer_.get() == renderbuffer; | 93 return renderbuffer_.get() == renderbuffer; |
94 } | 94 } |
95 | 95 |
96 virtual bool CanRenderTo() const OVERRIDE { | 96 virtual bool CanRenderTo() const override { |
97 return true; | 97 return true; |
98 } | 98 } |
99 | 99 |
100 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) const OVERRIDE { | 100 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) const override { |
101 // Nothing to do for renderbuffers. | 101 // Nothing to do for renderbuffers. |
102 } | 102 } |
103 | 103 |
104 virtual bool ValidForAttachmentType( | 104 virtual bool ValidForAttachmentType( |
105 GLenum attachment_type, uint32 max_color_attachments) OVERRIDE { | 105 GLenum attachment_type, uint32 max_color_attachments) override { |
106 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 106 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
107 attachment_type, max_color_attachments); | 107 attachment_type, max_color_attachments); |
108 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); | 108 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); |
109 return (need & have) != 0; | 109 return (need & have) != 0; |
110 } | 110 } |
111 | 111 |
112 Renderbuffer* renderbuffer() const { | 112 Renderbuffer* renderbuffer() const { |
113 return renderbuffer_.get(); | 113 return renderbuffer_.get(); |
114 } | 114 } |
115 | 115 |
116 virtual size_t GetSignatureSize( | 116 virtual size_t GetSignatureSize( |
117 TextureManager* texture_manager) const OVERRIDE { | 117 TextureManager* texture_manager) const override { |
118 return renderbuffer_->GetSignatureSize(); | 118 return renderbuffer_->GetSignatureSize(); |
119 } | 119 } |
120 | 120 |
121 virtual void AddToSignature( | 121 virtual void AddToSignature( |
122 TextureManager* texture_manager, std::string* signature) const OVERRIDE { | 122 TextureManager* texture_manager, std::string* signature) const override { |
123 DCHECK(signature); | 123 DCHECK(signature); |
124 renderbuffer_->AddToSignature(signature); | 124 renderbuffer_->AddToSignature(signature); |
125 } | 125 } |
126 | 126 |
127 virtual void OnWillRenderTo() const OVERRIDE {} | 127 virtual void OnWillRenderTo() const override {} |
128 virtual void OnDidRenderTo() const OVERRIDE {} | 128 virtual void OnDidRenderTo() const override {} |
129 | 129 |
130 protected: | 130 protected: |
131 virtual ~RenderbufferAttachment() { } | 131 virtual ~RenderbufferAttachment() { } |
132 | 132 |
133 private: | 133 private: |
134 scoped_refptr<Renderbuffer> renderbuffer_; | 134 scoped_refptr<Renderbuffer> renderbuffer_; |
135 | 135 |
136 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); | 136 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); |
137 }; | 137 }; |
138 | 138 |
139 class TextureAttachment | 139 class TextureAttachment |
140 : public Framebuffer::Attachment { | 140 : public Framebuffer::Attachment { |
141 public: | 141 public: |
142 TextureAttachment( | 142 TextureAttachment( |
143 TextureRef* texture_ref, GLenum target, GLint level, GLsizei samples) | 143 TextureRef* texture_ref, GLenum target, GLint level, GLsizei samples) |
144 : texture_ref_(texture_ref), | 144 : texture_ref_(texture_ref), |
145 target_(target), | 145 target_(target), |
146 level_(level), | 146 level_(level), |
147 samples_(samples) { | 147 samples_(samples) { |
148 } | 148 } |
149 | 149 |
150 virtual GLsizei width() const OVERRIDE { | 150 virtual GLsizei width() const override { |
151 GLsizei temp_width = 0; | 151 GLsizei temp_width = 0; |
152 GLsizei temp_height = 0; | 152 GLsizei temp_height = 0; |
153 texture_ref_->texture()->GetLevelSize( | 153 texture_ref_->texture()->GetLevelSize( |
154 target_, level_, &temp_width, &temp_height); | 154 target_, level_, &temp_width, &temp_height); |
155 return temp_width; | 155 return temp_width; |
156 } | 156 } |
157 | 157 |
158 virtual GLsizei height() const OVERRIDE { | 158 virtual GLsizei height() const override { |
159 GLsizei temp_width = 0; | 159 GLsizei temp_width = 0; |
160 GLsizei temp_height = 0; | 160 GLsizei temp_height = 0; |
161 texture_ref_->texture()->GetLevelSize( | 161 texture_ref_->texture()->GetLevelSize( |
162 target_, level_, &temp_width, &temp_height); | 162 target_, level_, &temp_width, &temp_height); |
163 return temp_height; | 163 return temp_height; |
164 } | 164 } |
165 | 165 |
166 virtual GLenum internal_format() const OVERRIDE { | 166 virtual GLenum internal_format() const override { |
167 GLenum temp_type = 0; | 167 GLenum temp_type = 0; |
168 GLenum temp_internal_format = 0; | 168 GLenum temp_internal_format = 0; |
169 texture_ref_->texture()->GetLevelType( | 169 texture_ref_->texture()->GetLevelType( |
170 target_, level_, &temp_type, &temp_internal_format); | 170 target_, level_, &temp_type, &temp_internal_format); |
171 return temp_internal_format; | 171 return temp_internal_format; |
172 } | 172 } |
173 | 173 |
174 virtual GLenum texture_type() const OVERRIDE { | 174 virtual GLenum texture_type() const override { |
175 GLenum temp_type = 0; | 175 GLenum temp_type = 0; |
176 GLenum temp_internal_format = 0; | 176 GLenum temp_internal_format = 0; |
177 texture_ref_->texture()->GetLevelType( | 177 texture_ref_->texture()->GetLevelType( |
178 target_, level_, &temp_type, &temp_internal_format); | 178 target_, level_, &temp_type, &temp_internal_format); |
179 return temp_type; | 179 return temp_type; |
180 } | 180 } |
181 | 181 |
182 virtual GLsizei samples() const OVERRIDE { | 182 virtual GLsizei samples() const override { |
183 return samples_; | 183 return samples_; |
184 } | 184 } |
185 | 185 |
186 virtual GLuint object_name() const OVERRIDE { | 186 virtual GLuint object_name() const override { |
187 return texture_ref_->client_id(); | 187 return texture_ref_->client_id(); |
188 } | 188 } |
189 | 189 |
190 virtual bool cleared() const OVERRIDE { | 190 virtual bool cleared() const override { |
191 return texture_ref_->texture()->IsLevelCleared(target_, level_); | 191 return texture_ref_->texture()->IsLevelCleared(target_, level_); |
192 } | 192 } |
193 | 193 |
194 virtual void SetCleared( | 194 virtual void SetCleared( |
195 RenderbufferManager* /* renderbuffer_manager */, | 195 RenderbufferManager* /* renderbuffer_manager */, |
196 TextureManager* texture_manager, | 196 TextureManager* texture_manager, |
197 bool cleared) OVERRIDE { | 197 bool cleared) override { |
198 texture_manager->SetLevelCleared( | 198 texture_manager->SetLevelCleared( |
199 texture_ref_.get(), target_, level_, cleared); | 199 texture_ref_.get(), target_, level_, cleared); |
200 } | 200 } |
201 | 201 |
202 virtual bool IsTexture(TextureRef* texture) const OVERRIDE { | 202 virtual bool IsTexture(TextureRef* texture) const override { |
203 return texture == texture_ref_.get(); | 203 return texture == texture_ref_.get(); |
204 } | 204 } |
205 | 205 |
206 virtual bool IsRenderbuffer( | 206 virtual bool IsRenderbuffer( |
207 Renderbuffer* /* renderbuffer */) | 207 Renderbuffer* /* renderbuffer */) |
208 const OVERRIDE { | 208 const override { |
209 return false; | 209 return false; |
210 } | 210 } |
211 | 211 |
212 TextureRef* texture() const { | 212 TextureRef* texture() const { |
213 return texture_ref_.get(); | 213 return texture_ref_.get(); |
214 } | 214 } |
215 | 215 |
216 virtual bool CanRenderTo() const OVERRIDE { | 216 virtual bool CanRenderTo() const override { |
217 return texture_ref_->texture()->CanRenderTo(); | 217 return texture_ref_->texture()->CanRenderTo(); |
218 } | 218 } |
219 | 219 |
220 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) | 220 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) |
221 const OVERRIDE { | 221 const override { |
222 texture_ref_->texture()->DetachFromFramebuffer(); | 222 texture_ref_->texture()->DetachFromFramebuffer(); |
223 framebuffer->OnTextureRefDetached(texture_ref_.get()); | 223 framebuffer->OnTextureRefDetached(texture_ref_.get()); |
224 } | 224 } |
225 | 225 |
226 virtual bool ValidForAttachmentType( | 226 virtual bool ValidForAttachmentType( |
227 GLenum attachment_type, uint32 max_color_attachments) OVERRIDE { | 227 GLenum attachment_type, uint32 max_color_attachments) override { |
228 GLenum type = 0; | 228 GLenum type = 0; |
229 GLenum internal_format = 0; | 229 GLenum internal_format = 0; |
230 if (!texture_ref_->texture()->GetLevelType( | 230 if (!texture_ref_->texture()->GetLevelType( |
231 target_, level_, &type, &internal_format)) { | 231 target_, level_, &type, &internal_format)) { |
232 return false; | 232 return false; |
233 } | 233 } |
234 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 234 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
235 attachment_type, max_color_attachments); | 235 attachment_type, max_color_attachments); |
236 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); | 236 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); |
237 | 237 |
238 // Workaround for NVIDIA drivers that incorrectly expose these formats as | 238 // Workaround for NVIDIA drivers that incorrectly expose these formats as |
239 // renderable: | 239 // renderable: |
240 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA || | 240 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA || |
241 internal_format == GL_LUMINANCE_ALPHA) { | 241 internal_format == GL_LUMINANCE_ALPHA) { |
242 return false; | 242 return false; |
243 } | 243 } |
244 return (need & have) != 0; | 244 return (need & have) != 0; |
245 } | 245 } |
246 | 246 |
247 virtual size_t GetSignatureSize( | 247 virtual size_t GetSignatureSize( |
248 TextureManager* texture_manager) const OVERRIDE { | 248 TextureManager* texture_manager) const override { |
249 return texture_manager->GetSignatureSize(); | 249 return texture_manager->GetSignatureSize(); |
250 } | 250 } |
251 | 251 |
252 virtual void AddToSignature( | 252 virtual void AddToSignature( |
253 TextureManager* texture_manager, std::string* signature) const OVERRIDE { | 253 TextureManager* texture_manager, std::string* signature) const override { |
254 DCHECK(signature); | 254 DCHECK(signature); |
255 texture_manager->AddToSignature( | 255 texture_manager->AddToSignature( |
256 texture_ref_.get(), target_, level_, signature); | 256 texture_ref_.get(), target_, level_, signature); |
257 } | 257 } |
258 | 258 |
259 virtual void OnWillRenderTo() const OVERRIDE { | 259 virtual void OnWillRenderTo() const override { |
260 texture_ref_->texture()->OnWillModifyPixels(); | 260 texture_ref_->texture()->OnWillModifyPixels(); |
261 } | 261 } |
262 | 262 |
263 virtual void OnDidRenderTo() const OVERRIDE { | 263 virtual void OnDidRenderTo() const override { |
264 texture_ref_->texture()->OnDidModifyPixels(); | 264 texture_ref_->texture()->OnDidModifyPixels(); |
265 } | 265 } |
266 | 266 |
267 protected: | 267 protected: |
268 virtual ~TextureAttachment() {} | 268 virtual ~TextureAttachment() {} |
269 | 269 |
270 private: | 270 private: |
271 scoped_refptr<TextureRef> texture_ref_; | 271 scoped_refptr<TextureRef> texture_ref_; |
272 GLenum target_; | 272 GLenum target_; |
273 GLint level_; | 273 GLint level_; |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 ++it) { | 754 ++it) { |
755 TextureDetachObserver* observer = *it; | 755 TextureDetachObserver* observer = *it; |
756 observer->OnTextureRefDetachedFromFramebuffer(texture); | 756 observer->OnTextureRefDetachedFromFramebuffer(texture); |
757 } | 757 } |
758 } | 758 } |
759 | 759 |
760 } // namespace gles2 | 760 } // namespace gles2 |
761 } // namespace gpu | 761 } // namespace gpu |
762 | 762 |
763 | 763 |
OLD | NEW |