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
|
/*
Copyright 2013 Adam Reichold
This file is part of qpdfview.
qpdfview is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
qpdfview is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qpdfview. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RENDERTASK_H
#define RENDERTASK_H
#include <QImage>
#include <QMutex>
#include <QRunnable>
#include <QWaitCondition>
#include "global.h"
namespace qpdfview
{
namespace Model
{
class Page;
}
class RenderTask : public QObject, QRunnable
{
Q_OBJECT
public:
explicit RenderTask(QObject* parent = 0);
void wait();
bool isRunning() const;
bool wasCanceled() const;
void run();
signals:
void finished();
void imageReady(int resolutionX, int resolutionY, qreal devicePixelRatio, qreal scaleFactor, Rotation rotation, bool invertColors, bool prefetch, QImage image);
public slots:
void start(Model::Page* page, int resolutionX, int resolutionY, qreal devicePixelRatio, qreal scaleFactor, Rotation rotation, bool invertColors, bool prefetch);
void cancel();
private:
Q_DISABLE_COPY(RenderTask)
mutable QMutex m_mutex;
QWaitCondition m_waitCondition;
void finish();
bool m_isRunning;
bool m_wasCanceled;
Model::Page* m_page;
int m_resolutionX;
int m_resolutionY;
qreal m_devicePixelRatio;
qreal m_scaleFactor;
Rotation m_rotation;
bool m_invertColors;
bool m_prefetch;
};
} // qpdfview
#endif // RENDERTASK_H
|