#pragma once

#include <QElapsedTimer>
#include <QObject>
#include <QQmlParserStatus>
#include <QQuickWindow>

class FpsCounter : public QObject, public QQmlParserStatus
{
    Q_OBJECT
    Q_PROPERTY(double fps READ fps NOTIFY fpsChanged)
    Q_INTERFACES(QQmlParserStatus)
public:
    FpsCounter(QObject *parent = nullptr);
    double fps() const { return m_fps; }

    void classBegin() override {}
    void componentComplete() override;

signals:
    void fpsChanged();

private:
    QElapsedTimer m_timer;
    qint64 m_frames = 0;
    double m_fps = 0;
};
