diff options
-rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/core/compositor/native_skia_output_device.cpp | 4 | ||||
-rw-r--r-- | src/core/compositor/native_skia_output_device_opengl.cpp | 10 | ||||
-rw-r--r-- | src/core/ozone/gl_ozone_qt.cpp (renamed from src/core/ozone/gl_ozone_angle_qt.cpp) | 96 | ||||
-rw-r--r-- | src/core/ozone/gl_ozone_qt.h (renamed from src/core/ozone/gl_ozone_angle_qt.h) | 29 | ||||
-rw-r--r-- | src/core/ozone/surface_factory_qt.cpp | 4 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 3 |
7 files changed, 119 insertions, 29 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e2594a09b..b12984820 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -206,7 +206,7 @@ foreach(arch ${archs}) extend_gn_target(${buildGn} CONDITION LINUX SOURCES - ozone/gl_ozone_angle_qt.cpp ozone/gl_ozone_angle_qt.h + ozone/gl_ozone_qt.cpp ozone/gl_ozone_qt.h ozone/ozone_util_qt.cpp ozone/ozone_util_qt.h ozone/platform_window_qt.cpp ozone/platform_window_qt.h ozone/surface_factory_qt.cpp ozone/surface_factory_qt.h diff --git a/src/core/compositor/native_skia_output_device.cpp b/src/core/compositor/native_skia_output_device.cpp index 948686be7..bf8fd575a 100644 --- a/src/core/compositor/native_skia_output_device.cpp +++ b/src/core/compositor/native_skia_output_device.cpp @@ -20,7 +20,7 @@ #include "ui/gl/gl_fence.h" #if BUILDFLAG(IS_OZONE) -#include "ozone/gl_ozone_angle_qt.h" +#include "ozone/gl_ozone_qt.h" #include "ui/ozone/public/ozone_platform.h" #endif @@ -77,7 +77,7 @@ NativeSkiaOutputDevice::NativeSkiaOutputDevice( } }; qCDebug(lcWebEngineCompositor, "Native Pixmap Support Type: %s", - typeToString(ui::GLOzoneANGLEQt::getNativePixmapSupportType())); + typeToString(ui::GLOzoneQt::getNativePixmapSupportType())); #endif } diff --git a/src/core/compositor/native_skia_output_device_opengl.cpp b/src/core/compositor/native_skia_output_device_opengl.cpp index 8f8413857..7421ea933 100644 --- a/src/core/compositor/native_skia_output_device_opengl.cpp +++ b/src/core/compositor/native_skia_output_device_opengl.cpp @@ -12,7 +12,7 @@ #if BUILDFLAG(IS_OZONE) #include "ozone/gl_helper.h" -#include "ozone/gl_ozone_angle_qt.h" +#include "ozone/gl_ozone_qt.h" #include "ozone/ozone_util_qt.h" #include "base/posix/eintr_wrapper.h" @@ -64,8 +64,14 @@ NativeSkiaOutputDeviceOpenGL::NativeSkiaOutputDeviceOpenGL( SkColorType skColorType = kRGBA_8888_SkColorType; #if BUILDFLAG(IS_OZONE) - if (ui::GLOzoneANGLEQt::getNativePixmapSupportType() == ui::NativePixmapSupportType::kX11Pixmap) + ui::NativePixmapSupportType type = ui::GLOzoneQt::getNativePixmapSupportType(); + if (type == ui::NativePixmapSupportType::kX11Pixmap) skColorType = kBGRA_8888_SkColorType; + + if (type == ui::NativePixmapSupportType::kDMABuf && OzoneUtilQt::usingGLX() + && gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2) { + skColorType = kBGRA_8888_SkColorType; + } #endif capabilities_.sk_color_type_map[viz::SinglePlaneFormat::kRGBA_8888] = skColorType; diff --git a/src/core/ozone/gl_ozone_angle_qt.cpp b/src/core/ozone/gl_ozone_qt.cpp index b5fa45cd8..2a9bd18b7 100644 --- a/src/core/ozone/gl_ozone_angle_qt.cpp +++ b/src/core/ozone/gl_ozone_qt.cpp @@ -5,8 +5,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "gl_ozone_angle_qt.h" +#include "gl_ozone_qt.h" #include "surface_factory_qt.h" +#include "ozone_util_qt.h" + +#include <QtCore/private/qconfig_p.h> +#include <QtGui/qopenglcontext.h> #include "ui/base/ozone_buildflags.h" #include "ui/gl/gl_bindings.h" @@ -21,6 +25,10 @@ #include "ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h" #endif +#if QT_CONFIG(dlopen) +#include <dlfcn.h> +#endif + extern "C" { typedef void (*__eglMustCastToProperFunctionPointerType)(void); extern __eglMustCastToProperFunctionPointerType EGL_GetProcAddress(const char *procname); @@ -28,7 +36,7 @@ extern __eglMustCastToProperFunctionPointerType EGL_GetProcAddress(const char *p namespace ui { -NativePixmapSupportType GLOzoneANGLEQt::getNativePixmapSupportType() +NativePixmapSupportType GLOzoneQt::getNativePixmapSupportType() { if (!QtWebEngineCore::SurfaceFactoryQt::SupportsNativePixmaps()) return NativePixmapSupportType::kNone; @@ -44,32 +52,31 @@ NativePixmapSupportType GLOzoneANGLEQt::getNativePixmapSupportType() return NativePixmapSupportType::kNone; } -bool GLOzoneANGLEQt::LoadGLES2Bindings(const gl::GLImplementationParts & /*implementation*/) +bool GLOzoneQt::LoadGLES2Bindings(const gl::GLImplementationParts & /*implementation*/) { - gl::SetGLGetProcAddressProc(&EGL_GetProcAddress); - return true; + return false; } -bool GLOzoneANGLEQt::InitializeStaticGLBindings(const gl::GLImplementationParts &implementation) +bool GLOzoneQt::InitializeStaticGLBindings(const gl::GLImplementationParts &implementation) { return GLOzoneEGL::InitializeStaticGLBindings(implementation); } -bool GLOzoneANGLEQt::InitializeExtensionSettingsOneOffPlatform(gl::GLDisplay *display) +bool GLOzoneQt::InitializeExtensionSettingsOneOffPlatform(gl::GLDisplay *display) { return GLOzoneEGL::InitializeExtensionSettingsOneOffPlatform( static_cast<gl::GLDisplayEGL *>(display)); } -scoped_refptr<gl::GLSurface> GLOzoneANGLEQt::CreateViewGLSurface(gl::GLDisplay * /*display*/, - gfx::AcceleratedWidget /*window*/) +scoped_refptr<gl::GLSurface> GLOzoneQt::CreateViewGLSurface(gl::GLDisplay * /*display*/, + gfx::AcceleratedWidget /*window*/) { return nullptr; } // based on GLOzoneEGLX11::CreateOffscreenGLSurface() (x11_surface_factory.cc) -scoped_refptr<gl::GLSurface> GLOzoneANGLEQt::CreateOffscreenGLSurface(gl::GLDisplay *display, - const gfx::Size &size) +scoped_refptr<gl::GLSurface> GLOzoneQt::CreateOffscreenGLSurface(gl::GLDisplay *display, + const gfx::Size &size) { gl::GLDisplayEGL *eglDisplay = display->GetAs<gl::GLDisplayEGL>(); @@ -79,7 +86,7 @@ scoped_refptr<gl::GLSurface> GLOzoneANGLEQt::CreateOffscreenGLSurface(gl::GLDisp return InitializeGLSurface(new gl::PbufferGLSurfaceEGL(eglDisplay, size)); } -gl::EGLDisplayPlatform GLOzoneANGLEQt::GetNativeDisplay() +gl::EGLDisplayPlatform GLOzoneQt::GetNativeDisplay() { #if BUILDFLAG(IS_OZONE_X11) static EGLNativeDisplayType nativeDisplay = @@ -94,7 +101,7 @@ gl::EGLDisplayPlatform GLOzoneANGLEQt::GetNativeDisplay() return gl::EGLDisplayPlatform(EGL_DEFAULT_DISPLAY); } -bool GLOzoneANGLEQt::CanImportNativePixmap(gfx::BufferFormat format) +bool GLOzoneQt::CanImportNativePixmap(gfx::BufferFormat format) { switch (getNativePixmapSupportType()) { case NativePixmapSupportType::kDMABuf: @@ -109,10 +116,10 @@ bool GLOzoneANGLEQt::CanImportNativePixmap(gfx::BufferFormat format) } std::unique_ptr<NativePixmapGLBinding> -GLOzoneANGLEQt::ImportNativePixmap(scoped_refptr<gfx::NativePixmap> pixmap, - gfx::BufferFormat plane_format, gfx::BufferPlane plane, - gfx::Size plane_size, const gfx::ColorSpace &color_space, - GLenum target, GLuint texture_id) +GLOzoneQt::ImportNativePixmap(scoped_refptr<gfx::NativePixmap> pixmap, + gfx::BufferFormat plane_format, gfx::BufferPlane plane, + gfx::Size plane_size, const gfx::ColorSpace &color_space, + GLenum target, GLuint texture_id) { switch (getNativePixmapSupportType()) { case NativePixmapSupportType::kDMABuf: @@ -129,4 +136,59 @@ GLOzoneANGLEQt::ImportNativePixmap(scoped_refptr<gfx::NativePixmap> pixmap, } } +bool GLOzoneANGLEQt::LoadGLES2Bindings(const gl::GLImplementationParts & /*implementation*/) +{ + gl::SetGLGetProcAddressProc(&EGL_GetProcAddress); + return true; +} + +void GLOzoneEGLQt::ShutdownGL(gl::GLDisplay *display) +{ + GLOzoneEGL::ShutdownGL(display); +#if QT_CONFIG(dlopen) + if (m_nativeEGLHandle) + dlclose(m_nativeEGLHandle); +#endif +} + +bool GLOzoneEGLQt::LoadGLES2Bindings(const gl::GLImplementationParts & /*implementation*/) +{ + gl::GLGetProcAddressProc getProcAddressPtr = nullptr; + + if (OzoneUtilQt::usingEGL()) { + QOpenGLContext *context = OzoneUtilQt::getQOpenGLContext(); + getProcAddressPtr = reinterpret_cast<gl::GLGetProcAddressProc>( + context->getProcAddress("eglGetProcAddress")); + } + +#if QT_CONFIG(dlopen) + if (getProcAddressPtr == nullptr) { + const char *eglPath = "libEGL.so.1"; + m_nativeEGLHandle = dlopen(eglPath, RTLD_NOW); + if (!m_nativeEGLHandle) { + qWarning("Failed to load EGL library %s: %s", eglPath, dlerror()); + return false; + } + + getProcAddressPtr = reinterpret_cast<gl::GLGetProcAddressProc>( + dlsym(m_nativeEGLHandle, "eglGetProcAddress")); + } +#endif // QT_CONFIG(dlopen) + + if (!getProcAddressPtr) { + char *error = nullptr; +#if QT_CONFIG(dlopen) + error = dlerror(); +#endif + qWarning("Failed to get address of eglGetProcAddress: %s", error ? error : "no error."); + return false; + } + + gl::SetGLGetProcAddressProc(getProcAddressPtr); + // TODO: Log EGL driver information. + // Nvidia fails to make EGL context current if libEGL.so.1 is loaded directly. This could + // be because of loading the wrong driver. + return true; +} + } // namespace ui diff --git a/src/core/ozone/gl_ozone_angle_qt.h b/src/core/ozone/gl_ozone_qt.h index 240fa98b6..aba63cbb2 100644 --- a/src/core/ozone/gl_ozone_angle_qt.h +++ b/src/core/ozone/gl_ozone_qt.h @@ -1,12 +1,11 @@ -// Copyright (C) 2024 The Qt Company Ltd. +// Copyright (C) 2025 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 2016 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -#ifndef GL_OZONE_ANGLE_QT_H -#define GL_OZONE_ANGLE_QT_H +#ifndef GL_OZONE_QT_H +#define GL_OZONE_QT_H #include "ui/ozone/common/gl_ozone_egl.h" @@ -26,7 +25,7 @@ enum class NativePixmapSupportType { kX11Pixmap, }; -class GLOzoneANGLEQt : public GLOzoneEGL +class GLOzoneQt : public GLOzoneEGL { public: static NativePixmapSupportType getNativePixmapSupportType(); @@ -53,6 +52,24 @@ protected: bool LoadGLES2Bindings(const gl::GLImplementationParts &implementation) override; }; +class GLOzoneANGLEQt : public GLOzoneQt +{ +protected: + bool LoadGLES2Bindings(const gl::GLImplementationParts &implementation) override; +}; + +class GLOzoneEGLQt : public GLOzoneQt +{ +public: + void ShutdownGL(gl::GLDisplay *display) override; + +protected: + bool LoadGLES2Bindings(const gl::GLImplementationParts &implementation) override; + +private: + void *m_nativeEGLHandle = nullptr; +}; + } // namespace ui -#endif // GL_OZONE_ANGLE_QT_H +#endif // GL_OZONE_QT_H diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp index 05f5b43f7..bda4bfb8a 100644 --- a/src/core/ozone/surface_factory_qt.cpp +++ b/src/core/ozone/surface_factory_qt.cpp @@ -4,7 +4,7 @@ #include "surface_factory_qt.h" #include "qtwebenginecoreglobal_p.h" -#include "ozone/gl_ozone_angle_qt.h" +#include "ozone/gl_ozone_qt.h" #include "ozone/ozone_util_qt.h" #include "qtwebenginecoreglobal_p.h" @@ -38,6 +38,8 @@ SurfaceFactoryQt::SurfaceFactoryQt() #if QT_CONFIG(opengl) m_impls.push_back({ gl::GLImplementationParts(gl::kGLImplementationEGLANGLE), std::make_unique<ui::GLOzoneANGLEQt>() }); + m_impls.push_back({ gl::GLImplementationParts(gl::kGLImplementationEGLGLES2), + std::make_unique<ui::GLOzoneEGLQt>() }); #endif m_impls.push_back({ gl::GLImplementationParts(gl::kGLImplementationStubGL), nullptr }); m_impls.push_back({ gl::GLImplementationParts(gl::kGLImplementationDisabled), nullptr }); diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 6346819ec..bdd212f61 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -412,6 +412,9 @@ static std::string getGLType(const base::CommandLine &cmd) static bool isGLTypeSupported(const std::string &glType, bool usingVulkan = false) { #if BUILDFLAG(IS_OZONE) + if (glType == gl::kGLImplementationEGLName) + return true; + if (glType == gl::kGLImplementationStubName) return usingVulkan; #else |