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

Side by Side Diff: ui/gl/gl_version_info.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « ui/gl/gl_version_info.h ('k') | ui/gl/gl_wgl_api_implementation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/gl/gl_version_info.h" 5 #include "ui/gl/gl_version_info.h"
6 6
7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_tokenizer.h"
7 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
8 10
9 namespace gfx { 11 namespace gfx {
10 12
11 GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str) 13 GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str)
12 : is_es(false), 14 : is_es(false),
13 is_es1(false), 15 is_angle(false),
14 is_es2(false), 16 major_version(0),
15 is_es3(false), 17 minor_version(0),
16 is_gl1(false), 18 is_es3(false) {
17 is_gl2(false),
18 is_gl3(false),
19 is_gl4(false),
20 is_angle(false) {
21 if (version_str) { 19 if (version_str) {
22 std::string lstr(base::StringToLowerASCII(std::string(version_str))); 20 std::string lstr(base::StringToLowerASCII(std::string(version_str)));
23 is_es = (lstr.substr(0, 9) == "opengl es"); 21 is_es = (lstr.length() > 12) && (lstr.substr(0, 9) == "opengl es");
24 if (is_es) { 22 if (is_es)
25 is_es1 = (lstr.substr(9, 2) == "-c" && lstr.substr(13, 2) == "1."); 23 lstr = lstr.substr(10, 3);
26 is_es2 = (lstr.substr(9, 3) == " 2."); 24 base::StringTokenizer tokenizer(lstr.begin(), lstr.end(), ".");
27 is_es3 = (lstr.substr(9, 3) == " 3."); 25 unsigned major, minor;
28 } else { 26 if (tokenizer.GetNext() &&
29 is_gl2 = (lstr.substr(0, 2) == "2."); 27 base::StringToUint(tokenizer.token_piece(), &major)) {
30 is_gl3 = (lstr.substr(0, 2) == "3."); 28 major_version = major;
31 is_gl4 = (lstr.substr(0, 2) == "4."); 29 if (tokenizer.GetNext() &&
32 // In early GL versions, GetString output format is implementation 30 base::StringToUint(tokenizer.token_piece(), &minor)) {
33 // dependent. 31 minor_version = minor;
34 is_gl1 = !is_gl2 && !is_gl3 && !is_gl4; 32 }
35 } 33 }
34 if (is_es && major_version == 3)
35 is_es3 = true;
36 } 36 }
37 if (renderer_str) { 37 if (renderer_str) {
38 is_angle = StartsWithASCII(renderer_str, "ANGLE", true); 38 is_angle = StartsWithASCII(renderer_str, "ANGLE", true);
39 } 39 }
40 } 40 }
41 41
42 } // namespace gfx 42 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_version_info.h ('k') | ui/gl/gl_wgl_api_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698