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/buffer_manager.h" | 5 #include "gpu/command_buffer/service/buffer_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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 8 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
9 | 9 |
10 namespace gpu { | 10 namespace gpu { |
11 namespace gles2 { | 11 namespace gles2 { |
12 | 12 |
| 13 BufferManager::~BufferManager() { |
| 14 DCHECK(buffer_infos_.empty()); |
| 15 } |
| 16 |
| 17 void BufferManager::Destroy(bool have_context) { |
| 18 while (!buffer_infos_.empty()) { |
| 19 if (have_context) { |
| 20 BufferInfo* info = buffer_infos_.begin()->second; |
| 21 if (!info->IsDeleted()) { |
| 22 GLuint service_id = info->service_id(); |
| 23 glDeleteBuffersARB(1, &service_id); |
| 24 info->MarkAsDeleted(); |
| 25 } |
| 26 } |
| 27 buffer_infos_.erase(buffer_infos_.begin()); |
| 28 } |
| 29 } |
| 30 |
13 void BufferManager::CreateBufferInfo(GLuint client_id, GLuint service_id) { | 31 void BufferManager::CreateBufferInfo(GLuint client_id, GLuint service_id) { |
14 std::pair<BufferInfoMap::iterator, bool> result = | 32 std::pair<BufferInfoMap::iterator, bool> result = |
15 buffer_infos_.insert( | 33 buffer_infos_.insert( |
16 std::make_pair(client_id, | 34 std::make_pair(client_id, |
17 BufferInfo::Ref(new BufferInfo(service_id)))); | 35 BufferInfo::Ref(new BufferInfo(service_id)))); |
18 DCHECK(result.second); | 36 DCHECK(result.second); |
19 } | 37 } |
20 | 38 |
21 BufferManager::BufferInfo* BufferManager::GetBufferInfo( | 39 BufferManager::BufferInfo* BufferManager::GetBufferInfo( |
22 GLuint client_id) { | 40 GLuint client_id) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 if (info->target() == 0) { | 181 if (info->target() == 0) { |
164 info->set_target(target); | 182 info->set_target(target); |
165 } | 183 } |
166 return true; | 184 return true; |
167 } | 185 } |
168 | 186 |
169 } // namespace gles2 | 187 } // namespace gles2 |
170 } // namespace gpu | 188 } // namespace gpu |
171 | 189 |
172 | 190 |
OLD | NEW |