-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patholedrenderer.h
68 lines (54 loc) · 1.4 KB
/
oledrenderer.h
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
67
68
#ifndef OLEDRENDERER_H
#define OLEDRENDERER_H
#include <QFutureWatcher>
#include <QObject>
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QOpenGLFramebufferObject>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQuickItem>
#include <QQuickRenderControl>
#include <QQuickWindow>
#include <QOpenGLFunctions>
#include <QTimer>
#include "animationdriver.h"
class OledRenderer : public QObject
{
Q_OBJECT
public:
enum Status {
NotRunning,
Running
};
explicit OledRenderer(QObject *parent = 0);
~OledRenderer();
void loadQmlFile(const QString &qmlFile, const QSize &size, qreal devicePixelRatio = 1.0, int fps = 24);
bool isRunning();
QQuickItem * rootItem();
signals:
void imageRendered(const QImage &image);
private slots:
void start();
void cleanup();
void createFbo();
void destroyFbo();
bool loadQml(const QString &qmlFile, const QSize &size);
void renderNext();
private:
QOpenGLContext *m_context;
QOffscreenSurface *m_offscreenSurface;
QQuickRenderControl *m_renderControl;
QQuickWindow *m_quickWindow;
QQmlEngine *m_qmlEngine;
QQmlComponent *m_qmlComponent;
QQuickItem *m_rootItem;
QOpenGLFramebufferObject *m_fbo;
qreal m_dpr;
QSize m_size;
AnimationDriver *m_animationDriver;
Status m_status;
int m_fps;
QTimer *m_renderTimer;
};
#endif // OLEDRENDERER_H