diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-10-06 17:06:14 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-12-02 09:18:45 +0100 |
commit | 61de0e721f672e854551a8938d2d42ba946398cf (patch) | |
tree | 2a36dfb72417701b093cde8b333a434f8fcacd27 /src/core/ozone | |
parent | 5dc3a3fb5e3286a9643fece7c7f94cec7fc29f3e (diff) |
Adaptations for Chromium 94
Change-Id: I9fb8998a3a7762b0aea70993ca231f0bbf4f7761
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core/ozone')
-rw-r--r-- | src/core/ozone/gl_surface_egl_qt.cpp | 135 | ||||
-rw-r--r-- | src/core/ozone/ozone_platform_qt.cpp | 12 | ||||
-rw-r--r-- | src/core/ozone/platform_window_qt.cpp | 6 | ||||
-rw-r--r-- | src/core/ozone/platform_window_qt.h | 2 | ||||
-rw-r--r-- | src/core/ozone/surface_factory_qt.cpp | 7 | ||||
-rw-r--r-- | src/core/ozone/surface_factory_qt.h | 4 |
6 files changed, 90 insertions, 76 deletions
diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp index 8c8ae98a7..f7d162923 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -60,71 +60,6 @@ using ui::GetLastEGLErrorString; namespace gl { -bool GLSurfaceEGLQt::g_egl_surfaceless_context_supported = false; -bool GLSurfaceEGLQt::s_initialized = false; - -GLSurfaceEGLQt::~GLSurfaceEGLQt() -{ - Destroy(); -} - -bool GLSurfaceEGLQt::InitializeOneOff() -{ - if (s_initialized) - return true; - - // Must be called before initializing the display. - g_driver_egl.InitializeClientExtensionBindings(); - - g_display = GLContextHelper::getEGLDisplay(); - if (!g_display) { - LOG(ERROR) << "GLContextHelper::getEGLDisplay() failed."; - return false; - } - - g_config = GLContextHelper::getEGLConfig(); - if (!g_config) { - LOG(ERROR) << "GLContextHelper::getEGLConfig() failed."; - return false; - } - - if (!eglInitialize(g_display, NULL, NULL)) { - LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); - return false; - } - - g_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); - g_extensions = eglQueryString(g_display, EGL_EXTENSIONS); - g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context"); - if (g_egl_surfaceless_context_supported) { - scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(gfx::Size(1, 1)); - gl::GLContextAttribs attribs; - scoped_refptr<GLContext> context = init::CreateGLContext( - NULL, surface.get(), attribs); - - if (!context->MakeCurrent(surface.get())) - g_egl_surfaceless_context_supported = false; - - // Ensure context supports GL_OES_surfaceless_context. - if (g_egl_surfaceless_context_supported) { - g_egl_surfaceless_context_supported = context->HasExtension( - "GL_OES_surfaceless_context"); - context->ReleaseCurrent(surface.get()); - } - } - - // Must be called after initializing the display. - g_driver_egl.InitializeExtensionBindings(); - - s_initialized = true; - return true; -} - -bool GLSurfaceEGLQt::InitializeExtensionSettingsOneOff() -{ - return s_initialized; -} - bool GLSurfaceEGL::InitializeExtensionSettingsOneOff() { return GLSurfaceEGLQt::InitializeExtensionSettingsOneOff(); @@ -242,12 +177,82 @@ DisplayType GLSurfaceEGL::GetDisplayType() return DisplayType::DEFAULT; } +GLSurface *GLSurfaceEGL::createSurfaceless(const gfx::Size& size) +{ + return new GLSurfacelessQtEGL(size); +} + +bool GLSurfaceEGLQt::g_egl_surfaceless_context_supported = false; +bool GLSurfaceEGLQt::s_initialized = false; + GLSurfaceEGLQt::GLSurfaceEGLQt(const gfx::Size& size) : GLSurfaceQt(size), m_surfaceBuffer(0) { } +GLSurfaceEGLQt::~GLSurfaceEGLQt() +{ + Destroy(); +} + +bool GLSurfaceEGLQt::InitializeOneOff() +{ + if (s_initialized) + return true; + + // Must be called before initializing the display. + g_driver_egl.InitializeClientExtensionBindings(); + + g_display = GLContextHelper::getEGLDisplay(); + if (!g_display) { + LOG(ERROR) << "GLContextHelper::getEGLDisplay() failed."; + return false; + } + + g_config = GLContextHelper::getEGLConfig(); + if (!g_config) { + LOG(ERROR) << "GLContextHelper::getEGLConfig() failed."; + return false; + } + + if (!eglInitialize(g_display, NULL, NULL)) { + LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); + return false; + } + + g_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + g_extensions = eglQueryString(g_display, EGL_EXTENSIONS); + g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context"); + if (g_egl_surfaceless_context_supported) { + scoped_refptr<GLSurface> surface = new GLSurfacelessQtEGL(gfx::Size(1, 1)); + gl::GLContextAttribs attribs; + scoped_refptr<GLContext> context = init::CreateGLContext( + NULL, surface.get(), attribs); + + if (!context->MakeCurrent(surface.get())) + g_egl_surfaceless_context_supported = false; + + // Ensure context supports GL_OES_surfaceless_context. + if (g_egl_surfaceless_context_supported) { + g_egl_surfaceless_context_supported = context->HasExtension( + "GL_OES_surfaceless_context"); + context->ReleaseCurrent(surface.get()); + } + } + + // Must be called after initializing the display. + g_driver_egl.InitializeExtensionBindings(); + + s_initialized = true; + return true; +} + +bool GLSurfaceEGLQt::InitializeExtensionSettingsOneOff() +{ + return s_initialized; +} + bool GLSurfaceEGLQt::Initialize(GLSurfaceFormat format) { Q_ASSERT(!m_surfaceBuffer); diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp index 33d7bd992..0affec0d3 100644 --- a/src/core/ozone/ozone_platform_qt.cpp +++ b/src/core/ozone/ozone_platform_qt.cpp @@ -92,6 +92,8 @@ private: void InitializeUI(const ui::OzonePlatform::InitParams &) override; void InitializeGPU(const ui::OzonePlatform::InitParams &) override; + void InitScreen(ui::PlatformScreen *) override {} + std::unique_ptr<QtWebEngineCore::SurfaceFactoryQt> surface_factory_ozone_; std::unique_ptr<CursorFactory> cursor_factory_ozone_; @@ -213,11 +215,6 @@ static std::string getCurrentKeyboardLayout() void OzonePlatformQt::InitializeUI(const ui::OzonePlatform::InitParams &) { - overlay_manager_.reset(new StubOverlayManager()); - cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone()); - gpu_platform_support_host_.reset(ui::CreateStubGpuPlatformSupportHost()); - input_controller_ = CreateStubInputController(); - #if BUILDFLAG(USE_XKBCOMMON) std::string layout = getCurrentKeyboardLayout(); if (layout.empty()) { @@ -231,6 +228,11 @@ void OzonePlatformQt::InitializeUI(const ui::OzonePlatform::InitParams &) #endif // BUILDFLAG(USE_XKBCOMMON) KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(m_keyboardLayoutEngine.get()); + + overlay_manager_.reset(new StubOverlayManager()); + input_controller_ = CreateStubInputController(); + cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone()); + gpu_platform_support_host_.reset(ui::CreateStubGpuPlatformSupportHost()); } void OzonePlatformQt::InitializeGPU(const ui::OzonePlatform::InitParams &) diff --git a/src/core/ozone/platform_window_qt.cpp b/src/core/ozone/platform_window_qt.cpp index 74b95d9a2..e8ac4d025 100644 --- a/src/core/ozone/platform_window_qt.cpp +++ b/src/core/ozone/platform_window_qt.cpp @@ -41,6 +41,7 @@ #include "base/bind.h" #include "ozone/platform_window_qt.h" +#include "ui/base/cursor/platform_cursor.h" #include "ui/events/ozone/events_ozone.h" #include "ui/events/platform/platform_event_source.h" #include "ui/platform_window/platform_window_delegate.h" @@ -64,6 +65,11 @@ gfx::Rect PlatformWindowQt::GetBounds() const return bounds_; } +void PlatformWindowQt::Close() +{ + delegate_->OnClosed(); +} + void PlatformWindowQt::SetBounds(const gfx::Rect& bounds) { if (bounds == bounds_) diff --git a/src/core/ozone/platform_window_qt.h b/src/core/ozone/platform_window_qt.h index 2e5d189aa..6a0984da8 100644 --- a/src/core/ozone/platform_window_qt.h +++ b/src/core/ozone/platform_window_qt.h @@ -60,7 +60,7 @@ public: void SetBounds(const gfx::Rect& bounds) override; void Show(bool inactive = false) override { } void Hide() override { } - void Close() override { } + void Close() override; bool IsVisible() const override { return true; } void SetTitle(const std::u16string&) override { } void SetCapture() override { } diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp index e2ffabe0e..719c8174a 100644 --- a/src/core/ozone/surface_factory_qt.cpp +++ b/src/core/ozone/surface_factory_qt.cpp @@ -52,19 +52,20 @@ SurfaceFactoryQt::SurfaceFactoryQt() { #if defined(USE_GLX) if (GLContextHelper::getGlxPlatformInterface()) { - m_impl = { gl::kGLImplementationDesktopGL }; + m_impl = { gl::GLImplementationParts(gl::kGLImplementationDesktopGL) }; m_ozone.reset(new ui::GLOzoneGLXQt()); } else #endif if (GLContextHelper::getEglPlatformInterface()) { - m_impl = { gl::kGLImplementationDesktopGL, gl::kGLImplementationEGLGLES2 }; + m_impl = { gl::GLImplementationParts(gl::kGLImplementationDesktopGL), + gl::GLImplementationParts(gl::kGLImplementationEGLGLES2) }; m_ozone.reset(new ui::GLOzoneEGLQt()); } else { qFatal("No suitable graphics backend found\n"); } } -std::vector<gl::GLImplementation> SurfaceFactoryQt::GetAllowedGLImplementations() +std::vector<gl::GLImplementationParts> SurfaceFactoryQt::GetAllowedGLImplementations() { return m_impl; } diff --git a/src/core/ozone/surface_factory_qt.h b/src/core/ozone/surface_factory_qt.h index fa8331a78..da208f8e6 100644 --- a/src/core/ozone/surface_factory_qt.h +++ b/src/core/ozone/surface_factory_qt.h @@ -50,10 +50,10 @@ class SurfaceFactoryQt : public ui::SurfaceFactoryOzone { public: SurfaceFactoryQt(); - std::vector<gl::GLImplementation> GetAllowedGLImplementations() override; + std::vector<gl::GLImplementationParts> GetAllowedGLImplementations() override; ui::GLOzone *GetGLOzone(const gl::GLImplementationParts &implementation) override; private: - std::vector<gl::GLImplementation> m_impl; + std::vector<gl::GLImplementationParts> m_impl; std::unique_ptr<ui::GLOzone> m_ozone; }; |