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

Side by Side 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 unified diff | Download patch
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 // This file is here so other GLES2 related files can have a common set of 5 // This file is here so other GLES2 related files can have a common set of
6 // includes where appropriate. 6 // includes where appropriate.
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 std::string GLES2Util::GetQualifiedEnumString( 660 std::string GLES2Util::GetQualifiedEnumString(
661 const EnumToString* table, size_t count, uint32 value) { 661 const EnumToString* table, size_t count, uint32 value) {
662 for (const EnumToString* end = table + count; table < end; ++table) { 662 for (const EnumToString* end = table + count; table < end; ++table) {
663 if (table->value == value) { 663 if (table->value == value) {
664 return table->name; 664 return table->name;
665 } 665 }
666 } 666 }
667 return GetStringEnum(value); 667 return GetStringEnum(value);
668 } 668 }
669 669
670 bool GLES2Util::ParseUniformName(
671 const std::string& name,
672 size_t* array_pos,
673 int* element_index,
674 bool* getting_array) {
675 bool getting_array_location = false;
676 size_t open_pos = std::string::npos;
677 int index = 0;
678 if (name[name.size() - 1] == ']') {
679 if (name.size() < 3) {
680 return false;
681 }
682 open_pos = name.find_last_of('[');
683 if (open_pos == std::string::npos ||
684 open_pos >= name.size() - 2) {
685 return false;
686 }
687 size_t last = name.size() - 1;
688 for (size_t pos = open_pos + 1; pos < last; ++pos) {
689 int8 digit = name[pos] - '0';
690 if (digit < 0 || digit > 9) {
691 return false;
692 }
693 index = index * 10 + digit;
694 }
695 getting_array_location = true;
696 }
697 *getting_array = getting_array_location;
698 *element_index = index;
699 *array_pos = open_pos;
700 return true;
701 }
702
670 ContextCreationAttribParser::ContextCreationAttribParser() 703 ContextCreationAttribParser::ContextCreationAttribParser()
671 : alpha_size_(-1), 704 : alpha_size_(-1),
672 blue_size_(-1), 705 blue_size_(-1),
673 green_size_(-1), 706 green_size_(-1),
674 red_size_(-1), 707 red_size_(-1),
675 depth_size_(-1), 708 depth_size_(-1),
676 stencil_size_(-1), 709 stencil_size_(-1),
677 samples_(-1), 710 samples_(-1),
678 sample_buffers_(-1), 711 sample_buffers_(-1),
679 buffer_preserved_(true), 712 buffer_preserved_(true),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 } 789 }
757 790
758 return true; 791 return true;
759 } 792 }
760 793
761 #include "../common/gles2_cmd_utils_implementation_autogen.h" 794 #include "../common/gles2_cmd_utils_implementation_autogen.h"
762 795
763 } // namespace gles2 796 } // namespace gles2
764 } // namespace gpu 797 } // namespace gpu
765 798
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698