1/****************************************************************************
2**
3** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
4** Copyright (C) 2016 The Qt Company Ltd.
5** Copyright (C) 2016 Pelagicore AG
6** Contact: https://www.qt.io/licensing/
7**
8** This file is part of the plugins of the Qt Toolkit.
9**
10** $QT_BEGIN_LICENSE:LGPL$
11** Commercial License Usage
12** Licensees holding valid commercial Qt licenses may use this file in
13** accordance with the commercial license agreement provided with the
14** Software or, alternatively, in accordance with the terms contained in
15** a written agreement between you and The Qt Company. For licensing terms
16** and conditions see https://www.qt.io/terms-conditions. For further
17** information use the contact form at https://www.qt.io/contact-us.
18**
19** GNU Lesser General Public License Usage
20** Alternatively, this file may be used under the terms of the GNU Lesser
21** General Public License version 3 as published by the Free Software
22** Foundation and appearing in the file LICENSE.LGPL3 included in the
23** packaging of this file. Please review the following information to
24** ensure the GNU Lesser General Public License version 3 requirements
25** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** GNU General Public License Usage
28** Alternatively, this file may be used under the terms of the GNU
29** General Public License version 2.0 or (at your option) the GNU General
30** Public license version 3 or any later version approved by the KDE Free
31** Qt Foundation. The licenses are as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
33** included in the packaging of this file. Please review the following
34** information to ensure the GNU General Public License requirements will
35** be met: https://www.gnu.org/licenses/gpl-2.0.html and
36** https://www.gnu.org/licenses/gpl-3.0.html.
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QEGLFSKMSGBMSCREEN_H
43#define QEGLFSKMSGBMSCREEN_H
44
45#include "qeglfskmsscreen.h"
46#include <QMutex>
47#include <QWaitCondition>
48
49#include <gbm.h>
50
51QT_BEGIN_NAMESPACE
52
53class QEglFSKmsGbmCursor;
54
55class QEglFSKmsGbmScreen : public QEglFSKmsScreen
56{
57public:
58 QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless);
59 ~QEglFSKmsGbmScreen();
60
61 QPlatformCursor *cursor() const override;
62
63 gbm_surface *createSurface(EGLConfig eglConfig);
64 void resetSurface();
65
66 void initCloning(QPlatformScreen *screenThisScreenClones,
67 const QVector<QPlatformScreen *> &screensCloningThisScreen);
68
69 void waitForFlip() override;
70
71 void flip();
72
73private:
74 void flipFinished();
75 void ensureModeSet(uint32_t fb);
76 void cloneDestFlipFinished(QEglFSKmsGbmScreen *cloneDestScreen);
77 void updateFlipStatus();
78
79 gbm_surface *m_gbm_surface;
80
81 gbm_bo *m_gbm_bo_current;
82 gbm_bo *m_gbm_bo_next;
83 bool m_flipPending;
84
85 QMutex m_flipMutex;
86 QWaitCondition m_flipCond;
87
88 QScopedPointer<QEglFSKmsGbmCursor> m_cursor;
89
90 struct FrameBuffer {
91 uint32_t fb = 0;
92 };
93 static void bufferDestroyedHandler(gbm_bo *bo, void *data);
94 FrameBuffer *framebufferForBufferObject(gbm_bo *bo);
95
96 QEglFSKmsGbmScreen *m_cloneSource;
97 struct CloneDestination {
98 QEglFSKmsGbmScreen *screen = nullptr;
99 bool cloneFlipPending = false;
100 };
101 QVector<CloneDestination> m_cloneDests;
102};
103
104QT_END_NAMESPACE
105
106#endif // QEGLFSKMSGBMSCREEN_H
107

source code of qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h