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

Commit c7bcf25d authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter Committed by Android (Google) Code Review
Browse files

Merge changes from topic "egl1.5-master"

* changes:
  Add EGL 1.5 Sync functions
  Add eglCreatePlatformWindowSurface
  Early exit to prep for refactoring
  Implement getPlatformDisplay with ANGLE support
  Implement eglCreateImage and eglDestroyImage
  Determine EGL version
  Generated EGL 1.5 support
  Update EGL headers to version 1.5
parents 380bf855 40627ba8
Loading
Loading
Loading
Loading
+61 −5
Original line number Diff line number Diff line
@@ -33,12 +33,12 @@ extern "C" {
** used to make the header, and the header can be found at
**   http://www.khronos.org/registry/egl
**
** Khronos $Git commit SHA1: a732b061e7 $ on $Git commit date: 2017-06-17 23:27:53 +0100 $
** Khronos $Git commit SHA1: bae3518c48 $ on $Git commit date: 2018-05-17 10:56:57 -0700 $
*/

#include <EGL/eglplatform.h>

/* Generated on date 20170627 */
/* Generated on date 20180517 */

/* Generated C header for:
 * API: egl
@@ -235,10 +235,66 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void);
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void);
#endif /* EGL_VERSION_1_4 */

/* This version of Android does not yet support EGL 1.5, but the following
 * portion of EGL 1.5 is included in order to support portions of "eglext.h".
 */
#ifndef EGL_VERSION_1_5
#define EGL_VERSION_1_5 1
typedef void *EGLSync;
typedef intptr_t EGLAttrib;
typedef khronos_utime_nanoseconds_t EGLTime;
typedef void *EGLImage;
#define EGL_CONTEXT_MAJOR_VERSION         0x3098
#define EGL_CONTEXT_MINOR_VERSION         0x30FB
#define EGL_CONTEXT_OPENGL_PROFILE_MASK   0x30FD
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD
#define EGL_NO_RESET_NOTIFICATION         0x31BE
#define EGL_LOSE_CONTEXT_ON_RESET         0x31BF
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002
#define EGL_CONTEXT_OPENGL_DEBUG          0x31B0
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS  0x31B2
#define EGL_OPENGL_ES3_BIT                0x00000040
#define EGL_CL_EVENT_HANDLE               0x309C
#define EGL_SYNC_CL_EVENT                 0x30FE
#define EGL_SYNC_CL_EVENT_COMPLETE        0x30FF
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE  0x30F0
#define EGL_SYNC_TYPE                     0x30F7
#define EGL_SYNC_STATUS                   0x30F1
#define EGL_SYNC_CONDITION                0x30F8
#define EGL_SIGNALED                      0x30F2
#define EGL_UNSIGNALED                    0x30F3
#define EGL_SYNC_FLUSH_COMMANDS_BIT       0x0001
#define EGL_FOREVER                       0xFFFFFFFFFFFFFFFFull
#define EGL_TIMEOUT_EXPIRED               0x30F5
#define EGL_CONDITION_SATISFIED           0x30F6
#define EGL_NO_SYNC                       EGL_CAST(EGLSync,0)
#define EGL_SYNC_FENCE                    0x30F9
#define EGL_GL_COLORSPACE                 0x309D
#define EGL_GL_COLORSPACE_SRGB            0x3089
#define EGL_GL_COLORSPACE_LINEAR          0x308A
#define EGL_GL_RENDERBUFFER               0x30B9
#define EGL_GL_TEXTURE_2D                 0x30B1
#define EGL_GL_TEXTURE_LEVEL              0x30BC
#define EGL_GL_TEXTURE_3D                 0x30B2
#define EGL_GL_TEXTURE_ZOFFSET            0x30BD
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8
#define EGL_IMAGE_PRESERVED               0x30D2
#define EGL_NO_IMAGE                      EGL_CAST(EGLImage,0)
EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync);
EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image);
EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags);
#endif /* EGL_VERSION_1_5 */

#ifdef __cplusplus
}
+28 −2
Original line number Diff line number Diff line
@@ -33,12 +33,12 @@ extern "C" {
** used to make the header, and the header can be found at
**   http://www.khronos.org/registry/egl
**
** Khronos $Git commit SHA1: feaaeb19e1 $ on $Git commit date: 2018-02-26 20:49:02 -0800 $
** Khronos $Git commit SHA1: bae3518c48 $ on $Git commit date: 2018-05-17 10:56:57 -0700 $
*/

#include <EGL/eglplatform.h>

#define EGL_EGLEXT_VERSION 20180228
#define EGL_EGLEXT_VERSION 20180517

/* Generated C header for:
 * API: egl
@@ -618,6 +618,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu
#define EGL_EXT_client_extensions 1
#endif /* EGL_EXT_client_extensions */

#ifndef EGL_EXT_client_sync
#define EGL_EXT_client_sync 1
#define EGL_SYNC_CLIENT_EXT               0x3364
#define EGL_SYNC_CLIENT_SIGNAL_EXT        0x3365
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCLIENTSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglClientSignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list);
#endif
#endif /* EGL_EXT_client_sync */

#ifndef EGL_EXT_compositor
#define EGL_EXT_compositor 1
#define EGL_PRIMARY_COMPOSITOR_CONTEXT_EXT 0x3460
@@ -903,6 +913,14 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSu
#endif
#endif /* EGL_EXT_swap_buffers_with_damage */

#ifndef EGL_EXT_sync_reuse
#define EGL_EXT_sync_reuse 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglUnsignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list);
#endif
#endif /* EGL_EXT_sync_reuse */

#ifndef EGL_EXT_yuv_surface
#define EGL_EXT_yuv_surface 1
#define EGL_YUV_ORDER_EXT                 0x3301
@@ -1147,6 +1165,14 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV (EGLDi
#define EGL_STREAM_FIFO_SYNCHRONOUS_NV    0x3336
#endif /* EGL_NV_stream_fifo_synchronous */

#ifndef EGL_NV_stream_flush
#define EGL_NV_stream_flush 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMFLUSHNVPROC) (EGLDisplay dpy, EGLStreamKHR stream);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglStreamFlushNV (EGLDisplay dpy, EGLStreamKHR stream);
#endif
#endif /* EGL_NV_stream_flush */

#ifndef EGL_NV_stream_frame_limits
#define EGL_NV_stream_frame_limits 1
#define EGL_PRODUCER_MAX_FRAME_HINT_NV    0x3337
+34 −2
Original line number Diff line number Diff line
@@ -77,12 +77,24 @@ typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND    EGLNativeWindowType;

#elif defined(__APPLE__) || defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */

typedef int   EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;

#elif defined(WL_EGL_PLATFORM)

typedef struct wl_display     *EGLNativeDisplayType;
typedef struct wl_egl_pixmap  *EGLNativePixmapType;
typedef struct wl_egl_window  *EGLNativeWindowType;

#elif defined(__GBM__)

typedef struct gbm_device  *EGLNativeDisplayType;
typedef struct gbm_bo      *EGLNativePixmapType;
typedef void               *EGLNativeWindowType;

#elif defined(__ANDROID__) || defined(ANDROID)

struct ANativeWindow;
@@ -92,7 +104,13 @@ typedef struct ANativeWindow* EGLNativeWindowType;
typedef struct egl_native_pixmap_t*     EGLNativePixmapType;
typedef void*                           EGLNativeDisplayType;

#elif defined(__unix__)
#elif defined(USE_OZONE)

typedef intptr_t EGLNativeDisplayType;
typedef intptr_t EGLNativeWindowType;
typedef intptr_t EGLNativePixmapType;

#elif defined(__unix__) || defined(USE_X11)

/* X11 (tentative)  */
#include <X11/Xlib.h>
@@ -102,6 +120,20 @@ typedef Display *EGLNativeDisplayType;
typedef Pixmap   EGLNativePixmapType;
typedef Window   EGLNativeWindowType;

#elif defined(__APPLE__)

typedef int   EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;

#elif defined(__HAIKU__)

#include <kernel/image.h>

typedef void              *EGLNativeDisplayType;
typedef khronos_uintptr_t  EGLNativePixmapType;
typedef khronos_uintptr_t  EGLNativeWindowType;

#else
#error "Platform not recognized"
#endif
+91 −0
Original line number Diff line number Diff line
@@ -52,6 +52,21 @@ EGLDisplay eglGetDisplay(EGLNativeDisplayType display) {
    return cnx->platform.eglGetDisplay(display);
}

EGLDisplay eglGetPlatformDisplay(EGLenum platform, EGLNativeDisplayType display,
                                 const EGLAttrib* attrib_list) {
    ATRACE_CALL();
    clearError();

    if (egl_init_drivers() == EGL_FALSE) {
        return setError(EGL_BAD_PARAMETER, EGL_NO_DISPLAY);
    }

    // Call down the chain, which usually points directly to the impl
    // but may also be routed through layers
    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglGetPlatformDisplay(platform, display, attrib_list);
}

EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
    clearError();

@@ -97,6 +112,14 @@ EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindow
    return cnx->platform.eglCreateWindowSurface(dpy, config, window, attrib_list);
}

EGLSurface eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void* native_window,
                                          const EGLAttrib* attrib_list) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglCreatePlatformWindowSurface(dpy, config, native_window, attrib_list);
}

EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap,
                                  const EGLint* attrib_list) {
    clearError();
@@ -105,6 +128,14 @@ EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, NativePixmap
    return cnx->platform.eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
}

EGLSurface eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void* native_pixmap,
                                          const EGLAttrib* attrib_list) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglCreatePlatformPixmapSurface(dpy, config, native_pixmap, attrib_list);
}

EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
    clearError();

@@ -352,6 +383,14 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
    return cnx->platform.eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
}

EGLImage eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer,
                        const EGLAttrib* attrib_list) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglCreateImage(dpy, ctx, target, buffer, attrib_list);
}

EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) {
    clearError();

@@ -359,6 +398,24 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) {
    return cnx->platform.eglDestroyImageKHR(dpy, img);
}

EGLBoolean eglDestroyImage(EGLDisplay dpy, EGLImageKHR img) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglDestroyImage(dpy, img);
}

// ----------------------------------------------------------------------------
// EGL_EGLEXT_VERSION 5
// ----------------------------------------------------------------------------

EGLSyncKHR eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib* attrib_list) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglCreateSync(dpy, type, attrib_list);
}

EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list) {
    clearError();

@@ -366,6 +423,13 @@ EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint* attrib_l
    return cnx->platform.eglCreateSyncKHR(dpy, type, attrib_list);
}

EGLBoolean eglDestroySync(EGLDisplay dpy, EGLSyncKHR sync) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglDestroySync(dpy, sync);
}

EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) {
    clearError();

@@ -373,6 +437,13 @@ EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) {
    return cnx->platform.eglDestroySyncKHR(dpy, sync);
}

EGLBoolean eglSignalSync(EGLDisplay dpy, EGLSync sync, EGLenum mode) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglSignalSync(dpy, sync, mode);
}

EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) {
    clearError();

@@ -380,6 +451,13 @@ EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) {
    return cnx->platform.eglSignalSyncKHR(dpy, sync, mode);
}

EGLint eglClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTimeKHR timeout) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglClientWaitSyncKHR(dpy, sync, flags, timeout);
}

EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) {
    clearError();

@@ -387,6 +465,13 @@ EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTi
    return cnx->platform.eglClientWaitSyncKHR(dpy, sync, flags, timeout);
}

EGLBoolean eglGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib* value) {
    clearError();

    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglGetSyncAttrib(dpy, sync, attribute, value);
}

EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint* value) {
    clearError();

@@ -490,6 +575,12 @@ EGLint eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) {
    return cnx->platform.eglWaitSyncKHR(dpy, sync, flags);
}

EGLBoolean eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) {
    clearError();
    egl_connection_t* const cnx = &gEGLImpl;
    return cnx->platform.eglWaitSync(dpy, sync, flags);
}

EGLint eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSyncKHR sync) {
    clearError();

+117 −34
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@ namespace android {
// ----------------------------------------------------------------------------

static char const * const sVendorString     = "Android";
static char const * const sVersionString    = "1.4 Android META-EGL";
static char const* const sVersionString14 = "1.4 Android META-EGL";
static char const* const sVersionString15 = "1.5 Android META-EGL";
static char const * const sClientApiString  = "OpenGL_ES";

extern char const * const gBuiltinExtensionString;
@@ -119,14 +120,15 @@ bool egl_display_t::getObject(egl_object_t* object) const {
    return false;
}

EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp) {
EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp,
                                               const EGLAttrib* attrib_list) {
    if (uintptr_t(disp) >= NUM_DISPLAYS)
        return nullptr;

    return sDisplay[uintptr_t(disp)].getDisplay(disp);
    return sDisplay[uintptr_t(disp)].getPlatformDisplay(disp, attrib_list);
}

static void addAnglePlatformAttributes(egl_connection_t* const cnx, const EGLAttrib* attrib_list,
static bool addAnglePlatformAttributes(egl_connection_t* const cnx, const EGLAttrib* attrib_list,
                                       std::vector<EGLAttrib>& attrs) {
    intptr_t vendorEGL = (intptr_t)cnx->vendorEGL;

@@ -153,24 +155,29 @@ static void addAnglePlatformAttributes(egl_connection_t* const cnx, const EGLAtt
        }
    }

    cnx->angleBackend = angleBackendDefault;

    // Allow debug property to override application's
    char prop[PROPERTY_VALUE_MAX];
    property_get("debug.angle.backend", prop, "0");
    switch (atoi(prop)) {
        case 1:
            ALOGV("addAnglePlatformAttributes: Requesting OpenGLES back-end");
            cnx->angleBackend = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
            angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
            break;
        case 2:
            ALOGV("addAnglePlatformAttributes: Requesting Vulkan back-end");
            cnx->angleBackend = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
            angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
            break;
        default:
            break;
    }

    if (cnx->angleBackend == 0) {
        // Haven't been initialized yet, so set it.
        cnx->angleBackend = angleBackendDefault;
    } else if (cnx->angleBackend != angleBackendDefault) {
        return false;
    }

    attrs.reserve(4 * 2);

    attrs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
@@ -198,6 +205,8 @@ static void addAnglePlatformAttributes(egl_connection_t* const cnx, const EGLAtt
    }
    attrs.push_back(EGL_PLATFORM_ANGLE_CONTEXT_VIRTUALIZATION_ANGLE);
    attrs.push_back(EGL_FALSE);

    return true;
}

// Initialize function ptrs for ANGLE PlatformMethods struct, used for systrace
@@ -237,24 +246,30 @@ bool initializeAnglePlatform(EGLDisplay dpy) {
    return true;
}

static EGLDisplay getDisplayAngle(EGLNativeDisplayType display, egl_connection_t* const cnx) {
static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_connection_t* const cnx,
                                          const EGLAttrib* attrib_list, EGLint* error) {
    EGLDisplay dpy = EGL_NO_DISPLAY;
    *error = EGL_NONE;

    // Locally define this until EGL 1.5 is supported
    typedef EGLDisplay (*PFNEGLGETPLATFORMDISPLAYPROC)(EGLenum platform, void* native_display,
                                                       const EGLAttrib* attrib_list);

    PFNEGLGETPLATFORMDISPLAYPROC eglGetPlatformDisplay =
            reinterpret_cast<PFNEGLGETPLATFORMDISPLAYPROC>(
                    cnx->egl.eglGetProcAddress("eglGetPlatformDisplay"));

    if (eglGetPlatformDisplay) {
    if (cnx->egl.eglGetPlatformDisplay) {
        std::vector<EGLAttrib> attrs;
        addAnglePlatformAttributes(cnx, nullptr, attrs);
        if (attrib_list) {
            for (const EGLAttrib* attr = attrib_list; *attr != EGL_NONE; attr += 2) {
                attrs.push_back(attr[0]);
                attrs.push_back(attr[1]);
            }
        }

        if (!addAnglePlatformAttributes(cnx, attrib_list, attrs)) {
            ALOGE("eglGetDisplay(%p) failed: Mismatch display request", display);
            *error = EGL_BAD_PARAMETER;
            return EGL_NO_DISPLAY;
        }
        attrs.push_back(EGL_NONE);

        dpy = eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE,
                                    reinterpret_cast<void*>(EGL_DEFAULT_DISPLAY), attrs.data());
        dpy = cnx->egl.eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE,
                                             reinterpret_cast<void*>(EGL_DEFAULT_DISPLAY),
                                             attrs.data());
        if (dpy == EGL_NO_DISPLAY) {
            ALOGE("eglGetPlatformDisplay failed!");
        } else {
@@ -270,8 +285,8 @@ static EGLDisplay getDisplayAngle(EGLNativeDisplayType display, egl_connection_t
    return dpy;
}

EGLDisplay egl_display_t::getDisplay(EGLNativeDisplayType display) {

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

@@ -283,11 +298,25 @@ EGLDisplay egl_display_t::getDisplay(EGLNativeDisplayType display) {
        EGLDisplay dpy = EGL_NO_DISPLAY;

        if (cnx->useAngle) {
            dpy = getDisplayAngle(display, cnx);
            EGLint error;
            dpy = getPlatformDisplayAngle(display, cnx, attrib_list, &error);
            if (error != EGL_NONE) {
                return setError(error, dpy);
            }
        }
        if (dpy == EGL_NO_DISPLAY) {
            // NOTE: eglGetPlatformDisplay with a empty attribute list
            // behaves the same as eglGetDisplay
            if (cnx->egl.eglGetPlatformDisplay) {
                dpy = cnx->egl.eglGetPlatformDisplay(EGL_PLATFORM_ANDROID_KHR, display,
                                                     attrib_list);
            } else {
                if (attrib_list) {
                    ALOGW("getPlatformDisplay: unexpected attribute list, attributes ignored");
                }
                dpy = cnx->egl.eglGetDisplay(display);
            }
        }

        disp.dpy = dpy;
        if (dpy == EGL_NO_DISPLAY) {
@@ -305,13 +334,20 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
        std::unique_lock<std::mutex> _l(refLock);
        refs++;
        if (refs > 1) {
            if (major != nullptr)
                *major = VERSION_MAJOR;
            if (minor != nullptr)
                *minor = VERSION_MINOR;
            // We don't know what to report until we know what the
            // driver supports. Make sure we are initialized before
            // returning the version info.
            while(!eglIsInitialized) {
                refCond.wait(_l);
            }
            egl_connection_t* const cnx = &gEGLImpl;

            // TODO: If device doesn't provide 1.4 or 1.5 then we'll be
            // changing the behavior from the past where we always advertise
            // version 1.4. May need to check that revision is valid
            // before using cnx->major & cnx->minor
            if (major != nullptr) *major = cnx->major;
            if (minor != nullptr) *minor = cnx->minor;
            return EGL_TRUE;
        }
        while(eglIsInitialized) {
@@ -358,7 +394,52 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {

        // the query strings are per-display
        mVendorString = sVendorString;
        mVersionString = sVersionString;
        mVersionString.clear();
        cnx->driverVersion = EGL_MAKE_VERSION(1, 4, 0);
        if ((cnx->major == 1) && (cnx->minor == 5)) {
            mVersionString = sVersionString15;
            cnx->driverVersion = EGL_MAKE_VERSION(1, 5, 0);
        } else if ((cnx->major == 1) && (cnx->minor == 4)) {
            mVersionString = sVersionString14;
            // Extensions needed for an EGL 1.4 implementation to be
            // able to support EGL 1.5 functionality
            std::vector<const char*> egl15extensions = {
                    "EGL_EXT_client_extensions",
                    // "EGL_EXT_platform_base",  // implemented by EGL runtime
                    "EGL_KHR_image_base",
                    "EGL_KHR_fence_sync",
                    "EGL_KHR_wait_sync",
                    "EGL_KHR_create_context",
                    "EGL_EXT_create_context_robustness",
                    "EGL_KHR_gl_colorspace",
                    "EGL_ANDROID_native_fence_sync",
            };
            bool extensionsFound = true;
            for (const auto& name : egl15extensions) {
                extensionsFound &= findExtension(disp.queryString.extensions, name);
                ALOGV("Extension %s: %s", name,
                      findExtension(disp.queryString.extensions, name) ? "Found" : "Missing");
            }
            // NOTE: From the spec:
            // Creation of fence sync objects requires support from the bound
            // client API, and will not succeed unless the client API satisfies:
            // client API is OpenGL ES, and either the OpenGL ES version is 3.0
            // or greater, or the GL_OES_EGL_sync extension is supported.
            // We don't have a way to check the GL_EXTENSIONS string at this
            // point in the code, assume that GL_OES_EGL_sync is supported
            // because EGL_KHR_fence_sync is supported (as verified above).
            if (extensionsFound) {
                // Have everything needed to emulate EGL 1.5 so report EGL 1.5
                // to the application.
                mVersionString = sVersionString15;
                cnx->major = 1;
                cnx->minor = 5;
            }
        }
        if (mVersionString.empty()) {
            ALOGW("Unexpected driver version: %d.%d, want 1.4 or 1.5", cnx->major, cnx->minor);
            mVersionString = sVersionString14;
        }
        mClientApiString = sClientApiString;

        mExtensionString = gBuiltinExtensionString;
@@ -419,10 +500,12 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
            traceGpuCompletion = true;
        }

        if (major != nullptr)
            *major = VERSION_MAJOR;
        if (minor != nullptr)
            *minor = VERSION_MINOR;
        // TODO: If device doesn't provide 1.4 or 1.5 then we'll be
        // changing the behavior from the past where we always advertise
        // version 1.4. May need to check that revision is valid
        // before using cnx->major & cnx->minor
        if (major != nullptr) *major = cnx->major;
        if (minor != nullptr) *minor = cnx->minor;
    }

    { // scope for refLock
Loading