summaryrefslogtreecommitdiffstats
path: root/src/shared-lib/frametimerimpl.h
blob: c75bf5d11d074e0c532628c205d185f8eb9de8f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef FRAMETIMERIMPL_H
#define FRAMETIMERIMPL_H

#include <functional>
#include <QtAppManShared/qtappmansharedglobal.h>


QT_BEGIN_NAMESPACE_AM

class FrameTimer;

class Q_APPMANSHARED_EXPORT FrameTimerImpl
{
public:
    static void setFactory(const std::function<FrameTimerImpl *(FrameTimer *)> &factory);

    static FrameTimerImpl *create(FrameTimer *timer);

    virtual ~FrameTimerImpl() = default;

    FrameTimer *frameTimer();

    virtual bool connectToSystemWindow(QObject *window) = 0;
    virtual void disconnectFromSystemWindow(QObject *window) = 0;

    void reportFrameSwap();

protected:
    FrameTimerImpl(FrameTimer *frameTimer);

private:
    FrameTimer *m_frameTimer = nullptr;

    static std::function<FrameTimerImpl *(FrameTimer *)> s_factory;
    Q_DISABLE_COPY_MOVE(FrameTimerImpl)
};

QT_END_NAMESPACE_AM

#endif // FRAMETIMERIMPL_H