diff options
Diffstat (limited to 'src/core/ozone/gl_surface_qt.cpp')
-rw-r--r-- | src/core/ozone/gl_surface_qt.cpp | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/src/core/ozone/gl_surface_qt.cpp b/src/core/ozone/gl_surface_qt.cpp index fad3ccc11..0cbe75cbd 100644 --- a/src/core/ozone/gl_surface_qt.cpp +++ b/src/core/ozone/gl_surface_qt.cpp @@ -1,4 +1,4 @@ -// 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. @@ -16,11 +16,15 @@ #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 @@ -29,7 +33,6 @@ namespace gl { GLDisplay *GLSurfaceQt::g_display = nullptr; void *GLSurfaceQt::g_config = nullptr; -std::string GLSurfaceQt::g_client_extensions; std::string GLSurfaceQt::g_extensions; GLSurfaceQt::~GLSurfaceQt() @@ -59,7 +62,7 @@ bool GLSurfaceQt::IsOffscreen() return true; } -gfx::SwapResult GLSurfaceQt::SwapBuffers(PresentationCallback callback, FrameData data) +gfx::SwapResult GLSurfaceQt::SwapBuffers(PresentationCallback callback, gfx::FrameData data) { LOG(ERROR) << "Attempted to call SwapBuffers on a pbuffer."; Q_UNREACHABLE(); @@ -89,17 +92,31 @@ void* GLSurfaceQt::GetConfig() #if BUILDFLAG(IS_WIN) namespace init { -gl::GLDisplay *InitializeGLOneOffPlatform(uint64_t system_device_id) +gl::GLDisplay *InitializeGLOneOffPlatform(gl::GpuPreference gpu_preference) { VSyncProviderWin::InitializeOneOff(); - if (GetGLImplementation() == kGLImplementationEGLGLES2 || GetGLImplementation() == kGLImplementationEGLANGLE) - return GLSurfaceEGLQt::InitializeOneOff(system_device_id); - if (GetGLImplementation() == kGLImplementationDesktopGL || GetGLImplementation() == kGLImplementationDesktopGLCoreProfile) - return GLSurfaceWGLQt::InitializeOneOff(system_device_id); + return GLSurfaceWGLQt::InitializeOneOff(gpu_preference); - return nullptr; + 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() @@ -125,21 +142,10 @@ CreateOffscreenGLSurfaceWithFormat(GLDisplay *display, const gfx::Size& size, GL } case kGLImplementationEGLANGLE: case kGLImplementationEGLGLES2: { - surface = new GLSurfaceEGLQt(static_cast<gl::GLDisplayEGL*>(display), 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(static_cast<gl::GLDisplayEGL*>(display), 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; @@ -150,9 +156,8 @@ CreateOffscreenGLSurfaceWithFormat(GLDisplay *display, const gfx::Size& size, GL } scoped_refptr<GLSurface> -CreateViewGLSurface(gfx::AcceleratedWidget window) +CreateViewGLSurface(GLDisplay *display, gfx::AcceleratedWidget window) { - QT_NOT_USED return nullptr; } @@ -160,18 +165,4 @@ CreateViewGLSurface(gfx::AcceleratedWidget window) #endif // BUILDFLAG(IS_WIN) } // namespace gl -#if BUILDFLAG(IS_WIN) -namespace gpu { -class GpuCommandBufferStub; -class GpuChannelManager; -scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface(gl::GLDisplay *, - base::WeakPtr<ImageTransportSurfaceDelegate>, - SurfaceHandle, gl::GLSurfaceFormat) -{ - QT_NOT_USED - return scoped_refptr<gl::GLSurface>(); -} -} // namespace gpu -#endif // BUILDFLAG(IS_WIN) - #endif // !defined(Q_OS_MACOS) |