summaryrefslogtreecommitdiffstats
path: root/tools/qqem/fpshelper.h
blob: ea5ae3ba2e213a7c09c5a53ab2af6b60d224fc30 (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef FPSHELPER_H
#define FPSHELPER_H

#include <QQuickItem>
#include <QElapsedTimer>

class FpsHelper : public QQuickItem
{
    Q_OBJECT
    Q_PROPERTY(float fps READ fps NOTIFY fpsChanged)

public:
    FpsHelper();

    float fps() const;

protected:
    QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *) override;

signals:
    void fpsChanged();

private:
    float m_fps = 0.0f;
    int m_frames = 0;
    QElapsedTimer m_timer;
};

#endif // FPSHELPER_H