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

Unified Diff: gpu/command_buffer/common/gles2_cmd_utils.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
Index: gpu/command_buffer/common/gles2_cmd_utils.cc
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index ea0bd7387487462c7ef9b953fcb2bffd739491d8..3ceaad890afa02e8507b36e78df760a6e57a6ade 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -667,6 +667,39 @@ std::string GLES2Util::GetQualifiedEnumString(
return GetStringEnum(value);
}
+bool GLES2Util::ParseUniformName(
+ const std::string& name,
+ size_t* array_pos,
+ int* element_index,
+ bool* getting_array) {
+ bool getting_array_location = false;
+ size_t open_pos = std::string::npos;
+ int index = 0;
+ if (name[name.size() - 1] == ']') {
+ if (name.size() < 3) {
+ return false;
+ }
+ open_pos = name.find_last_of('[');
+ if (open_pos == std::string::npos ||
+ open_pos >= name.size() - 2) {
+ return false;
+ }
+ size_t last = name.size() - 1;
+ for (size_t pos = open_pos + 1; pos < last; ++pos) {
+ int8 digit = name[pos] - '0';
+ if (digit < 0 || digit > 9) {
+ return false;
+ }
+ index = index * 10 + digit;
+ }
+ getting_array_location = true;
+ }
+ *getting_array = getting_array_location;
+ *element_index = index;
+ *array_pos = open_pos;
+ return true;
+}
+
ContextCreationAttribParser::ContextCreationAttribParser()
: alpha_size_(-1),
blue_size_(-1),

Powered by Google App Engine
This is Rietveld 408576698