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

Unified Diff: gpu/command_buffer/client/program_info_manager.cc

Issue 10855274: Fix Uniform Name Parsing (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/program_info_manager.cc
diff --git a/gpu/command_buffer/client/program_info_manager.cc b/gpu/command_buffer/client/program_info_manager.cc
index 86fbd13e9b830dc80ec477e6d49b51402ded4625..eb5ee32cb3bf64f2cfe5c24c02af658b71cb005e 100644
--- a/gpu/command_buffer/client/program_info_manager.cc
+++ b/gpu/command_buffer/client/program_info_manager.cc
@@ -5,6 +5,7 @@
#include "../client/program_info_manager.h"
#include "../client/atomicops.h"
#include "../client/gles2_implementation.h"
+#include "../common/gles2_cmd_utils.h"
#include <map>
@@ -226,35 +227,27 @@ GLint CachedProgramInfoManager::ProgramInfo::GetAttribLocation(
return -1;
}
-// TODO(gman): Add a faster lookup.
GLint CachedProgramInfoManager::ProgramInfo::GetUniformLocation(
const std::string& name) const {
+ bool getting_array_location = false;
+ size_t open_pos = std::string::npos;
+ int index = 0;
+ if (!GLES2Util::ParseUniformName(
+ name, &open_pos, &index, &getting_array_location)) {
+ return -1;
+ }
for (GLuint ii = 0; ii < uniform_infos_.size(); ++ii) {
const UniformInfo& info = uniform_infos_[ii];
if (info.name == name ||
(info.is_array &&
info.name.compare(0, info.name.size() - 3, name) == 0)) {
return info.element_locations[0];
- } else if (info.is_array &&
- name.size() >= 3 && name[name.size() - 1] == ']') {
+ } else if (getting_array_location && info.is_array) {
// Look for an array specification.
- size_t open_pos = name.find_last_of('[');
- if (open_pos != std::string::npos &&
- open_pos < name.size() - 2 &&
- info.name.size() > open_pos &&
+ size_t open_pos_2 = info.name.find_last_of('[');
+ if (open_pos_2 == open_pos &&
name.compare(0, open_pos, info.name, 0, open_pos) == 0) {
- GLint index = 0;
- size_t last = name.size() - 1;
- bool bad = false;
- for (size_t pos = open_pos + 1; pos < last; ++pos) {
- int8 digit = name[pos] - '0';
- if (digit < 0 || digit > 9) {
- bad = true;
- break;
- }
- index = index * 10 + digit;
- }
- if (!bad && index >= 0 && index < info.size) {
+ if (index >= 0 && index < info.size) {
return info.element_locations[index];
}
}
« no previous file with comments | « no previous file | gpu/command_buffer/common/gles2_cmd_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698