summaryrefslogtreecommitdiff
path: root/libs/hwui/Extensions.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2013-03-29 18:32:29 -0700
committer Romain Guy <romainguy@google.com> 2013-04-04 10:50:48 -0700
commitdf1dc28ba0c63b195016ad0453fc58025ee82acb (patch)
tree11f126bd3dd87fcdf97c4cd27fea8a795479578b /libs/hwui/Extensions.cpp
parent02b49b70ede0b9eb760ff334823aee1d9520ed85 (diff)
Add internal API to query GL version number
Change-Id: Idc02efc237b8e97445a9bab05c291bf193c7f279
Diffstat (limited to 'libs/hwui/Extensions.cpp')
-rw-r--r--libs/hwui/Extensions.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/hwui/Extensions.cpp b/libs/hwui/Extensions.cpp
index edc90fbc80f0..51aec8d36715 100644
--- a/libs/hwui/Extensions.cpp
+++ b/libs/hwui/Extensions.cpp
@@ -64,10 +64,32 @@ Extensions::Extensions(): Singleton<Extensions>() {
mHas4BitStencil = hasExtension("GL_OES_stencil4");
mExtensions = strdup(buffer);
+
+ const char* version = (const char*) glGetString(GL_VERSION);
+ mVersion = strdup(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;
+ }
}
Extensions::~Extensions() {
free(mExtensions);
+ free(mVersion);
}
///////////////////////////////////////////////////////////////////////////////
@@ -80,6 +102,7 @@ bool Extensions::hasExtension(const char* extension) const {
}
void Extensions::dump() const {
+ ALOGD("%s", mVersion);
ALOGD("Supported extensions:\n%s", mExtensions);
}