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

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

Issue 2857083002: Fix behavior of GetOriginalNameFromHashedName (Closed)
Patch Set: remove GetMappedName Created 3 years, 7 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
« no previous file with comments | « gpu/command_buffer/service/shader_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 const std::string& original_name) const { 217 const std::string& original_name) const {
218 for (const auto& value : output_variable_list_) { 218 for (const auto& value : output_variable_list_) {
219 if (value.name == original_name) 219 if (value.name == original_name)
220 return &value.mappedName; 220 return &value.mappedName;
221 } 221 }
222 return nullptr; 222 return nullptr;
223 } 223 }
224 224
225 const std::string* Shader::GetOriginalNameFromHashedName( 225 const std::string* Shader::GetOriginalNameFromHashedName(
226 const std::string& hashed_name) const { 226 const std::string& hashed_name) const {
227 NameMap::const_iterator it = name_map_.find(hashed_name); 227 if (const auto* info = GetAttribInfo(hashed_name)) {
228 if (it != name_map_.end()) 228 return &info->name;
229 return &(it->second);
230 return NULL;
231 }
232
233 const std::string* Shader::GetMappedName(
234 const std::string& original_name) const {
235 for (const auto& key_value : name_map_) {
236 if (key_value.second == original_name)
237 return &(key_value.first);
238 } 229 }
239 return NULL; 230 if (const auto* info = GetUniformInfo(hashed_name)) {
231 return &info->name;
232 }
233 if (const auto* info = GetVaryingInfo(hashed_name)) {
234 return &info->name;
235 }
236 if (const auto* info = GetInterfaceBlockInfo(hashed_name)) {
237 return &info->name;
238 }
239 if (const auto* info = GetOutputVariableInfo(hashed_name)) {
240 return &info->name;
241 }
242 return nullptr;
240 } 243 }
241 244
242 const sh::Uniform* Shader::GetUniformInfo(const std::string& name) const { 245 const sh::Uniform* Shader::GetUniformInfo(const std::string& name) const {
243 UniformMap::const_iterator it = uniform_map_.find(GetTopVariableName(name)); 246 UniformMap::const_iterator it = uniform_map_.find(GetTopVariableName(name));
244 return it != uniform_map_.end() ? &it->second : NULL; 247 return it != uniform_map_.end() ? &it->second : NULL;
245 } 248 }
246 249
247 const sh::Varying* Shader::GetVaryingInfo(const std::string& name) const { 250 const sh::Varying* Shader::GetVaryingInfo(const std::string& name) const {
248 VaryingMap::const_iterator it = varying_map_.find(GetTopVariableName(name)); 251 VaryingMap::const_iterator it = varying_map_.find(GetTopVariableName(name));
249 return it != varying_map_.end() ? &it->second : NULL; 252 return it != varying_map_.end() ? &it->second : NULL;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 359
357 void ShaderManager::UnuseShader(Shader* shader) { 360 void ShaderManager::UnuseShader(Shader* shader) {
358 DCHECK(shader); 361 DCHECK(shader);
359 DCHECK(IsOwned(shader)); 362 DCHECK(IsOwned(shader));
360 shader->DecUseCount(); 363 shader->DecUseCount();
361 RemoveShader(shader); 364 RemoveShader(shader);
362 } 365 }
363 366
364 } // namespace gles2 367 } // namespace gles2
365 } // namespace gpu 368 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698