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 : allow_buffers_on_multiple_targets_(false) { |
| 15 } |
| 16 |
13 BufferManager::~BufferManager() { | 17 BufferManager::~BufferManager() { |
14 DCHECK(buffer_infos_.empty()); | 18 DCHECK(buffer_infos_.empty()); |
15 } | 19 } |
16 | 20 |
17 void BufferManager::Destroy(bool have_context) { | 21 void BufferManager::Destroy(bool have_context) { |
18 while (!buffer_infos_.empty()) { | 22 while (!buffer_infos_.empty()) { |
19 if (have_context) { | 23 if (have_context) { |
20 BufferInfo* info = buffer_infos_.begin()->second; | 24 BufferInfo* info = buffer_infos_.begin()->second; |
21 if (!info->IsDeleted()) { | 25 if (!info->IsDeleted()) { |
22 GLuint service_id = info->service_id(); | 26 GLuint service_id = info->service_id(); |
(...skipping 20 matching lines...) Expand all Loading... |
43 } | 47 } |
44 | 48 |
45 void BufferManager::RemoveBufferInfo(GLuint client_id) { | 49 void BufferManager::RemoveBufferInfo(GLuint client_id) { |
46 BufferInfoMap::iterator it = buffer_infos_.find(client_id); | 50 BufferInfoMap::iterator it = buffer_infos_.find(client_id); |
47 if (it != buffer_infos_.end()) { | 51 if (it != buffer_infos_.end()) { |
48 it->second->MarkAsDeleted(); | 52 it->second->MarkAsDeleted(); |
49 buffer_infos_.erase(it); | 53 buffer_infos_.erase(it); |
50 } | 54 } |
51 } | 55 } |
52 | 56 |
| 57 BufferManager::BufferInfo::BufferInfo(GLuint service_id) |
| 58 : service_id_(service_id), |
| 59 target_(0), |
| 60 size_(0), |
| 61 shadowed_(false) { |
| 62 } |
| 63 |
| 64 BufferManager::BufferInfo::~BufferInfo() { } |
| 65 |
53 void BufferManager::BufferInfo::SetSize(GLsizeiptr size, bool shadow) { | 66 void BufferManager::BufferInfo::SetSize(GLsizeiptr size, bool shadow) { |
54 DCHECK(!IsDeleted()); | 67 DCHECK(!IsDeleted()); |
55 if (size != size_ || shadow != shadowed_) { | 68 if (size != size_ || shadow != shadowed_) { |
56 shadowed_ = shadow; | 69 shadowed_ = shadow; |
57 size_ = size; | 70 size_ = size; |
58 ClearCache(); | 71 ClearCache(); |
59 if (shadowed_) { | 72 if (shadowed_) { |
60 shadow_.reset(new int8[size]); | 73 shadow_.reset(new int8[size]); |
61 memset(shadow_.get(), 0, size); | 74 memset(shadow_.get(), 0, size); |
62 } | 75 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 if (info->target() == 0) { | 194 if (info->target() == 0) { |
182 info->set_target(target); | 195 info->set_target(target); |
183 } | 196 } |
184 return true; | 197 return true; |
185 } | 198 } |
186 | 199 |
187 } // namespace gles2 | 200 } // namespace gles2 |
188 } // namespace gpu | 201 } // namespace gpu |
189 | 202 |
190 | 203 |
OLD | NEW |