Merge "Add internal API to query GL version number" into jb-mr2-dev

This commit is contained in:
Romain Guy
2013-04-04 17:53:06 +00:00
committed by Android (Google) Code Review
2 changed files with 30 additions and 0 deletions

View File

@@ -64,10 +64,32 @@ Extensions::Extensions(): Singleton<Extensions>() {
mHas4BitStencil = hasExtension("GL_OES_stencil4"); mHas4BitStencil = hasExtension("GL_OES_stencil4");
mExtensions = strdup(buffer); 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() { Extensions::~Extensions() {
free(mExtensions); free(mExtensions);
free(mVersion);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -80,6 +102,7 @@ bool Extensions::hasExtension(const char* extension) const {
} }
void Extensions::dump() const { void Extensions::dump() const {
ALOGD("%s", mVersion);
ALOGD("Supported extensions:\n%s", mExtensions); ALOGD("Supported extensions:\n%s", mExtensions);
} }

View File

@@ -45,6 +45,9 @@ public:
inline bool has1BitStencil() const { return mHas1BitStencil; } inline bool has1BitStencil() const { return mHas1BitStencil; }
inline bool has4BitStencil() const { return mHas4BitStencil; } inline bool has4BitStencil() const { return mHas4BitStencil; }
inline int getMajorGlVersion() const { return mVersionMajor; }
inline int getMinorGlVersion() const { return mVersionMinor; }
bool hasExtension(const char* extension) const; bool hasExtension(const char* extension) const;
void dump() const; void dump() const;
@@ -55,6 +58,7 @@ private:
SortedVector<String8> mExtensionList; SortedVector<String8> mExtensionList;
char* mExtensions; char* mExtensions;
char* mVersion;
bool mHasNPot; bool mHasNPot;
bool mHasFramebufferFetch; bool mHasFramebufferFetch;
@@ -64,6 +68,9 @@ private:
bool mHasTiledRendering; bool mHasTiledRendering;
bool mHas1BitStencil; bool mHas1BitStencil;
bool mHas4BitStencil; bool mHas4BitStencil;
int mVersionMajor;
int mVersionMinor;
}; // class Extensions }; // class Extensions
}; // namespace uirenderer }; // namespace uirenderer