File indexing completed on 2024-05-12 17:02:08

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 KWIN_EXPORT RenderLoopPrivate
0020 {
0021 public:
0022     static RenderLoopPrivate *get(RenderLoop *loop);
0023     explicit RenderLoopPrivate(RenderLoop *q);
0024 
0025     void dispatch();
0026     void invalidate();
0027 
0028     void delayScheduleRepaint();
0029     void scheduleRepaint();
0030     void maybeScheduleRepaint();
0031 
0032     void notifyFrameFailed();
0033     void notifyFrameCompleted(std::chrono::nanoseconds timestamp);
0034 
0035     RenderLoop *q;
0036     std::chrono::nanoseconds lastPresentationTimestamp = std::chrono::nanoseconds::zero();
0037     std::chrono::nanoseconds nextPresentationTimestamp = std::chrono::nanoseconds::zero();
0038     QTimer compositeTimer;
0039     RenderJournal renderJournal;
0040     int refreshRate = 60000;
0041     int pendingFrameCount = 0;
0042     int inhibitCount = 0;
0043     bool pendingReschedule = false;
0044     bool pendingRepaint = false;
0045     RenderLoop::VrrPolicy vrrPolicy = RenderLoop::VrrPolicy::Never;
0046     std::optional<LatencyPolicy> latencyPolicy;
0047     Item *fullscreenItem = nullptr;
0048     bool allowTearing = false;
0049 
0050     enum class SyncMode {
0051         Fixed,
0052         Adaptive,
0053         /* adaptive if possible, async if not */
0054         AdaptiveAsync,
0055         Async
0056     };
0057     SyncMode presentMode = SyncMode::Fixed;
0058     bool canDoTearing = false;
0059 };
0060 
0061 } // namespace KWin