Debian Codegraph @

src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp

raw
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
5 #include "qxcbglxnativeinterfacehandler.h"
6
7 #include "qglxintegration.h"
8 #include <QtGui/QOpenGLContext>
9 QT_BEGIN_NAMESPACE
10
11 static int resourceType(const QByteArray &key)
12 {
13 static const QByteArray names[] = { // match QXcbGlxNativeInterfaceHandler::ResourceType
14 QByteArrayLiteral("glxconfig"),
15 QByteArrayLiteral("glxcontext"),
16 };
17 for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
18 if (key == names[i])
19 return i;
20 }
21
22 return sizeof(names) / sizeof(names[0]);
23 }
24
25 QXcbGlxNativeInterfaceHandler::QXcbGlxNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
26 : QXcbNativeInterfaceHandler(nativeInterface)
27 {
28 }
29
30 QPlatformNativeInterface::NativeResourceForContextFunction QXcbGlxNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
31 {
32 switch (resourceType(resource)) {
33 case GLXConfig:
34 return glxConfigForContext;
35 case GLXContext:
36 return glxContextForContext;
37 default:
38 break;
39 }
40 return nullptr;
41 }
42
43 void *QXcbGlxNativeInterfaceHandler::glxContextForContext(QOpenGLContext *context)
44 {
45 Q_ASSERT(context);
46 QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
47 return glxPlatformContext->glxContext();
48 }
49
50 void *QXcbGlxNativeInterfaceHandler::glxConfigForContext(QOpenGLContext *context)
51 {
52 Q_ASSERT(context);
53 QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
54 return glxPlatformContext->glxConfig();
55
56 }
57
58 QT_END_NAMESPACE