| 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/context_group.h" | 5 #include "gpu/command_buffer/service/context_group.h" |
| 6 #include "gpu/command_buffer/common/id_allocator.h" | 6 #include "gpu/command_buffer/common/id_allocator.h" |
| 7 #include "gpu/command_buffer/service/buffer_manager.h" | 7 #include "gpu/command_buffer/service/buffer_manager.h" |
| 8 #include "gpu/command_buffer/service/framebuffer_manager.h" | 8 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 10 #include "gpu/command_buffer/service/program_manager.h" | 10 #include "gpu/command_buffer/service/program_manager.h" |
| 11 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 11 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 12 #include "gpu/command_buffer/service/shader_manager.h" | 12 #include "gpu/command_buffer/service/shader_manager.h" |
| 13 #include "gpu/command_buffer/service/texture_manager.h" | 13 #include "gpu/command_buffer/service/texture_manager.h" |
| 14 #include "gpu/GLES2/gles2_command_buffer.h" | 14 #include "gpu/GLES2/gles2_command_buffer.h" |
| 15 #include "ui/gfx/gl/gl_implementation.h" | 15 #include "ui/gfx/gl/gl_implementation.h" |
| 16 | 16 |
| 17 namespace gpu { | 17 namespace gpu { |
| 18 namespace gles2 { | 18 namespace gles2 { |
| 19 | 19 |
| 20 ContextGroup::ContextGroup() | 20 ContextGroup::ContextGroup() |
| 21 : initialized_(false), | 21 : initialized_(false), |
| 22 have_context_(true), | 22 have_context_(true), |
| 23 max_vertex_attribs_(0u), | 23 max_vertex_attribs_(0u), |
| 24 max_texture_units_(0u), | 24 max_texture_units_(0u), |
| 25 max_texture_image_units_(0u), | 25 max_texture_image_units_(0u), |
| 26 max_vertex_texture_image_units_(0u), | 26 max_vertex_texture_image_units_(0u), |
| 27 max_fragment_uniform_vectors_(0u), | 27 max_fragment_uniform_vectors_(0u), |
| 28 max_varying_vectors_(0u), | 28 max_varying_vectors_(0u), |
| 29 max_vertex_uniform_vectors_(0u) { | 29 max_vertex_uniform_vectors_(0u) { |
| 30 id_namespaces_[id_namespaces::kBuffers].reset(new IdAllocator); |
| 31 id_namespaces_[id_namespaces::kFramebuffers].reset(new IdAllocator); |
| 32 id_namespaces_[id_namespaces::kProgramsAndShaders].reset( |
| 33 new NonReusedIdAllocator); |
| 34 id_namespaces_[id_namespaces::kRenderbuffers].reset(new IdAllocator); |
| 35 id_namespaces_[id_namespaces::kTextures].reset(new IdAllocator); |
| 30 } | 36 } |
| 31 | 37 |
| 32 ContextGroup::~ContextGroup() { | 38 ContextGroup::~ContextGroup() { |
| 33 Destroy(); | 39 Destroy(); |
| 34 } | 40 } |
| 35 | 41 |
| 36 static void GetIntegerv(GLenum pname, uint32* var) { | 42 static void GetIntegerv(GLenum pname, uint32* var) { |
| 37 GLint value = 0; | 43 GLint value = 0; |
| 38 glGetIntegerv(pname, &value); | 44 glGetIntegerv(pname, &value); |
| 39 *var = value; | 45 *var = value; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 program_manager_->Destroy(have_context_); | 144 program_manager_->Destroy(have_context_); |
| 139 program_manager_.reset(); | 145 program_manager_.reset(); |
| 140 } | 146 } |
| 141 | 147 |
| 142 if (shader_manager_ != NULL) { | 148 if (shader_manager_ != NULL) { |
| 143 shader_manager_->Destroy(have_context_); | 149 shader_manager_->Destroy(have_context_); |
| 144 shader_manager_.reset(); | 150 shader_manager_.reset(); |
| 145 } | 151 } |
| 146 } | 152 } |
| 147 | 153 |
| 148 IdAllocator* ContextGroup::GetIdAllocator(unsigned namespace_id) { | 154 IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) { |
| 149 IdAllocatorMap::iterator it = id_namespaces_.find(namespace_id); | 155 if (namespace_id >= arraysize(id_namespaces_)) |
| 150 if (it != id_namespaces_.end()) { | 156 return NULL; |
| 151 return it->second.get(); | 157 |
| 152 } | 158 return id_namespaces_[namespace_id].get(); |
| 153 IdAllocator* id_allocator = new IdAllocator(); | |
| 154 id_namespaces_[namespace_id] = linked_ptr<IdAllocator>(id_allocator); | |
| 155 return id_allocator; | |
| 156 } | 159 } |
| 157 | 160 |
| 158 } // namespace gles2 | 161 } // namespace gles2 |
| 159 } // namespace gpu | 162 } // namespace gpu |
| 160 | 163 |
| 161 | 164 |
| OLD | NEW |