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
qeglfsrcarintegration.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
<
QDebug
>
6
#
include
<
QtGui
/
private
/
qeglconvenience_p
.
h
>
7
#
include
<
EGL
/
egl
.
h
>
8
#
include
"INTEGRITY.h"
9
#
include
"qeglfsrcarintegration.h"
10
11
#
define
RCAR_DEFAULT_DISPLAY
1
12
#
define
RCAR_DEFAULT_WM_LAYER
2
13
14
extern
"C"
unsigned
long
PVRGrfxServerInit(
void
);
15
16
QT_BEGIN_NAMESPACE
17
18
void
QEglFSRcarIntegration::platformInit()
19
{
20
bool
ok;
21
22
QEglFSDeviceIntegration::platformInit();
23
24
PVRGrfxServerInit();
25
26
mScreenSize = q_screenSizeFromFb(0);
27
mNativeDisplay = (NativeDisplayType)EGL_DEFAULT_DISPLAY;
28
29
mNativeDisplayID = qEnvironmentVariableIntValue(
"QT_QPA_WM_DISP_ID"
, &ok);
30
if
(!ok)
31
mNativeDisplayID =
RCAR_DEFAULT_DISPLAY
;
32
33
r_wm_Error_t wm_err = R_WM_DevInit(mNativeDisplayID);
34
if
(wm_err != R_WM_ERR_OK)
35
qFatal(
"Failed to init WM Dev: %d, error: %d"
, mNativeDisplayID, wm_err);
36
wm_err = R_WM_ScreenBgColorSet(mNativeDisplayID, 0x20, 0x20, 0x20);
// Grey
37
if
(wm_err != R_WM_ERR_OK)
38
qFatal(
"Failed to set screen background: %d"
, wm_err);
39
wm_err = R_WM_ScreenEnable(mNativeDisplayID);
40
if
(wm_err != R_WM_ERR_OK)
41
qFatal(
"Failed to enable screen: %d"
, wm_err);
42
}
43
44
QSize QEglFSRcarIntegration::screenSize()
const
45
{
46
return
mScreenSize;
47
}
48
49
EGLNativeDisplayType QEglFSRcarIntegration::platformDisplay()
const
50
{
51
return
mNativeDisplay;
52
}
53
54
static
r_wm_WinColorFmt_t
getWMColorFormat
(
const
QSurfaceFormat &format)
55
{
56
const
int
a = format.alphaBufferSize();
57
const
int
r = format.redBufferSize();
58
const
int
g = format.greenBufferSize();
59
const
int
b = format.blueBufferSize();
60
61
switch
(r) {
62
case
4:
63
if
(g == 4 && b == 4 && a == 4)
64
return
R_WM_COLORFMT_ARGB4444;
65
break
;
66
case
5:
67
if
(g == 6 && b == 5 && a == 0)
68
return
R_WM_COLORFMT_RGB565;
69
else
if
(g == 5 && b == 5 && a == 1)
70
return
R_WM_COLORFMT_ARGB1555;
71
break
;
72
case
8:
73
if
(g == 8 && b == 8 && a == 0)
74
return
R_WM_COLORFMT_RGB0888;
75
else
if
(g == 8 && b == 8 && a == 8)
76
return
R_WM_COLORFMT_ARGB8888;
77
break
;
78
}
79
80
qFatal(
"Unsupported color format: R:%d G:%d B:%d A:%d"
, r, g, b, a);
81
return
R_WM_COLORFMT_LAST;
82
}
83
84
EGLNativeWindowType QEglFSRcarIntegration::createNativeWindow(QPlatformWindow *window,
const
QSize &size,
const
QSurfaceFormat &format)
85
{
86
bool
ok;
87
88
mNativeWindow = (EGLNativeWindowTypeREL*)malloc(
sizeof
(EGLNativeWindowTypeREL));
89
memset(mNativeWindow, 0,
sizeof
(EGLNativeWindowTypeREL));
90
91
mNativeWindow->ColorFmt = getWMColorFormat(format);
92
mNativeWindow->PosX = 0;
93
mNativeWindow->PosY = 0;
94
mNativeWindow->PosZ = qEnvironmentVariableIntValue(
"QT_QPA_WM_LAYER"
, &ok);
95
if
(!ok)
96
mNativeWindow->PosZ =
RCAR_DEFAULT_WM_LAYER
;
97
mNativeWindow->Pitch = size.width();
98
mNativeWindow->Width = size.width();
99
mNativeWindow->Height = size.height();
100
mNativeWindow->Alpha = format.alphaBufferSize();
101
102
if
(format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior)
103
mNativeWindow->Surface.BufNum = 3;
104
else
105
mNativeWindow->Surface.BufNum = format.swapBehavior();
106
107
mNativeWindow->Surface.Type = R_WM_SURFACE_FB;
108
mNativeWindow->Surface.BufMode = R_WM_WINBUF_ALLOC_INTERNAL;
109
110
r_wm_Error_t wm_err = R_WM_WindowCreate(mNativeDisplayID, mNativeWindow);
111
if
(wm_err != R_WM_ERR_OK)
112
qFatal(
"Failed to create window layer: %d"
, wm_err);
113
wm_err = R_WM_DevEventRegister(mNativeDisplayID, R_WM_EVENT_VBLANK, 0);
114
if
(wm_err != R_WM_ERR_OK)
115
qFatal(
"Failed to Register vsync event: %d"
, wm_err);
116
wm_err = R_WM_WindowEnable(mNativeDisplayID, mNativeWindow);
117
if
(wm_err != R_WM_ERR_OK)
118
qFatal(
"Failed to Enable window surface: %d"
, wm_err);
119
120
return
static_cast
<EGLNativeWindowType>(mNativeWindow);
121
}
122
123
void
QEglFSRcarIntegration::destroyNativeWindow(EGLNativeWindowType window)
124
{
125
R_WM_WindowDisable(mNativeDisplayID, mNativeWindow);
126
usleep(100000);
//Needed to allow Window Manager make the window transparent
127
R_WM_WindowDelete(mNativeDisplayID, mNativeWindow);
128
R_WM_DevDeinit(mNativeDisplayID);
129
free(mNativeWindow);
130
}
131
132
QT_END_NAMESPACE
getWMColorFormat
static r_wm_WinColorFmt_t getWMColorFormat(const QSurfaceFormat &format)
Definition
qeglfsrcarintegration.cpp:54
RCAR_DEFAULT_DISPLAY
#define RCAR_DEFAULT_DISPLAY
Definition
qeglfsrcarintegration.cpp:11
RCAR_DEFAULT_WM_LAYER
#define RCAR_DEFAULT_WM_LAYER
Definition
qeglfsrcarintegration.cpp:12
qtbase
src
plugins
platforms
eglfs
deviceintegration
eglfs_rcar
qeglfsrcarintegration.cpp
Generated on
for Qt by
1.18.0