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