Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: gpu/command_buffer/service/context_group.cc

Issue 2880013: Free the resources used by a context group. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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/program_manager.h" 9 #include "gpu/command_buffer/service/program_manager.h"
10 #include "gpu/command_buffer/service/renderbuffer_manager.h" 10 #include "gpu/command_buffer/service/renderbuffer_manager.h"
11 #include "gpu/command_buffer/service/shader_manager.h" 11 #include "gpu/command_buffer/service/shader_manager.h"
12 #include "gpu/command_buffer/service/texture_manager.h" 12 #include "gpu/command_buffer/service/texture_manager.h"
13 13
14 namespace gpu { 14 namespace gpu {
15 namespace gles2 { 15 namespace gles2 {
16 16
17 ContextGroup::ContextGroup() 17 ContextGroup::ContextGroup()
18 : initialized_(false), 18 : initialized_(false),
19 max_vertex_attribs_(0u), 19 max_vertex_attribs_(0u),
20 max_texture_units_(0u), 20 max_texture_units_(0u),
21 max_texture_image_units_(0u), 21 max_texture_image_units_(0u),
22 max_vertex_texture_image_units_(0u), 22 max_vertex_texture_image_units_(0u),
23 max_fragment_uniform_vectors_(0u), 23 max_fragment_uniform_vectors_(0u),
24 max_varying_vectors_(0u), 24 max_varying_vectors_(0u),
25 max_vertex_uniform_vectors_(0u) { 25 max_vertex_uniform_vectors_(0u) {
26 } 26 }
27 27
28 ContextGroup::~ContextGroup() { 28 ContextGroup::~ContextGroup() {
29 // Check that Destroy has been called.
30 DCHECK(buffer_manager_ == NULL);
31 DCHECK(framebuffer_manager_ == NULL);
32 DCHECK(renderbuffer_manager_ == NULL);
33 DCHECK(texture_manager_ == NULL);
34 DCHECK(program_manager_ == NULL);
35 DCHECK(shader_manager_ == NULL);
29 } 36 }
30 37
31 static void GetIntegerv(GLenum pname, uint32* var) { 38 static void GetIntegerv(GLenum pname, uint32* var) {
32 GLint value = 0; 39 GLint value = 0;
33 glGetIntegerv(pname, &value); 40 glGetIntegerv(pname, &value);
34 *var = value; 41 *var = value;
35 } 42 }
36 43
37 bool ContextGroup::Initialize() { 44 bool ContextGroup::Initialize() {
38 if (initialized_) { 45 if (initialized_) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 max_varying_vectors_ /= 4; 87 max_varying_vectors_ /= 4;
81 GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &max_vertex_uniform_vectors_); 88 GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &max_vertex_uniform_vectors_);
82 max_vertex_uniform_vectors_ /= 4; 89 max_vertex_uniform_vectors_ /= 4;
83 90
84 #endif // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) 91 #endif // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
85 92
86 initialized_ = true; 93 initialized_ = true;
87 return true; 94 return true;
88 } 95 }
89 96
97 void ContextGroup::Destroy(bool have_context) {
98 if (buffer_manager_ != NULL) {
99 buffer_manager_->Destroy(have_context);
100 buffer_manager_.reset();
101 }
102
103 if (framebuffer_manager_ != NULL) {
104 framebuffer_manager_->Destroy(have_context);
105 framebuffer_manager_.reset();
106 }
107
108 if (renderbuffer_manager_ != NULL) {
109 renderbuffer_manager_->Destroy(have_context);
110 renderbuffer_manager_.reset();
111 }
112
113 if (texture_manager_ != NULL) {
114 texture_manager_->Destroy(have_context);
115 texture_manager_.reset();
116 }
117
118 if (program_manager_ != NULL) {
119 program_manager_->Destroy(have_context);
120 program_manager_.reset();
121 }
122
123 if (shader_manager_ != NULL) {
124 shader_manager_->Destroy(have_context);
125 shader_manager_.reset();
126 }
127 }
128
90 IdAllocator* ContextGroup::GetIdAllocator(unsigned namespace_id) { 129 IdAllocator* ContextGroup::GetIdAllocator(unsigned namespace_id) {
91 IdAllocatorMap::iterator it = id_namespaces_.find(namespace_id); 130 IdAllocatorMap::iterator it = id_namespaces_.find(namespace_id);
92 if (it != id_namespaces_.end()) { 131 if (it != id_namespaces_.end()) {
93 return it->second.get(); 132 return it->second.get();
94 } 133 }
95 IdAllocator* id_allocator = new IdAllocator(); 134 IdAllocator* id_allocator = new IdAllocator();
96 id_namespaces_[namespace_id] = linked_ptr<IdAllocator>(id_allocator); 135 id_namespaces_[namespace_id] = linked_ptr<IdAllocator>(id_allocator);
97 return id_allocator; 136 return id_allocator;
98 } 137 }
99 138
100 } // namespace gles2 139 } // namespace gles2
101 } // namespace gpu 140 } // namespace gpu
102 141
103 142
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_group.h ('k') | gpu/command_buffer/service/framebuffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698