Debian Codegraph @

src/imports/PerformanceMetrics/plugin/upmrenderingtimes.h

raw
1 /*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Florian Boucault <[email protected]>
17 */
18
19 #ifndef UPMRENDERINGTIMES_H
20 #define UPMRENDERINGTIMES_H
21
22 #include <QtCore/QElapsedTimer>
23 #include <QtQuick/QQuickItem>
24 #include <QtQuick/QQuickWindow>
25
26 #include "upmgraphmodel.h"
27 #include "rendertimer.h"
28
29 class UPMRenderingTimes : public QQuickItem
30 {
31 Q_OBJECT
32
33 Q_PROPERTY(int period READ period WRITE setPeriod NOTIFY periodChanged)
34 Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged)
35 Q_PROPERTY(UPMGraphModel* graphModel READ graphModel NOTIFY graphModelChanged)
36 Q_PROPERTY(RenderTimer::TimerType timerType READ timerType WRITE setTimerType NOTIFY timerTypeChanged)
37
38 Q_ENUMS(RenderTimer::TimerType)
39
40 public:
41 explicit UPMRenderingTimes(QQuickItem* parent = 0);
42
43 // getters
44 int period() const;
45 int samples() const;
46 UPMGraphModel* graphModel() const;
47 RenderTimer::TimerType timerType() const;
48
49 // setters
50 void setPeriod(int period);
51 void setSamples(int samples);
52 void setTimerType(RenderTimer::TimerType timerType);
53
54 Q_SIGNALS:
55 void periodChanged();
56 void samplesChanged();
57 void graphModelChanged();
58 void timerTypeChanged();
59 void frameRendered(qint64 renderTime);
60
61 protected:
62 void itemChange(ItemChange change, const ItemChangeData & value) override;
63
64 private Q_SLOTS:
65 void connectToWindow(QQuickWindow* window);
66 void onSceneGraphInitialized();
67 void onSceneGraphInvalidated();
68 void onBeforeRendering();
69 void onAfterRendering();
70 void onFrameSwapped();
71 void onFrameRendered(qint64 renderTime);
72
73 private:
74 void appendRenderTime(qint64 renderTime);
75
76 private:
77 int m_period;
78 UPMGraphModel* m_graphModel;
79 RenderTimer::TimerType m_timerType;
80 bool m_needsNewTimer;
81 RenderTimer m_renderingTimer;
82 QQuickWindow* m_window;
83 bool m_oddFrame;
84 qint64 m_oddFrameRenderTime;
85 };
86
87 #endif // UPMRENDERINGTIMES_H