aboutsummaryrefslogtreecommitdiff
path: root/demos/widgetsgallery/swaphook.h
blob: a7a1435c056cd999cb8b9ab085859d3783e60da3 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef SWAPHOOK_H
#define SWAPHOOK_H

// Used to store time in milliseconds.
typedef unsigned long long timestamp;

#ifdef __arm__
#define EGL
#include <EGL/egl.h>
#   ifdef M_OS_MAEMO5
#       define EGLAPI
#       define EGLAPIENTRY
#   endif //M_OS_MAEMO5
#endif //__arm__

#include <QObject>
#include <QLinkedList>

class SwapHookPrivate;

/**
  * Swap hooks saves the timestamps when eglSwapBuffers is beein called
  * or as fallback monitors paint events.
  *
  */
class SwapHook : public QObject
{
    Q_OBJECT
#ifdef EGL
friend EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
#endif //EGL

private:
  SwapHook();
  ~SwapHook();

public:

  /**
    * Return the saved timestamps.
    */
  QLinkedList<timestamp> timestamps();

  /**
    * Returns the global SwapHook instance.
    */
  static SwapHook* instance();

public slots:
  /**
    * Starts to monitor buffer switches.
    */
  void startLurking();

  /**
    * Stops to monitor buffer switches.
    */
  void stopLurking();

private:
  QScopedPointer<SwapHookPrivate> d;

};


#endif // __SWAPHOOK_H__