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
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// Qt-Security score:significant reason:default
4
6
7#include <QtGui/private/qguiapplication_p.h>
11#include "qxcbeglcontext.h"
12
14
15static int resourceType(const QByteArray &key)
16{
17 static const QByteArray names[] = { // match QXcbEglNativeInterfaceHandler::ResourceType
18 QByteArrayLiteral("egldisplay"),
19 QByteArrayLiteral("eglcontext"),
20 QByteArrayLiteral("eglconfig")
21 };
22 for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
23 if (key == names[i])
24 return i;
25 }
26
27 if (key == QByteArrayLiteral("get_egl_context"))
29
30 return sizeof(names) / sizeof(names[0]);
31}
32
37
39 switch (resourceType(resource)) {
40 case EglDisplay:
41 return eglDisplay;
42 default:
43 break;
44 }
45 return nullptr;
46}
47
49{
50 switch (resourceType(resource)) {
51 case EglContext:
52 return eglContextForContext;
53 case EglConfig:
54 return eglConfigForContext;
55 default:
56 break;
57 }
58 return nullptr;
59}
60
62{
63 switch (resourceType(resource)) {
64 case EglDisplay:
65 return eglDisplayForWindow;
66 default:
67 break;
68 }
69 return nullptr;
70}
71
72void *QXcbEglNativeInterfaceHandler::eglDisplay()
73{
74 QXcbIntegration *integration = QXcbIntegration::instance();
75 QXcbEglIntegration *eglIntegration = static_cast<QXcbEglIntegration *>(integration->connection()->glIntegration());
76 return eglIntegration->eglDisplay();
77}
78
79void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window)
80{
81 Q_ASSERT(window);
82 if (window->supportsOpenGL() && window->handle() == nullptr)
83 return eglDisplay();
84 else if (window->supportsOpenGL())
85 return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay();
86 return nullptr;
87}
88
89void *QXcbEglNativeInterfaceHandler::eglContextForContext(QOpenGLContext *context)
90{
91 Q_ASSERT(context);
92 Q_ASSERT(context->handle());
93 return static_cast<QXcbEglContext *>(context->handle())->eglContext();
94}
95
96void *QXcbEglNativeInterfaceHandler::eglConfigForContext(QOpenGLContext *context)
97{
98 Q_ASSERT(context);
99 Q_ASSERT(context->handle());
100 return static_cast<QXcbEglContext *>(context->handle())->eglConfig();
101}
102
103QT_END_NAMESPACE
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 QT_BEGIN_NAMESPACE int resourceType(const QByteArray &key)