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
qeglfscontext.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// Qt-Security score:significant reason:default
4
6#include <QtGui/QSurface>
7#include <QtGui/private/qeglconvenience_p.h>
8#include <QtGui/private/qeglpbuffer_p.h>
9
11#include "qeglfswindow_p.h"
12#include "qeglfshooks_p.h"
13#include "qeglfscursor_p.h"
14
16
17QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
18 EGLConfig *config)
19 : QEGLPlatformContext(format, share, display, config,
20 qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags() : QEGLPlatformContext::NoSurfaceless)
21{
22}
23
24EGLSurface QEglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
25{
26 if (surface->surface()->surfaceClass() == QSurface::Window) {
27
28 QEglFSWindow *w = static_cast<QEglFSWindow *>(surface);
29 EGLSurface s = w->surface();
30 if (s == EGL_NO_SURFACE) {
31 w->resetSurface();
32 s = w->surface();
33 }
34 return s;
35
36 } else {
37 return static_cast<QEGLPbuffer *>(surface)->pbuffer();
38 }
39}
40
41EGLSurface QEglFSContext::createTemporaryOffscreenSurface()
42{
43 if (qt_egl_device_integration()->supportsPBuffers())
44 return QEGLPlatformContext::createTemporaryOffscreenSurface();
45
46 if (!m_tempWindow) {
47 m_tempWindow = qt_egl_device_integration()->createNativeOffscreenWindow(format());
48 if (!m_tempWindow) {
49 qWarning("QEglFSContext: Failed to create temporary native window");
50 return EGL_NO_SURFACE;
51 }
52 }
53 EGLConfig config = q_configFromGLFormat(eglDisplay(), format());
54 return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, nullptr);
55}
56
57void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface)
58{
59 if (qt_egl_device_integration()->supportsPBuffers()) {
60 QEGLPlatformContext::destroyTemporaryOffscreenSurface(surface);
61 } else {
62 eglDestroySurface(eglDisplay(), surface);
63 qt_egl_device_integration()->destroyNativeWindow(m_tempWindow);
64 m_tempWindow = 0;
65 }
66}
67
68void QEglFSContext::runGLChecks()
69{
70 // Note that even though there is an EGL context current here,
71 // QOpenGLContext and QOpenGLFunctions are not yet usable at this stage.
72 const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
73 // Be nice and warn about a common source of confusion.
74 if (renderer && strstr(renderer, "llvmpipe"))
75 qWarning("Running on a software rasterizer (LLVMpipe), expect limited performance.");
76}
77
78void QEglFSContext::swapBuffers(QPlatformSurface *surface)
79{
80 // draw the cursor
81 if (surface->surface()->surfaceClass() == QSurface::Window) {
82 QPlatformWindow *window = static_cast<QPlatformWindow *>(surface);
83 if (QPlatformScreen *screen = window->screen()) {
84 if (QEglFSCursor *cursor = qobject_cast<QEglFSCursor *>(screen->cursor()))
85 cursor->paintOnScreen();
86 }
87 }
88
89 qt_egl_device_integration()->waitForVSync(surface);
90 QEGLPlatformContext::swapBuffers(surface);
91 qt_egl_device_integration()->presentBuffer(surface);
92}
93
94QT_END_NAMESPACE
Combined button and popup list for selecting options.