diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 19:42:41 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 19:42:41 +0000 |
commit | 3ae01938b23545caf941c7fcaa655a17db77351b (patch) | |
tree | bdd9f3ecf59f1e6c2e244d576879b82dffde6bf4 /gpu/command_buffer/service/context_group.cc | |
parent | 2974287a9ca47547a00347b786c651b4953ecc82 (diff) | |
download | chromium_src-3ae01938b23545caf941c7fcaa655a17db77351b.zip chromium_src-3ae01938b23545caf941c7fcaa655a17db77351b.tar.gz chromium_src-3ae01938b23545caf941c7fcaa655a17db77351b.tar.bz2 |
Ensure that ContextGroup is destroyed when an appropriate GL context is current.
Before it relied on the destructor being invoked and this was not always true. I think the subsequent invalid GL commands might have caused memory corruption that lead to the bug referenced below.
Now the ContextGroup is destroyed explicitly when the context is known to be correct.
BUG=97775
Review URL: http://codereview.chromium.org/8135014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104157 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/context_group.cc')
-rw-r--r-- | gpu/command_buffer/service/context_group.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc index d04d1d8..ec22342 100644 --- a/gpu/command_buffer/service/context_group.cc +++ b/gpu/command_buffer/service/context_group.cc @@ -17,8 +17,7 @@ namespace gpu { namespace gles2 { ContextGroup::ContextGroup(bool bind_generates_resource) - : initialized_(false), - have_context_(true), + : num_contexts_(0), bind_generates_resource_(bind_generates_resource), max_vertex_attribs_(0u), max_texture_units_(0u), @@ -36,7 +35,7 @@ ContextGroup::ContextGroup(bool bind_generates_resource) } ContextGroup::~ContextGroup() { - Destroy(); + CHECK(num_contexts_ == 0); } static void GetIntegerv(GLenum pname, uint32* var) { @@ -47,7 +46,8 @@ static void GetIntegerv(GLenum pname, uint32* var) { bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features, const char* allowed_features) { - if (initialized_) { + if (num_contexts_ > 0) { + ++num_contexts_; return true; } @@ -115,38 +115,42 @@ bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features, return false; } - initialized_ = true; + ++num_contexts_; return true; } -void ContextGroup::Destroy() { +void ContextGroup::Destroy(bool have_context) { + DCHECK(num_contexts_ > 0); + if (--num_contexts_ > 0) + return; + if (buffer_manager_ != NULL) { - buffer_manager_->Destroy(have_context_); + buffer_manager_->Destroy(have_context); buffer_manager_.reset(); } if (framebuffer_manager_ != NULL) { - framebuffer_manager_->Destroy(have_context_); + framebuffer_manager_->Destroy(have_context); framebuffer_manager_.reset(); } if (renderbuffer_manager_ != NULL) { - renderbuffer_manager_->Destroy(have_context_); + renderbuffer_manager_->Destroy(have_context); renderbuffer_manager_.reset(); } if (texture_manager_ != NULL) { - texture_manager_->Destroy(have_context_); + texture_manager_->Destroy(have_context); texture_manager_.reset(); } if (program_manager_ != NULL) { - program_manager_->Destroy(have_context_); + program_manager_->Destroy(have_context); program_manager_.reset(); } if (shader_manager_ != NULL) { - shader_manager_->Destroy(have_context_); + shader_manager_->Destroy(have_context); shader_manager_.reset(); } } |