Debian Codegraph @

src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp

raw
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
4 #include "qeglfsvivintegration.h"
5 #include <EGL/eglvivante.h>
6 #include <QDebug>
7
8 #ifdef Q_OS_INTEGRITY
9 extern "C" void VivanteInit(void);
10 #endif
11
12 QT_BEGIN_NAMESPACE
13
14 void QEglFSVivIntegration::platformInit()
15 {
16 QEglFSDeviceIntegration::platformInit();
17
18 int width, height;
19
20 bool multiBufferNotEnabledYet = qEnvironmentVariableIsEmpty("FB_MULTI_BUFFER");
21 bool multiBuffer = qEnvironmentVariableIsEmpty("QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER");
22 if (multiBufferNotEnabledYet && multiBuffer) {
23 qWarning() << "QEglFSVivIntegration will set environment variable FB_MULTI_BUFFER=2 to enable double buffering and vsync.\n"
24 << "If this is not desired, you can override this via: export QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1";
25 qputenv("FB_MULTI_BUFFER", "2");
26 }
27
28 #ifdef Q_OS_INTEGRITY
29 VivanteInit();
30 mNativeDisplay = fbGetDisplay();
31 #else
32 mNativeDisplay = static_cast<EGLNativeDisplayType>(fbGetDisplayByIndex(framebufferIndex()));
33 #endif
34
35 fbGetDisplayGeometry(mNativeDisplay, &width, &height);
36 mScreenSize.setHeight(height);
37 mScreenSize.setWidth(width);
38 }
39
40 QSize QEglFSVivIntegration::screenSize() const
41 {
42 return mScreenSize;
43 }
44
45 EGLNativeDisplayType QEglFSVivIntegration::platformDisplay() const
46 {
47 return mNativeDisplay;
48 }
49
50 EGLNativeWindowType QEglFSVivIntegration::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format)
51 {
52 Q_UNUSED(window);
53 Q_UNUSED(format);
54
55 EGLNativeWindowType eglWindow = static_cast<EGLNativeWindowType>(fbCreateWindow(mNativeDisplay, 0, 0, size.width(), size.height()));
56 return eglWindow;
57 }
58
59 void QEglFSVivIntegration::destroyNativeWindow(EGLNativeWindowType window)
60 {
61 fbDestroyWindow(window);
62 }
63
64 QT_END_NAMESPACE