Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
include
"qeglfsbrcmintegration.h"
6
#
include
<
bcm_host
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
static
DISPMANX_DISPLAY_HANDLE_T
dispman_display
= 0;
11
12
static
EGLNativeWindowType
createDispmanxLayer
(
const
QPoint &pos,
const
QSize &size,
int
z, DISPMANX_FLAGS_ALPHA_T flags)
13
{
14
VC_RECT_T dst_rect;
15
dst_rect.x = pos.x();
16
dst_rect.y = pos.y();
17
dst_rect.width = size.width();
18
dst_rect.height = size.height();
19
20
VC_RECT_T src_rect;
21
src_rect.x = 0;
22
src_rect.y = 0;
23
src_rect.width = size.width() << 16;
24
src_rect.height = size.height() << 16;
25
26
DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start(0);
27
28
VC_DISPMANX_ALPHA_T alpha;
29
alpha.flags = flags;
30
alpha.opacity = 0xFF;
31
alpha.mask = 0;
32
33
DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add(
34
dispman_update, dispman_display, z, &dst_rect, 0, &src_rect,
35
DISPMANX_PROTECTION_NONE, &alpha, (DISPMANX_CLAMP_T *)NULL, (DISPMANX_TRANSFORM_T)0);
36
37
vc_dispmanx_update_submit_sync(dispman_update);
38
39
EGL_DISPMANX_WINDOW_T *eglWindow =
new
EGL_DISPMANX_WINDOW_T;
40
eglWindow->element = dispman_element;
41
eglWindow->width = size.width();
42
eglWindow->height = size.height();
43
44
return
eglWindow;
45
}
46
47
static
void
destroyDispmanxLayer
(EGLNativeWindowType window)
48
{
49
EGL_DISPMANX_WINDOW_T *eglWindow =
static_cast
<EGL_DISPMANX_WINDOW_T *>(window);
50
DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start(0);
51
vc_dispmanx_element_remove(dispman_update, eglWindow->element);
52
vc_dispmanx_update_submit_sync(dispman_update);
53
delete
eglWindow;
54
}
55
56
void
QEglFSBrcmIntegration::platformInit()
57
{
58
bcm_host_init();
59
}
60
61
static
int
getDisplayId
()
62
{
63
// As defined in vc_dispmanx_types.h
64
// DISPMANX_ID_MAIN_LCD 0
65
// DISPMANX_ID_AUX_LCD 1
66
// DISPMANX_ID_HDMI 2
67
// DISPMANX_ID_SDTV 3
68
// DISPMANX_ID_FORCE_LCD 4
69
// DISPMANX_ID_FORCE_TV 5
70
// DISPMANX_ID_FORCE_OTHER 6 /* non-default display */
71
static
const
int
dispmanxId = qEnvironmentVariableIntValue(
"QT_QPA_EGLFS_DISPMANX_ID"
);
72
return
(dispmanxId >= 0 && dispmanxId <= 6) ? dispmanxId : 0;
73
}
74
75
EGLNativeDisplayType QEglFSBrcmIntegration::platformDisplay()
const
76
{
77
dispman_display
= vc_dispmanx_display_open(
getDisplayId
(
)
);
78
return
EGL_DEFAULT_DISPLAY;
79
}
80
81
void
QEglFSBrcmIntegration::platformDestroy()
82
{
83
vc_dispmanx_display_close(dispman_display);
84
}
85
86
QSize QEglFSBrcmIntegration::screenSize()
const
87
{
88
uint32_t width, height;
89
graphics_get_display_size(
getDisplayId
(
)
, &width, &height);
90
return
QSize(width, height);
91
}
92
93
EGLNativeWindowType QEglFSBrcmIntegration::createNativeWindow(QPlatformWindow *window,
const
QSize &size,
const
QSurfaceFormat &format)
94
{
95
Q_UNUSED(window);
96
return
createDispmanxLayer(QPoint(0, 0), size, 1, format.hasAlpha() ? DISPMANX_FLAGS_ALPHA_FROM_SOURCE : DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS);
97
}
98
99
void
QEglFSBrcmIntegration::destroyNativeWindow(EGLNativeWindowType window)
100
{
101
destroyDispmanxLayer(window);
102
}
103
104
bool
QEglFSBrcmIntegration::hasCapability(QPlatformIntegration::Capability cap)
const
105
{
106
switch
(cap) {
107
case
QPlatformIntegration::ThreadedPixmaps:
108
case
QPlatformIntegration::OpenGL:
109
case
QPlatformIntegration::ThreadedOpenGL:
110
case
QPlatformIntegration::BufferQueueingOpenGL:
111
return
true
;
112
default
:
113
return
false
;
114
}
115
}
116
117
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
createDispmanxLayer
static EGLNativeWindowType createDispmanxLayer(const QPoint &pos, const QSize &size, int z, DISPMANX_FLAGS_ALPHA_T flags)
Definition
qeglfsbrcmintegration.cpp:12
getDisplayId
static int getDisplayId()
Definition
qeglfsbrcmintegration.cpp:61
dispman_display
static QT_BEGIN_NAMESPACE DISPMANX_DISPLAY_HANDLE_T dispman_display
Definition
qeglfsbrcmintegration.cpp:10
destroyDispmanxLayer
static void destroyDispmanxLayer(EGLNativeWindowType window)
Definition
qeglfsbrcmintegration.cpp:47
qtbase
src
plugins
platforms
eglfs
deviceintegration
eglfs_brcm
qeglfsbrcmintegration.cpp
Generated on
for Qt by
1.18.0