diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-07 08:25:57 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-07 08:25:57 +0000 |
commit | e7afab7ad9635d67318260eadb13c2d7ee0aa241 (patch) | |
tree | 7c557c6295dbf7b91d9806433b23ceed4bf261f4 /gpu | |
parent | c1d26b47aab279e3ec073ca1e6179643ba6c5532 (diff) | |
download | chromium_src-e7afab7ad9635d67318260eadb13c2d7ee0aa241.zip chromium_src-e7afab7ad9635d67318260eadb13c2d7ee0aa241.tar.gz chromium_src-e7afab7ad9635d67318260eadb13c2d7ee0aa241.tar.bz2 |
Make StrictSharedIdHandler free its unused ids.
TEST=none
BUG=109330
Review URL: http://codereview.chromium.org/9109030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 24 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_unittest.cc | 6 |
2 files changed, 27 insertions, 3 deletions
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index ccbffc8..d3f9054 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -143,7 +143,9 @@ class StrictSharedIdHandler : public IdHandlerInterface { id_namespace_(id_namespace) { } - virtual ~StrictSharedIdHandler() { } + virtual ~StrictSharedIdHandler() { + Destroy(); + } virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) { for (GLsizei ii = 0; ii < n; ++ii) { @@ -185,6 +187,19 @@ class StrictSharedIdHandler : public IdHandlerInterface { typedef std::queue<GLuint> ResourceIdQueue; typedef std::set<GLuint> ResourceIdSet; + void Destroy() { + // Free all the ids not being used. + while (!free_ids_.empty()) { + GLuint ids[kNumIdsToGet]; + int count = 0; + while (count < kNumIdsToGet && !free_ids_.empty()) { + ids[count++] = free_ids_.front(); + free_ids_.pop(); + } + gles2_->DeleteSharedIdsCHROMIUM(id_namespace_, count, ids); + } + } + GLuint GetId(GLuint id_offset) { if (free_ids_.empty()) { GLuint ids[kNumIdsToGet]; @@ -723,6 +738,11 @@ GLES2Implementation::~GLES2Implementation() { #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) DeleteBuffers(arraysize(reserved_ids_), &reserved_ids_[0]); #endif + for (int i = 0; i < id_namespaces::kNumIdNamespaces; ++i) { + id_handlers_[i].reset(); + } + // Make sure the commands make it the service. + Finish(); } void GLES2Implementation::SetSharedMemoryChunkSizeMultiple( diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index dc94ad3..46f60ae 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,6 +16,7 @@ #endif using testing::_; +using testing::AnyNumber; using testing::DoAll; using testing::InSequence; using testing::Invoke; @@ -447,6 +448,9 @@ class GLES2ImplementationTest : public GLES2CommandBufferTestBase { } virtual void TearDown() { + Mock::VerifyAndClear(gl_.get()); + EXPECT_CALL(*command_buffer_, OnFlush(_)).Times(AnyNumber()); + gl_.reset(); } void Initialize(bool shared_resources, bool bind_generates_resource) { |