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

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

Issue 6733045: Merge 79130 - Fix bug in shader and program managers. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/696/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
« no previous file with comments | « gpu/command_buffer/service/shader_manager.h ('k') | gpu/command_buffer/service/shader_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/shader_manager.cc
===================================================================
--- gpu/command_buffer/service/shader_manager.cc (revision 79346)
+++ gpu/command_buffer/service/shader_manager.cc (working copy)
@@ -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.
@@ -8,6 +8,30 @@
namespace gpu {
namespace gles2 {
+ShaderManager::ShaderInfo::ShaderInfo(GLuint service_id, GLenum shader_type)
+ : use_count_(0),
+ service_id_(service_id),
+ shader_type_(shader_type),
+ valid_(false) {
+}
+
+ShaderManager::ShaderInfo::~ShaderInfo() {
+}
+
+void ShaderManager::ShaderInfo::IncUseCount() {
+ ++use_count_;
+}
+
+void ShaderManager::ShaderInfo::DecUseCount() {
+ --use_count_;
+ DCHECK_GE(use_count_, 0);
+}
+
+void ShaderManager::ShaderInfo::MarkAsDeleted() {
+ DCHECK_NE(service_id_, 0u);
+ service_id_ = 0;
+}
+
void ShaderManager::ShaderInfo::SetStatus(
bool valid, const char* log, ShaderTranslatorInterface* translator) {
valid_ = valid;
@@ -80,12 +104,23 @@
return false;
}
+bool ShaderManager::IsOwned(ShaderManager::ShaderInfo* info) {
+ for (ShaderInfoMap::iterator it = shader_infos_.begin();
+ it != shader_infos_.end(); ++it) {
+ if (it->second.get() == info) {
+ return true;
+ }
+ }
+ return false;
+}
+
void ShaderManager::RemoveShaderInfoIfUnused(ShaderManager::ShaderInfo* info) {
DCHECK(info);
+ DCHECK(IsOwned(info));
if (info->IsDeleted() && !info->InUse()) {
for (ShaderInfoMap::iterator it = shader_infos_.begin();
it != shader_infos_.end(); ++it) {
- if (it->second->service_id() == info->service_id()) {
+ if (it->second.get() == info) {
shader_infos_.erase(it);
return;
}
@@ -96,17 +131,20 @@
void ShaderManager::MarkAsDeleted(ShaderManager::ShaderInfo* info) {
DCHECK(info);
+ DCHECK(IsOwned(info));
info->MarkAsDeleted();
RemoveShaderInfoIfUnused(info);
}
void ShaderManager::UseShader(ShaderManager::ShaderInfo* info) {
DCHECK(info);
+ DCHECK(IsOwned(info));
info->IncUseCount();
}
void ShaderManager::UnuseShader(ShaderManager::ShaderInfo* info) {
DCHECK(info);
+ DCHECK(IsOwned(info));
info->DecUseCount();
RemoveShaderInfoIfUnused(info);
}
« no previous file with comments | « gpu/command_buffer/service/shader_manager.h ('k') | gpu/command_buffer/service/shader_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698