| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void RequestCompile(scoped_refptr<ShaderTranslatorInterface> translator, | 38 void RequestCompile(scoped_refptr<ShaderTranslatorInterface> translator, |
| 39 TranslatedShaderSourceType type); | 39 TranslatedShaderSourceType type); |
| 40 | 40 |
| 41 void DoCompile(); | 41 void DoCompile(); |
| 42 | 42 |
| 43 ShaderState shader_state() const { | 43 ShaderState shader_state() const { |
| 44 return shader_state_; | 44 return shader_state_; |
| 45 } | 45 } |
| 46 | 46 |
| 47 GLuint service_id() const { | 47 GLuint service_id() const { |
| 48 return service_id_; | 48 return marked_for_deletion_ ? 0 : service_id_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 GLenum shader_type() const { | 51 GLenum shader_type() const { |
| 52 return shader_type_; | 52 return shader_type_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 const std::string& source() const { | 55 const std::string& source() const { |
| 56 return source_; | 56 return source_; |
| 57 } | 57 } |
| 58 | 58 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 const std::string& log_info() const { | 91 const std::string& log_info() const { |
| 92 return log_info_; | 92 return log_info_; |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool valid() const { | 95 bool valid() const { |
| 96 return shader_state_ == kShaderStateCompiled && valid_; | 96 return shader_state_ == kShaderStateCompiled && valid_; |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool IsDeleted() const { | 99 bool IsDeleted() const { |
| 100 return service_id_ == 0; | 100 return marked_for_deletion_; |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool InUse() const { | 103 bool InUse() const { |
| 104 DCHECK_GE(use_count_, 0); | 104 DCHECK_GE(use_count_, 0); |
| 105 return use_count_ != 0; | 105 return use_count_ != 0; |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Used by program cache. | 108 // Used by program cache. |
| 109 const AttributeMap& attrib_map() const { | 109 const AttributeMap& attrib_map() const { |
| 110 return attrib_map_; | 110 return attrib_map_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 138 varying_map_ = VaryingMap(varying_map); | 138 varying_map_ = VaryingMap(varying_map); |
| 139 } | 139 } |
| 140 | 140 |
| 141 private: | 141 private: |
| 142 friend class base::RefCounted<Shader>; | 142 friend class base::RefCounted<Shader>; |
| 143 friend class ShaderManager; | 143 friend class ShaderManager; |
| 144 | 144 |
| 145 Shader(GLuint service_id, GLenum shader_type); | 145 Shader(GLuint service_id, GLenum shader_type); |
| 146 ~Shader(); | 146 ~Shader(); |
| 147 | 147 |
| 148 // Must be called only if we currently own the context. Forces the deletion |
| 149 // of the underlying shader service id. |
| 150 void Destroy(); |
| 151 |
| 148 void IncUseCount(); | 152 void IncUseCount(); |
| 149 void DecUseCount(); | 153 void DecUseCount(); |
| 150 void Delete(); | 154 void MarkForDeletion(); |
| 155 void DeleteServiceID(); |
| 151 | 156 |
| 152 int use_count_; | 157 int use_count_; |
| 153 | 158 |
| 154 // The current state of the shader. | 159 // The current state of the shader. |
| 155 ShaderState shader_state_; | 160 ShaderState shader_state_; |
| 156 | 161 |
| 162 // The shader has been marked for deletion. |
| 163 bool marked_for_deletion_; |
| 164 |
| 157 // The shader this Shader is tracking. | 165 // The shader this Shader is tracking. |
| 158 GLuint service_id_; | 166 GLuint service_id_; |
| 159 | 167 |
| 160 // Type of shader - GL_VERTEX_SHADER or GL_FRAGMENT_SHADER. | 168 // Type of shader - GL_VERTEX_SHADER or GL_FRAGMENT_SHADER. |
| 161 GLenum shader_type_; | 169 GLenum shader_type_; |
| 162 | 170 |
| 163 // Translated source type when shader was last requested to be compiled. | 171 // Translated source type when shader was last requested to be compiled. |
| 164 TranslatedShaderSourceType source_type_; | 172 TranslatedShaderSourceType source_type_; |
| 165 | 173 |
| 166 // Translator to use, set when shader was last requested to be compiled. | 174 // Translator to use, set when shader was last requested to be compiled. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 void RemoveShader(Shader* shader); | 245 void RemoveShader(Shader* shader); |
| 238 | 246 |
| 239 DISALLOW_COPY_AND_ASSIGN(ShaderManager); | 247 DISALLOW_COPY_AND_ASSIGN(ShaderManager); |
| 240 }; | 248 }; |
| 241 | 249 |
| 242 } // namespace gles2 | 250 } // namespace gles2 |
| 243 } // namespace gpu | 251 } // namespace gpu |
| 244 | 252 |
| 245 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ | 253 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ |
| 246 | 254 |
| OLD | NEW |