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/context_group.h" | 5 #include "gpu/command_buffer/service/context_group.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "gpu/command_buffer/common/id_allocator.h" | 11 #include "gpu/command_buffer/common/id_allocator.h" |
12 #include "gpu/command_buffer/service/buffer_manager.h" | 12 #include "gpu/command_buffer/service/buffer_manager.h" |
13 #include "gpu/command_buffer/service/framebuffer_manager.h" | 13 #include "gpu/command_buffer/service/framebuffer_manager.h" |
14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
15 #include "gpu/command_buffer/service/gpu_switches.h" | 15 #include "gpu/command_buffer/service/gpu_switches.h" |
| 16 #include "gpu/command_buffer/service/mailbox_manager.h" |
16 #include "gpu/command_buffer/service/program_manager.h" | 17 #include "gpu/command_buffer/service/program_manager.h" |
17 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 18 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
18 #include "gpu/command_buffer/service/shader_manager.h" | 19 #include "gpu/command_buffer/service/shader_manager.h" |
19 #include "gpu/command_buffer/service/texture_manager.h" | 20 #include "gpu/command_buffer/service/texture_manager.h" |
20 #include "ui/gfx/gl/gl_implementation.h" | 21 #include "ui/gfx/gl/gl_implementation.h" |
21 | 22 |
22 namespace gpu { | 23 namespace gpu { |
23 namespace gles2 { | 24 namespace gles2 { |
24 | 25 |
25 ContextGroup::ContextGroup(bool bind_generates_resource) | 26 ContextGroup::ContextGroup(MailboxManager* mailbox_manager, |
26 : num_contexts_(0), | 27 bool bind_generates_resource) |
| 28 : mailbox_manager_(mailbox_manager ? mailbox_manager : new MailboxManager), |
| 29 num_contexts_(0), |
27 enforce_gl_minimums_(CommandLine::ForCurrentProcess()->HasSwitch( | 30 enforce_gl_minimums_(CommandLine::ForCurrentProcess()->HasSwitch( |
28 switches::kEnforceGLMinimums)), | 31 switches::kEnforceGLMinimums)), |
29 bind_generates_resource_(bind_generates_resource), | 32 bind_generates_resource_(bind_generates_resource), |
30 max_vertex_attribs_(0u), | 33 max_vertex_attribs_(0u), |
31 max_texture_units_(0u), | 34 max_texture_units_(0u), |
32 max_texture_image_units_(0u), | 35 max_texture_image_units_(0u), |
33 max_vertex_texture_image_units_(0u), | 36 max_vertex_texture_image_units_(0u), |
34 max_fragment_uniform_vectors_(0u), | 37 max_fragment_uniform_vectors_(0u), |
35 max_varying_vectors_(0u), | 38 max_varying_vectors_(0u), |
36 max_vertex_uniform_vectors_(0u), | 39 max_vertex_uniform_vectors_(0u), |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 framebuffer_manager_->Destroy(have_context); | 245 framebuffer_manager_->Destroy(have_context); |
243 framebuffer_manager_.reset(); | 246 framebuffer_manager_.reset(); |
244 } | 247 } |
245 | 248 |
246 if (renderbuffer_manager_ != NULL) { | 249 if (renderbuffer_manager_ != NULL) { |
247 renderbuffer_manager_->Destroy(have_context); | 250 renderbuffer_manager_->Destroy(have_context); |
248 renderbuffer_manager_.reset(); | 251 renderbuffer_manager_.reset(); |
249 } | 252 } |
250 | 253 |
251 if (texture_manager_ != NULL) { | 254 if (texture_manager_ != NULL) { |
| 255 mailbox_manager_->DestroyOwnedTextures(texture_manager_.get(), |
| 256 have_context); |
252 texture_manager_->Destroy(have_context); | 257 texture_manager_->Destroy(have_context); |
253 texture_manager_.reset(); | 258 texture_manager_.reset(); |
254 } | 259 } |
255 | 260 |
256 if (program_manager_ != NULL) { | 261 if (program_manager_ != NULL) { |
257 program_manager_->Destroy(have_context); | 262 program_manager_->Destroy(have_context); |
258 program_manager_.reset(); | 263 program_manager_.reset(); |
259 } | 264 } |
260 | 265 |
261 if (shader_manager_ != NULL) { | 266 if (shader_manager_ != NULL) { |
262 shader_manager_->Destroy(have_context); | 267 shader_manager_->Destroy(have_context); |
263 shader_manager_.reset(); | 268 shader_manager_.reset(); |
264 } | 269 } |
265 } | 270 } |
266 | 271 |
267 IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) { | 272 IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) { |
268 if (namespace_id >= arraysize(id_namespaces_)) | 273 if (namespace_id >= arraysize(id_namespaces_)) |
269 return NULL; | 274 return NULL; |
270 | 275 |
271 return id_namespaces_[namespace_id].get(); | 276 return id_namespaces_[namespace_id].get(); |
272 } | 277 } |
273 | 278 |
274 } // namespace gles2 | 279 } // namespace gles2 |
275 } // namespace gpu | 280 } // namespace gpu |
276 | 281 |
277 | 282 |
OLD | NEW |