diff options
author | Romain Guy <romainguy@google.com> | 2013-05-23 19:50:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-05-23 19:50:58 +0000 |
commit | 608094041177193dcce7a91e8dc96a2556d29bfd (patch) | |
tree | e3c6f0564980c2b38c3e41fab7105bfdca06b3f9 /libs | |
parent | ac5b347d03c52e286f11994699d4e6d462789988 (diff) | |
parent | e9bc11f7121dbe373b0cbe5779ee6a12d824492c (diff) | |
download | frameworks_base-608094041177193dcce7a91e8dc96a2556d29bfd.zip frameworks_base-608094041177193dcce7a91e8dc96a2556d29bfd.tar.gz frameworks_base-608094041177193dcce7a91e8dc96a2556d29bfd.tar.bz2 |
Merge "Add PerfHUD ES profiling capabilities"
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Extensions.cpp | 80 | ||||
-rw-r--r-- | libs/hwui/Extensions.h | 20 |
2 files changed, 60 insertions, 40 deletions
diff --git a/libs/hwui/Extensions.cpp b/libs/hwui/Extensions.cpp index 51aec8d..eefdb84 100644 --- a/libs/hwui/Extensions.cpp +++ b/libs/hwui/Extensions.cpp @@ -14,6 +14,16 @@ * limitations under the License. */ +#define LOG_TAG "OpenGLRenderer" + +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> + +#include <EGL/egl.h> +#include <EGL/eglext.h> + +#include <utils/Log.h> + #include "Debug.h" #include "Extensions.h" @@ -40,33 +50,22 @@ namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// Extensions::Extensions(): Singleton<Extensions>() { - const char* buffer = (const char*) glGetString(GL_EXTENSIONS); - const char* current = buffer; - const char* head = current; - EXT_LOGD("Available GL extensions:"); - do { - head = strchr(current, ' '); - String8 s(current, head ? head - current : strlen(current)); - if (s.length()) { - mExtensionList.add(s); - EXT_LOGD(" %s", s.string()); - } - current = head + 1; - } while (head); - - mHasNPot = hasExtension("GL_OES_texture_npot"); - mHasFramebufferFetch = hasExtension("GL_NV_shader_framebuffer_fetch"); - mHasDiscardFramebuffer = hasExtension("GL_EXT_discard_framebuffer"); - mHasDebugMarker = hasExtension("GL_EXT_debug_marker"); - mHasDebugLabel = hasExtension("GL_EXT_debug_label"); - mHasTiledRendering = hasExtension("GL_QCOM_tiled_rendering"); - mHas1BitStencil = hasExtension("GL_OES_stencil1"); - mHas4BitStencil = hasExtension("GL_OES_stencil4"); - - mExtensions = strdup(buffer); + // Query GL extensions + findExtensions((const char*) glGetString(GL_EXTENSIONS), mGlExtensionList); + mHasNPot = hasGlExtension("GL_OES_texture_npot"); + mHasFramebufferFetch = hasGlExtension("GL_NV_shader_framebuffer_fetch"); + mHasDiscardFramebuffer = hasGlExtension("GL_EXT_discard_framebuffer"); + mHasDebugMarker = hasGlExtension("GL_EXT_debug_marker"); + mHasDebugLabel = hasGlExtension("GL_EXT_debug_label"); + mHasTiledRendering = hasGlExtension("GL_QCOM_tiled_rendering"); + mHas1BitStencil = hasGlExtension("GL_OES_stencil1"); + mHas4BitStencil = hasGlExtension("GL_OES_stencil4"); + + // Query EGL extensions + findExtensions(eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS), mEglExtensionList); + mHasNvSystemTime = hasEglExtension("EGL_NV_system_time"); 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: @@ -88,22 +87,41 @@ Extensions::Extensions(): Singleton<Extensions>() { } Extensions::~Extensions() { - free(mExtensions); - free(mVersion); } /////////////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////////////// -bool Extensions::hasExtension(const char* extension) const { +bool Extensions::hasGlExtension(const char* extension) const { const String8 s(extension); - return mExtensionList.indexOf(s) >= 0; + return mGlExtensionList.indexOf(s) >= 0; +} + +bool Extensions::hasEglExtension(const char* extension) const { + const String8 s(extension); + return mEglExtensionList.indexOf(s) >= 0; +} + +void Extensions::findExtensions(const char* extensions, SortedVector<String8>& list) const { + const char* current = extensions; + const char* head = current; + EXT_LOGD("Available extensions:"); + do { + head = strchr(current, ' '); + String8 s(current, head ? head - current : strlen(current)); + if (s.length()) { + list.add(s); + EXT_LOGD(" %s", s.string()); + } + current = head + 1; + } while (head); } void Extensions::dump() const { - ALOGD("%s", mVersion); - ALOGD("Supported extensions:\n%s", mExtensions); + ALOGD("%s", (const char*) glGetString(GL_VERSION)); + ALOGD("Supported GL extensions:\n%s", (const char*) glGetString(GL_EXTENSIONS)); + ALOGD("Supported EGL extensions:\n%s", eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS)); } }; // namespace uirenderer diff --git a/libs/hwui/Extensions.h b/libs/hwui/Extensions.h index a3f7c44..3112244 100644 --- a/libs/hwui/Extensions.h +++ b/libs/hwui/Extensions.h @@ -17,13 +17,12 @@ #ifndef ANDROID_HWUI_EXTENSIONS_H #define ANDROID_HWUI_EXTENSIONS_H +#include <cutils/compiler.h> + #include <utils/Singleton.h> #include <utils/SortedVector.h> #include <utils/String8.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> - namespace android { namespace uirenderer { @@ -31,7 +30,7 @@ namespace uirenderer { // Classes /////////////////////////////////////////////////////////////////////////////// -class Extensions: public Singleton<Extensions> { +class ANDROID_API Extensions: public Singleton<Extensions> { public: inline bool hasNPot() const { return mHasNPot; } inline bool hasFramebufferFetch() const { return mHasFramebufferFetch; } @@ -41,11 +40,13 @@ public: inline bool hasTiledRendering() const { return mHasTiledRendering; } inline bool has1BitStencil() const { return mHas1BitStencil; } inline bool has4BitStencil() const { return mHas4BitStencil; } + inline bool hasNvSystemTime() const { return mHasNvSystemTime; } inline int getMajorGlVersion() const { return mVersionMajor; } inline int getMinorGlVersion() const { return mVersionMinor; } - bool hasExtension(const char* extension) const; + bool hasGlExtension(const char* extension) const; + bool hasEglExtension(const char* extension) const; void dump() const; @@ -53,12 +54,12 @@ private: Extensions(); ~Extensions(); - friend class Singleton<Extensions>; + void findExtensions(const char* extensions, SortedVector<String8>& list) const; - SortedVector<String8> mExtensionList; + friend class Singleton<Extensions>; - char* mExtensions; - char* mVersion; + SortedVector<String8> mGlExtensionList; + SortedVector<String8> mEglExtensionList; bool mHasNPot; bool mHasFramebufferFetch; @@ -68,6 +69,7 @@ private: bool mHasTiledRendering; bool mHas1BitStencil; bool mHas4BitStencil; + bool mHasNvSystemTime; int mVersionMajor; int mVersionMinor; |