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