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

Side by Side Diff: gpu/command_buffer/service/shader_manager.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 DCHECK_GE(use_count_, 0); 71 DCHECK_GE(use_count_, 0);
72 return use_count_ != 0; 72 return use_count_ != 0;
73 } 73 }
74 74
75 private: 75 private:
76 typedef ShaderTranslator::VariableMap VariableMap; 76 typedef ShaderTranslator::VariableMap VariableMap;
77 77
78 friend class base::RefCounted<ShaderInfo>; 78 friend class base::RefCounted<ShaderInfo>;
79 friend class ShaderManager; 79 friend class ShaderManager;
80 80
81 ShaderInfo(GLuint service_id, GLenum shader_type) 81 ShaderInfo(GLuint service_id, GLenum shader_type);
82 : use_count_(0), 82 ~ShaderInfo();
83 service_id_(service_id),
84 shader_type_(shader_type),
85 valid_(false) {
86 }
87 83
88 ~ShaderInfo() { } 84 void IncUseCount();
89 85 void DecUseCount();
90 void IncUseCount() { 86 void MarkAsDeleted();
91 ++use_count_;
92 }
93
94 void DecUseCount() {
95 --use_count_;
96 DCHECK_GE(use_count_, 0);
97 }
98
99 void MarkAsDeleted() {
100 DCHECK_NE(service_id_, 0u);
101 service_id_ = 0;
102 }
103 87
104 int use_count_; 88 int use_count_;
105 89
106 // The shader this ShaderInfo is tracking. 90 // The shader this ShaderInfo is tracking.
107 GLuint service_id_; 91 GLuint service_id_;
108 // Type of shader - GL_VERTEX_SHADER or GL_FRAGMENT_SHADER. 92 // Type of shader - GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
109 GLenum shader_type_; 93 GLenum shader_type_;
110 94
111 // True if compilation succeeded. 95 // True if compilation succeeded.
112 bool valid_; 96 bool valid_;
(...skipping 29 matching lines...) Expand all
142 126
143 void MarkAsDeleted(ShaderInfo* info); 127 void MarkAsDeleted(ShaderInfo* info);
144 128
145 // Mark a shader as used 129 // Mark a shader as used
146 void UseShader(ShaderInfo* info); 130 void UseShader(ShaderInfo* info);
147 131
148 // Unmark a shader as used. If it has been deleted and is not used 132 // Unmark a shader as used. If it has been deleted and is not used
149 // then we free the info. 133 // then we free the info.
150 void UnuseShader(ShaderInfo* info); 134 void UnuseShader(ShaderInfo* info);
151 135
136 // Check if a ShaderInfo is owned by this ShaderManager.
137 bool IsOwned(ShaderInfo* info);
138
152 private: 139 private:
153 // Info for each shader by service side shader Id. 140 // Info for each shader by service side shader Id.
154 typedef std::map<GLuint, ShaderInfo::Ref> ShaderInfoMap; 141 typedef std::map<GLuint, ShaderInfo::Ref> ShaderInfoMap;
155 ShaderInfoMap shader_infos_; 142 ShaderInfoMap shader_infos_;
156 143
157 void RemoveShaderInfoIfUnused(ShaderInfo* info); 144 void RemoveShaderInfoIfUnused(ShaderInfo* info);
158 145
159 DISALLOW_COPY_AND_ASSIGN(ShaderManager); 146 DISALLOW_COPY_AND_ASSIGN(ShaderManager);
160 }; 147 };
161 148
162 } // namespace gles2 149 } // namespace gles2
163 } // namespace gpu 150 } // namespace gpu
164 151
165 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ 152 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_
166 153
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager_unittest.cc ('k') | gpu/command_buffer/service/shader_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698