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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils.cc

Issue 2070283002: Use container::back() and container::pop_back(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 <sstream> 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
9
9 #include <GLES2/gl2.h> 10 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 11 #include <GLES2/gl2ext.h>
11 #include <GLES2/gl2extchromium.h> 12 #include <GLES2/gl2extchromium.h>
12 #include <GLES3/gl3.h> 13 #include <GLES3/gl3.h>
13 14
15 #include <sstream>
16
14 #include "base/numerics/safe_math.h" 17 #include "base/numerics/safe_math.h"
15 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
16 18
17 namespace gpu { 19 namespace gpu {
18 namespace gles2 { 20 namespace gles2 {
19 21
20 namespace gl_error_bit { 22 namespace gl_error_bit {
21 enum GLErrorBit { 23 enum GLErrorBit {
22 kNoError = 0, 24 kNoError = 0,
23 kInvalidEnum = (1 << 0), 25 kInvalidEnum = (1 << 0),
24 kInvalidValue = (1 << 1), 26 kInvalidValue = (1 << 1),
25 kInvalidOperation = (1 << 2), 27 kInvalidOperation = (1 << 2),
26 kOutOfMemory = (1 << 3), 28 kOutOfMemory = (1 << 3),
27 kInvalidFrameBufferOperation = (1 << 4), 29 kInvalidFrameBufferOperation = (1 << 4),
28 kContextLost = (1 << 5) 30 kContextLost = (1 << 5)
29 }; 31 };
30 } 32 } // namespace gl_error_bit
31 33
32 int GLES2Util::GLGetNumValuesReturned(int id) const { 34 int GLES2Util::GLGetNumValuesReturned(int id) const {
33 switch (id) { 35 switch (id) {
34 // -- glGetBooleanv, glGetFloatv, glGetIntergerv 36 // -- glGetBooleanv, glGetFloatv, glGetIntergerv
35 case GL_ACTIVE_TEXTURE: 37 case GL_ACTIVE_TEXTURE:
36 return 1; 38 return 1;
37 case GL_ALIASED_LINE_WIDTH_RANGE: 39 case GL_ALIASED_LINE_WIDTH_RANGE:
38 return 2; 40 return 2;
39 case GL_ALIASED_POINT_SIZE_RANGE: 41 case GL_ALIASED_POINT_SIZE_RANGE:
40 return 2; 42 return 2;
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 GL_COLOR_ATTACHMENT0 + max_color_attachments)) { 1449 GL_COLOR_ATTACHMENT0 + max_color_attachments)) {
1448 return kRGBA; 1450 return kRGBA;
1449 } 1451 }
1450 return 0x0000; 1452 return 0x0000;
1451 } 1453 }
1452 } 1454 }
1453 1455
1454 std::string GLES2Util::GetStringEnum(uint32_t value) { 1456 std::string GLES2Util::GetStringEnum(uint32_t value) {
1455 const EnumToString* entry = enum_to_string_table_; 1457 const EnumToString* entry = enum_to_string_table_;
1456 const EnumToString* end = entry + enum_to_string_table_len_; 1458 const EnumToString* end = entry + enum_to_string_table_len_;
1457 for (;entry < end; ++entry) { 1459 for (; entry < end; ++entry) {
1458 if (value == entry->value) { 1460 if (value == entry->value)
1459 return entry->name; 1461 return entry->name;
1460 }
1461 } 1462 }
1462 std::stringstream ss; 1463 std::stringstream ss;
1463 ss.fill('0'); 1464 ss.fill('0');
1464 ss.width(value < 0x10000 ? 4 : 8); 1465 ss.width(value < 0x10000 ? 4 : 8);
1465 ss << std::hex << value; 1466 ss << std::hex << value;
1466 return "0x" + ss.str(); 1467 return "0x" + ss.str();
1467 } 1468 }
1468 1469
1469 std::string GLES2Util::GetStringError(uint32_t value) { 1470 std::string GLES2Util::GetStringError(uint32_t value) {
1470 static EnumToString string_table[] = { 1471 static EnumToString string_table[] = {
(...skipping 14 matching lines...) Expand all
1485 if (table->value == value) { 1486 if (table->value == value) {
1486 return table->name; 1487 return table->name;
1487 } 1488 }
1488 } 1489 }
1489 return GetStringEnum(value); 1490 return GetStringEnum(value);
1490 } 1491 }
1491 1492
1492 GLSLArrayName::GLSLArrayName(const std::string& name) : element_index_(-1) { 1493 GLSLArrayName::GLSLArrayName(const std::string& name) : element_index_(-1) {
1493 if (name.size() < 4) 1494 if (name.size() < 4)
1494 return; 1495 return;
1495 if (name[name.size() - 1] != ']') 1496 if (name.back() != ']')
1496 return; 1497 return;
1497 1498
1498 size_t open_pos = name.find_last_of('['); 1499 size_t open_pos = name.find_last_of('[');
1499 if (open_pos >= name.size() - 2) 1500 if (open_pos >= name.size() - 2)
1500 return; 1501 return;
1501 1502
1502 base::CheckedNumeric<int> index = 0; 1503 base::CheckedNumeric<int> index = 0;
1503 size_t last = name.size() - 1; 1504 size_t last = name.size() - 1;
1504 for (size_t pos = open_pos + 1; pos < last; ++pos) { 1505 for (size_t pos = open_pos + 1; pos < last; ++pos) {
1505 int8_t digit = name[pos] - '0'; 1506 int8_t digit = name[pos] - '0';
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 } 1876 }
1876 1877
1877 return true; 1878 return true;
1878 } 1879 }
1879 1880
1880 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" 1881 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h"
1881 1882
1882 } // namespace gles2 1883 } // namespace gles2
1883 } // namespace gpu 1884 } // namespace gpu
1884 1885
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/program_info_manager.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698