diff options
Diffstat (limited to 'opengl/libs/EGL/egl_object.cpp')
-rw-r--r-- | opengl/libs/EGL/egl_object.cpp | 144 |
1 files changed, 84 insertions, 60 deletions
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp index ff4fe2dd9c..efbe613542 100644 --- a/opengl/libs/EGL/egl_object.cpp +++ b/opengl/libs/EGL/egl_object.cpp @@ -18,19 +18,14 @@ #include <sstream> - -// ---------------------------------------------------------------------------- namespace android { -// ---------------------------------------------------------------------------- -egl_object_t::egl_object_t(egl_display_t* disp) : - display(disp), count(1) { +egl_object_t::egl_object_t(egl_display_t* disp) : display(disp), count(1) { // NOTE: this does an implicit incRef display->addObject(this); } -egl_object_t::~egl_object_t() { -} +egl_object_t::~egl_object_t() {} void egl_object_t::terminate() { // this marks the object as "terminated" @@ -53,8 +48,6 @@ bool egl_object_t::get(egl_display_t const* display, egl_object_t* object) { return display->getObject(object); } -// ---------------------------------------------------------------------------- - egl_surface_t::egl_surface_t(egl_display_t* dpy, EGLConfig config, EGLNativeWindowType win, EGLSurface surface, EGLint colorSpace, egl_connection_t const* cnx) : egl_object_t(dpy), @@ -66,10 +59,10 @@ egl_surface_t::egl_surface_t(egl_display_t* dpy, EGLConfig config, EGLNativeWind colorSpace(colorSpace), egl_smpte2086_dirty(false), egl_cta861_3_dirty(false) { - egl_smpte2086_metadata.displayPrimaryRed = { EGL_DONT_CARE, EGL_DONT_CARE }; - egl_smpte2086_metadata.displayPrimaryGreen = { EGL_DONT_CARE, EGL_DONT_CARE }; - egl_smpte2086_metadata.displayPrimaryBlue = { EGL_DONT_CARE, EGL_DONT_CARE }; - egl_smpte2086_metadata.whitePoint = { EGL_DONT_CARE, EGL_DONT_CARE }; + egl_smpte2086_metadata.displayPrimaryRed = {EGL_DONT_CARE, EGL_DONT_CARE}; + egl_smpte2086_metadata.displayPrimaryGreen = {EGL_DONT_CARE, EGL_DONT_CARE}; + egl_smpte2086_metadata.displayPrimaryBlue = {EGL_DONT_CARE, EGL_DONT_CARE}; + egl_smpte2086_metadata.whitePoint = {EGL_DONT_CARE, EGL_DONT_CARE}; egl_smpte2086_metadata.maxLuminance = EGL_DONT_CARE; egl_smpte2086_metadata.minLuminance = EGL_DONT_CARE; egl_cta861_3_metadata.maxFrameAverageLightLevel = EGL_DONT_CARE; @@ -89,9 +82,13 @@ egl_surface_t::~egl_surface_t() { void egl_surface_t::disconnect() { if (win != nullptr && connected) { - native_window_set_buffers_format(win, 0); - if (native_window_api_disconnect(win, NATIVE_WINDOW_API_EGL)) { - ALOGW("EGLNativeWindowType %p disconnect failed", win); + // NOTE: When using Vulkan backend, the Vulkan runtime makes all the + // native_window_* calls, so don't do them here. + if (!cnx->useAngle) { + native_window_set_buffers_format(win, 0); + if (native_window_api_disconnect(win, NATIVE_WINDOW_API_EGL)) { + ALOGW("EGLNativeWindowType %p disconnect failed", win); + } } connected = false; } @@ -173,16 +170,30 @@ EGLBoolean egl_surface_t::getSmpte2086Metadata(android_smpte2086_metadata& metad return EGL_FALSE; } - metadata.displayPrimaryRed.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.x) / EGL_METADATA_SCALING_EXT; - metadata.displayPrimaryRed.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.y) / EGL_METADATA_SCALING_EXT; - metadata.displayPrimaryGreen.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.x) / EGL_METADATA_SCALING_EXT; - metadata.displayPrimaryGreen.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.y) / EGL_METADATA_SCALING_EXT; - metadata.displayPrimaryBlue.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.x) / EGL_METADATA_SCALING_EXT; - metadata.displayPrimaryBlue.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.y) / EGL_METADATA_SCALING_EXT; - metadata.whitePoint.x = static_cast<float>(egl_smpte2086_metadata.whitePoint.x) / EGL_METADATA_SCALING_EXT; - metadata.whitePoint.y = static_cast<float>(egl_smpte2086_metadata.whitePoint.y) / EGL_METADATA_SCALING_EXT; - metadata.maxLuminance = static_cast<float>(egl_smpte2086_metadata.maxLuminance) / EGL_METADATA_SCALING_EXT; - metadata.minLuminance = static_cast<float>(egl_smpte2086_metadata.minLuminance) / EGL_METADATA_SCALING_EXT; + metadata.displayPrimaryRed.x = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.x) / + EGL_METADATA_SCALING_EXT; + metadata.displayPrimaryRed.y = static_cast<float>(egl_smpte2086_metadata.displayPrimaryRed.y) / + EGL_METADATA_SCALING_EXT; + metadata.displayPrimaryGreen.x = + static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.x) / + EGL_METADATA_SCALING_EXT; + metadata.displayPrimaryGreen.y = + static_cast<float>(egl_smpte2086_metadata.displayPrimaryGreen.y) / + EGL_METADATA_SCALING_EXT; + metadata.displayPrimaryBlue.x = + static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.x) / + EGL_METADATA_SCALING_EXT; + metadata.displayPrimaryBlue.y = + static_cast<float>(egl_smpte2086_metadata.displayPrimaryBlue.y) / + EGL_METADATA_SCALING_EXT; + metadata.whitePoint.x = + static_cast<float>(egl_smpte2086_metadata.whitePoint.x) / EGL_METADATA_SCALING_EXT; + metadata.whitePoint.y = + static_cast<float>(egl_smpte2086_metadata.whitePoint.y) / EGL_METADATA_SCALING_EXT; + metadata.maxLuminance = + static_cast<float>(egl_smpte2086_metadata.maxLuminance) / EGL_METADATA_SCALING_EXT; + metadata.minLuminance = + static_cast<float>(egl_smpte2086_metadata.minLuminance) / EGL_METADATA_SCALING_EXT; return EGL_TRUE; } @@ -196,13 +207,15 @@ EGLBoolean egl_surface_t::getCta8613Metadata(android_cta861_3_metadata& metadata return EGL_FALSE; } - metadata.maxContentLightLevel = static_cast<float>(egl_cta861_3_metadata.maxContentLightLevel) / EGL_METADATA_SCALING_EXT; - metadata.maxFrameAverageLightLevel = static_cast<float>(egl_cta861_3_metadata.maxFrameAverageLightLevel) / EGL_METADATA_SCALING_EXT; + metadata.maxContentLightLevel = static_cast<float>(egl_cta861_3_metadata.maxContentLightLevel) / + EGL_METADATA_SCALING_EXT; + metadata.maxFrameAverageLightLevel = + static_cast<float>(egl_cta861_3_metadata.maxFrameAverageLightLevel) / + EGL_METADATA_SCALING_EXT; return EGL_TRUE; } - EGLBoolean egl_surface_t::getColorSpaceAttribute(EGLint attribute, EGLint* value) const { if (attribute == EGL_GL_COLORSPACE_KHR) { *value = colorSpace; @@ -211,7 +224,7 @@ EGLBoolean egl_surface_t::getColorSpaceAttribute(EGLint attribute, EGLint* value return EGL_FALSE; } -EGLBoolean egl_surface_t::getSmpte2086Attribute(EGLint attribute, EGLint *value) const { +EGLBoolean egl_surface_t::getSmpte2086Attribute(EGLint attribute, EGLint* value) const { switch (attribute) { case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT: *value = egl_smpte2086_metadata.displayPrimaryRed.x; @@ -257,7 +270,7 @@ EGLBoolean egl_surface_t::getSmpte2086Attribute(EGLint attribute, EGLint *value) return EGL_FALSE; } -EGLBoolean egl_surface_t::getCta8613Attribute(EGLint attribute, EGLint *value) const { +EGLBoolean egl_surface_t::getCta8613Attribute(EGLint attribute, EGLint* value) const { switch (attribute) { case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT: *value = egl_cta861_3_metadata.maxContentLightLevel; @@ -276,13 +289,16 @@ void egl_surface_t::terminate() { egl_object_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; @@ -297,31 +313,39 @@ void egl_context_t::onMakeCurrent(EGLSurface draw, EGLSurface read) { * Here we cache the GL_EXTENSIONS string for this context and we * add the extensions always handled by the wrapper */ + if (!gl_extensions.empty()) return; + + // call the implementation's glGetString(GL_EXTENSIONS) + const char* exts = (const char*)gEGLImpl.hooks[version]->gl.glGetString(GL_EXTENSIONS); + if (!exts) return; + + // If this context is sharing with another context, and the other context was reset + // e.g. due to robustness failure, this context might also be reset and glGetString can + // return NULL. + gl_extensions = exts; + if (gl_extensions.find("GL_EXT_debug_marker") == std::string::npos) { + gl_extensions.insert(0, "GL_EXT_debug_marker "); + // eglGetProcAddress could return function pointers to these + // functions while they actually don't work. Fix them now. + __eglMustCastToProperFunctionPointerType* f; + f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version] + ->gl.glInsertEventMarkerEXT; + if (*f != gl_noop) *f = gl_noop; + f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version] + ->gl.glPushGroupMarkerEXT; + if (*f != gl_noop) *f = gl_noop; + f = (__eglMustCastToProperFunctionPointerType*)&gEGLImpl.hooks[version] + ->gl.glPopGroupMarkerEXT; + if (*f != gl_noop) *f = gl_noop; + } - if (gl_extensions.empty()) { - // call the implementation's glGetString(GL_EXTENSIONS) - const char* exts = (const char *)gEGLImpl.hooks[version]->gl.glGetString(GL_EXTENSIONS); - - // If this context is sharing with another context, and the other context was reset - // e.g. due to robustness failure, this context might also be reset and glGetString can - // return NULL. - if (exts) { - gl_extensions = exts; - if (gl_extensions.find("GL_EXT_debug_marker") == std::string::npos) { - gl_extensions.insert(0, "GL_EXT_debug_marker "); - } - - // tokenize the supported extensions for the glGetStringi() wrapper - std::stringstream ss; - std::string str; - ss << gl_extensions; - while (ss >> str) { - tokenized_gl_extensions.push_back(str); - } - } + // tokenize the supported extensions for the glGetStringi() wrapper + std::stringstream ss; + std::string str; + ss << gl_extensions; + while (ss >> str) { + tokenized_gl_extensions.push_back(str); } } -// ---------------------------------------------------------------------------- }; // namespace android -// ---------------------------------------------------------------------------- |