Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qeglplatformcontext_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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
4#ifndef QEGLPLATFORMCONTEXT_H
5#define QEGLPLATFORMCONTEXT_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qtextstream.h>
19#include <qpa/qplatformwindow.h>
20#include <qpa/qplatformopenglcontext.h>
21#include <QtCore/qvariant.h>
22#include <QtGui/private/qt_egl_p.h>
23#include <QtGui/private/qopenglcontext_p.h>
24
26
27class Q_GUI_EXPORT QEGLPlatformContext : public QPlatformOpenGLContext,
28 public QNativeInterface::QEGLContext
29{
30public:
31 enum Flag {
32 NoSurfaceless = 0x01
33 };
35
37 EGLConfig *config = nullptr, Flags flags = { });
38
39 template <typename T>
40 static QOpenGLContext *createFrom(EGLContext context, EGLDisplay contextDisplay,
41 EGLDisplay platformDisplay, QOpenGLContext *shareContext)
42 {
43 if (!context)
44 return nullptr;
45
46 // A context belonging to a given EGLDisplay cannot be used with another one
47 if (contextDisplay != platformDisplay) {
48 qWarning("QEGLPlatformContext: Cannot adopt context from different display");
49 return nullptr;
50 }
51
52 QPlatformOpenGLContext *shareHandle = shareContext ? shareContext->handle() : nullptr;
53
54 auto *resultingContext = new QOpenGLContext;
55 auto *contextPrivate = QOpenGLContextPrivate::get(resultingContext);
56 auto *platformContext = new T;
57 platformContext->adopt(context, contextDisplay, shareHandle);
58 contextPrivate->adopt(platformContext);
59 return resultingContext;
60 }
61
63
64 void initialize() override;
65 bool makeCurrent(QPlatformSurface *surface) override;
66 void doneCurrent() override;
67 void swapBuffers(QPlatformSurface *surface) override;
68 QFunctionPointer getProcAddress(const char *procName) override;
69
70 QSurfaceFormat format() const override;
71 bool isSharing() const override { return m_shareContext != EGL_NO_CONTEXT; }
72 bool isValid() const override { return m_eglContext != EGL_NO_CONTEXT && !m_markedInvalid; }
73
74 EGLContext nativeContext() const override { return eglContext(); }
75 EGLConfig config() const override { return eglConfig(); }
76 EGLDisplay display() const override { return eglDisplay(); }
77
78 virtual void invalidateContext() override { m_markedInvalid = true; }
79
80 EGLContext eglContext() const;
81 EGLDisplay eglDisplay() const;
82 EGLConfig eglConfig() const;
83
84protected:
85 QEGLPlatformContext() {} // For adoption
87 virtual EGLSurface createTemporaryOffscreenSurface();
88 virtual void destroyTemporaryOffscreenSurface(EGLSurface surface);
89 virtual void runGLChecks();
90
91private:
92 void adopt(EGLContext context, EGLDisplay display, QPlatformOpenGLContext *shareContext);
93 void updateFormatFromGL();
94
95 EGLContext m_eglContext;
96 EGLContext m_shareContext;
97 EGLDisplay m_eglDisplay;
98 EGLConfig m_eglConfig;
99 QSurfaceFormat m_format;
100 EGLenum m_api;
101 int m_swapInterval = -1;
102 bool m_swapIntervalEnvChecked = false;
103 int m_swapIntervalFromEnv = -1;
104 Flags m_flags;
105 bool m_ownsContext = false;
106 QList<EGLint> m_contextAttrs;
107
108 bool m_markedInvalid = false;
109};
110
111Q_DECLARE_OPERATORS_FOR_FLAGS(QEGLPlatformContext::Flags)
112
114
115#endif //QEGLPLATFORMCONTEXT_H
An EGL context implementation.
EGLDisplay display() const override
bool isSharing() const override
EGLContext nativeContext() const override
virtual void invalidateContext() override
static QOpenGLContext * createFrom(EGLContext context, EGLDisplay contextDisplay, EGLDisplay platformDisplay, QOpenGLContext *shareContext)
virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)=0
EGLConfig config() const override
bool isValid() const override
static QOpenGLContextPrivate * get(QOpenGLContext *context)
\inmodule QtGui
QPlatformOpenGLContext * handle() const
Returns the underlying platform context.
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
The QPlatformSurface class provides an abstraction for a surface.
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
static void * context
static bool initialize()
Definition qctf.cpp:94
EGLConfig config
typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Flags
#define qWarning
Definition qlogging.h:166
GLbitfield flags
GLint GLsizei GLsizei GLenum format
const void * getProcAddress