diff options
-rw-r--r-- | libs/hwui/Caches.cpp | 50 | ||||
-rw-r--r-- | libs/hwui/Caches.h | 21 | ||||
-rw-r--r-- | libs/hwui/Extensions.h | 4 |
3 files changed, 53 insertions, 22 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index 123695a..f210820 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -48,25 +48,9 @@ namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// Caches::Caches(): Singleton<Caches>(), mInitialized(false) { - GLint maxTextureUnits; - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); - if (maxTextureUnits < REQUIRED_TEXTURE_UNITS_COUNT) { - ALOGW("At least %d texture units are required!", REQUIRED_TEXTURE_UNITS_COUNT); - } - - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); - - if (extensions.hasDebugMarker()) { - eventMark = glInsertEventMarkerEXT; - startMark = glPushGroupMarkerEXT; - endMark = glPopGroupMarkerEXT; - } else { - eventMark = eventMarkNull; - startMark = startMarkNull; - endMark = endMarkNull; - } - init(); + initExtensions(); + initConstraints(); mDebugLevel = readDebugLevel(); ALOGD("Enabling debug mode %d", mDebugLevel); @@ -105,6 +89,36 @@ void Caches::init() { mInitialized = true; } +void Caches::initExtensions() { + if (extensions.hasDebugMarker()) { + eventMark = glInsertEventMarkerEXT; + startMark = glPushGroupMarkerEXT; + endMark = glPopGroupMarkerEXT; + } else { + eventMark = eventMarkNull; + startMark = startMarkNull; + endMark = endMarkNull; + } + + if (extensions.hasDebugLabel()) { + setLabel = glLabelObjectEXT; + getLabel = glGetObjectLabelEXT; + } else { + setLabel = setLabelNull; + getLabel = getLabelNull; + } +} + +void Caches::initConstraints() { + GLint maxTextureUnits; + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); + if (maxTextureUnits < REQUIRED_TEXTURE_UNITS_COUNT) { + ALOGW("At least %d texture units are required!", REQUIRED_TEXTURE_UNITS_COUNT); + } + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); +} + void Caches::terminate() { if (!mInitialized) return; diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index 65ff9ad..58361c9 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -107,7 +107,7 @@ public: }; /** - * Initializes the cache. + * Initialize caches. */ void init(); @@ -247,15 +247,30 @@ public: GammaFontRenderer fontRenderer; ResourceCache resourceCache; + // Debug methods PFNGLINSERTEVENTMARKEREXTPROC eventMark; PFNGLPUSHGROUPMARKEREXTPROC startMark; PFNGLPOPGROUPMARKEREXTPROC endMark; + PFNGLLABELOBJECTEXTPROC setLabel; + PFNGLGETOBJECTLABELEXTPROC getLabel; + private: - static void eventMarkNull(GLsizei length, const GLchar *marker) { } - static void startMarkNull(GLsizei length, const GLchar *marker) { } + void initExtensions(); + void initConstraints(); + + static void eventMarkNull(GLsizei length, const GLchar* marker) { } + static void startMarkNull(GLsizei length, const GLchar* marker) { } static void endMarkNull() { } + static void setLabelNull(GLenum type, uint object, GLsizei length, + const char* label) { } + static void getLabelNull(GLenum type, uint object, GLsizei bufferSize, + GLsizei* length, char* label) { + if (length) *length = 0; + if (label) *label = '\0'; + } + GLuint mCurrentBuffer; GLuint mCurrentIndicesBuffer; void* mCurrentPositionPointer; diff --git a/libs/hwui/Extensions.h b/libs/hwui/Extensions.h index f11fecc..6b174d6 100644 --- a/libs/hwui/Extensions.h +++ b/libs/hwui/Extensions.h @@ -40,7 +40,6 @@ namespace uirenderer { #endif // Vendor strings - #define VENDOR_IMG "Imagination Technologies" /////////////////////////////////////////////////////////////////////////////// @@ -68,6 +67,7 @@ public: 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"); const char* vendor = (const char*) glGetString(GL_VENDOR); EXT_LOGD("Vendor: %s", vendor); @@ -84,6 +84,7 @@ public: inline bool needsHighpTexCoords() const { return mNeedsHighpTexCoords; } inline bool hasDiscardFramebuffer() const { return mHasDiscardFramebuffer; } inline bool hasDebugMarker() const { return mHasDebugMarker; } + inline bool hasDebugLabel() const { return mHasDebugLabel; } bool hasExtension(const char* extension) const { const String8 s(extension); @@ -104,6 +105,7 @@ private: bool mHasFramebufferFetch; bool mHasDiscardFramebuffer; bool mHasDebugMarker; + bool mHasDebugLabel; }; // class Extensions }; // namespace uirenderer |