diff options
Diffstat (limited to 'src/core/ozone/gl_surface_qt.cpp')
-rw-r--r-- | src/core/ozone/gl_surface_qt.cpp | 141 |
1 files changed, 50 insertions, 91 deletions
diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp index 0e181b4c1..0cbe75cbd 100644 --- a/src/core/ozone/gl_surface_qt.cpp +++ b/src/core/ozone/gl_surface_qt.cpp @@ -1,32 +1,38 @@ -// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE.Chromium file. -#if !defined(OS_MAC) +#include "qtwebenginecoreglobal_p.h" + +#if !defined(Q_OS_MACOS) #include "gl_surface_qt.h" -#include "qtwebenginecoreglobal_p.h" -#if defined(OS_WIN) +#include "base/logging.h" + +#if BUILDFLAG(IS_WIN) #include "web_engine_context.h" #include "ozone/gl_surface_wgl_qt.h" -#include "ozone/gl_surface_egl_qt.h" #include "gpu/ipc/service/image_transport_surface.h" +#include "ui/gl/init/gl_display_initializer.h" +#include "ui/gl/direct_composition_support.h" +#include "ui/gl/gl_angle_util_win.h" +#include "ui/gl/gl_display.h" #include "ui/gl/gl_implementation.h" -#include "ui/gl/direct_composition_surface_win.h" +#include "ui/gl/gl_surface_egl.h" +#include "ui/gl/gl_utils.h" #include "ui/gl/vsync_provider_win.h" #endif namespace gl { -void *GLSurfaceQt::g_display = nullptr; +GLDisplay *GLSurfaceQt::g_display = nullptr; void *GLSurfaceQt::g_config = nullptr; -std::string GLSurfaceQt::g_client_extensions; std::string GLSurfaceQt::g_extensions; GLSurfaceQt::~GLSurfaceQt() @@ -56,7 +62,7 @@ bool GLSurfaceQt::IsOffscreen() return true; } -gfx::SwapResult GLSurfaceQt::SwapBuffers(PresentationCallback callback) +gfx::SwapResult GLSurfaceQt::SwapBuffers(PresentationCallback callback, gfx::FrameData data) { LOG(ERROR) << "Attempted to call SwapBuffers on a pbuffer."; Q_UNREACHABLE(); @@ -73,7 +79,7 @@ GLSurfaceFormat GLSurfaceQt::GetFormat() return m_format; } -void* GLSurfaceQt::GetDisplay() +GLDisplay *GLSurfaceQt::GetGLDisplay() { return g_display; } @@ -83,28 +89,47 @@ void* GLSurfaceQt::GetConfig() return g_config; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) namespace init { -bool InitializeGLOneOffPlatform() + +gl::GLDisplay *InitializeGLOneOffPlatform(gl::GpuPreference gpu_preference) { VSyncProviderWin::InitializeOneOff(); - if (GetGLImplementation() == kGLImplementationEGLGLES2 || GetGLImplementation() == kGLImplementationEGLANGLE) - return GLSurfaceEGLQt::InitializeOneOff(); - if (GetGLImplementation() == kGLImplementationDesktopGL || GetGLImplementation() == kGLImplementationDesktopGLCoreProfile) - return GLSurfaceWGLQt::InitializeOneOff(); + return GLSurfaceWGLQt::InitializeOneOff(gpu_preference); - return false; + GLDisplayEGL *display = GetDisplayEGL(gpu_preference); + switch (GetGLImplementation()) { + case kGLImplementationEGLANGLE: + case kGLImplementationEGLGLES2: + if (!InitializeDisplay(display, EGLDisplayPlatform(GetDC(nullptr)))) { + LOG(ERROR) << "GLDisplayEGL::Initialize failed."; + return nullptr; + } + if (auto d3d11_device = QueryD3D11DeviceObjectFromANGLE()) + InitializeDirectComposition(std::move(d3d11_device)); + break; + case kGLImplementationMockGL: + case kGLImplementationStubGL: + break; + default: + NOTREACHED(); + } + return display; } bool usingSoftwareDynamicGL() { +#if QT_CONFIG(opengl) return QtWebEngineCore::usingSoftwareDynamicGL(); +#else + return false; +#endif // QT_CONFIG(opengl) } scoped_refptr<GLSurface> -CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format) +CreateOffscreenGLSurfaceWithFormat(GLDisplay *display, const gfx::Size& size, GLSurfaceFormat format) { scoped_refptr<GLSurface> surface; switch (GetGLImplementation()) { @@ -117,21 +142,10 @@ CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format } case kGLImplementationEGLANGLE: case kGLImplementationEGLGLES2: { - surface = new GLSurfaceEGLQt(size); - if (surface->Initialize(format)) - return surface; - - // Surfaceless context will be used ONLY if pseudo surfaceless context - // is not available since some implementations of surfaceless context - // have problems. (e.g. QTBUG-57290) - if (GLSurfaceEGLQt::g_egl_surfaceless_context_supported) { - surface = new GLSurfacelessQtEGL(size); - if (surface->Initialize(format)) - return surface; - } - LOG(ERROR) << "eglCreatePbufferSurface failed and surfaceless context not available"; - LOG(WARNING) << "Failed to create offscreen GL surface"; - break; + GLDisplayEGL *display_egl = display->GetAs<gl::GLDisplayEGL>(); + if (display_egl->IsEGLSurfacelessContextSupported() && size.width() == 0 && size.height() == 0) + return InitializeGLSurfaceWithFormat(new SurfacelessEGL(display_egl, size), format); + return InitializeGLSurfaceWithFormat(new PbufferGLSurfaceEGL(display_egl, size), format); } default: break; @@ -142,68 +156,13 @@ CreateOffscreenGLSurfaceWithFormat(const gfx::Size& size, GLSurfaceFormat format } scoped_refptr<GLSurface> -CreateViewGLSurface(gfx::AcceleratedWidget window) +CreateViewGLSurface(GLDisplay *display, gfx::AcceleratedWidget window) { - QT_NOT_USED return nullptr; } } // namespace init -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // namespace gl -#if defined(OS_WIN) -namespace gpu { -class GpuCommandBufferStub; -class GpuChannelManager; -scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface(base::WeakPtr<ImageTransportSurfaceDelegate>, - SurfaceHandle, gl::GLSurfaceFormat) -{ - QT_NOT_USED - return scoped_refptr<gl::GLSurface>(); -} -} // namespace gpu - -namespace gl { - -bool DirectCompositionSurfaceWin::IsDirectCompositionSupported() -{ - return false; -} - -bool DirectCompositionSurfaceWin::IsDecodeSwapChainSupported() -{ - return false; -} - -bool DirectCompositionSurfaceWin::IsHDRSupported() -{ - return false; -} - -bool DirectCompositionSurfaceWin::IsSwapChainTearingSupported() -{ - return false; -} - -bool DirectCompositionSurfaceWin::AreOverlaysSupported() -{ - return false; -} - -UINT DirectCompositionSurfaceWin::GetOverlaySupportFlags(DXGI_FORMAT format) -{ - Q_UNUSED(format); - return 0; -} - -void DirectCompositionSurfaceWin::DisableDecodeSwapChain() -{ -} - -void DirectCompositionSurfaceWin::DisableSoftwareOverlays() -{ -} -} // namespace gl -#endif -#endif // !defined(OS_MAC) +#endif // !defined(Q_OS_MACOS) |