Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qeglfsoffscreenwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6#include <QtGui/QOffscreenSurface>
7#include <QtGui/private/qeglconvenience_p.h>
8
10
11/*
12 In some cases pbuffers are not available. Triggering QtGui's built-in
13 fallback for a hidden QWindow is not suitable for eglfs since this would be
14 treated as an attempt to create multiple top-level, native windows.
15
16 Therefore this class is provided as an alternative to QEGLPbuffer.
17
18 This class requires the hooks to implement createNativeOffscreenWindow().
19*/
20
21QEglFSOffscreenWindow::QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface)
22 : QPlatformOffscreenSurface(offscreenSurface)
23 , m_format(format)
24 , m_display(display)
25 , m_surface(EGL_NO_SURFACE)
26 , m_window(0)
27{
28 m_window = qt_egl_device_integration()->createNativeOffscreenWindow(format);
29 if (!m_window) {
30 qWarning("QEglFSOffscreenWindow: Failed to create native window");
31 return;
32 }
33 EGLConfig config = q_configFromGLFormat(m_display, m_format);
34 m_surface = eglCreateWindowSurface(m_display, config, m_window, nullptr);
35 if (m_surface != EGL_NO_SURFACE)
36 m_format = q_glFormatFromConfig(m_display, config);
37}
38
39QEglFSOffscreenWindow::~QEglFSOffscreenWindow()
40{
41 if (m_surface != EGL_NO_SURFACE)
42 eglDestroySurface(m_display, m_surface);
43 if (m_window)
44 qt_egl_device_integration()->destroyNativeWindow(m_window);
45}
46
47QT_END_NAMESPACE