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

Commit 4ac31c2c authored by Danny Trunk's avatar Danny Trunk Committed by Bruno Martins
Browse files

EGL: Conditionally revert commit a9550f3f

This conditionally reverts a commit [1]
which causes random camera crashes on tama devices

[1] https://github.com/LineageOS/android_frameworks_native/commit/a9550f3fe9097e0934e9b44c5aac6b914fb46aec

Change-Id: If3d9c722c63a9da2f9ca10e21de9d7bc6dba7c52
parent 4cd62e31
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -151,7 +151,10 @@ cc_library_static {

cc_library_shared {
    name: "libEGL",
    defaults: ["egl_libs_defaults"],
    defaults: [
        "egl_libs_defaults",
        "egl_display_array_defaults"
    ],
    llndk: {
        symbol_file: "libEGL.map.txt",
        export_llndk_headers: ["gl_headers"],
+31 −1
Original line number Diff line number Diff line
@@ -74,8 +74,12 @@ int egl_get_init_count(EGLDisplay dpy) {
    return eglDisplay ? eglDisplay->getRefsCount() : 0;
}

#ifdef EGL_DISPLAY_ARRAY
egl_display_t egl_display_t::sDisplay[NUM_DISPLAYS];
#else
std::map<EGLDisplay, std::unique_ptr<egl_display_t>> egl_display_t::displayMap;
std::mutex egl_display_t::displayMapLock;
#endif

egl_display_t::egl_display_t()
      : magic('_dpy'),
@@ -94,12 +98,21 @@ egl_display_t* egl_display_t::get(EGLDisplay dpy) {
        return nullptr;
    }

#ifdef EGL_DISPLAY_ARRAY
    uintptr_t index = uintptr_t(dpy) - 1U;
    if (index >= NUM_DISPLAYS || !sDisplay[index].isValid()) {
#else
    const std::lock_guard<std::mutex> lock(displayMapLock);
    auto search = displayMap.find(dpy);
    if (search == displayMap.end() || !search->second->isValid()) {
#endif
        return nullptr;
    }
#ifdef EGL_DISPLAY_ARRAY
    return &sDisplay[index];
#else
    return search->second.get();
#endif
}

void egl_display_t::addObject(egl_object_t* object) {
@@ -127,7 +140,11 @@ EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp,
                                               const EGLAttrib* attrib_list) {
    if (uintptr_t(disp) >= NUM_DISPLAYS) return nullptr;

#ifdef EGL_DISPLAY_ARRAY
    return sDisplay[uintptr_t(disp)].getPlatformDisplay(disp, attrib_list);
#else
    return getPlatformDisplay(disp, attrib_list);
#endif
}

static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_connection_t* const cnx,
@@ -182,6 +199,9 @@ static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_conn

EGLDisplay egl_display_t::getPlatformDisplay(EGLNativeDisplayType display,
                                             const EGLAttrib* attrib_list) {
#ifdef EGL_DISPLAY_ARRAY
    std::lock_guard<std::mutex> _l(lock);
#endif
    ATRACE_CALL();

    // get our driver loader
@@ -217,9 +237,14 @@ EGLDisplay egl_display_t::getPlatformDisplay(EGLNativeDisplayType display,
            }
        }

#ifdef EGL_DISPLAY_ARRAY
        disp.dpy = dpy;
#endif
        if (dpy == EGL_NO_DISPLAY) {
            loader.close(cnx);
        } else {
        }
#ifndef EGL_DISPLAY_ARRAY
        else {
            const std::lock_guard<std::mutex> lock(displayMapLock);
            if (displayMap.find(dpy) == displayMap.end()) {
                auto d = std::make_unique<egl_display_t>();
@@ -228,9 +253,14 @@ EGLDisplay egl_display_t::getPlatformDisplay(EGLNativeDisplayType display,
            }
            return dpy;
        }
#endif
    }

#ifdef EGL_DISPLAY_ARRAY
    return EGLDisplay(uintptr_t(display) + 1U);
#else
    return nullptr;
#endif
}

EGLBoolean egl_display_t::initialize(EGLint* major, EGLint* minor) {
+10 −0
Original line number Diff line number Diff line
@@ -23,8 +23,10 @@
#include <stdint.h>

#include <condition_variable>
#ifndef EGL_DISPLAY_ARRAY
#include <map>
#include <memory>
#endif
#include <mutex>
#include <string>
#include <unordered_set>
@@ -42,11 +44,19 @@ bool findExtension(const char* exts, const char* name, size_t nameLen = 0);
bool needsAndroidPEglMitigation();

class EGLAPI egl_display_t { // marked as EGLAPI for testing purposes
#ifdef EGL_DISPLAY_ARRAY
    static egl_display_t sDisplay[NUM_DISPLAYS];
#else
    static std::map<EGLDisplay, std::unique_ptr<egl_display_t>> displayMap;
    static std::mutex displayMapLock;
#endif
    EGLDisplay getDisplay(EGLNativeDisplayType display);
#ifdef EGL_DISPLAY_ARRAY
    EGLDisplay getPlatformDisplay(EGLNativeDisplayType display, const EGLAttrib* attrib_list);
#else
    static EGLDisplay getPlatformDisplay(EGLNativeDisplayType display,
                                         const EGLAttrib* attrib_list);
#endif
    void loseCurrentImpl(egl_context_t* cur_c);

public: