Skip to content

Commit 75b0d12

Browse files
committed
Add "default" and "gl" ANGLE implementation support to Ozone
The EGL_EXT_image_dma_buf_import display extension is not available for non EGL display thus importing NativePixmap with EGL is not possible. Make possible to import NativePixmap as X11 pixmap. This makes --webEngineArgs --use-gl=angle --webEngineArgs --use-gl=angle --use-angle=default --webEngineArgs --use-gl=angle --use-angle=gl configurations work on Linux. Pick-to: 6.8 6.9 Task-number: QTBUG-129769 Task-number: QTBUG-133570 Change-Id: Ic6a40de373c5fd27c62abc3effb2f3ddee9210a8 Reviewed-by: Moss Heim <[email protected]> Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent dbf4592 commit 75b0d12

File tree

2 files changed

+61
-4
lines changed

2 files changed

+61
-4
lines changed

src/core/configure/BUILD.root.gn.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,14 @@ source_set("qtwebengine_sources") {
406406
deps += [
407407
"//ui/base/x:gl",
408408
"//ui/gfx/linux:gpu_memory_buffer_support_x11",
409+
"//ui/gfx/x",
409410
]
410411

411412
sources += [
412413
"//ui/ozone/platform/x11/gl_egl_utility_x11.cc",
413414
"//ui/ozone/platform/x11/gl_egl_utility_x11.h",
415+
"//ui/ozone/platform/x11/native_pixmap_egl_x11_binding.cc",
416+
"//ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h",
414417
]
415418
}
416419
}

src/core/ozone/gl_ozone_angle_qt.cpp

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
// Copyright (C) 2024 The Qt Company Ltd.
1+
// Copyright (C) 2025 The Qt Company Ltd.
22
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
33

4+
// Copyright 2016 The Chromium Authors
5+
// Use of this source code is governed by a BSD-style license that can be
6+
// found in the LICENSE file.
7+
48
#include "gl_ozone_angle_qt.h"
59

610
#include "ui/base/ozone_buildflags.h"
@@ -12,6 +16,8 @@
1216

1317
#if BUILDFLAG(IS_OZONE_X11)
1418
#include "ozone_util_qt.h"
19+
20+
#include "ui/ozone/platform/x11/native_pixmap_egl_x11_binding.h"
1521
#endif
1622

1723
extern "C" {
@@ -20,6 +26,34 @@ extern __eglMustCastToProperFunctionPointerType EGL_GetProcAddress(const char *p
2026
}
2127

2228
namespace ui {
29+
namespace {
30+
// Based on //ui/ozone/platform/x11/x11_surface_factory.cc
31+
enum class NativePixmapSupportType {
32+
// Importing native pixmaps not supported.
33+
kNone,
34+
35+
// Native pixmaps are imported directly into EGL using the
36+
// EGL_EXT_image_dma_buf_import extension.
37+
kDMABuf,
38+
39+
// Native pixmaps are first imported as X11 pixmaps using DRI3 and then into
40+
// EGL.
41+
kX11Pixmap,
42+
};
43+
44+
NativePixmapSupportType GetNativePixmapSupportType()
45+
{
46+
if (gl::GLSurfaceEGL::GetGLDisplayEGL()->ext->b_EGL_EXT_image_dma_buf_import)
47+
return NativePixmapSupportType::kDMABuf;
48+
49+
#if BUILDFLAG(IS_OZONE_X11)
50+
if (NativePixmapEGLX11Binding::CanImportNativeGLXPixmap())
51+
return NativePixmapSupportType::kX11Pixmap;
52+
#endif
53+
54+
return NativePixmapSupportType::kNone;
55+
}
56+
} // namespace
2357

2458
bool GLOzoneANGLEQt::LoadGLES2Bindings(const gl::GLImplementationParts & /*implementation*/)
2559
{
@@ -73,7 +107,16 @@ gl::EGLDisplayPlatform GLOzoneANGLEQt::GetNativeDisplay()
73107

74108
bool GLOzoneANGLEQt::CanImportNativePixmap(gfx::BufferFormat format)
75109
{
76-
return gl::GLSurfaceEGL::GetGLDisplayEGL()->ext->b_EGL_EXT_image_dma_buf_import;
110+
switch (GetNativePixmapSupportType()) {
111+
case NativePixmapSupportType::kDMABuf:
112+
return NativePixmapEGLBinding::IsBufferFormatSupported(format);
113+
#if BUILDFLAG(IS_OZONE_X11)
114+
case NativePixmapSupportType::kX11Pixmap:
115+
return NativePixmapEGLX11Binding::IsBufferFormatSupported(format);
116+
#endif
117+
default:
118+
return false;
119+
}
77120
}
78121

79122
std::unique_ptr<NativePixmapGLBinding>
@@ -82,8 +125,19 @@ GLOzoneANGLEQt::ImportNativePixmap(scoped_refptr<gfx::NativePixmap> pixmap,
82125
gfx::Size plane_size, const gfx::ColorSpace &color_space,
83126
GLenum target, GLuint texture_id)
84127
{
85-
return NativePixmapEGLBinding::Create(pixmap, plane_format, plane, plane_size, color_space,
86-
target, texture_id);
128+
switch (GetNativePixmapSupportType()) {
129+
case NativePixmapSupportType::kDMABuf:
130+
return NativePixmapEGLBinding::Create(pixmap, plane_format, plane, plane_size, color_space,
131+
target, texture_id);
132+
#if BUILDFLAG(IS_OZONE_X11)
133+
case NativePixmapSupportType::kX11Pixmap:
134+
return NativePixmapEGLX11Binding::Create(pixmap, plane_format, plane_size, target,
135+
texture_id);
136+
#endif
137+
default:
138+
NOTREACHED();
139+
return nullptr;
140+
}
87141
}
88142

89143
} // namespace ui

0 commit comments

Comments
 (0)