Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qeglfsbrcmintegration.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#include <bcm_host.h>
6
8
9static DISPMANX_DISPLAY_HANDLE_T dispman_display = 0;
10
11static EGLNativeWindowType createDispmanxLayer(const QPoint &pos, const QSize &size, int z, DISPMANX_FLAGS_ALPHA_T flags)
12{
13 VC_RECT_T dst_rect;
14 dst_rect.x = pos.x();
15 dst_rect.y = pos.y();
16 dst_rect.width = size.width();
17 dst_rect.height = size.height();
18
19 VC_RECT_T src_rect;
20 src_rect.x = 0;
21 src_rect.y = 0;
22 src_rect.width = size.width() << 16;
23 src_rect.height = size.height() << 16;
24
25 DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start(0);
26
27 VC_DISPMANX_ALPHA_T alpha;
28 alpha.flags = flags;
29 alpha.opacity = 0xFF;
30 alpha.mask = 0;
31
32 DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add(
33 dispman_update, dispman_display, z, &dst_rect, 0, &src_rect,
34 DISPMANX_PROTECTION_NONE, &alpha, (DISPMANX_CLAMP_T *)NULL, (DISPMANX_TRANSFORM_T)0);
35
36 vc_dispmanx_update_submit_sync(dispman_update);
37
38 EGL_DISPMANX_WINDOW_T *eglWindow = new EGL_DISPMANX_WINDOW_T;
39 eglWindow->element = dispman_element;
40 eglWindow->width = size.width();
41 eglWindow->height = size.height();
42
43 return eglWindow;
44}
45
46static void destroyDispmanxLayer(EGLNativeWindowType window)
47{
48 EGL_DISPMANX_WINDOW_T *eglWindow = static_cast<EGL_DISPMANX_WINDOW_T *>(window);
49 DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start(0);
50 vc_dispmanx_element_remove(dispman_update, eglWindow->element);
51 vc_dispmanx_update_submit_sync(dispman_update);
52 delete eglWindow;
53}
54
56{
57 bcm_host_init();
58}
59
60static int getDisplayId()
61{
62 // As defined in vc_dispmanx_types.h
63 // DISPMANX_ID_MAIN_LCD 0
64 // DISPMANX_ID_AUX_LCD 1
65 // DISPMANX_ID_HDMI 2
66 // DISPMANX_ID_SDTV 3
67 // DISPMANX_ID_FORCE_LCD 4
68 // DISPMANX_ID_FORCE_TV 5
69 // DISPMANX_ID_FORCE_OTHER 6 /* non-default display */
70 static const int dispmanxId = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISPMANX_ID");
71 return (dispmanxId >= 0 && dispmanxId <= 6) ? dispmanxId : 0;
72}
73
74EGLNativeDisplayType QEglFSBrcmIntegration::platformDisplay() const
75{
76 dispman_display = vc_dispmanx_display_open(getDisplayId());
77 return EGL_DEFAULT_DISPLAY;
78}
79
81{
82 vc_dispmanx_display_close(dispman_display);
83}
84
86{
87 uint32_t width, height;
88 graphics_get_display_size(getDisplayId(), &width, &height);
89 return QSize(width, height);
90}
91
93{
95 return createDispmanxLayer(QPoint(0, 0), size, 1, format.hasAlpha() ? DISPMANX_FLAGS_ALPHA_FROM_SOURCE : DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS);
96}
97
102
115
bool hasCapability(QPlatformIntegration::Capability cap) const override
EGLNativeDisplayType platformDisplay() const override
void destroyNativeWindow(EGLNativeWindowType window) override
QSize screenSize() const override
EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) override
Capability
Capabilities are used to determine specific features of a platform integration.
The QPlatformWindow class provides an abstraction for top-level windows.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore
Definition qsize.h:25
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE DISPMANX_DISPLAY_HANDLE_T dispman_display
static EGLNativeWindowType createDispmanxLayer(const QPoint &pos, const QSize &size, int z, DISPMANX_FLAGS_ALPHA_T flags)
static int getDisplayId()
static void destroyDispmanxLayer(EGLNativeWindowType window)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei width
GLbitfield flags
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat alpha
Definition qopenglext.h:418
GLenum cap
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
#define Q_UNUSED(x)
aWidget window() -> setWindowTitle("New Window Title")
[2]