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