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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
13 #include "gpu/command_buffer/common/id_allocator.h" | |
14 #include "gpu/command_buffer/service/buffer_manager.h" | 13 #include "gpu/command_buffer/service/buffer_manager.h" |
15 #include "gpu/command_buffer/service/framebuffer_manager.h" | 14 #include "gpu/command_buffer/service/framebuffer_manager.h" |
16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
17 #include "gpu/command_buffer/service/gpu_switches.h" | 16 #include "gpu/command_buffer/service/gpu_switches.h" |
18 #include "gpu/command_buffer/service/mailbox_manager.h" | 17 #include "gpu/command_buffer/service/mailbox_manager.h" |
19 #include "gpu/command_buffer/service/memory_tracking.h" | 18 #include "gpu/command_buffer/service/memory_tracking.h" |
20 #include "gpu/command_buffer/service/program_manager.h" | 19 #include "gpu/command_buffer/service/program_manager.h" |
21 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 20 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
22 #include "gpu/command_buffer/service/shader_manager.h" | 21 #include "gpu/command_buffer/service/shader_manager.h" |
23 #include "gpu/command_buffer/service/texture_manager.h" | 22 #include "gpu/command_buffer/service/texture_manager.h" |
(...skipping 29 matching lines...) Expand all Loading... |
53 draw_buffer_(GL_BACK) { | 52 draw_buffer_(GL_BACK) { |
54 { | 53 { |
55 if (!mailbox_manager_.get()) | 54 if (!mailbox_manager_.get()) |
56 mailbox_manager_ = new MailboxManager; | 55 mailbox_manager_ = new MailboxManager; |
57 if (!feature_info.get()) | 56 if (!feature_info.get()) |
58 feature_info_ = new FeatureInfo; | 57 feature_info_ = new FeatureInfo; |
59 TransferBufferManager* manager = new TransferBufferManager(); | 58 TransferBufferManager* manager = new TransferBufferManager(); |
60 transfer_buffer_manager_.reset(manager); | 59 transfer_buffer_manager_.reset(manager); |
61 manager->Initialize(); | 60 manager->Initialize(); |
62 } | 61 } |
63 | |
64 id_namespaces_[id_namespaces::kBuffers].reset(new IdAllocator); | |
65 id_namespaces_[id_namespaces::kFramebuffers].reset(new IdAllocator); | |
66 id_namespaces_[id_namespaces::kProgramsAndShaders].reset( | |
67 new NonReusedIdAllocator); | |
68 id_namespaces_[id_namespaces::kRenderbuffers].reset(new IdAllocator); | |
69 id_namespaces_[id_namespaces::kTextures].reset(new IdAllocator); | |
70 id_namespaces_[id_namespaces::kQueries].reset(new IdAllocator); | |
71 id_namespaces_[id_namespaces::kVertexArrays].reset(new IdAllocator); | |
72 } | 62 } |
73 | 63 |
74 static void GetIntegerv(GLenum pname, uint32* var) { | 64 static void GetIntegerv(GLenum pname, uint32* var) { |
75 GLint value = 0; | 65 GLint value = 0; |
76 glGetIntegerv(pname, &value); | 66 glGetIntegerv(pname, &value); |
77 *var = value; | 67 *var = value; |
78 } | 68 } |
79 | 69 |
80 bool ContextGroup::Initialize( | 70 bool ContextGroup::Initialize( |
81 GLES2Decoder* decoder, | 71 GLES2Decoder* decoder, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 311 } |
322 | 312 |
323 if (shader_manager_ != NULL) { | 313 if (shader_manager_ != NULL) { |
324 shader_manager_->Destroy(have_context); | 314 shader_manager_->Destroy(have_context); |
325 shader_manager_.reset(); | 315 shader_manager_.reset(); |
326 } | 316 } |
327 | 317 |
328 memory_tracker_ = NULL; | 318 memory_tracker_ = NULL; |
329 } | 319 } |
330 | 320 |
331 IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) { | |
332 if (namespace_id >= arraysize(id_namespaces_)) | |
333 return NULL; | |
334 | |
335 return id_namespaces_[namespace_id].get(); | |
336 } | |
337 | |
338 uint32 ContextGroup::GetMemRepresented() const { | 321 uint32 ContextGroup::GetMemRepresented() const { |
339 uint32 total = 0; | 322 uint32 total = 0; |
340 if (buffer_manager_.get()) | 323 if (buffer_manager_.get()) |
341 total += buffer_manager_->mem_represented(); | 324 total += buffer_manager_->mem_represented(); |
342 if (renderbuffer_manager_.get()) | 325 if (renderbuffer_manager_.get()) |
343 total += renderbuffer_manager_->mem_represented(); | 326 total += renderbuffer_manager_->mem_represented(); |
344 if (texture_manager_.get()) | 327 if (texture_manager_.get()) |
345 total += texture_manager_->mem_represented(); | 328 total += texture_manager_->mem_represented(); |
346 return total; | 329 return total; |
347 } | 330 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 GLenum pname, GLint min_required, uint32* v) { | 371 GLenum pname, GLint min_required, uint32* v) { |
389 uint32 value = 0; | 372 uint32 value = 0; |
390 GetIntegerv(pname, &value); | 373 GetIntegerv(pname, &value); |
391 bool result = CheckGLFeatureU(min_required, &value); | 374 bool result = CheckGLFeatureU(min_required, &value); |
392 *v = value; | 375 *v = value; |
393 return result; | 376 return result; |
394 } | 377 } |
395 | 378 |
396 } // namespace gles2 | 379 } // namespace gles2 |
397 } // namespace gpu | 380 } // namespace gpu |
OLD | NEW |