summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/program_manager.cc
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 16:07:46 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 16:07:46 +0000
commit4e474231c1e813aee06704812685b1e74110bc91 (patch)
tree900e932be19f20ea89e1ed7f4970440f27502411 /gpu/command_buffer/service/program_manager.cc
parent7cadb41e59cf41cec77ad58b4fe2b96fb0a65ded (diff)
downloadchromium_src-4e474231c1e813aee06704812685b1e74110bc91.zip
chromium_src-4e474231c1e813aee06704812685b1e74110bc91.tar.gz
chromium_src-4e474231c1e813aee06704812685b1e74110bc91.tar.bz2
Fix bug in shader and program managers.
The bug was that the code would search by id instead of by pointer. This meant it was possible to free the wrong thing (ie, pass in an info with id=4 and free a different info that also happened to have id=4). This was most likely to happen when calling MarkAsDeleted since MarkAsDelete sets the id to 0. TEST=unit tests BUG=75629 R=apatrick@chromium.org Review URL: http://codereview.chromium.org/6721010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79130 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/program_manager.cc')
-rw-r--r--gpu/command_buffer/service/program_manager.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index 683449a..b52c017 100644
--- a/gpu/command_buffer/service/program_manager.cc
+++ b/gpu/command_buffer/service/program_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -454,15 +454,26 @@ bool ProgramManager::GetClientId(GLuint service_id, GLuint* client_id) const {
return false;
}
+bool ProgramManager::IsOwned(ProgramManager::ProgramInfo* info) {
+ for (ProgramInfoMap::iterator it = program_infos_.begin();
+ it != program_infos_.end(); ++it) {
+ if (it->second.get() == info) {
+ return true;
+ }
+ }
+ return false;
+}
+
void ProgramManager::RemoveProgramInfoIfUnused(
ShaderManager* shader_manager, ProgramInfo* info) {
DCHECK(shader_manager);
DCHECK(info);
+ DCHECK(IsOwned(info));
if (info->IsDeleted() && !info->InUse()) {
info->DetachShaders(shader_manager);
for (ProgramInfoMap::iterator it = program_infos_.begin();
it != program_infos_.end(); ++it) {
- if (it->second->service_id() == info->service_id()) {
+ if (it->second.get() == info) {
program_infos_.erase(it);
return;
}
@@ -476,12 +487,14 @@ void ProgramManager::MarkAsDeleted(
ProgramManager::ProgramInfo* info) {
DCHECK(shader_manager);
DCHECK(info);
+ DCHECK(IsOwned(info));
info->MarkAsDeleted();
RemoveProgramInfoIfUnused(shader_manager, info);
}
void ProgramManager::UseProgram(ProgramManager::ProgramInfo* info) {
DCHECK(info);
+ DCHECK(IsOwned(info));
info->IncUseCount();
}
@@ -490,6 +503,7 @@ void ProgramManager::UnuseProgram(
ProgramManager::ProgramInfo* info) {
DCHECK(shader_manager);
DCHECK(info);
+ DCHECK(IsOwned(info));
info->DecUseCount();
RemoveProgramInfoIfUnused(shader_manager, info);
}