KWin
Loading...
Searching...
No Matches
drm_commit_thread.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2023 Xaver Hugl <xaver.hugl@gmail.com>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include <QObject>
12#include <QThread>
13#include <condition_variable>
14#include <mutex>
15#include <vector>
16
17namespace KWin
18{
19
20class DrmGpu;
21class DrmCommit;
22class DrmAtomicCommit;
23class DrmLegacyCommit;
24
25using TimePoint = std::chrono::steady_clock::time_point;
26
27class DrmCommitThread : public QObject
28{
29 Q_OBJECT
30public:
31 explicit DrmCommitThread(DrmGpu *gpu, const QString &name);
33
34 void addCommit(std::unique_ptr<DrmAtomicCommit> &&commit);
35 void setPendingCommit(std::unique_ptr<DrmLegacyCommit> &&commit);
36
37 void setModeInfo(uint32_t maximum, std::chrono::nanoseconds vblankTime);
38 void pageFlipped(std::chrono::nanoseconds timestamp);
39 bool pageflipsPending();
44 std::chrono::nanoseconds safetyMargin() const;
45
46Q_SIGNALS:
48
49private:
50 void clearDroppedCommits();
51 TimePoint estimateNextVblank(TimePoint now) const;
52 void optimizeCommits();
53
54 std::unique_ptr<DrmCommit> m_committed;
55 std::vector<std::unique_ptr<DrmAtomicCommit>> m_commits;
56 std::unique_ptr<QThread> m_thread;
57 std::mutex m_mutex;
58 std::condition_variable m_commitPending;
59 TimePoint m_lastPageflip;
60 TimePoint m_targetPageflipTime;
61 std::chrono::nanoseconds m_minVblankInterval;
62 std::vector<std::unique_ptr<DrmAtomicCommit>> m_droppedCommits;
63 bool m_vrr = false;
64 std::chrono::nanoseconds m_safetyMargin{0};
65};
66
67}
void pageFlipped(std::chrono::nanoseconds timestamp)
void addCommit(std::unique_ptr< DrmAtomicCommit > &&commit)
std::chrono::nanoseconds safetyMargin() const
void setModeInfo(uint32_t maximum, std::chrono::nanoseconds vblankTime)
DrmCommitThread(DrmGpu *gpu, const QString &name)
void setPendingCommit(std::unique_ptr< DrmLegacyCommit > &&commit)
std::chrono::steady_clock::time_point TimePoint