Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e6646c0 authored by Chris Craik's avatar Chris Craik
Browse files

Unify extensions parsing behavior

Removes remnants of EGL extension support, and persistence of
GL extension list.

Change-Id: I35aec12d900bdb33549ea47654bb8146f350ef48
parent 0e35962e
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ hwui_src_files := \
    utils/GLUtils.cpp \
    utils/LinearAllocator.cpp \
    utils/NinePatchImpl.cpp \
    utils/StringUtils.cpp \
    AmbientShadow.cpp \
    AnimationContext.cpp \
    Animator.cpp \
@@ -168,7 +169,8 @@ LOCAL_SRC_FILES += \
    unit_tests/CanvasStateTests.cpp \
    unit_tests/ClipAreaTests.cpp \
    unit_tests/DamageAccumulatorTests.cpp \
    unit_tests/LinearAllocatorTests.cpp
    unit_tests/LinearAllocatorTests.cpp \
    unit_tests/StringUtilsTests.cpp

include $(BUILD_NATIVE_TEST)

+0 −3
Original line number Diff line number Diff line
@@ -20,9 +20,6 @@
// Turn on to check for OpenGL errors on each frame
#define DEBUG_OPENGL 1

// Turn on to display informations about the GPU
#define DEBUG_EXTENSIONS 0

// Turn on to enable initialization information
#define DEBUG_INIT 0

+9 −57
Original line number Diff line number Diff line
@@ -18,23 +18,14 @@

#include "Debug.h"
#include "Properties.h"
#include "utils/StringUtils.h"

#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2ext.h>
#include <utils/Log.h>

namespace android {

using namespace uirenderer;
ANDROID_SINGLETON_STATIC_INSTANCE(Extensions);

namespace uirenderer {

///////////////////////////////////////////////////////////////////////////////
// Defines
///////////////////////////////////////////////////////////////////////////////

// Debug
#if DEBUG_EXTENSIONS
    #define EXT_LOGD(...) ALOGD(__VA_ARGS__)
@@ -42,20 +33,16 @@ namespace uirenderer {
    #define EXT_LOGD(...)
#endif

///////////////////////////////////////////////////////////////////////////////
// Constructors
///////////////////////////////////////////////////////////////////////////////

Extensions::Extensions() {
    // 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");
    mHas1BitStencil = hasGlExtension("GL_OES_stencil1");
    mHas4BitStencil = hasGlExtension("GL_OES_stencil4");
    mHasUnpackSubImage = hasGlExtension("GL_EXT_unpack_subimage");
    StringCollection extensions((const char*) glGetString(GL_EXTENSIONS));
    mHasNPot = extensions.has("GL_OES_texture_npot");
    mHasFramebufferFetch = extensions.has("GL_NV_shader_framebuffer_fetch");
    mHasDiscardFramebuffer = extensions.has("GL_EXT_discard_framebuffer");
    mHasDebugMarker = extensions.has("GL_EXT_debug_marker");
    mHas1BitStencil = extensions.has("GL_OES_stencil1");
    mHas4BitStencil = extensions.has("GL_OES_stencil4");
    mHasUnpackSubImage = extensions.has("GL_EXT_unpack_subimage");

    const char* version = (const char*) glGetString(GL_VERSION);

@@ -78,40 +65,5 @@ Extensions::Extensions() {
    }
}

///////////////////////////////////////////////////////////////////////////////
// Methods
///////////////////////////////////////////////////////////////////////////////

bool Extensions::hasGlExtension(const char* extension) const {
   const String8 s(extension);
   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", (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
}; // namespace android
+0 −10
Original line number Diff line number Diff line
@@ -50,17 +50,7 @@ public:
    inline int getMajorGlVersion() const { return mVersionMajor; }
    inline int getMinorGlVersion() const { return mVersionMinor; }

    bool hasGlExtension(const char* extension) const;
    bool hasEglExtension(const char* extension) const;

    void dump() const;

private:
    void findExtensions(const char* extensions, SortedVector<String8>& list) const;

    SortedVector<String8> mGlExtensionList;
    SortedVector<String8> mEglExtensionList;

    bool mHasNPot;
    bool mHasFramebufferFetch;
    bool mHasDiscardFramebuffer;
+4 −6
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "Properties.h"
#include "RenderThread.h"
#include "renderstate/RenderState.h"
#include "utils/StringUtils.h"

#include <cutils/log.h>
#include <cutils/properties.h>
@@ -133,12 +134,9 @@ void EglManager::initialize() {
}

void EglManager::initExtensions() {
    std::string extensions(eglQueryString(mEglDisplay, EGL_EXTENSIONS));
    auto has = [&](const char* ext) {
        return extensions.find(ext) != std::string::npos;
    };
    EglExtensions.bufferAge = has("EGL_EXT_buffer_age");
    EglExtensions.setDamage = has("EGL_KHR_partial_update");
    StringCollection extensions(eglQueryString(mEglDisplay, EGL_EXTENSIONS));
    EglExtensions.bufferAge = extensions.has("EGL_EXT_buffer_age");
    EglExtensions.setDamage = extensions.has("EGL_KHR_partial_update");
}

bool EglManager::hasEglContext() {
Loading