| OLD | NEW |
| 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" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_tokenizer.h" | 8 #include "base/strings/string_tokenizer.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 is_desktop_core_profile = | 36 is_desktop_core_profile = |
| 37 DesktopCoreCommonCheck(is_es, major_version, minor_version) && | 37 DesktopCoreCommonCheck(is_es, major_version, minor_version) && |
| 38 extensions.find("GL_ARB_compatibility") == extensions.end(); | 38 extensions.find("GL_ARB_compatibility") == extensions.end(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str) | 41 GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str) |
| 42 : is_es(false), | 42 : is_es(false), |
| 43 is_angle(false), | 43 is_angle(false), |
| 44 major_version(0), | 44 major_version(0), |
| 45 minor_version(0), | 45 minor_version(0), |
| 46 is_es2(false), | |
| 47 is_es3(false), | 46 is_es3(false), |
| 48 is_desktop_core_profile(false) { | 47 is_desktop_core_profile(false) { |
| 49 if (version_str) { | 48 if (version_str) { |
| 50 ParseVersionString(version_str, &major_version, &minor_version, | 49 ParseVersionString(version_str, &major_version, &minor_version, |
| 51 &is_es, &is_es2, &is_es3); | 50 &is_es, &is_es3); |
| 52 } | 51 } |
| 53 if (renderer_str) { | 52 if (renderer_str) { |
| 54 is_angle = base::StartsWith(renderer_str, "ANGLE", | 53 is_angle = base::StartsWith(renderer_str, "ANGLE", |
| 55 base::CompareCase::SENSITIVE); | 54 base::CompareCase::SENSITIVE); |
| 56 } | 55 } |
| 57 } | 56 } |
| 58 | 57 |
| 59 void GLVersionInfo::ParseVersionString(const char* version_str, | 58 void GLVersionInfo::ParseVersionString(const char* version_str, |
| 60 unsigned* major_version, | 59 unsigned* major_version, |
| 61 unsigned* minor_version, | 60 unsigned* minor_version, |
| 62 bool* is_es, | 61 bool* is_es, |
| 63 bool* is_es2, | |
| 64 bool* is_es3) { | 62 bool* is_es3) { |
| 65 // Make sure the outputs are always initialized. | 63 // Make sure the outputs are always initialized. |
| 66 *major_version = 0; | 64 *major_version = 0; |
| 67 *minor_version = 0; | 65 *minor_version = 0; |
| 68 *is_es = false; | 66 *is_es = false; |
| 69 *is_es2 = false; | |
| 70 *is_es3 = false; | 67 *is_es3 = false; |
| 71 if (!version_str) | 68 if (!version_str) |
| 72 return; | 69 return; |
| 73 std::string lstr(base::ToLowerASCII(version_str)); | 70 std::string lstr(base::ToLowerASCII(version_str)); |
| 74 *is_es = (lstr.length() > 12) && (lstr.substr(0, 9) == "opengl es"); | 71 *is_es = (lstr.length() > 12) && (lstr.substr(0, 9) == "opengl es"); |
| 75 if (*is_es) | 72 if (*is_es) |
| 76 lstr = lstr.substr(10, 3); | 73 lstr = lstr.substr(10, 3); |
| 77 base::StringTokenizer tokenizer(lstr.begin(), lstr.end(), "."); | 74 base::StringTokenizer tokenizer(lstr.begin(), lstr.end(), "."); |
| 78 unsigned major, minor; | 75 unsigned major, minor; |
| 79 if (tokenizer.GetNext() && | 76 if (tokenizer.GetNext() && |
| 80 base::StringToUint(tokenizer.token_piece(), &major)) { | 77 base::StringToUint(tokenizer.token_piece(), &major)) { |
| 81 *major_version = major; | 78 *major_version = major; |
| 82 if (tokenizer.GetNext() && | 79 if (tokenizer.GetNext() && |
| 83 base::StringToUint(tokenizer.token_piece(), &minor)) { | 80 base::StringToUint(tokenizer.token_piece(), &minor)) { |
| 84 *minor_version = minor; | 81 *minor_version = minor; |
| 85 } | 82 } |
| 86 } | 83 } |
| 87 if (*is_es && *major_version == 2) | |
| 88 *is_es2 = true; | |
| 89 if (*is_es && *major_version == 3) | 84 if (*is_es && *major_version == 3) |
| 90 *is_es3 = true; | 85 *is_es3 = true; |
| 91 DCHECK(major_version != 0); | 86 DCHECK(major_version != 0); |
| 92 } | 87 } |
| 93 | 88 |
| 94 } // namespace gfx | 89 } // namespace gfx |
| OLD | NEW |