2021-05-24 07:25:56 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org>
|
2021-06-03 18:33:18 +00:00
|
|
|
|
|
|
|
Work sponsored by the LiMux project of the city of Munich:
|
2021-05-24 11:41:08 +00:00
|
|
|
SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB a KDAB Group company <info@kdab.com>
|
2021-05-24 07:25:56 +00:00
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-01-24 15:06:45 +00:00
|
|
|
|
|
|
|
#ifndef OKULAR_THREADEDGENERATOR_P_H
|
|
|
|
#define OKULAR_THREADEDGENERATOR_P_H
|
|
|
|
|
2008-05-20 15:20:40 +00:00
|
|
|
#include "area.h"
|
|
|
|
|
2018-08-31 09:23:45 +00:00
|
|
|
#include <QImage>
|
2020-01-30 08:28:17 +00:00
|
|
|
#include <QMutex>
|
2018-08-31 09:23:45 +00:00
|
|
|
#include <QSet>
|
|
|
|
#include <QThread>
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
class QEventLoop;
|
2007-04-20 17:17:44 +00:00
|
|
|
|
2018-02-01 18:42:37 +00:00
|
|
|
#include "generator.h"
|
2017-10-20 10:00:30 +00:00
|
|
|
#include "page.h"
|
|
|
|
|
2007-01-24 15:06:45 +00:00
|
|
|
namespace Okular
|
|
|
|
{
|
2013-02-24 21:58:53 +00:00
|
|
|
class DocumentObserver;
|
2007-09-14 15:29:16 +00:00
|
|
|
class DocumentPrivate;
|
2007-07-07 20:35:01 +00:00
|
|
|
class FontInfo;
|
2007-04-20 17:17:44 +00:00
|
|
|
class Generator;
|
|
|
|
class Page;
|
|
|
|
class PixmapGenerationThread;
|
|
|
|
class PixmapRequest;
|
|
|
|
class TextPage;
|
|
|
|
class TextPageGenerationThread;
|
2014-02-19 22:40:43 +00:00
|
|
|
class TilesManager;
|
2007-04-20 17:17:44 +00:00
|
|
|
|
|
|
|
class GeneratorPrivate
|
2007-01-24 15:06:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-09-14 13:31:55 +00:00
|
|
|
GeneratorPrivate();
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
virtual ~GeneratorPrivate();
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
Q_DECLARE_PUBLIC(Generator)
|
|
|
|
Generator *q_ptr;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2007-04-20 17:59:12 +00:00
|
|
|
PixmapGenerationThread *pixmapGenerationThread();
|
|
|
|
TextPageGenerationThread *textPageGenerationThread();
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
void pixmapGenerationFinished();
|
|
|
|
void textpageGenerationFinished();
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
QMutex *threadsLock();
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2008-03-15 02:15:16 +00:00
|
|
|
virtual QVariant metaData(const QString &key, const QVariant &option) const;
|
2008-05-06 20:20:10 +00:00
|
|
|
virtual QImage image(PixmapRequest *);
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2007-09-14 15:29:16 +00:00
|
|
|
DocumentPrivate *m_document;
|
2007-04-20 17:17:44 +00:00
|
|
|
// NOTE: the following should be a QSet< GeneratorFeature >,
|
|
|
|
// but it is not to avoid #include'ing generator.h
|
|
|
|
QSet<int> m_features;
|
|
|
|
PixmapGenerationThread *mPixmapGenerationThread;
|
|
|
|
TextPageGenerationThread *mTextPageGenerationThread;
|
2020-01-30 08:28:17 +00:00
|
|
|
mutable QMutex m_mutex;
|
|
|
|
QMutex m_threadsMutex;
|
2007-09-07 13:13:50 +00:00
|
|
|
bool mPixmapReady : 1;
|
|
|
|
bool mTextPageReady : 1;
|
2007-10-08 21:49:27 +00:00
|
|
|
bool m_closing : 1;
|
|
|
|
QEventLoop *m_closingLoop;
|
2014-01-13 00:15:55 +00:00
|
|
|
QSizeF m_dpi;
|
2007-04-20 17:17:44 +00:00
|
|
|
};
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2007-09-30 21:44:31 +00:00
|
|
|
class PixmapRequestPrivate
|
|
|
|
{
|
|
|
|
public:
|
2007-12-04 21:36:32 +00:00
|
|
|
void swap();
|
2014-02-19 22:40:43 +00:00
|
|
|
TilesManager *tilesManager() const;
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2018-02-01 18:42:37 +00:00
|
|
|
static PixmapRequestPrivate *get(const PixmapRequest *req);
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2013-02-24 21:58:53 +00:00
|
|
|
DocumentObserver *mObserver;
|
2007-09-30 21:44:31 +00:00
|
|
|
int mPageNumber;
|
|
|
|
int mWidth;
|
|
|
|
int mHeight;
|
|
|
|
int mPriority;
|
2013-02-24 21:58:53 +00:00
|
|
|
int mFeatures;
|
2008-03-07 15:50:48 +00:00
|
|
|
bool mForce : 1;
|
2012-08-24 16:32:39 +00:00
|
|
|
bool mTile : 1;
|
2017-10-03 07:29:18 +00:00
|
|
|
bool mPartialUpdatesWanted : 1;
|
2012-11-09 17:05:10 +00:00
|
|
|
Page *mPage;
|
2012-07-08 16:52:00 +00:00
|
|
|
NormalizedRect mNormalizedRect;
|
2018-02-01 18:42:37 +00:00
|
|
|
QAtomicInt mShouldAbortRender;
|
|
|
|
QImage mResultImage;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TextRequestPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static TextRequestPrivate *get(const TextRequest *req);
|
|
|
|
|
|
|
|
Page *mPage;
|
|
|
|
QAtomicInt mShouldAbortExtraction;
|
2007-09-30 21:44:31 +00:00
|
|
|
};
|
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
class PixmapGenerationThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
public:
|
2018-09-01 08:25:57 +00:00
|
|
|
explicit PixmapGenerationThread(Generator *generator);
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2019-12-20 15:40:59 +00:00
|
|
|
void startGeneration(PixmapRequest *request, bool calcBoundingBox);
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
void endGeneration();
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
PixmapRequest *request() const;
|
|
|
|
|
|
|
|
QImage image() const;
|
2008-05-20 15:20:40 +00:00
|
|
|
bool calcBoundingBox() const;
|
|
|
|
NormalizedRect boundingBox() const;
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
protected:
|
2017-03-02 19:38:50 +00:00
|
|
|
void run() override;
|
2007-01-24 15:06:45 +00:00
|
|
|
|
|
|
|
private:
|
2007-01-31 18:31:19 +00:00
|
|
|
Generator *mGenerator;
|
2007-01-24 15:06:45 +00:00
|
|
|
PixmapRequest *mRequest;
|
2008-05-20 15:20:40 +00:00
|
|
|
NormalizedRect mBoundingBox;
|
|
|
|
bool mCalcBoundingBox : 1;
|
2007-01-24 15:06:45 +00:00
|
|
|
};
|
|
|
|
|
2007-01-24 18:27:54 +00:00
|
|
|
class TextPageGenerationThread : public QThread
|
|
|
|
{
|
2007-04-20 17:17:44 +00:00
|
|
|
Q_OBJECT
|
2007-01-24 18:27:54 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
public:
|
2018-09-01 08:25:57 +00:00
|
|
|
explicit TextPageGenerationThread(Generator *generator);
|
2007-01-24 18:27:54 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
void endGeneration();
|
2007-01-24 18:27:54 +00:00
|
|
|
|
2018-02-01 18:42:37 +00:00
|
|
|
void setPage(Page *page);
|
2007-04-20 17:17:44 +00:00
|
|
|
Page *page() const;
|
2007-01-24 18:27:54 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
TextPage *textPage() const;
|
2007-01-24 18:27:54 +00:00
|
|
|
|
2018-02-01 18:42:37 +00:00
|
|
|
void abortExtraction();
|
|
|
|
bool shouldAbortExtraction() const;
|
|
|
|
|
2022-03-18 21:38:36 +00:00
|
|
|
public Q_SLOTS:
|
2018-02-01 18:42:37 +00:00
|
|
|
void startGeneration();
|
2017-10-20 10:00:30 +00:00
|
|
|
|
2007-01-24 18:27:54 +00:00
|
|
|
protected:
|
2017-03-02 19:38:50 +00:00
|
|
|
void run() override;
|
2007-01-24 18:27:54 +00:00
|
|
|
|
|
|
|
private:
|
2007-01-31 18:31:19 +00:00
|
|
|
Generator *mGenerator;
|
2007-01-24 18:27:54 +00:00
|
|
|
TextPage *mTextPage;
|
2018-02-01 18:42:37 +00:00
|
|
|
TextRequest mTextRequest;
|
2007-01-24 18:27:54 +00:00
|
|
|
};
|
|
|
|
|
2007-07-07 20:35:01 +00:00
|
|
|
class FontExtractionThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
FontExtractionThread(Generator *generator, int pages);
|
|
|
|
|
|
|
|
void startExtraction(bool async);
|
2007-07-08 21:22:37 +00:00
|
|
|
void stopExtraction();
|
2007-07-07 20:35:01 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void gotFont(const Okular::FontInfo &);
|
|
|
|
void progress(int page);
|
|
|
|
|
|
|
|
protected:
|
2017-03-02 19:38:50 +00:00
|
|
|
void run() override;
|
2007-07-07 20:35:01 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Generator *mGenerator;
|
|
|
|
int mNumOfPages;
|
2007-07-08 21:22:37 +00:00
|
|
|
bool mGoOn;
|
2007-07-07 20:35:01 +00:00
|
|
|
};
|
|
|
|
|
2007-01-24 15:06:45 +00:00
|
|
|
}
|
|
|
|
|
2017-10-20 10:00:30 +00:00
|
|
|
Q_DECLARE_METATYPE(Okular::Page *)
|
|
|
|
|
2007-01-24 15:06:45 +00:00
|
|
|
#endif
|