blob: e2aa0deab7997c1cf585371a3052d26704c6b7bc [file] [log] [blame]
[email protected]a37d7ff2014-01-17 21:31:001// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ui/gl/gl_version_info.h"
6
sieverse3b17fd52015-01-29 04:00:537#include "base/strings/string_number_conversions.h"
8#include "base/strings/string_tokenizer.h"
[email protected]a37d7ff2014-01-17 21:31:009#include "base/strings/string_util.h"
10
11namespace gfx {
12
[email protected]17a961192014-02-14 15:20:5213GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str)
[email protected]a37d7ff2014-01-17 21:31:0014 : is_es(false),
sieverse3b17fd52015-01-29 04:00:5315 is_angle(false),
16 major_version(0),
17 minor_version(0),
18 is_es3(false) {
[email protected]a37d7ff2014-01-17 21:31:0019 if (version_str) {
[email protected]cb1f4ac2014-08-07 16:55:4220 std::string lstr(base::StringToLowerASCII(std::string(version_str)));
sieverse3b17fd52015-01-29 04:00:5321 is_es = (lstr.length() > 12) && (lstr.substr(0, 9) == "opengl es");
22 if (is_es)
23 lstr = lstr.substr(10, 3);
24 base::StringTokenizer tokenizer(lstr.begin(), lstr.end(), ".");
25 unsigned major, minor;
26 if (tokenizer.GetNext() &&
27 base::StringToUint(tokenizer.token_piece(), &major)) {
28 major_version = major;
29 if (tokenizer.GetNext() &&
30 base::StringToUint(tokenizer.token_piece(), &minor)) {
31 minor_version = minor;
32 }
[email protected]a37d7ff2014-01-17 21:31:0033 }
sieverse3b17fd52015-01-29 04:00:5334 if (is_es && major_version == 3)
35 is_es3 = true;
[email protected]a37d7ff2014-01-17 21:31:0036 }
[email protected]17a961192014-02-14 15:20:5237 if (renderer_str) {
38 is_angle = StartsWithASCII(renderer_str, "ANGLE", true);
39 }
[email protected]a37d7ff2014-01-17 21:31:0040}
41
42} // namespace gfx