diff options
author | 2016-12-01 09:50:49 -0800 | |
---|---|---|
committer | 2016-12-01 09:50:49 -0800 | |
commit | b136c8556efaec0aa2645c1b3bb526c56c50b96c (patch) | |
tree | 855f839c527534215b00de1ff0ceeda61494a716 /libs/hwui/Extensions.cpp | |
parent | 986af188b67811792b60fdf948129d27ec35dd64 (diff) |
Query GL version before using it
Bug: 32984164
Test: manual testing of linear blending
Change-Id: Ie20bdc34d1b98e93eae22b15f3e2a7994d3b4ff7
Diffstat (limited to 'libs/hwui/Extensions.cpp')
-rw-r--r-- | libs/hwui/Extensions.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/libs/hwui/Extensions.cpp b/libs/hwui/Extensions.cpp index 1d675791b851..00238a25ebde 100644 --- a/libs/hwui/Extensions.cpp +++ b/libs/hwui/Extensions.cpp @@ -37,6 +37,26 @@ namespace uirenderer { Extensions::Extensions() { + const char* version = (const char*) glGetString(GL_VERSION); + + // Section 6.1.5 of the OpenGL ES specification indicates the GL version + // string strictly follows this format: + // + // OpenGL<space>ES<space><version number><space><vendor-specific information> + // + // In addition section 6.1.5 describes the version number thusly: + // + // "The version number is either of the form major number.minor number or + // major number.minor number.release number, where the numbers all have one + // or more digits. The release number and vendor specific information are + // optional." + + if (sscanf(version, "OpenGL ES %d.%d", &mVersionMajor, &mVersionMinor) != 2) { + // If we cannot parse the version number, assume OpenGL ES 2.0 + mVersionMajor = 2; + mVersionMinor = 0; + } + auto extensions = StringUtils::split((const char*) glGetString(GL_EXTENSIONS)); mHasNPot = extensions.has("GL_OES_texture_npot"); mHasFramebufferFetch = extensions.has("GL_NV_shader_framebuffer_fetch"); @@ -58,26 +78,6 @@ Extensions::Extensions() { mHasSRGB = false; mHasSRGBWriteControl = false; #endif - - const char* version = (const char*) glGetString(GL_VERSION); - - // Section 6.1.5 of the OpenGL ES specification indicates the GL version - // string strictly follows this format: - // - // OpenGL<space>ES<space><version number><space><vendor-specific information> - // - // In addition section 6.1.5 describes the version number thusly: - // - // "The version number is either of the form major number.minor number or - // major number.minor number.release number, where the numbers all have one - // or more digits. The release number and vendor specific information are - // optional." - - if (sscanf(version, "OpenGL ES %d.%d", &mVersionMajor, &mVersionMinor) != 2) { - // If we cannot parse the version number, assume OpenGL ES 2.0 - mVersionMajor = 2; - mVersionMinor = 0; - } } }; // namespace uirenderer |