| 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 #include "gpu/command_buffer/service/shader_manager.h" | 5 #include "gpu/command_buffer/service/shader_manager.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 | 8 |
| 9 namespace gpu { | 9 namespace gpu { |
| 10 namespace gles2 { | 10 namespace gles2 { |
| 11 | 11 |
| 12 ShaderManager::ShaderInfo::ShaderInfo(GLuint service_id, GLenum shader_type) | 12 ShaderManager::ShaderInfo::ShaderInfo(GLuint service_id, GLenum shader_type) |
| 13 : use_count_(0), | 13 : use_count_(0), |
| 14 service_id_(service_id), | 14 service_id_(service_id), |
| 15 shader_type_(shader_type), | 15 shader_type_(shader_type), |
| 16 valid_(false) { | 16 valid_(false), |
| 17 pending_cache_miss_compilation_(false) { |
| 17 } | 18 } |
| 18 | 19 |
| 19 ShaderManager::ShaderInfo::~ShaderInfo() { | 20 ShaderManager::ShaderInfo::~ShaderInfo() { |
| 20 } | 21 } |
| 21 | 22 |
| 22 void ShaderManager::ShaderInfo::IncUseCount() { | 23 void ShaderManager::ShaderInfo::IncUseCount() { |
| 23 ++use_count_; | 24 ++use_count_; |
| 24 } | 25 } |
| 25 | 26 |
| 26 void ShaderManager::ShaderInfo::DecUseCount() { | 27 void ShaderManager::ShaderInfo::DecUseCount() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 log_info_.reset(log ? new std::string(log) : NULL); | 40 log_info_.reset(log ? new std::string(log) : NULL); |
| 40 if (translator && valid) { | 41 if (translator && valid) { |
| 41 attrib_map_ = translator->attrib_map(); | 42 attrib_map_ = translator->attrib_map(); |
| 42 uniform_map_ = translator->uniform_map(); | 43 uniform_map_ = translator->uniform_map(); |
| 43 } else { | 44 } else { |
| 44 attrib_map_.clear(); | 45 attrib_map_.clear(); |
| 45 uniform_map_.clear(); | 46 uniform_map_.clear(); |
| 46 } | 47 } |
| 47 } | 48 } |
| 48 | 49 |
| 50 void ShaderManager::ShaderInfo::SetPendingCompilation( |
| 51 bool pending_cache_miss_compilation) { |
| 52 pending_cache_miss_compilation_ = pending_cache_miss_compilation; |
| 53 } |
| 54 |
| 49 const ShaderManager::ShaderInfo::VariableInfo* | 55 const ShaderManager::ShaderInfo::VariableInfo* |
| 50 ShaderManager::ShaderInfo::GetAttribInfo( | 56 ShaderManager::ShaderInfo::GetAttribInfo( |
| 51 const std::string& name) const { | 57 const std::string& name) const { |
| 52 VariableMap::const_iterator it = attrib_map_.find(name); | 58 VariableMap::const_iterator it = attrib_map_.find(name); |
| 53 return it != attrib_map_.end() ? &it->second : NULL; | 59 return it != attrib_map_.end() ? &it->second : NULL; |
| 54 } | 60 } |
| 55 | 61 |
| 56 const std::string* ShaderManager::ShaderInfo::GetAttribMappedName( | 62 const std::string* ShaderManager::ShaderInfo::GetAttribMappedName( |
| 57 const std::string& original_name) const { | 63 const std::string& original_name) const { |
| 58 for (VariableMap::const_iterator it = attrib_map_.begin(); | 64 for (VariableMap::const_iterator it = attrib_map_.begin(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 DCHECK(info); | 165 DCHECK(info); |
| 160 DCHECK(IsOwned(info)); | 166 DCHECK(IsOwned(info)); |
| 161 info->DecUseCount(); | 167 info->DecUseCount(); |
| 162 RemoveShaderInfoIfUnused(info); | 168 RemoveShaderInfoIfUnused(info); |
| 163 } | 169 } |
| 164 | 170 |
| 165 } // namespace gles2 | 171 } // namespace gles2 |
| 166 } // namespace gpu | 172 } // namespace gpu |
| 167 | 173 |
| 168 | 174 |
| OLD | NEW |