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}-
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}-
40-
41void QEglFSIntegration::addScreen(QPlatformScreen *screen)-
42{-
43 screenAdded(screen);-
44}-
45-
46void QEglFSIntegration::removeScreen(QPlatformScreen *screen)-
47{-
48 destroyScreen(screen);-
49}-
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(!!(
__builtin_expe...ay)0)), false)Description
TRUEnever evaluated
FALSEnever evaluated
m_display == ((EGLDisplay)0)), false)
__builtin_expe...ay)0)), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
57 QMessageLogger(__FILE__, 120127, __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(!!(!
__builtin_expe...inor)), false)Description
TRUEnever evaluated
FALSEnever evaluated
eglInitialize(m_display, &major, &minor)), false)
__builtin_expe...inor)), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
61 QMessageLogger(__FILE__, 124131, __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();-
81-
82 qt_egl_device_integration()->screenDestroy();-
83-
84 if (m_display != ((EGLDisplay)0))-
85 eglTerminate(m_display);-
86-
87 qt_egl_device_integration()->platformDestroy();-
88}-
89-
90QAbstractEventDispatcher *QEglFSIntegration::createEventDispatcher() const-
91{-
92 return createUnixEventDispatcher();-
93}-
94-
95QPlatformServices *QEglFSIntegration::services() const-
96{-
97 return m_services.data();-
98}-
99-
100QPlatformFontDatabase *QEglFSIntegration::fontDatabase() const-
101{-
102 return m_fontDb.data();-
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())-
114 window->create();-
115 static_cast<QEglFSWindow *>(window->handle())->setBackingStore(bs);-
116 return bs;-
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)-
125 w->requestActivateWindow();-
126 return w;-
127}-
128-
129QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const-
130{-
131 EGLDisplay dpy = context->screen() ? static_cast<QEglFSScreen *>(context->screen()->handle())->display() : display();-
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()) {-
138 EGLConfig config = QEglFSIntegration::chooseConfig(dpy, adjustedFormat);-
139 ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant());-
140 } else {-
141 ctx = new QEglFSContext(adjustedFormat, share, dpy, 0, nativeHandle);-
142 }-
143 nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), dpy));-
144-
145 context->setNativeHandle(nativeHandle);-
146 return ctx;-
147}-
148-
149QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const-
150{-
151 EGLDisplay dpy = surface->screen() ? static_cast<QEglFSScreen *>(surface->screen()->handle())->display() : display();-
152 QSurfaceFormat fmt = qt_egl_device_integration()->surfaceFormatFor(surface->requestedFormat());-
153 if (qt_egl_device_integration()->supportsPBuffers()) {-
154 QEGLPlatformContext::Flags flags = 0;-
155 if (!qt_egl_device_integration()->supportsSurfacelessContexts())-
156 flags |= QEGLPlatformContext::NoSurfaceless;-
157 return new QEGLPbuffer(dpy, fmt, surface, flags);-
158 } else {-
159 return new QEglFSOffscreenWindow(dpy, fmt, surface);-
160 }-
161-
162}-
163-
164bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const-
165{-
166-
167 if (qt_egl_device_integration()->hasCapability(cap))-
168 return true;-
169-
170 switch (cap) {-
171 case ThreadedPixmaps: return true;-
172 case OpenGL: return true;-
173 case ThreadedOpenGL: return true;-
174 case WindowManagement: return false;-
175 case RasterGLSurface: return true;-
176 default: return QPlatformIntegration::hasCapability(cap);-
177 }-
178}-
179-
180QPlatformNativeInterface *QEglFSIntegration::nativeInterface() const-
181{-
182 return const_cast<QEglFSIntegration *>(this);-
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)-
209 result = std::find(names, end, key.toLower());-
210 return int(result - names);-
211}-
212-
213void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource)-
214{-
215 void *result = 0;-
216-
217 switch (resourceType(resource)) {-
218 case EglDisplay:-
219 result = display();-
220 break;-
221 case NativeDisplay:-
222 result = reinterpret_cast<void*>(nativeDisplay());-
223 break;-
224 case WaylandDisplay:-
225 result = qt_egl_device_integration()->wlDisplay();-
226 break;-
227 default:-
228 break;-
229 }-
230-
231 return result;-
232}-
233-
234void *QEglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QScreen *)-
235{-
236 void *result = 0;-
237-
238 switch (resourceType(resource)) {-
239 case XlibDisplay:-
240-
241-
242 result = reinterpret_cast<void*>(nativeDisplay());-
243 break;-
244 default:-
245 break;-
246 }-
247-
248 return result;-
249}-
250-
251void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)-
252{-
253 void *result = 0;-
254-
255 switch (resourceType(resource)) {-
256 case EglDisplay:-
257 if (window && window->handle())-
258 result = static_cast<QEglFSScreen *>(window->handle()->screen())->display();-
259 else-
260 result = display();-
261 break;-
262 case EglWindow:-
263 if (window && window->handle())-
264 result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->eglWindow());-
265 break;-
266 default:-
267 break;-
268 }-
269-
270 return result;-
271}-
272-
273void *QEglFSIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)-
274{-
275 void *result = 0;-
276-
277 switch (resourceType(resource)) {-
278 case EglContext:-
279 if (context->handle())-
280 result = static_cast<QEglFSContext *>(context->handle())->eglContext();-
281 break;-
282 case EglConfig:-
283 if (context->handle())-
284 result = static_cast<QEglFSContext *>(context->handle())->eglConfig();-
285 break;-
286 case EglDisplay:-
287 if (context->handle())-
288 result = static_cast<QEglFSContext *>(context->handle())->eglDisplay();-
289 break;-
290 default:-
291 break;-
292 }-
293-
294 return result;-
295}-
296-
297static void *eglContextForContext(QOpenGLContext *context)-
298{-
299 ((!(context)) ? qt_assert("context",__FILE__,357369) : qt_noop());-
300-
301 QEglFSContext *handle = static_cast<QEglFSContext *>(context->handle());-
302 if (!handle)-
303 return 0;-
304-
305 return handle->eglContext();-
306}-
307-
308QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::nativeResourceFunctionForContext(const QByteArray &resource)-
309{-
310 QByteArray lowerCaseResource = resource.toLower();-
311 if (lowerCaseResource == "get_egl_context")-
312 return NativeResourceForContextFunction(eglContextForContext);-
313-
314 return 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__, 394406, __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 qt_egl_device_integration()->platformDisplay();-
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) { }-
377 bool filterConfig(EGLConfig config) const override {-
378 return qt_egl_device_integration()->filterConfig(display(), config)-
379 && QEglConfigChooser::filterConfig(config);-
380 }-
381 };-
382-
383 Chooser chooser(display);-
384 chooser.setSurfaceType(qt_egl_device_integration()->surfaceType());-
385 chooser.setSurfaceFormat(format);-
386 return chooser.chooseConfig();-
387}-
388-
389-
Switch to Source codePreprocessed file

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