Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
IMotionClock.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorAnimation/phosphoranimation_export.h>
7
8#include <QtGlobal>
9
10#include <chrono>
11
12namespace PhosphorAnimation {
13
17class PHOSPHORANIMATION_EXPORT IMotionClock
18{
19public:
20 virtual ~IMotionClock() = default;
21
22 IMotionClock(const IMotionClock&) = delete;
26
28 virtual std::chrono::nanoseconds now() const = 0;
29
31 virtual qreal refreshRate() const = 0;
32
34 virtual void requestFrame() = 0;
35
39 virtual const void* epochIdentity() const
40 {
41 return nullptr;
42 }
43
45 static const void* steadyClockEpoch();
46
48 static bool epochCompatible(const IMotionClock* a, const IMotionClock* b)
49 {
50 if (!a || !b) {
51 return false;
52 }
53 const void* epochA = a->epochIdentity();
54 const void* epochB = b->epochIdentity();
55 return epochA && epochA == epochB;
56 }
57
58protected:
59 IMotionClock() = default;
60};
61
62} // namespace PhosphorAnimation
Abstract clock interface for the motion runtime.
Definition IMotionClock.h:18
static bool epochCompatible(const IMotionClock *a, const IMotionClock *b)
True iff both clocks are non-null and share the same non-null epochIdentity.
Definition IMotionClock.h:48
IMotionClock(const IMotionClock &)=delete
virtual ~IMotionClock()=default
IMotionClock & operator=(IMotionClock &&)=delete
static const void * steadyClockEpoch()
Shared sentinel for std::chrono::steady_clock-backed clocks.
virtual void requestFrame()=0
Schedule another paint tick. Idempotent within a single frame.
virtual std::chrono::nanoseconds now() const =0
Monotonically non-decreasing steady-clock reading (nanoseconds).
IMotionClock & operator=(const IMotionClock &)=delete
IMotionClock(IMotionClock &&)=delete
virtual qreal refreshRate() const =0
Nominal refresh rate in Hz, or zero if unknown.
virtual const void * epochIdentity() const
Opaque epoch identity for rebindClock compatibility.
Definition IMotionClock.h:39
Definition AnimatedValue.h:31