blob: 47a95d68763f5ae862bc1489192b291c0d8cfd93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qxcbeglnativeinterfacehandler.h"
#include <QtGui/private/qguiapplication_p.h>
#include "qxcbeglwindow.h"
#include "qxcbintegration.h"
#include "qxcbeglintegration.h"
#include "qxcbeglcontext.h"
QT_BEGIN_NAMESPACE
static int resourceType(const QByteArray &key)
{
static const QByteArray names[] = { // match QXcbEglNativeInterfaceHandler::ResourceType
QByteArrayLiteral("egldisplay"),
QByteArrayLiteral("eglcontext"),
QByteArrayLiteral("eglconfig")
};
for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
if (key == names[i])
return i;
}
if (key == QByteArrayLiteral("get_egl_context"))
return QXcbEglNativeInterfaceHandler::EglContext;
return sizeof(names) / sizeof(names[0]);
}
QXcbEglNativeInterfaceHandler::QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
: QXcbNativeInterfaceHandler(nativeInterface)
{
}
QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForIntegration(const QByteArray &resource) const{
switch (resourceType(resource)) {
case EglDisplay:
return eglDisplay;
default:
break;
}
return nullptr;
}
QPlatformNativeInterface::NativeResourceForContextFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
{
switch (resourceType(resource)) {
case EglContext:
return eglContextForContext;
case EglConfig:
return eglConfigForContext;
default:
break;
}
return nullptr;
}
QPlatformNativeInterface::NativeResourceForWindowFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForWindow(const QByteArray &resource) const
{
switch (resourceType(resource)) {
case EglDisplay:
return eglDisplayForWindow;
default:
break;
}
return nullptr;
}
void *QXcbEglNativeInterfaceHandler::eglDisplay()
{
QXcbIntegration *integration = QXcbIntegration::instance();
QXcbEglIntegration *eglIntegration = static_cast<QXcbEglIntegration *>(integration->connection()->glIntegration());
return eglIntegration->eglDisplay();
}
void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window)
{
Q_ASSERT(window);
if (window->supportsOpenGL() && window->handle() == nullptr)
return eglDisplay();
else if (window->supportsOpenGL())
return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay();
return nullptr;
}
void *QXcbEglNativeInterfaceHandler::eglContextForContext(QOpenGLContext *context)
{
Q_ASSERT(context);
Q_ASSERT(context->handle());
return static_cast<QXcbEglContext *>(context->handle())->eglContext();
}
void *QXcbEglNativeInterfaceHandler::eglConfigForContext(QOpenGLContext *context)
{
Q_ASSERT(context);
Q_ASSERT(context->handle());
return static_cast<QXcbEglContext *>(context->handle())->eglConfig();
}
QT_END_NAMESPACE
|