commit:     dbf0385ebcedbae3e192b592e0a74c905b52b5a2
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 30 17:14:12 2025 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Sat Aug 30 17:32:39 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dbf0385e

dev-qt/qtwebengine: revert commit for QTBUG-139424

Untested given I do not have the required hardware to reproduce,
but doing this seems to have worked for Arch.

Closes: https://bugs.gentoo.org/962055
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 .../files/qtwebengine-6.9.2-QTBUG-139424.patch     | 133 +++++++++++++++++++++
 dev-qt/qtwebengine/qtwebengine-6.10.9999.ebuild    |   1 +
 ...ne-6.9.2.ebuild => qtwebengine-6.9.2-r1.ebuild} |   1 +
 dev-qt/qtwebengine/qtwebengine-6.9.9999.ebuild     |   1 +
 4 files changed, 136 insertions(+)

diff --git a/dev-qt/qtwebengine/files/qtwebengine-6.9.2-QTBUG-139424.patch 
b/dev-qt/qtwebengine/files/qtwebengine-6.9.2-QTBUG-139424.patch
new file mode 100644
index 000000000000..340bf86ae8b9
--- /dev/null
+++ b/dev-qt/qtwebengine/files/qtwebengine-6.9.2-QTBUG-139424.patch
@@ -0,0 +1,133 @@
+Revert of [1] from [2] for [3][4]
+[1] https://github.com/qt/qtwebengine/commit/812bf186b15
+[2] https://bugreports.qt.io/browse/QTBUG-136257
+[3] https://bugreports.qt.io/browse/QTBUG-139424
+[4] https://bugs.gentoo.org/962055
+--- a/src/core/ozone/egl_helper.cpp
++++ b/src/core/ozone/egl_helper.cpp
+@@ -60,2 +60,80 @@
+ 
++class ScopedGLContext
++{
++public:
++    ScopedGLContext(QOffscreenSurface *surface, EGLHelper::EGLFunctions 
*eglFun)
++        : m_context(new QOpenGLContext()), m_eglFun(eglFun)
++    {
++        if ((m_previousEGLContext = m_eglFun->eglGetCurrentContext())) {
++            m_previousEGLDrawSurface = 
m_eglFun->eglGetCurrentSurface(EGL_DRAW);
++            m_previousEGLReadSurface = 
m_eglFun->eglGetCurrentSurface(EGL_READ);
++            m_previousEGLDisplay = m_eglFun->eglGetCurrentDisplay();
++        }
++
++        if (!m_context->create()) {
++            qWarning("Failed to create OpenGL context.");
++            return;
++        }
++
++        Q_ASSERT(surface->isValid());
++        if (!m_context->makeCurrent(surface)) {
++            qWarning("Failed to make OpenGL context current.");
++            return;
++        }
++    }
++
++    ~ScopedGLContext()
++    {
++        if (!m_textures.empty()) {
++            auto *glFun = m_context->functions();
++            glFun->glDeleteTextures(m_textures.size(), m_textures.data());
++        }
++
++        if (m_previousEGLContext) {
++            // Make sure the scoped context is not current when restoring the 
previous
++            // EGL context otherwise the QOpenGLContext destructor resets the 
restored
++            // current context.
++            m_context->doneCurrent();
++
++            m_eglFun->eglMakeCurrent(m_previousEGLDisplay, 
m_previousEGLDrawSurface,
++                                     m_previousEGLReadSurface, 
m_previousEGLContext);
++            if (m_eglFun->eglGetError() != EGL_SUCCESS)
++                qWarning("Failed to restore EGL context.");
++        }
++    }
++
++    bool isValid() const { return m_context->isValid() && 
(m_context->surface() != nullptr); }
++
++    EGLContext eglContext() const
++    {
++        QNativeInterface::QEGLContext *nativeInterface =
++                m_context->nativeInterface<QNativeInterface::QEGLContext>();
++        return nativeInterface->nativeContext();
++    }
++
++    uint createTexture(int width, int height)
++    {
++        auto *glFun = m_context->functions();
++
++        uint glTexture;
++        glFun->glGenTextures(1, &glTexture);
++        glFun->glBindTexture(GL_TEXTURE_2D, glTexture);
++        glFun->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, 
GL_RGBA, GL_UNSIGNED_BYTE,
++                            NULL);
++        glFun->glBindTexture(GL_TEXTURE_2D, 0);
++
++        m_textures.push_back(glTexture);
++        return glTexture;
++    }
++
++private:
++    QScopedPointer<QOpenGLContext> m_context;
++    EGLHelper::EGLFunctions *m_eglFun;
++    EGLContext m_previousEGLContext = nullptr;
++    EGLSurface m_previousEGLDrawSurface = nullptr;
++    EGLSurface m_previousEGLReadSurface = nullptr;
++    EGLDisplay m_previousEGLDisplay = nullptr;
++    std::vector<uint> m_textures;
++};
++
+ EGLHelper::EGLFunctions::EGLFunctions()
+@@ -66,4 +144,2 @@
+             
reinterpret_cast<PFNEGLCREATEIMAGEPROC>(context->getProcAddress("eglCreateImage"));
+-    eglCreateDRMImageMESA = reinterpret_cast<PFNEGLCREATEDRMIMAGEMESAPROC>(
+-            context->getProcAddress("eglCreateDRMImageMESA"));
+     eglDestroyImage =
+@@ -124,3 +200,2 @@
+                 && strstr(displayExtensions, 
"EGL_EXT_image_dma_buf_import_modifiers")
+-                && strstr(displayExtensions, "EGL_MESA_drm_image")
+                 && strstr(displayExtensions, "EGL_MESA_image_dma_buf_export");
+@@ -145,13 +220,15 @@
+ 
+-    // clang-format off
+-    EGLint attribs[] = {
+-        EGL_WIDTH, width,
+-        EGL_HEIGHT, height,
+-        EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
+-        EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SHARE_MESA,
+-        EGL_NONE
+-    };
+-    // clang-format on
++    ScopedGLContext context(m_offscreenSurface.get(), m_functions.get());
++    if (!context.isValid())
++        return;
++
++    EGLContext eglContext = context.eglContext();
++    if (!eglContext) {
++        qWarning("EGL: No EGLContext.");
++        return;
++    }
+ 
+-    EGLImage eglImage = m_functions->eglCreateDRMImageMESA(m_eglDisplay, 
attribs);
++    uint64_t textureId = context.createTexture(width, height);
++    EGLImage eglImage = m_functions->eglCreateImage(m_eglDisplay, eglContext, 
EGL_GL_TEXTURE_2D,
++                                                    
(EGLClientBuffer)textureId, NULL);
+     if (eglImage == EGL_NO_IMAGE) {
+--- a/src/core/ozone/egl_helper.h
++++ b/src/core/ozone/egl_helper.h
+@@ -13,3 +13,2 @@
+ #undef eglCreateImage
+-#undef eglCreateDRMImageMESA
+ #undef eglDestroyImage
+@@ -36,3 +35,2 @@
+         PFNEGLCREATEIMAGEPROC eglCreateImage;
+-        PFNEGLCREATEDRMIMAGEMESAPROC eglCreateDRMImageMESA;
+         PFNEGLDESTROYIMAGEPROC eglDestroyImage;

diff --git a/dev-qt/qtwebengine/qtwebengine-6.10.9999.ebuild 
b/dev-qt/qtwebengine/qtwebengine-6.10.9999.ebuild
index a601817b08d7..4776fb8d314c 100644
--- a/dev-qt/qtwebengine/qtwebengine-6.10.9999.ebuild
+++ b/dev-qt/qtwebengine/qtwebengine-6.10.9999.ebuild
@@ -109,6 +109,7 @@ PATCHES=( "${WORKDIR}"/patches/${PN} )
 PATCHES+=(
        # add extras as needed here, may merge in set if carries across versions
        "${FILESDIR}"/${PN}-6.9.2-clang-21.patch
+       "${FILESDIR}"/${PN}-6.9.2-QTBUG-139424.patch
 )
 
 python_check_deps() {

diff --git a/dev-qt/qtwebengine/qtwebengine-6.9.2.ebuild 
b/dev-qt/qtwebengine/qtwebengine-6.9.2-r1.ebuild
similarity index 99%
rename from dev-qt/qtwebengine/qtwebengine-6.9.2.ebuild
rename to dev-qt/qtwebengine/qtwebengine-6.9.2-r1.ebuild
index 271500989fe0..8f499444bb1c 100644
--- a/dev-qt/qtwebengine/qtwebengine-6.9.2.ebuild
+++ b/dev-qt/qtwebengine/qtwebengine-6.9.2-r1.ebuild
@@ -109,6 +109,7 @@ PATCHES=( "${WORKDIR}"/patches/${PN} )
 PATCHES+=(
        # add extras as needed here, may merge in set if carries across versions
        "${FILESDIR}"/${PN}-6.9.2-clang-21.patch
+       "${FILESDIR}"/${PN}-6.9.2-QTBUG-139424.patch
 )
 
 python_check_deps() {

diff --git a/dev-qt/qtwebengine/qtwebengine-6.9.9999.ebuild 
b/dev-qt/qtwebengine/qtwebengine-6.9.9999.ebuild
index 271500989fe0..8f499444bb1c 100644
--- a/dev-qt/qtwebengine/qtwebengine-6.9.9999.ebuild
+++ b/dev-qt/qtwebengine/qtwebengine-6.9.9999.ebuild
@@ -109,6 +109,7 @@ PATCHES=( "${WORKDIR}"/patches/${PN} )
 PATCHES+=(
        # add extras as needed here, may merge in set if carries across versions
        "${FILESDIR}"/${PN}-6.9.2-clang-21.patch
+       "${FILESDIR}"/${PN}-6.9.2-QTBUG-139424.patch
 )
 
 python_check_deps() {

Reply via email to