OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 { |
11 | 11 |
| 12 FramebufferManager::FramebufferManager() {} |
| 13 |
12 FramebufferManager::~FramebufferManager() { | 14 FramebufferManager::~FramebufferManager() { |
13 DCHECK(framebuffer_infos_.empty()); | 15 DCHECK(framebuffer_infos_.empty()); |
14 } | 16 } |
15 | 17 |
16 void FramebufferManager::Destroy(bool have_context) { | 18 void FramebufferManager::Destroy(bool have_context) { |
17 while (!framebuffer_infos_.empty()) { | 19 while (!framebuffer_infos_.empty()) { |
18 if (have_context) { | 20 if (have_context) { |
19 FramebufferInfo* info = framebuffer_infos_.begin()->second; | 21 FramebufferInfo* info = framebuffer_infos_.begin()->second; |
20 if (!info->IsDeleted()) { | 22 if (!info->IsDeleted()) { |
21 GLuint service_id = info->service_id(); | 23 GLuint service_id = info->service_id(); |
22 glDeleteFramebuffersEXT(1, &service_id); | 24 glDeleteFramebuffersEXT(1, &service_id); |
23 info->MarkAsDeleted(); | 25 info->MarkAsDeleted(); |
24 } | 26 } |
25 } | 27 } |
26 framebuffer_infos_.erase(framebuffer_infos_.begin()); | 28 framebuffer_infos_.erase(framebuffer_infos_.begin()); |
27 } | 29 } |
28 } | 30 } |
29 | 31 |
30 void FramebufferManager::CreateFramebufferInfo( | 32 void FramebufferManager::CreateFramebufferInfo( |
31 GLuint client_id, GLuint service_id) { | 33 GLuint client_id, GLuint service_id) { |
32 std::pair<FramebufferInfoMap::iterator, bool> result = | 34 std::pair<FramebufferInfoMap::iterator, bool> result = |
33 framebuffer_infos_.insert( | 35 framebuffer_infos_.insert( |
34 std::make_pair( | 36 std::make_pair( |
35 client_id, | 37 client_id, |
36 FramebufferInfo::Ref(new FramebufferInfo(service_id)))); | 38 FramebufferInfo::Ref(new FramebufferInfo(service_id)))); |
37 DCHECK(result.second); | 39 DCHECK(result.second); |
38 } | 40 } |
39 | 41 |
| 42 FramebufferManager::FramebufferInfo::FramebufferInfo(GLuint service_id) |
| 43 : service_id_(service_id) { |
| 44 } |
| 45 |
| 46 FramebufferManager::FramebufferInfo::~FramebufferInfo() {} |
| 47 |
40 bool FramebufferManager::FramebufferInfo::HasUnclearedAttachment( | 48 bool FramebufferManager::FramebufferInfo::HasUnclearedAttachment( |
41 GLenum attachment) const { | 49 GLenum attachment) const { |
42 AttachmentToRenderbufferMap::const_iterator it = | 50 AttachmentToRenderbufferMap::const_iterator it = |
43 renderbuffers_.find(attachment); | 51 renderbuffers_.find(attachment); |
44 if (it != renderbuffers_.end()) { | 52 if (it != renderbuffers_.end()) { |
45 RenderbufferManager::RenderbufferInfo* info = it->second; | 53 RenderbufferManager::RenderbufferInfo* info = it->second; |
46 return !info->cleared(); | 54 return !info->cleared(); |
47 } | 55 } |
48 return false; | 56 return false; |
49 } | 57 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 return true; | 102 return true; |
95 } | 103 } |
96 } | 104 } |
97 return false; | 105 return false; |
98 } | 106 } |
99 | 107 |
100 } // namespace gles2 | 108 } // namespace gles2 |
101 } // namespace gpu | 109 } // namespace gpu |
102 | 110 |
103 | 111 |
OLD | NEW |