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
qxcbeglnativeinterfacehandler.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
5
6#include <QtGui/private/qguiapplication_p.h>
7#include "qxcbeglwindow.h"
8#include "qxcbintegration.h"
10#include "qxcbeglcontext.h"
11
13
14static int resourceType(const QByteArray &key)
15{
16 static const QByteArray names[] = { // match QXcbEglNativeInterfaceHandler::ResourceType
17 QByteArrayLiteral("egldisplay"),
18 QByteArrayLiteral("eglcontext"),
19 QByteArrayLiteral("eglconfig")
20 };
21 for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
22 if (key == names[i])
23 return i;
24 }
25
26 if (key == QByteArrayLiteral("get_egl_context"))
28
29 return sizeof(names) / sizeof(names[0]);
30}
31
36
38 switch (resourceType(resource)) {
39 case EglDisplay:
40 return eglDisplay;
41 default:
42 break;
43 }
44 return nullptr;
45}
46
48{
49 switch (resourceType(resource)) {
50 case EglContext:
51 return eglContextForContext;
52 case EglConfig:
53 return eglConfigForContext;
54 default:
55 break;
56 }
57 return nullptr;
58}
59
61{
62 switch (resourceType(resource)) {
63 case EglDisplay:
64 return eglDisplayForWindow;
65 default:
66 break;
67 }
68 return nullptr;
69}
70
71void *QXcbEglNativeInterfaceHandler::eglDisplay()
72{
74 QXcbEglIntegration *eglIntegration = static_cast<QXcbEglIntegration *>(integration->connection()->glIntegration());
75 return eglIntegration->eglDisplay();
76}
77
78void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window)
79{
81 if (window->supportsOpenGL() && window->handle() == nullptr)
82 return eglDisplay();
83 else if (window->supportsOpenGL())
84 return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay();
85 return nullptr;
86}
87
88void *QXcbEglNativeInterfaceHandler::eglContextForContext(QOpenGLContext *context)
89{
91 Q_ASSERT(context->handle());
92 return static_cast<QXcbEglContext *>(context->handle())->eglContext();
93}
94
95void *QXcbEglNativeInterfaceHandler::eglConfigForContext(QOpenGLContext *context)
96{
98 Q_ASSERT(context->handle());
99 return static_cast<QXcbEglContext *>(context->handle())->eglConfig();
100}
101
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtGui
void *(* NativeResourceForWindowFunction)(QWindow *window)
void *(* NativeResourceForContextFunction)(QOpenGLContext *context)
\inmodule QtGui
Definition qwindow.h:63
QXcbGlIntegration * glIntegration() const
EGLDisplay eglDisplay() const
QPlatformNativeInterface::NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) const override
QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const override
QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const override
static QXcbIntegration * instance()
QXcbConnection * connection() const
Combined button and popup list for selecting options.
static void * context
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
static int resourceType(const QByteArray &key)
GLuint64 key
GLuint GLuint * names
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static QT_BEGIN_NAMESPACE int resourceType(const QByteArray &key)
aWidget window() -> setWindowTitle("New Window Title")
[2]