| 1 |
// Copyright (C) 2015 Pier Luigi Fiorini <[email protected]> |
| 2 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 3 |
// Copyright (C) 2016 Pelagicore AG |
| 4 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 5 |
|
| 6 |
#ifndef QEGLFSKMSGBMSCREEN_H |
| 7 |
#define QEGLFSKMSGBMSCREEN_H |
| 8 |
|
| 9 |
// |
| 10 |
// W A R N I N G |
| 11 |
// ------------- |
| 12 |
// |
| 13 |
// This file is not part of the Qt API. It exists purely as an |
| 14 |
// implementation detail. This header file may change from version to |
| 15 |
// version without notice, or even be removed. |
| 16 |
// |
| 17 |
// We mean it. |
| 18 |
// |
| 19 |
|
| 20 |
#include <private/qeglfskmsscreen_p.h> |
| 21 |
#include <QMutex> |
| 22 |
#include <QWaitCondition> |
| 23 |
|
| 24 |
#include <gbm.h> |
| 25 |
|
| 26 |
QT_BEGIN_NAMESPACE |
| 27 |
|
| 28 |
class QEglFSKmsGbmCursor; |
| 29 |
|
| 30 |
class Q_EGLFS_EXPORT QEglFSKmsGbmScreen : public QEglFSKmsScreen |
| 31 |
{ |
| 32 |
public: |
| 33 |
QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless); |
| 34 |
~QEglFSKmsGbmScreen(); |
| 35 |
|
| 36 |
QPlatformCursor *cursor() const override; |
| 37 |
|
| 38 |
gbm_surface *createSurface(EGLConfig eglConfig); |
| 39 |
void resetSurface(); |
| 40 |
|
| 41 |
void initCloning(QPlatformScreen *screenThisScreenClones, |
| 42 |
const QList<QPlatformScreen *> &screensCloningThisScreen); |
| 43 |
|
| 44 |
void waitForFlip() override; |
| 45 |
|
| 46 |
virtual void flip(); |
| 47 |
virtual void updateFlipStatus(); |
| 48 |
|
| 49 |
virtual uint32_t gbmFlags() { return GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; } |
| 50 |
|
| 51 |
protected: |
| 52 |
void flipFinished(); |
| 53 |
void ensureModeSet(uint32_t fb); |
| 54 |
void cloneDestFlipFinished(QEglFSKmsGbmScreen *cloneDestScreen); |
| 55 |
void waitForFlipWithEventReader(QEglFSKmsGbmScreen *screen); |
| 56 |
static void nonThreadedPageFlipHandler(int fd, |
| 57 |
unsigned int sequence, |
| 58 |
unsigned int tv_sec, |
| 59 |
unsigned int tv_usec, |
| 60 |
void *user_data); |
| 61 |
|
| 62 |
gbm_surface *m_gbm_surface; |
| 63 |
|
| 64 |
gbm_bo *m_gbm_bo_current; |
| 65 |
gbm_bo *m_gbm_bo_next; |
| 66 |
bool m_flipPending; |
| 67 |
|
| 68 |
QMutex m_flipMutex; |
| 69 |
QWaitCondition m_flipCond; |
| 70 |
static QMutex m_nonThreadedFlipMutex; |
| 71 |
|
| 72 |
QScopedPointer<QEglFSKmsGbmCursor> m_cursor; |
| 73 |
|
| 74 |
struct FrameBuffer { |
| 75 |
uint32_t fb = 0; |
| 76 |
}; |
| 77 |
static void bufferDestroyedHandler(gbm_bo *bo, void *data); |
| 78 |
FrameBuffer *framebufferForBufferObject(gbm_bo *bo); |
| 79 |
|
| 80 |
QEglFSKmsGbmScreen *m_cloneSource; |
| 81 |
struct CloneDestination { |
| 82 |
QEglFSKmsGbmScreen *screen = nullptr; |
| 83 |
bool cloneFlipPending = false; |
| 84 |
}; |
| 85 |
QList<CloneDestination> m_cloneDests; |
| 86 |
|
| 87 |
bool needsNewModeSetForNextFb = false; |
| 88 |
}; |
| 89 |
|
| 90 |
QT_END_NAMESPACE |
| 91 |
|
| 92 |
#endif // QEGLFSKMSGBMSCREEN_H |