OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "gpu/command_buffer/common/gles2_cmd_utils.h" | 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
8 | 8 |
9 namespace gpu { | 9 namespace gpu { |
10 namespace gles2 { | 10 namespace gles2 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 virtual void SetCleared( | 42 virtual void SetCleared( |
43 RenderbufferManager* renderbuffer_manager, | 43 RenderbufferManager* renderbuffer_manager, |
44 TextureManager* /* texture_manager */) { | 44 TextureManager* /* texture_manager */) { |
45 renderbuffer_manager->SetCleared(renderbuffer_); | 45 renderbuffer_manager->SetCleared(renderbuffer_); |
46 } | 46 } |
47 | 47 |
48 virtual bool IsTexture(TextureManager::TextureInfo* /* texture */) const { | 48 virtual bool IsTexture(TextureManager::TextureInfo* /* texture */) const { |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
| 52 virtual bool IsRenderbuffer( |
| 53 RenderbufferManager::RenderbufferInfo* renderbuffer) const { |
| 54 return renderbuffer_ == renderbuffer; |
| 55 } |
| 56 |
52 virtual bool CanRenderTo() const { | 57 virtual bool CanRenderTo() const { |
53 return true; | 58 return true; |
54 } | 59 } |
55 | 60 |
56 virtual void DetachFromFramebuffer() { | 61 virtual void DetachFromFramebuffer() { |
57 // Nothing to do for renderbuffers. | 62 // Nothing to do for renderbuffers. |
58 } | 63 } |
59 | 64 |
60 virtual bool ValidForAttachmentType(GLenum attachment_type) { | 65 virtual bool ValidForAttachmentType(GLenum attachment_type) { |
61 // TODO(gman): Fill this out. | 66 // TODO(gman): Fill this out. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 virtual void SetCleared( | 121 virtual void SetCleared( |
117 RenderbufferManager* /* renderbuffer_manager */, | 122 RenderbufferManager* /* renderbuffer_manager */, |
118 TextureManager* texture_manager) { | 123 TextureManager* texture_manager) { |
119 texture_manager->SetLevelCleared(texture_, target_, level_); | 124 texture_manager->SetLevelCleared(texture_, target_, level_); |
120 } | 125 } |
121 | 126 |
122 virtual bool IsTexture(TextureManager::TextureInfo* texture) const { | 127 virtual bool IsTexture(TextureManager::TextureInfo* texture) const { |
123 return texture == texture_.get(); | 128 return texture == texture_.get(); |
124 } | 129 } |
125 | 130 |
| 131 virtual bool IsRenderbuffer( |
| 132 RenderbufferManager::RenderbufferInfo* /* renderbuffer */) const { |
| 133 return false; |
| 134 } |
| 135 |
126 TextureManager::TextureInfo* texture() const { | 136 TextureManager::TextureInfo* texture() const { |
127 return texture_.get(); | 137 return texture_.get(); |
128 } | 138 } |
129 | 139 |
130 virtual bool CanRenderTo() const { | 140 virtual bool CanRenderTo() const { |
131 return texture_->CanRenderTo(); | 141 return texture_->CanRenderTo(); |
132 } | 142 } |
133 | 143 |
134 virtual void DetachFromFramebuffer() { | 144 virtual void DetachFromFramebuffer() { |
135 texture_->DetachFromFramebuffer(); | 145 texture_->DetachFromFramebuffer(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 for (AttachmentMap::const_iterator it = attachments_.begin(); | 287 for (AttachmentMap::const_iterator it = attachments_.begin(); |
278 it != attachments_.end(); ++it) { | 288 it != attachments_.end(); ++it) { |
279 Attachment* attachment = it->second; | 289 Attachment* attachment = it->second; |
280 if (!attachment->cleared()) { | 290 if (!attachment->cleared()) { |
281 return false; | 291 return false; |
282 } | 292 } |
283 } | 293 } |
284 return true; | 294 return true; |
285 } | 295 } |
286 | 296 |
| 297 void FramebufferManager::FramebufferInfo::UnbindRenderbuffer( |
| 298 GLenum target, RenderbufferManager::RenderbufferInfo* renderbuffer) { |
| 299 bool done; |
| 300 do { |
| 301 done = true; |
| 302 for (AttachmentMap::const_iterator it = attachments_.begin(); |
| 303 it != attachments_.end(); ++it) { |
| 304 Attachment* attachment = it->second; |
| 305 if (attachment->IsRenderbuffer(renderbuffer)) { |
| 306 // TODO(gman): manually detach renderbuffer. |
| 307 // glFramebufferRenderbufferEXT(target, it->first, GL_RENDERBUFFER, 0); |
| 308 AttachRenderbuffer(it->first, NULL); |
| 309 done = false; |
| 310 break; |
| 311 } |
| 312 } |
| 313 } while (!done); |
| 314 } |
| 315 |
| 316 void FramebufferManager::FramebufferInfo::UnbindTexture( |
| 317 GLenum target, TextureManager::TextureInfo* texture) { |
| 318 bool done; |
| 319 do { |
| 320 done = true; |
| 321 for (AttachmentMap::const_iterator it = attachments_.begin(); |
| 322 it != attachments_.end(); ++it) { |
| 323 Attachment* attachment = it->second; |
| 324 if (attachment->IsTexture(texture)) { |
| 325 // TODO(gman): manually detach texture. |
| 326 // glFramebufferTexture2DEXT(target, it->first, GL_TEXTURE_2D, 0, 0); |
| 327 AttachTexture(it->first, NULL, GL_TEXTURE_2D, 0); |
| 328 done = false; |
| 329 break; |
| 330 } |
| 331 } |
| 332 } while (!done); |
| 333 } |
| 334 |
287 FramebufferManager::FramebufferInfo* FramebufferManager::GetFramebufferInfo( | 335 FramebufferManager::FramebufferInfo* FramebufferManager::GetFramebufferInfo( |
288 GLuint client_id) { | 336 GLuint client_id) { |
289 FramebufferInfoMap::iterator it = framebuffer_infos_.find(client_id); | 337 FramebufferInfoMap::iterator it = framebuffer_infos_.find(client_id); |
290 return it != framebuffer_infos_.end() ? it->second : NULL; | 338 return it != framebuffer_infos_.end() ? it->second : NULL; |
291 } | 339 } |
292 | 340 |
293 void FramebufferManager::RemoveFramebufferInfo(GLuint client_id) { | 341 void FramebufferManager::RemoveFramebufferInfo(GLuint client_id) { |
294 FramebufferInfoMap::iterator it = framebuffer_infos_.find(client_id); | 342 FramebufferInfoMap::iterator it = framebuffer_infos_.find(client_id); |
295 if (it != framebuffer_infos_.end()) { | 343 if (it != framebuffer_infos_.end()) { |
296 it->second->MarkAsDeleted(); | 344 it->second->MarkAsDeleted(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 return true; | 400 return true; |
353 } | 401 } |
354 } | 402 } |
355 return false; | 403 return false; |
356 } | 404 } |
357 | 405 |
358 } // namespace gles2 | 406 } // namespace gles2 |
359 } // namespace gpu | 407 } // namespace gpu |
360 | 408 |
361 | 409 |
OLD | NEW |