diff options
Diffstat (limited to 'src/core/ozone/gl_surface_egl_qt.cpp')
-rw-r--r-- | src/core/ozone/gl_surface_egl_qt.cpp | 155 |
1 files changed, 34 insertions, 121 deletions
diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp index 163d9242d..7f00ea6ed 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -8,13 +8,14 @@ #include "gl_context_qt.h" #include "ozone/gl_surface_egl_qt.h" -#if !BUILDFLAG(IS_MAC) #include "ui/gl/egl_util.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_display.h" +#include "ui/gl/gl_display_manager.h" #include "ui/gl/gl_surface_egl.h" #include "ui/gl/init/gl_factory.h" +#if !BUILDFLAG(IS_MAC) // From ANGLE's egl/eglext.h. #ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle #define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 @@ -25,157 +26,69 @@ using ui::GetLastEGLErrorString; namespace gl { -bool GLSurfaceEGL::InitializeExtensionSettingsOneOff(GLDisplayEGL* display) +bool GLDisplayEGL::InitializeExtensionSettings() { return GLSurfaceEGLQt::InitializeExtensionSettingsOneOff(); } -EGLDisplay GLDisplayEGL::GetHardwareDisplay() -{ - return GLSurfaceQt::g_display ? static_cast<EGLDisplay>(GLSurfaceQt::g_display->GetDisplay()) : EGL_NO_DISPLAY; -} - -bool GLDisplayEGL::IsCreateContextRobustnessSupported() +GLDisplayEGL *GLDisplayEGL::GetDisplayForCurrentContext() { - return GLContextHelper::isCreateContextRobustnessSupported() && HasEGLExtension("EGL_EXT_create_context_robustness"); + GLContext *context = GLContext::GetCurrent(); + return context ? context->GetGLDisplayEGL() : nullptr; } -bool GLDisplayEGL::IsCreateContextBindGeneratesResourceSupported() -{ - return false; -} - -bool GLDisplayEGL::IsCreateContextWebGLCompatabilitySupported() -{ - return false; -} bool GLDisplayEGL::IsEGLSurfacelessContextSupported() { return GLSurfaceEGLQt::g_egl_surfaceless_context_supported; } -bool GLDisplayEGL::IsEGLContextPrioritySupported() -{ - return false; -} - -bool GLDisplayEGL::IsRobustResourceInitSupported() -{ - return false; -} - -bool GLDisplayEGL::IsDisplayTextureShareGroupSupported() -{ - return false; -} - -bool GLDisplayEGL::IsCreateContextClientArraysSupported() -{ - return false; -} - -bool GLDisplayEGL::IsPixelFormatFloatSupported() -{ - return false; -} - -bool GLDisplayEGL::IsANGLEFeatureControlSupported() -{ - return false; -} - -bool GLDisplayEGL::IsANGLEPowerPreferenceSupported() -{ - return false; -} -bool GLDisplayEGL::IsANGLEExternalContextAndSurfaceSupported() -{ - return false; -} - -bool GLDisplayEGL::IsDisplaySemaphoreShareGroupSupported() -{ - return false; -} - -bool GLDisplayEGL::IsRobustnessVideoMemoryPurgeSupported() -{ - return false; -} - -bool GLDisplayEGL::IsANGLEContextVirtualizationSupported() +bool GLDisplayEGL::IsEGLContextPrioritySupported() { return false; } -bool GLDisplayEGL::IsANGLEVulkanImageSupported() -{ - return false; -} - -bool GLDisplayEGL::IsEGLQueryDeviceSupported() +bool GLDisplayEGL::Initialize(gl::EGLDisplayPlatform native_display) { - return false; -} + auto glDisplay = GLSurfaceEGLQt::InitializeOneOff(0); -void GLSurfaceEGL::ShutdownOneOff(GLDisplayEGL *) -{ -} - -const char *GetEGLClientExtensions() -{ - return GLSurfaceQt::g_client_extensions.c_str(); -} - -const char *GetEGLExtensions() -{ - return GLSurfaceQt::g_extensions.c_str(); -} - -bool GLDisplayEGL::HasEGLClientExtension(const char *name) -{ - return GLSurface::ExtensionsContain(GetEGLClientExtensions(), name); -} - -bool GLDisplayEGL::HasEGLExtension(const char *name) -{ - return GLSurface::ExtensionsContain(GetEGLExtensions(), name); -} + if (glDisplay) { + display_ = glDisplay->GetDisplay(); + native_display_ = native_display; + } -GLDisplayEGL *GLSurfaceEGL::InitializeOneOff(gl::EGLDisplayPlatform /*native_display*/, uint64_t system_id) -{ - return static_cast<GLDisplayEGL *>(GLSurfaceEGLQt::InitializeOneOff(system_id)); + return glDisplay; } -bool GLDisplayEGL::IsEGLNoConfigContextSupported() +bool GLDisplayEGL::IsAndroidNativeFenceSyncSupported() { return false; } -bool GLDisplayEGL::IsAndroidNativeFenceSyncSupported() +// static +GLDisplayEGL *GLSurfaceEGL::GetGLDisplayEGL() { - return false; + return GLDisplayManagerEGL::GetInstance()->GetDisplay(GpuPreference::kDefault); } -GLDisplayEGL *GLSurfaceEGL::GetGLDisplayEGL() +DisplayType GLDisplayEGL::GetDisplayType() const { - return static_cast<GLDisplayEGL *>(GLSurfaceEGLQt::g_display); + return DisplayType::DEFAULT; } -DisplayType GLDisplayEGL::GetDisplayType() +EGLDisplayPlatform GLDisplayEGL::GetNativeDisplay() const { - return DisplayType::DEFAULT; + return native_display_; } -GLSurface *GLSurfaceEGL::createSurfaceless(const gfx::Size& size) +GLSurface *GLSurfaceEGL::createSurfaceless(gl::GLDisplayEGL *display, const gfx::Size& size) { - return new GLSurfacelessQtEGL(size); + return new GLSurfacelessQtEGL(display, size); } bool GLSurfaceEGLQt::g_egl_surfaceless_context_supported = false; bool GLSurfaceEGLQt::s_initialized = false; -GLSurfaceEGLQt::GLSurfaceEGLQt(const gfx::Size& size) +GLSurfaceEGLQt::GLSurfaceEGLQt(gl::GLDisplayEGL *display, const gfx::Size& size) : GLSurfaceQt(size), m_surfaceBuffer(0) { @@ -191,10 +104,10 @@ gl::GLDisplay *GLSurfaceEGLQt::InitializeOneOff(uint64_t system_device_id) if (s_initialized) return g_display; - auto *egl_display = new GLDisplayEGL(system_device_id); + auto *egl_display = GLDisplayManagerEGL::GetInstance()->GetDisplay(system_device_id); g_display = egl_display; egl_display->SetDisplay(GLContextHelper::getEGLDisplay()); - if (!g_display->GetDisplay()) { + if (!egl_display->GetDisplay()) { LOG(ERROR) << "GLContextHelper::getEGLDisplay() failed."; return nullptr; } @@ -205,16 +118,16 @@ gl::GLDisplay *GLSurfaceEGLQt::InitializeOneOff(uint64_t system_device_id) return nullptr; } - if (!eglInitialize(g_display->GetDisplay(), NULL, NULL)) { + if (!eglInitialize(egl_display->GetDisplay(), NULL, NULL)) { LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); return nullptr; } g_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); - g_extensions = eglQueryString(g_display->GetDisplay(), EGL_EXTENSIONS); + g_extensions = eglQueryString(egl_display->GetDisplay(), EGL_EXTENSIONS); g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions.c_str(), "EGL_KHR_surfaceless_context"); if (g_egl_surfaceless_context_supported) { - scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(gfx::Size(1, 1)); + scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(egl_display, gfx::Size(1, 1)); gl::GLContextAttribs attribs; scoped_refptr<GLContext> context = init::CreateGLContext( NULL, surface.get(), attribs); @@ -231,7 +144,7 @@ gl::GLDisplay *GLSurfaceEGLQt::InitializeOneOff(uint64_t system_device_id) } s_initialized = true; - return g_display; + return egl_display; } bool GLSurfaceEGLQt::InitializeExtensionSettingsOneOff() @@ -244,7 +157,7 @@ bool GLSurfaceEGLQt::Initialize(GLSurfaceFormat format) Q_ASSERT(!m_surfaceBuffer); m_format = format; - EGLDisplay display = g_display->GetDisplay(); + EGLDisplay display = GLContextHelper::getEGLDisplay(); if (!display) { LOG(ERROR) << "Trying to create surface with invalid display."; return false; @@ -272,7 +185,7 @@ bool GLSurfaceEGLQt::Initialize(GLSurfaceFormat format) void GLSurfaceEGLQt::Destroy() { if (m_surfaceBuffer) { - if (!eglDestroySurface(g_display->GetDisplay(), m_surfaceBuffer)) + if (!eglDestroySurface(GLContextHelper::getEGLDisplay(), m_surfaceBuffer)) LOG(ERROR) << "eglDestroySurface failed with error " << GetLastEGLErrorString(); m_surfaceBuffer = 0; @@ -310,7 +223,7 @@ void* GLSurfaceEGLQt::GetHandle() return reinterpret_cast<void*>(m_surfaceBuffer); } -GLSurfacelessQtEGL::GLSurfacelessQtEGL(const gfx::Size& size) +GLSurfacelessQtEGL::GLSurfacelessQtEGL(GLDisplayEGL *display, const gfx::Size& size) : GLSurfaceQt(size) { } |