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
qwaylandbrcmeglintegration.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 <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
8
11
12#include <QtCore/QDebug>
13
14#include "wayland-brcm-client-protocol.h"
15
17
18namespace QtWaylandClient {
19
21{
22 qDebug() << "Using Brcm-EGL";
23}
24
25void QWaylandBrcmEglIntegration::wlDisplayHandleGlobal(void *data, struct ::wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
26{
27 Q_UNUSED(version);
28 if (interface == "qt_brcm") {
29 QWaylandBrcmEglIntegration *integration = static_cast<QWaylandBrcmEglIntegration *>(data);
30 integration->m_waylandBrcm = static_cast<struct qt_brcm *>(wl_registry_bind(registry, id, &qt_brcm_interface, 1));
31 }
32}
33
35{
36 return m_waylandBrcm;
37}
38
40{
41 eglTerminate(m_eglDisplay);
42}
43
44void QWaylandBrcmEglIntegration::initialize(QWaylandDisplay *waylandDisplay)
45{
46 m_display = waylandDisplay;
47 m_waylandDisplay = waylandDisplay->wl_display();
48 waylandDisplay->addRegistryListener(wlDisplayHandleGlobal, this);
49 EGLint major,minor;
50 m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
51 if (m_eglDisplay == NULL) {
52 qWarning("EGL not available");
53 } else {
54 if (!eglInitialize(m_eglDisplay, &major, &minor)) {
55 qWarning("failed to initialize EGL display");
56 return;
57 }
58
59 eglFlushBRCM = (PFNEGLFLUSHBRCMPROC)eglGetProcAddress("eglFlushBRCM");
60 if (!eglFlushBRCM) {
61 qWarning("failed to resolve eglFlushBRCM, performance will suffer");
62 }
63
64 eglCreateGlobalImageBRCM = (PFNEGLCREATEGLOBALIMAGEBRCMPROC)eglGetProcAddress("eglCreateGlobalImageBRCM");
65 if (!eglCreateGlobalImageBRCM) {
66 qWarning("failed to resolve eglCreateGlobalImageBRCM");
67 return;
68 }
69
70 eglDestroyGlobalImageBRCM = (PFNEGLDESTROYGLOBALIMAGEBRCMPROC)eglGetProcAddress("eglDestroyGlobalImageBRCM");
71 if (!eglDestroyGlobalImageBRCM) {
72 qWarning("failed to resolve eglDestroyGlobalImageBRCM");
73 return;
74 }
75 }
76}
77
78QWaylandWindow *QWaylandBrcmEglIntegration::createEglWindow(QWindow *window)
79{
80 return new QWaylandBrcmEglWindow(window, m_display);
81}
82
83QPlatformOpenGLContext *QWaylandBrcmEglIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const
84{
85 return new QWaylandBrcmGLContext(m_eglDisplay, glFormat, share);
86}
87
88QOpenGLContext *QWaylandBrcmEglIntegration::createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const
89{
90 return QEGLPlatformContext::createFrom<QWaylandBrcmGLContext>(context, contextDisplay, m_eglDisplay, shareContext);
91}
92
94{
95 return m_eglDisplay;
96}
97
98void *QWaylandBrcmEglIntegration::nativeResource(NativeResource resource)
99{
100 switch (resource) {
101 case EglDisplay:
102 return m_eglDisplay;
103 default:
104 break;
105 }
106 return nullptr;
107}
108
109void *QWaylandBrcmEglIntegration::nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context)
110{
111 Q_ASSERT(context);
112 switch (resource) {
113 case EglConfig:
114 return static_cast<QWaylandBrcmGLContext *>(context)->eglConfig();
115 case EglContext:
116 return static_cast<QWaylandBrcmGLContext *>(context)->eglContext();
117 case EglDisplay:
118 return m_eglDisplay;
119 default:
120 break;
121 }
122 return nullptr;
123}
124
125}
126
127QT_END_NAMESPACE
void * nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context) override
QOpenGLContext * createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext) const override
void * nativeResource(NativeResource resource) override
QPlatformOpenGLContext * createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const override
void initialize(QWaylandDisplay *waylandDisplay) override
Combined button and popup list for selecting options.