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

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

Issue 5676003: Make shader and program object lifetimes match OpenGL ES spec.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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 68425)
+++ gpu/command_buffer/service/shader_manager.cc (working copy)
@@ -68,14 +68,6 @@
return it != shader_infos_.end() ? it->second : NULL;
}
-void ShaderManager::RemoveShaderInfo(GLuint client_id) {
- ShaderInfoMap::iterator it = shader_infos_.find(client_id);
- if (it != shader_infos_.end()) {
- it->second->MarkAsDeleted();
- shader_infos_.erase(it);
- }
-}
-
bool ShaderManager::GetClientId(GLuint service_id, GLuint* client_id) const {
// This doesn't need to be fast. It's only used during slow queries.
for (ShaderInfoMap::const_iterator it = shader_infos_.begin();
@@ -88,6 +80,37 @@
return false;
}
+void ShaderManager::RemoveShaderInfoIfUnused(ShaderManager::ShaderInfo* info) {
+ DCHECK(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()) {
+ shader_infos_.erase(it);
+ return;
+ }
+ }
+ NOTREACHED();
+ }
+}
+
+void ShaderManager::MarkAsDeleted(ShaderManager::ShaderInfo* info) {
+ DCHECK(info);
+ info->MarkAsDeleted();
+ RemoveShaderInfoIfUnused(info);
+}
+
+void ShaderManager::UseShader(ShaderManager::ShaderInfo* info) {
+ DCHECK(info);
+ info->IncUseCount();
+}
+
+void ShaderManager::UnuseShader(ShaderManager::ShaderInfo* info) {
+ DCHECK(info);
+ info->DecUseCount();
+ RemoveShaderInfoIfUnused(info);
+}
+
} // namespace gles2
} // namespace gpu
« 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