| 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 RENDERTIMER_H |
| 20 |
#define RENDERTIMER_H |
| 21 |
|
| 22 |
#include <QtCore/QtGlobal> |
| 23 |
#include <QtCore/QObject> |
| 24 |
#include <QtCore/QElapsedTimer> |
| 25 |
#include <QtGui/qopenglfunctions.h> |
| 26 |
|
| 27 |
class RenderTimerPrivate; |
| 28 |
|
| 29 |
class RenderTimer : public QObject |
| 30 |
{ |
| 31 |
Q_OBJECT |
| 32 |
|
| 33 |
Q_ENUMS(TimerType) |
| 34 |
|
| 35 |
public: |
| 36 |
enum TimerType { |
| 37 |
Automatic, |
| 38 |
Trivial, |
| 39 |
KHRFence, |
| 40 |
NVFence, |
| 41 |
ARBTimerQuery, |
| 42 |
EXTTimerQuery |
| 43 |
}; |
| 44 |
|
| 45 |
explicit RenderTimer(QObject* parent = 0); |
| 46 |
virtual ~RenderTimer(); |
| 47 |
|
| 48 |
static bool isAvailable(TimerType type); |
| 49 |
static TimerType optimalTimerType(); |
| 50 |
void setup(TimerType type); |
| 51 |
void teardown(); |
| 52 |
void start(); |
| 53 |
qint64 stop(); |
| 54 |
|
| 55 |
protected: |
| 56 |
void teardown(TimerType type); |
| 57 |
|
| 58 |
private: |
| 59 |
Q_DECLARE_PRIVATE(RenderTimer) |
| 60 |
RenderTimerPrivate *d_ptr; |
| 61 |
}; |
| 62 |
|
| 63 |
#endif // RENDERTIMER_H |