-
Notifications
You must be signed in to change notification settings - Fork 0
/
rendering_pool.h
100 lines (78 loc) · 2.26 KB
/
rendering_pool.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Manages render threads
// Author: Max Schwarz <[email protected]>
#ifndef RENDERING_POOL_H
#define RENDERING_POOL_H
#include <QObject>
#include <QList>
#include <QImage>
#include <QThreadPool>
#include <QFuture>
#include <QMutex>
#include <poppler-qt5.h>
#include <memory>
class RenderingPage : public QObject
{
Q_OBJECT
Q_PROPERTY(bool ready READ ready NOTIFY readyChanged)
Q_PROPERTY(QImage image READ image NOTIFY imageChanged)
Q_PROPERTY(QList<QObject*> videoObjects READ videoObjects CONSTANT)
Q_PROPERTY(QString label READ label CONSTANT)
Q_PROPERTY(int slideNumber READ slideNumber CONSTANT)
Q_PROPERTY(int slideAnimationIndex READ slideAnimationIndex CONSTANT)
Q_PROPERTY(int slideAnimationCount READ slideAnimationCount CONSTANT)
public:
explicit RenderingPage(const QUrl& file, Poppler::Page* page, QThreadPool* pool, QObject* parent = 0);
virtual ~RenderingPage();
bool ready() const;
QImage image() const;
void triggerRender(const QSize& size);
void render();
const QList<QObject*>& videoObjects() const
{ return m_videoObjects; }
Poppler::Page* page() const
{ return m_page; }
QString label() const
{ return m_page->label(); }
int slideNumber() const
{ return m_slideNumber; }
int slideAnimationIndex() const
{ return m_slideAnimationIndex; }
int slideAnimationCount() const
{ return m_slideAnimationCount; }
void setSlideNumberInformation(int slideNumber, int animationIndex, int animationCount)
{
m_slideNumber = slideNumber;
m_slideAnimationIndex = animationIndex;
m_slideAnimationCount = animationCount;
}
Q_SIGNALS:
void readyChanged();
void imageChanged();
private:
mutable QMutex m_mutex;
Poppler::Page* m_page;
QSize m_size;
QImage m_image;
QList<QObject*> m_videoObjects;
QThreadPool* m_pool;
QFuture<void> m_future;
int m_slideNumber = 0;
int m_slideAnimationIndex = 0;
int m_slideAnimationCount = 1;
};
class RenderingPool : public QObject, public QList<QObject*>
{
Q_OBJECT
public:
explicit RenderingPool(const QUrl& url, const std::shared_ptr<Poppler::Document>& doc, QObject* parent = 0);
virtual ~RenderingPool();
void triggerRender(const QSize& size);
Q_SIGNALS:
void renderingFinished();
private Q_SLOTS:
void checkFinished();
private:
std::shared_ptr<Poppler::Document> m_doc;
QThreadPool* m_pool;
};
#endif