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

Commit 3d393f2e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "EGL: remove redundant codes for hibernation"

parents 133340ff 0657fba1
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -81,25 +81,22 @@ static int sEarlyInitState = pthread_once(&once_control, &early_egl_init);

// ----------------------------------------------------------------------------

egl_display_ptr validate_display(EGLDisplay dpy) {
    egl_display_ptr dp = get_display(dpy);
    if (!dp)
        return setError(EGL_BAD_DISPLAY, egl_display_ptr(nullptr));
    if (!dp->isReady())
        return setError(EGL_NOT_INITIALIZED, egl_display_ptr(nullptr));
egl_display_t* validate_display(EGLDisplay dpy) {
    egl_display_t* const dp = get_display(dpy);
    if (!dp) return setError(EGL_BAD_DISPLAY, (egl_display_t*)nullptr);
    if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, (egl_display_t*)nullptr);

    return dp;
}

egl_display_ptr validate_display_connection(EGLDisplay dpy,
        egl_connection_t*& cnx) {
    cnx = nullptr;
    egl_display_ptr dp = validate_display(dpy);
egl_display_t* validate_display_connection(EGLDisplay dpy, egl_connection_t** outCnx) {
    *outCnx = nullptr;
    egl_display_t* dp = validate_display(dpy);
    if (!dp)
        return dp;
    cnx = &gEGLImpl;
    if (cnx->dso == nullptr) {
        return setError(EGL_BAD_CONFIG, egl_display_ptr(nullptr));
    *outCnx = &gEGLImpl;
    if ((*outCnx)->dso == nullptr) {
        return setError(EGL_BAD_CONFIG, (egl_display_t*)nullptr);
    }
    return dp;
}
+0 −1
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
 ** limitations under the License.
 */

#define __STDC_LIMIT_MACROS 1
#define ATRACE_TAG ATRACE_TAG_GRAPHICS

#include "egl_display.h"
+3 −53
Original line number Diff line number Diff line
@@ -29,8 +29,6 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>

#include <cutils/compiler.h>

#include "egldefs.h"
#include "../hooks.h"

@@ -118,8 +116,6 @@ public:
    bool    hasColorSpaceSupport;

private:
    friend class egl_display_ptr;

            uint32_t                    refs;
            bool                        eglIsInitialized;
    mutable std::mutex                  lock;
@@ -134,60 +130,14 @@ private:

// ----------------------------------------------------------------------------

// An egl_display_ptr is a kind of smart pointer for egl_display_t objects.
// It doesn't refcount the egl_display_t, but does ensure that the underlying
// EGL implementation is "awake" (not hibernating) and ready for use as long
// as the egl_display_ptr exists.
class egl_display_ptr {
public:
    explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) {}

    // We only really need a C++11 move constructor, not a copy constructor.
    // A move constructor would save an enter()/leave() pair on every EGL API
    // call. But enabling -std=c++0x causes lots of errors elsewhere, so I
    // can't use a move constructor until those are cleaned up.
    //
    // egl_display_ptr(egl_display_ptr&& other) {
    //     mDpy = other.mDpy;
    //     other.mDpy = NULL;
    // }
    //
    egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) {}

    ~egl_display_ptr() {}

    const egl_display_t* operator->() const { return mDpy; }
          egl_display_t* operator->()       { return mDpy; }

    const egl_display_t* get() const { return mDpy; }
          egl_display_t* get()       { return mDpy; }

    operator bool() const { return mDpy != nullptr; }

private:
    egl_display_t* mDpy;

    // non-assignable
    egl_display_ptr& operator=(const egl_display_ptr&);
};

// ----------------------------------------------------------------------------

inline egl_display_ptr get_display(EGLDisplay dpy) {
    return egl_display_ptr(egl_display_t::get(dpy));
}

// Does not ensure EGL is unhibernated. Use with caution: calls into the
// underlying EGL implementation are not safe.
inline egl_display_t* get_display_nowake(EGLDisplay dpy) {
inline egl_display_t* get_display(EGLDisplay dpy) {
    return egl_display_t::get(dpy);
}

// ----------------------------------------------------------------------------

egl_display_ptr validate_display(EGLDisplay dpy);
egl_display_ptr validate_display_connection(EGLDisplay dpy,
        egl_connection_t*& cnx);
egl_display_t* validate_display(EGLDisplay dpy);
egl_display_t* validate_display_connection(EGLDisplay dpy, egl_connection_t** outCnx);
EGLBoolean validate_display_context(EGLDisplay dpy, EGLContext ctx);
EGLBoolean validate_display_surface(EGLDisplay dpy, EGLSurface surface);

+0 −5
Original line number Diff line number Diff line
@@ -104,11 +104,6 @@ EGL_ENTRY(EGLClientBuffer, eglGetNativeClientBufferANDROID, const AHardwareBuffe
EGL_ENTRY(EGLuint64NV, eglGetSystemTimeFrequencyNV, void)
EGL_ENTRY(EGLuint64NV, eglGetSystemTimeNV, void)

/* IMG extensions */

EGL_ENTRY(EGLBoolean, eglHibernateProcessIMG, void)
EGL_ENTRY(EGLBoolean, eglAwakenProcessIMG, void)

/* Partial update extensions */

EGL_ENTRY(EGLBoolean, eglSwapBuffersWithDamageKHR, EGLDisplay, EGLSurface, EGLint *, EGLint)
+9 −4
Original line number Diff line number Diff line
@@ -279,10 +279,15 @@ void egl_surface_t::terminate() {
// ----------------------------------------------------------------------------

egl_context_t::egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
        egl_connection_t const* cnx, int version) :
    egl_object_t(get_display_nowake(dpy)), dpy(dpy), context(context),
            config(config), read(nullptr), draw(nullptr), cnx(cnx), version(version) {
}
                             egl_connection_t const* cnx, int version)
      : egl_object_t(get_display(dpy)),
        dpy(dpy),
        context(context),
        config(config),
        read(nullptr),
        draw(nullptr),
        cnx(cnx),
        version(version) {}

void egl_context_t::onLooseCurrent() {
    read = nullptr;
Loading