bitmaploadworker.h 1,6 КБ
Newer Older
vladislav.larionov's avatar
vladislav.larionov включено в состав коммита
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
/*
 * Copyright (c) 2022 Open Mobile Platform LLC
 *
 * This program 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; version 2 only.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#pragma once

#include <QObject>
#include <QRunnable>
#include <QSharedPointer>
#include <QImage>
#include <QFutureWatcher>
#include <QMutex>

class BasePage;
class BitmapLoaderWorker : public QObject, public QRunnable
{
    Q_OBJECT

public:
    BitmapLoaderWorker(QSharedPointer<BasePage> p, qreal scaleX, qreal scaleY, int flags, qreal zoom = 1.0, QPointF bias = QPointF(), qreal pageScale = 1.0);
    ~BitmapLoaderWorker() override;

    void run() override;

public slots:
    void cancel();

signals:
    void done(QImage);

private slots:
    void _getResult();

private:
    QSharedPointer<BasePage> m_page;
    QFutureWatcher<QImage> m_watcher;
    qreal m_scaleX;
    qreal m_scaleY;
    int m_flags;
    qreal m_zoom;
    QPointF m_bias;
    qreal m_pageScale;
    static QMutex m_mutex;
    std::atomic<bool> m_isCanceled;
    std::atomic<bool> m_loaded;
};