summaryrefslogtreecommitdiffstats
path: root/src/shared-main-lib/frametimerimpl.h
blob: d4cb2cea69742c217f1931bc4712c9edbca55338 (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
// 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 <QtAppManCommon/global.h>


QT_BEGIN_NAMESPACE_AM

class FrameTimer;

class 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);

    FrameTimer *m_frameTimer = nullptr;

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

QT_END_NAMESPACE_AM

#endif // FRAMETIMERIMPL_H