Chromium Code Reviews| Index: ui/gl/gl_version_info.cc |
| diff --git a/ui/gl/gl_version_info.cc b/ui/gl/gl_version_info.cc |
| index 07bc6bb76809fb35890efa17cbd53f7d2bd32a3e..6a572858cbc96a1b4ca4c39ae9e4266e2a4a24e2 100644 |
| --- a/ui/gl/gl_version_info.cc |
| +++ b/ui/gl/gl_version_info.cc |
| @@ -5,6 +5,7 @@ |
| #include "ui/gl/gl_version_info.h" |
| #include "base/strings/string_number_conversions.h" |
| +#include "base/strings/string_split.h" |
| #include "base/strings/string_tokenizer.h" |
| #include "base/strings/string_util.h" |
| @@ -21,30 +22,39 @@ bool DesktopCoreCommonCheck( |
| namespace gl { |
| -GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str, |
| +GLVersionInfo::GLVersionInfo(const char* version_str, |
| + const char* renderer_str, |
| const char* extensions_str) |
| - : GLVersionInfo(version_str, renderer_str) { |
| - is_desktop_core_profile = |
| - DesktopCoreCommonCheck(is_es, major_version, minor_version) && |
| - !strstr(extensions_str, "GL_ARB_compatibility"); |
| + : GLVersionInfo() { |
| + std::set<std::string> extensions; |
| + if (extensions_str) { |
| + auto split = base::SplitString(extensions_str, " ", base::KEEP_WHITESPACE, |
| + base::SPLIT_WANT_NONEMPTY); |
| + extensions.insert(split.begin(), split.end()); |
| + } |
| + Initialize(version_str, renderer_str, extensions); |
| } |
| -GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str, |
| +GLVersionInfo::GLVersionInfo(const char* version_str, |
| + const char* renderer_str, |
| const std::set<std::string>& extensions) |
| - : GLVersionInfo(version_str, renderer_str) { |
| - is_desktop_core_profile = |
| - DesktopCoreCommonCheck(is_es, major_version, minor_version) && |
| - extensions.find("GL_ARB_compatibility") == extensions.end(); |
| + : GLVersionInfo() { |
| + Initialize(version_str, renderer_str, extensions); |
| } |
| -GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str) |
| +GLVersionInfo::GLVersionInfo() |
| : is_es(false), |
| is_angle(false), |
| major_version(0), |
| minor_version(0), |
| is_es2(false), |
| is_es3(false), |
| - is_desktop_core_profile(false) { |
| + is_desktop_core_profile(false), |
| + is_es3_capable(false) {} |
| + |
| +void GLVersionInfo::Initialize(const char* version_str, |
| + const char* renderer_str, |
| + const std::set<std::string>& extensions) { |
| if (version_str) { |
| ParseVersionString(version_str, &major_version, &minor_version, |
| &is_es, &is_es2, &is_es3); |
| @@ -53,6 +63,45 @@ GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str) |
| is_angle = base::StartsWith(renderer_str, "ANGLE", |
| base::CompareCase::SENSITIVE); |
| } |
| + is_desktop_core_profile = |
| + DesktopCoreCommonCheck(is_es, major_version, minor_version) && |
| + extensions.find("GL_ARB_compatibility") == extensions.end(); |
| + is_es3_capable = IsES3Capable(extensions); |
| +} |
| + |
| +bool GLVersionInfo::IsES3Capable( |
| + const std::set<std::string>& extensions) const { |
| + auto hasExtension = [&extensions](std::string extension) -> bool { |
|
piman
2016/06/24 21:38:56
nit: has_extension
Corentin Wallez
2016/06/27 15:35:42
Done
|
| + return extensions.find(extension) != extensions.end(); |
| + }; |
| + |
| + // Version ES3 capable without extensions needed. |
| + if (IsAtLeastGLES(3, 0) || IsAtLeastGL(4, 2)) { |
| + return true; |
| + } |
| + |
| + // Don't try supporting ES3 on ES2, or desktop before 3.2 because there are no |
| + // extension that allow querying for GL_MAX_FRAGMENT_INPUT_COMPONENTS |
| + if (is_es || !IsAtLeastGL(3, 2)) { |
| + return false; |
| + } |
| + |
| + bool hasShaderPacking = IsAtLeastGL(4, 2) || |
|
piman
2016/06/24 21:38:56
nit: has_shader_packing
piman
2016/06/24 21:38:56
nit: we already did early out if IsAtLeastGL(4, 2)
Corentin Wallez
2016/06/27 15:35:42
Done (both)
|
| + hasExtension("GL_ARB_shading_bit_packing") || |
| + hasExtension("GL_ARB_shader_bit_encoding"); |
| + bool hasTransformFeedback = |
|
piman
2016/06/24 21:38:56
nit: has_transform_feedback
Corentin Wallez
2016/06/27 15:35:42
Done
|
| + IsAtLeastGL(4, 0) || hasExtension("GL_ARB_transform_feedback2"); |
| + bool hasSamplers = IsAtLeastGL(3, 3) || hasExtension("GL_ARB_sampler_object"); |
|
piman
2016/06/24 21:38:56
nit: has_samplers
Corentin Wallez
2016/06/27 15:35:42
Done
|
| + bool hasSwizzle = IsAtLeastGL(3, 3) || |
|
piman
2016/06/24 21:38:56
nit: has_swizzle
Corentin Wallez
2016/06/27 15:35:42
Done
|
| + hasExtension("GL_ARB_texture_swizzle") || |
| + hasExtension("GL_EXT_texture_swizzle"); |
| + bool hasAttribLocation = |
|
piman
2016/06/24 21:38:56
nit: has_attrib_location
Corentin Wallez
2016/06/27 15:35:42
Done
|
| + IsAtLeastGL(3, 3) || hasExtension("GL_ARB_explicit_attrib_location"); |
| + |
| + // TODO(cwallez) check for texture related extensions. |
|
Zhenyao Mo
2016/06/24 21:35:50
Please create a bug so we don't end up forgetting
Corentin Wallez
2016/06/27 15:35:42
Done
|
| + |
| + return hasShaderPacking && hasTransformFeedback && hasSamplers && |
| + hasSwizzle && hasAttribLocation; |
| } |
| void GLVersionInfo::ParseVersionString(const char* version_str, |