File indexing completed on 2024-05-19 05:31:36

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 "renderjournal.h"
0010 #include "renderloop.h"
0011 
0012 #include <QTimer>
0013 
0014 #include <optional>
0015 
0016 namespace KWin
0017 {
0018 
0019 class SurfaceItem;
0020 
0021 class KWIN_EXPORT RenderLoopPrivate
0022 {
0023 public:
0024     static RenderLoopPrivate *get(RenderLoop *loop);
0025     explicit RenderLoopPrivate(RenderLoop *q, Output *output);
0026 
0027     void dispatch();
0028     void invalidate();
0029 
0030     void delayScheduleRepaint();
0031     void scheduleRepaint();
0032     void maybeScheduleRepaint();
0033 
0034     void notifyFrameFailed();
0035     void notifyFrameCompleted(std::chrono::nanoseconds timestamp, std::chrono::nanoseconds renderTime, PresentationMode mode = PresentationMode::VSync);
0036     void notifyVblank(std::chrono::nanoseconds timestamp);
0037 
0038     RenderLoop *const q;
0039     Output *const output;
0040     std::chrono::nanoseconds lastPresentationTimestamp = std::chrono::nanoseconds::zero();
0041     std::chrono::nanoseconds nextPresentationTimestamp = std::chrono::nanoseconds::zero();
0042     QTimer compositeTimer;
0043     RenderJournal renderJournal;
0044     int refreshRate = 60000;
0045     int pendingFrameCount = 0;
0046     int inhibitCount = 0;
0047     bool pendingReschedule = false;
0048     bool pendingRepaint = false;
0049     std::chrono::nanoseconds safetyMargin{0};
0050 
0051     PresentationMode presentationMode = PresentationMode::VSync;
0052 };
0053 
0054 } // namespace KWin