File indexing completed on 2024-05-12 05:31:23

0001 /*
0002     SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "effect/globals.h"
0010 
0011 #include <QElapsedTimer>
0012 #include <QQueue>
0013 
0014 namespace KWin
0015 {
0016 
0017 /**
0018  * The RenderJournal class measures how long it takes to render frames and estimates how
0019  * long it will take to render the next frame.
0020  */
0021 class KWIN_EXPORT RenderJournal
0022 {
0023 public:
0024     RenderJournal();
0025 
0026     void add(std::chrono::nanoseconds renderTime, std::chrono::nanoseconds presentationTimestamp);
0027 
0028     std::chrono::nanoseconds result() const;
0029 
0030 private:
0031     std::chrono::nanoseconds m_result{0};
0032     std::chrono::nanoseconds m_variance{0};
0033     std::optional<std::chrono::nanoseconds> m_lastAdd;
0034 };
0035 
0036 } // namespace KWin