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

Unified Diff: gpu/command_buffer/service/program_manager.cc

Issue 6721010: Fix bug in shader and program managers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/program_manager.cc
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index 683449a05ad220d74fc0f294aa7219ca00fa1ca8..b52c017bc83d040761e08a376e38a893409e0299 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);
}
« no previous file with comments | « gpu/command_buffer/service/program_manager.h ('k') | gpu/command_buffer/service/program_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698