qeglfsintegration.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/eglfs/qeglfsintegration.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
19static void initResources()-
20{-
21-
22 do { extern int qInitResources_cursor (); qInitResources_cursor (); } while (0);-
23-
24}
never executed: end of block
0
25-
26-
27-
28QEglFSIntegration::QEglFSIntegration()-
29 : m_display(((EGLDisplay)0)),-
30 m_inputContext(0),-
31 m_fontDb(new QGenericUnixFontDatabase),-
32 m_services(new QGenericUnixServices),-
33 m_kbdMgr(0),-
34 m_disableInputHandlers(false)-
35{-
36 m_disableInputHandlers = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISABLE_INPUT");-
37-
38 initResources();-
39}
never executed: end of block
0
40-
41void QEglFSIntegration::addScreen(QPlatformScreen *screen)-
42{-
43 screenAdded(screen);-
44}
never executed: end of block
0
45-
46void QEglFSIntegration::removeScreen(QPlatformScreen *screen)-
47{-
48 destroyScreen(screen);-
49}
never executed: end of block
0
50-
51void QEglFSIntegration::initialize()-
52{-
53 qt_egl_device_integration()->platformInit();-
54-
55 m_display = qt_egl_device_integration()->createDisplay(nativeDisplay());-
56 if (__builtin_expect(!!(m_display == ((EGLDisplay)0)), false)
__builtin_expe...ay)0)), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
57 QMessageLogger(__FILE__, 127, __PRETTY_FUNCTION__).fatal("Could not open egl display");
never executed: QMessageLogger(__FILE__, 127, __PRETTY_FUNCTION__).fatal("Could not open egl display");
0
58-
59 EGLint major, minor;-
60 if (__builtin_expect(!!(!eglInitialize(m_display, &major, &minor)), false)
__builtin_expe...inor)), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
61 QMessageLogger(__FILE__, 131, __PRETTY_FUNCTION__).fatal("Could not initialize egl display");
never executed: QMessageLogger(__FILE__, 131, __PRETTY_FUNCTION__).fatal("Could not initialize egl display");
0
62-
63 m_inputContext = QPlatformInputContextFactory::create();-
64-
65 m_vtHandler.reset(new QFbVtHandler);-
66-
67 if (qt_egl_device_integration()->usesDefaultScreen()
qt_egl_device_...efaultScreen()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
68 addScreen(new QEglFSScreen(display()));
never executed: addScreen(new QEglFSScreen(display()));
0
69 else-
70 qt_egl_device_integration()->screenInit();
never executed: qt_egl_device_integration()->screenInit();
0
71-
72-
73 if (!m_disableInputHandlers
!m_disableInputHandlersDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
74 createInputHandlers();
never executed: createInputHandlers();
0
75}
never executed: end of block
0
76-
77void QEglFSIntegration::destroy()-
78{-
79 for (QForeachContainer<typename QtPrivate::remove_reference<decltype((static_cast<QGuiApplication *>(QCoreApplication::instance()))->topLevelWindows())>::type> _container_(((static_cast<QGuiApplication *>(QCoreApplication::instance()))->topLevelWindows())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QWindow *w = *_container_.i; _container_.control; _container_.control = 0)-
80 w->destroy();
never executed: w->destroy();
0
81-
82 qt_egl_device_integration()->screenDestroy();-
83-
84 if (m_display != ((EGLDisplay)0)
m_display != ((EGLDisplay)0)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
85 eglTerminate(m_display);
never executed: eglTerminate(m_display);
0
86-
87 qt_egl_device_integration()->platformDestroy();-
88}
never executed: end of block
0
89-
90QAbstractEventDispatcher *QEglFSIntegration::createEventDispatcher() const-
91{-
92 return
never executed: return createUnixEventDispatcher();
createUnixEventDispatcher();
never executed: return createUnixEventDispatcher();
0
93}-
94-
95QPlatformServices *QEglFSIntegration::services() const-
96{-
97 return
never executed: return m_services.data();
m_services.data();
never executed: return m_services.data();
0
98}-
99-
100QPlatformFontDatabase *QEglFSIntegration::fontDatabase() const-
101{-
102 return
never executed: return m_fontDb.data();
m_fontDb.data();
never executed: return m_fontDb.data();
0
103}-
104-
105QPlatformTheme *QEglFSIntegration::createPlatformTheme(const QString &name) const-
106{-
107 return
never executed: return QGenericUnixTheme::createUnixTheme(name);
QGenericUnixTheme::createUnixTheme(name);
never executed: return QGenericUnixTheme::createUnixTheme(name);
0
108}-
109-
110QPlatformBackingStore *QEglFSIntegration::createPlatformBackingStore(QWindow *window) const-
111{-
112 QOpenGLCompositorBackingStore *bs = new QOpenGLCompositorBackingStore(window);-
113 if (!window->handle()
!window->handle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
114 window->create();
never executed: window->create();
0
115 static_cast<QEglFSWindow *>(window->handle())->setBackingStore(bs);-
116 return
never executed: return bs;
bs;
never executed: return bs;
0
117}-
118-
119QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window) const-
120{-
121 QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);-
122 QEglFSWindow *w = qt_egl_device_integration()->createWindow(window);-
123 w->create();-
124 if (window->type() != Qt::ToolTip
window->type() != Qt::ToolTipDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
125 w->requestActivateWindow();
never executed: w->requestActivateWindow();
0
126 return
never executed: return w;
w;
never executed: return w;
0
127}-
128-
129QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const-
130{-
131 EGLDisplay dpy = context->screen()
context->screen()Description
TRUEnever evaluated
FALSEnever evaluated
? static_cast<QEglFSScreen *>(context->screen()->handle())->display() : display();
0
132 QPlatformOpenGLContext *share = context->shareHandle();-
133 QVariant nativeHandle = context->nativeHandle();-
134-
135 QEglFSContext *ctx;-
136 QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(context->format());-
137 if (nativeHandle.isNull()
nativeHandle.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
138 EGLConfig config = QEglFSIntegration::chooseConfig(dpy, adjustedFormat);-
139 ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant());-
140 }
never executed: end of block
else {
0
141 ctx = new QEglFSContext(adjustedFormat, share, dpy, 0, nativeHandle);-
142 }
never executed: end of block
0
143 nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), dpy));-
144-
145 context->setNativeHandle(nativeHandle);-
146 return
never executed: return ctx;
ctx;
never executed: return ctx;
0
147}-
148-
149QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const-
150{-
151 EGLDisplay dpy = surface->screen()
surface->screen()Description
TRUEnever evaluated
FALSEnever evaluated
? static_cast<QEglFSScreen *>(surface->screen()->handle())->display() : display();
0
152 QSurfaceFormat fmt = qt_egl_device_integration()->surfaceFormatFor(surface->requestedFormat());-
153 if (qt_egl_device_integration()->supportsPBuffers()
qt_egl_device_...ortsPBuffers()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
154 QEGLPlatformContext::Flags flags = 0;-
155 if (!qt_egl_device_integration()->supportsSurfacelessContexts()
!qt_egl_device...lessContexts()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
156 flags |= QEGLPlatformContext::NoSurfaceless;
never executed: flags |= QEGLPlatformContext::NoSurfaceless;
0
157 return
never executed: return new QEGLPbuffer(dpy, fmt, surface, flags);
new QEGLPbuffer(dpy, fmt, surface, flags);
never executed: return new QEGLPbuffer(dpy, fmt, surface, flags);
0
158 } else {-
159 return
never executed: return new QEglFSOffscreenWindow(dpy, fmt, surface);
new QEglFSOffscreenWindow(dpy, fmt, surface);
never executed: return new QEglFSOffscreenWindow(dpy, fmt, surface);
0
160 }-
161-
162}-
163-
164bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const-
165{-
166-
167 if (qt_egl_device_integration()->hasCapability(cap)
qt_egl_device_...apability(cap)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
168 return
never executed: return true;
true;
never executed: return true;
0
169-
170 switch (cap) {-
171 case
never executed: case ThreadedPixmaps:
ThreadedPixmaps:
never executed: case ThreadedPixmaps:
return
never executed: return true;
true;
never executed: return true;
0
172 case
never executed: case OpenGL:
OpenGL:
never executed: case OpenGL:
return
never executed: return true;
true;
never executed: return true;
0
173 case
never executed: case ThreadedOpenGL:
ThreadedOpenGL:
never executed: case ThreadedOpenGL:
return
never executed: return true;
true;
never executed: return true;
0
174 case
never executed: case WindowManagement:
WindowManagement:
never executed: case WindowManagement:
return
never executed: return false;
false;
never executed: return false;
0
175 case
never executed: case RasterGLSurface:
RasterGLSurface:
never executed: case RasterGLSurface:
return
never executed: return true;
true;
never executed: return true;
0
176 default
never executed: default:
:
never executed: default:
return
never executed: return QPlatformIntegration::hasCapability(cap);
QPlatformIntegration::hasCapability(cap);
never executed: return QPlatformIntegration::hasCapability(cap);
0
177 }-
178}-
179-
180QPlatformNativeInterface *QEglFSIntegration::nativeInterface() const-
181{-
182 return
never executed: return const_cast<QEglFSIntegration *>(this);
const_cast<QEglFSIntegration *>(this);
never executed: return const_cast<QEglFSIntegration *>(this);
0
183}-
184-
185enum ResourceType {-
186 EglDisplay,-
187 EglWindow,-
188 EglContext,-
189 EglConfig,-
190 NativeDisplay,-
191 XlibDisplay,-
192 WaylandDisplay-
193};-
194-
195static int resourceType(const QByteArray &key)-
196{-
197 static const QByteArray names[] = {-
198 ([]() -> QByteArray { enum { Size = sizeof("egldisplay") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "egldisplay" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()),-
199 ([]() -> QByteArray { enum { Size = sizeof("eglwindow") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "eglwindow" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()),-
200 ([]() -> QByteArray { enum { Size = sizeof("eglcontext") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "eglcontext" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()),-
201 ([]() -> QByteArray { enum { Size = sizeof("eglconfig") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "eglconfig" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()),-
202 ([]() -> QByteArray { enum { Size = sizeof("nativedisplay") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "nativedisplay" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()),-
203 ([]() -> QByteArray { enum { Size = sizeof("display") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "display" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()),-
204 ([]() -> QByteArray { enum { Size = sizeof("server_wl_display") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "server_wl_display" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())-
205 };-
206 const QByteArray *end = names + sizeof(names) / sizeof(names[0]);-
207 const QByteArray *result = std::find(names, end, key);-
208 if (result == end
result == endDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
209 result = std::find(names, end, key.toLower());
never executed: result = std::find(names, end, key.toLower());
0
210 return
never executed: return int(result - names);
int(result - names);
never executed: return int(result - names);
0
211}-
212-
213void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource)-
214{-
215 void *result = 0;-
216-
217 switch (resourceType(resource)) {-
218 case
never executed: case EglDisplay:
EglDisplay:
never executed: case EglDisplay:
0
219 result = display();-
220 break;
never executed: break;
0
221 case
never executed: case NativeDisplay:
NativeDisplay:
never executed: case NativeDisplay:
0
222 result = reinterpret_cast<void*>(nativeDisplay());-
223 break;
never executed: break;
0
224 case
never executed: case WaylandDisplay:
WaylandDisplay:
never executed: case WaylandDisplay:
0
225 result = qt_egl_device_integration()->wlDisplay();-
226 break;
never executed: break;
0
227 default
never executed: default:
:
never executed: default:
0
228 break;
never executed: break;
0
229 }-
230-
231 return
never executed: return result;
result;
never executed: return result;
0
232}-
233-
234void *QEglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QScreen *)-
235{-
236 void *result = 0;-
237-
238 switch (resourceType(resource)) {-
239 case
never executed: case XlibDisplay:
XlibDisplay:
never executed: case XlibDisplay:
0
240-
241-
242 result = reinterpret_cast<void*>(nativeDisplay());-
243 break;
never executed: break;
0
244 default
never executed: default:
:
never executed: default:
0
245 break;
never executed: break;
0
246 }-
247-
248 return
never executed: return result;
result;
never executed: return result;
0
249}-
250-
251void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)-
252{-
253 void *result = 0;-
254-
255 switch (resourceType(resource)) {-
256 case
never executed: case EglDisplay:
EglDisplay:
never executed: case EglDisplay:
0
257 if (window
windowDescription
TRUEnever evaluated
FALSEnever evaluated
&& window->handle()
window->handle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
258 result = static_cast<QEglFSScreen *>(window->handle()->screen())->display();
never executed: result = static_cast<QEglFSScreen *>(window->handle()->screen())->display();
0
259 else-
260 result = display();
never executed: result = display();
0
261 break;
never executed: break;
0
262 case
never executed: case EglWindow:
EglWindow:
never executed: case EglWindow:
0
263 if (window
windowDescription
TRUEnever evaluated
FALSEnever evaluated
&& window->handle()
window->handle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
264 result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->eglWindow());
never executed: result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->eglWindow());
0
265 break;
never executed: break;
0
266 default
never executed: default:
:
never executed: default:
0
267 break;
never executed: break;
0
268 }-
269-
270 return
never executed: return result;
result;
never executed: return result;
0
271}-
272-
273void *QEglFSIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)-
274{-
275 void *result = 0;-
276-
277 switch (resourceType(resource)) {-
278 case
never executed: case EglContext:
EglContext:
never executed: case EglContext:
0
279 if (context->handle()
context->handle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
280 result = static_cast<QEglFSContext *>(context->handle())->eglContext();
never executed: result = static_cast<QEglFSContext *>(context->handle())->eglContext();
0
281 break;
never executed: break;
0
282 case
never executed: case EglConfig:
EglConfig:
never executed: case EglConfig:
0
283 if (context->handle()
context->handle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
284 result = static_cast<QEglFSContext *>(context->handle())->eglConfig();
never executed: result = static_cast<QEglFSContext *>(context->handle())->eglConfig();
0
285 break;
never executed: break;
0
286 case
never executed: case EglDisplay:
EglDisplay:
never executed: case EglDisplay:
0
287 if (context->handle()
context->handle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
288 result = static_cast<QEglFSContext *>(context->handle())->eglDisplay();
never executed: result = static_cast<QEglFSContext *>(context->handle())->eglDisplay();
0
289 break;
never executed: break;
0
290 default
never executed: default:
:
never executed: default:
0
291 break;
never executed: break;
0
292 }-
293-
294 return
never executed: return result;
result;
never executed: return result;
0
295}-
296-
297static void *eglContextForContext(QOpenGLContext *context)-
298{-
299 ((!(context)) ? qt_assert("context",__FILE__,369) : qt_noop());-
300-
301 QEglFSContext *handle = static_cast<QEglFSContext *>(context->handle());-
302 if (!handle
!handleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
303 return
never executed: return 0;
0;
never executed: return 0;
0
304-
305 return
never executed: return handle->eglContext();
handle->eglContext();
never executed: return handle->eglContext();
0
306}-
307-
308QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::nativeResourceFunctionForContext(const QByteArray &resource)-
309{-
310 QByteArray lowerCaseResource = resource.toLower();-
311 if (lowerCaseResource == "get_egl_context"
lowerCaseResou...t_egl_context"Description
TRUEnever evaluated
FALSEnever evaluated
)
0
312 return
never executed: return NativeResourceForContextFunction(eglContextForContext);
NativeResourceForContextFunction(eglContextForContext);
never executed: return NativeResourceForContextFunction(eglContextForContext);
0
313-
314 return
never executed: return 0;
0;
never executed: return 0;
0
315}-
316-
317QFunctionPointer QEglFSIntegration::platformFunction(const QByteArray &function) const-
318{-
319-
320 if (function == QEglFSFunctions::loadKeymapTypeIdentifier()
function == QE...peIdentifier()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
321 return
never executed: return QFunctionPointer(loadKeymapStatic);
QFunctionPointer(loadKeymapStatic);
never executed: return QFunctionPointer(loadKeymapStatic);
0
322-
323-
324-
325-
326 return
never executed: return 0;
0;
never executed: return 0;
0
327}-
328-
329void QEglFSIntegration::loadKeymapStatic(const QString &filename)-
330{-
331-
332 QEglFSIntegration *self = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());-
333 if (self->m_kbdMgr
self->m_kbdMgrDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
334 self->m_kbdMgr->loadKeymap(filename);
never executed: self->m_kbdMgr->loadKeymap(filename);
0
335 else-
336 QMessageLogger(__FILE__, 406, __PRETTY_FUNCTION__).warning("QEglFSIntegration: Cannot load keymap, no keyboard handler found");
never executed: QMessageLogger(__FILE__, 406, __PRETTY_FUNCTION__).warning("QEglFSIntegration: Cannot load keymap, no keyboard handler found");
0
337-
338-
339-
340}-
341-
342void QEglFSIntegration::createInputHandlers()-
343{-
344-
345-
346-
347-
348-
349-
350-
351 bool useTslib = false;-
352-
353-
354-
355-
356-
357-
358-
359 m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() , this);-
360 new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() , this);-
361 if (!useTslib
!useTslibDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
362 new
never executed: new QEvdevTouchManager(QLatin1String("EvdevTouch"), QString() , this);
QEvdevTouchManager(QLatin1String("EvdevTouch"), QString() , this);
never executed: new QEvdevTouchManager(QLatin1String("EvdevTouch"), QString() , this);
0
363-
364}
never executed: end of block
0
365-
366EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const-
367{-
368 return
never executed: return qt_egl_device_integration()->platformDisplay();
qt_egl_device_integration()->platformDisplay();
never executed: return qt_egl_device_integration()->platformDisplay();
0
369}-
370-
371EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)-
372{-
373 class Chooser : public QEglConfigChooser {-
374 public:-
375 Chooser(EGLDisplay display)-
376 : QEglConfigChooser(display) { }
never executed: end of block
0
377 bool filterConfig(EGLConfig config) const override {-
378 return
never executed: return qt_egl_device_integration()->filterConfig(display(), config) && QEglConfigChooser::filterConfig(config);
qt_egl_device_integration()->filterConfig(display(), config)
never executed: return qt_egl_device_integration()->filterConfig(display(), config) && QEglConfigChooser::filterConfig(config);
0
379 && QEglConfigChooser::filterConfig(config);
never executed: return qt_egl_device_integration()->filterConfig(display(), config) && QEglConfigChooser::filterConfig(config);
0
380 }-
381 };-
382-
383 Chooser chooser(display);-
384 chooser.setSurfaceType(qt_egl_device_integration()->surfaceType());-
385 chooser.setSurfaceFormat(format);-
386 return
never executed: return chooser.chooseConfig();
chooser.chooseConfig();
never executed: return chooser.chooseConfig();
0
387}-
388-
389-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9