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
qdirectfb_egl.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
"qdirectfb_egl.h"
6
#
include
"qdirectfbwindow.h"
7
#
include
"qdirectfbscreen.h"
8
#
include
"qdirectfbeglhooks.h"
9
10
#
include
<
QtGui
/
QOpenGLContext
>
11
#
include
<
qpa
/
qplatformopenglcontext
.
h
>
12
#
include
<
qpa
/
qwindowsysteminterface
.
h
>
13
#
include
<
QtGui
/
QScreen
>
14
15
#
include
<
QtGui
/
private
/
qeglplatformcontext_p
.
h
>
16
#
include
<
QtGui
/
private
/
qeglconvenience_p
.
h
>
17
18
#
include
<
QtGui
/
private
/
qt_egl_p
.
h
>
19
20
QT_BEGIN_NAMESPACE
21
22
#
ifdef
DIRECTFB_PLATFORM_HOOKS
23
extern
QDirectFBEGLHooks platform_hook;
24
static
QDirectFBEGLHooks *hooks = &platform_hook;
25
#
else
26
static
QDirectFBEGLHooks
*
hooks
=
nullptr
;
27
#
endif
28
29
/**
30
* This provides OpenGL ES 2.0 integration with DirectFB. It assumes that
31
* one can adapt a DirectFBSurface as a EGLSurface. It might need some vendor
32
* init code in the QDirectFbScreenEGL class to initialize EGL and one might
33
* need to provide a custom QDirectFbWindowEGL::format() to return the
34
* QSurfaceFormat used by the device.
35
*/
36
37
class
QDirectFbScreenEGL
:
public
QDirectFbScreen
{
38
public
:
39
QDirectFbScreenEGL
(
int
display);
40
~
QDirectFbScreenEGL
();
41
42
// EGL helper
43
EGLDisplay
eglDisplay
();
44
45
private
:
46
void
initializeEGL();
47
void
platformInit();
48
void
platformDestroy();
49
50
private
:
51
EGLDisplay m_eglDisplay;
52
};
53
54
class
QDirectFbWindowEGL
:
public
QDirectFbWindow
{
55
public
:
56
QDirectFbWindowEGL
(QWindow *tlw,
QDirectFbInput
*inputhandler);
57
~
QDirectFbWindowEGL
();
58
59
void
createDirectFBWindow
();
60
61
// EGL. Subclass it instead to have different GL integrations?
62
EGLSurface
eglSurface
();
63
64
QSurfaceFormat
format
()
const
;
65
66
private
:
67
EGLSurface m_eglSurface;
68
};
69
70
class
QDirectFbEGLContext
:
public
QEGLPlatformContext
{
71
public
:
72
QDirectFbEGLContext
(
QDirectFbScreenEGL
*screen, QOpenGLContext *context);
73
74
protected
:
75
EGLSurface
eglSurfaceForPlatformSurface
(QPlatformSurface *surface);
76
77
private
:
78
QDirectFbScreen
*m_screen;
79
};
80
81
QDirectFbScreenEGL
::
QDirectFbScreenEGL
(
int
display)
82
:
QDirectFbScreen
(
display
)
83
,
m_eglDisplay
(
EGL_NO_DISPLAY
)
84
{}
85
86
QDirectFbScreenEGL
::~
QDirectFbScreenEGL
()
87
{
88
platformDestroy();
89
}
90
91
EGLDisplay
QDirectFbScreenEGL
::
eglDisplay
()
92
{
93
if
(m_eglDisplay == EGL_NO_DISPLAY)
94
initializeEGL();
95
return
m_eglDisplay;
96
}
97
98
void
QDirectFbScreenEGL
::initializeEGL()
99
{
100
m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
101
if
(m_eglDisplay == EGL_NO_DISPLAY)
102
return
;
103
104
platformInit();
105
106
EGLint major, minor;
107
eglBindAPI(EGL_OPENGL_ES_API);
108
eglInitialize(m_eglDisplay, &major, &minor);
109
return
;
110
}
111
112
void
QDirectFbScreenEGL
::platformInit()
113
{
114
if
(
hooks
)
115
hooks
->
platformInit
(
)
;
116
}
117
118
void
QDirectFbScreenEGL
::platformDestroy()
119
{
120
if
(
hooks
)
121
hooks
->
platformDestroy
(
)
;
122
}
123
124
QDirectFbWindowEGL
::
QDirectFbWindowEGL
(QWindow *tlw,
QDirectFbInput
*input)
125
:
QDirectFbWindow
(tlw, input)
126
,
m_eglSurface
(
EGL_NO_SURFACE
)
127
{}
128
129
QDirectFbWindowEGL
::~
QDirectFbWindowEGL
()
130
{
131
if
(m_eglSurface != EGL_NO_SURFACE) {
132
QDirectFbScreenEGL
*dfbScreen;
133
dfbScreen =
static_cast
<
QDirectFbScreenEGL
*>(screen());
134
eglDestroySurface(dfbScreen->eglDisplay(), m_eglSurface);
135
}
136
}
137
138
void
QDirectFbWindowEGL
::
createDirectFBWindow
()
139
{
140
// Use the default for the raster surface.
141
if
(window()->surfaceType() == QSurface::RasterSurface)
142
return
QDirectFbWindow
::
createDirectFBWindow
();
143
144
Q_ASSERT(!m_dfbWindow.data());
145
146
DFBWindowDescription description;
147
memset(&description, 0,
sizeof
(DFBWindowDescription));
148
description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH | DWDESC_HEIGHT|
149
DWDESC_POSX | DWDESC_POSY|
150
DWDESC_PIXELFORMAT | DWDESC_SURFACE_CAPS);
151
description.width = qMax(1, window()->width());
152
description.height = qMax(1, window()->height());
153
description.posx = window()->x();
154
description.posy = window()->y();
155
156
description.surface_caps = DSCAPS_GL;
157
description.pixelformat = DSPF_RGB16;
158
159
IDirectFBDisplayLayer *layer;
160
layer = toDfbScreen(window())->dfbLayer();
161
DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr());
162
if
(result != DFB_OK)
163
DirectFBError(
"QDirectFbWindow: failed to create window"
, result);
164
165
m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);
166
m_inputHandler->addWindow(m_dfbWindow.data(), window());
167
}
168
169
EGLSurface
QDirectFbWindowEGL
::
eglSurface
()
170
{
171
if
(m_eglSurface == EGL_NO_SURFACE) {
172
QDirectFbScreenEGL
*dfbScreen =
static_cast
<
QDirectFbScreenEGL
*>(screen());
173
EGLConfig config = q_configFromGLFormat(dfbScreen->eglDisplay(), format(),
true
);
174
m_eglSurface = eglCreateWindowSurface(dfbScreen->eglDisplay(), config, dfbSurface(), NULL);
175
176
if
(m_eglSurface == EGL_NO_SURFACE)
177
eglGetError();
178
}
179
180
return
m_eglSurface;
181
}
182
183
QSurfaceFormat
QDirectFbWindowEGL
::
format
()
const
184
{
185
return
window()->requestedFormat();
186
}
187
188
189
QDirectFbEGLContext
::
QDirectFbEGLContext
(
QDirectFbScreenEGL
*screen, QOpenGLContext *context)
190
:
QEGLPlatformContext
(
context
->
format
(),
context
->
shareHandle
(),
screen
->
eglDisplay
())
191
, m_screen(screen)
192
{}
193
194
EGLSurface
QDirectFbEGLContext
::
eglSurfaceForPlatformSurface
(QPlatformSurface *surface)
195
{
196
QDirectFbWindowEGL
*window =
static_cast
<
QDirectFbWindowEGL
*>(surface);
197
return
window->eglSurface();
198
}
199
200
QPlatformWindow *QDirectFbIntegrationEGL::createPlatformWindow(QWindow *window)
const
201
{
202
QDirectFbWindow *dfbWindow =
new
QDirectFbWindowEGL(window, m_input.data());
203
dfbWindow->createDirectFBWindow();
204
return
dfbWindow;
205
}
206
207
QPlatformOpenGLContext *QDirectFbIntegrationEGL::createPlatformOpenGLContext(QOpenGLContext *context)
const
208
{
209
QDirectFbScreenEGL *screen;
210
screen =
static_cast
<QDirectFbScreenEGL*>(context->screen()->handle());
211
return
new
QDirectFbEGLContext(screen, context);
212
}
213
214
void
QDirectFbIntegrationEGL::initializeScreen()
215
{
216
m_primaryScreen.reset(
new
QDirectFbScreenEGL(0));
217
QWindowSystemInterface::handleScreenAdded(m_primaryScreen.data());
218
}
219
220
bool
QDirectFbIntegrationEGL::hasCapability(QPlatformIntegration::Capability cap)
const
221
{
222
// We assume that devices will have more and not less capabilities
223
if
(hooks && hooks->hasCapability(cap))
224
return
true
;
225
return
QDirectFbIntegration::hasCapability(cap);
226
}
227
228
QT_END_NAMESPACE
QDirectFbEGLContext
Definition
qdirectfb_egl.cpp:70
QDirectFbEGLContext::QDirectFbEGLContext
QDirectFbEGLContext(QDirectFbScreenEGL *screen, QOpenGLContext *context)
Definition
qdirectfb_egl.cpp:189
QDirectFbEGLContext::eglSurfaceForPlatformSurface
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
Definition
qdirectfb_egl.cpp:194
QDirectFbInput
Definition
qdirectfbinput.h:20
QDirectFbScreenEGL
Definition
qdirectfb_egl.cpp:37
QDirectFbScreenEGL::QDirectFbScreenEGL
QDirectFbScreenEGL(int display)
Definition
qdirectfb_egl.cpp:81
QDirectFbScreenEGL::eglDisplay
EGLDisplay eglDisplay()
Definition
qdirectfb_egl.cpp:91
QDirectFbScreenEGL::~QDirectFbScreenEGL
~QDirectFbScreenEGL()
Definition
qdirectfb_egl.cpp:86
QDirectFbScreen
Definition
qdirectfbscreen.h:19
QDirectFbScreen::QDirectFbScreen
QDirectFbScreen(int display)
Definition
qdirectfbscreen.cpp:10
QDirectFbWindowEGL
Definition
qdirectfb_egl.cpp:54
QDirectFbWindowEGL::eglSurface
EGLSurface eglSurface()
Definition
qdirectfb_egl.cpp:169
QDirectFbWindowEGL::createDirectFBWindow
void createDirectFBWindow()
Definition
qdirectfb_egl.cpp:138
QDirectFbWindowEGL::QDirectFbWindowEGL
QDirectFbWindowEGL(QWindow *tlw, QDirectFbInput *inputhandler)
Definition
qdirectfb_egl.cpp:124
QDirectFbWindowEGL::~QDirectFbWindowEGL
~QDirectFbWindowEGL()
Definition
qdirectfb_egl.cpp:129
QDirectFbWindowEGL::format
QSurfaceFormat format() const
Returns the actual surface format of the window.
Definition
qdirectfb_egl.cpp:183
QDirectFbWindow
Definition
qdirectfbwindow.h:16
QDirectFbWindow::createDirectFBWindow
virtual void createDirectFBWindow()
Definition
qdirectfbwindow.cpp:21
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
hooks
static QT_BEGIN_NAMESPACE QDirectFBEGLHooks * hooks
Definition
qdirectfb_egl.cpp:26
QDirectFBEGLHooks
Definition
qdirectfbeglhooks.h:12
QDirectFBEGLHooks::platformInit
void platformInit()
Definition
qdirectfbeglhooks_stub.cpp:12
QDirectFBEGLHooks::platformDestroy
void platformDestroy()
Definition
qdirectfbeglhooks_stub.cpp:16
qtbase
src
plugins
platforms
directfb
qdirectfb_egl.cpp
Generated on
for Qt by
1.18.0