2007-01-24 15:06:45 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2007 Tobias Koenig <tokoe@kde.org> *
|
2017-10-03 07:29:18 +00:00
|
|
|
* Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group *
|
|
|
|
* company, info@kdab.com. Work sponsored by the *
|
|
|
|
* LiMux project of the city of Munich *
|
2007-01-24 15:06:45 +00:00
|
|
|
* *
|
|
|
|
* 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; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef OKULAR_THREADEDGENERATOR_P_H
|
|
|
|
#define OKULAR_THREADEDGENERATOR_P_H
|
|
|
|
|
2008-05-20 15:20:40 +00:00
|
|
|
#include "area.h"
|
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
#include <QtCore/QSet>
|
2007-01-24 15:06:45 +00:00
|
|
|
#include <QtCore/QThread>
|
2007-04-19 18:30:20 +00:00
|
|
|
#include <QtGui/QImage>
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
class QEventLoop;
|
2007-09-15 11:35:53 +00:00
|
|
|
class QMutex;
|
2007-04-20 17:17:44 +00:00
|
|
|
|
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();
|
2007-04-20 17:17:44 +00:00
|
|
|
|
2007-09-14 13:31:55 +00:00
|
|
|
virtual ~GeneratorPrivate();
|
|
|
|
|
|
|
|
Q_DECLARE_PUBLIC( Generator )
|
|
|
|
Generator *q_ptr;
|
2007-04-20 17:17:44 +00:00
|
|
|
|
2007-04-20 17:59:12 +00:00
|
|
|
PixmapGenerationThread* pixmapGenerationThread();
|
|
|
|
TextPageGenerationThread* textPageGenerationThread();
|
2007-04-20 17:17:44 +00:00
|
|
|
|
|
|
|
void pixmapGenerationFinished();
|
|
|
|
void textpageGenerationFinished();
|
|
|
|
|
2007-10-08 21:49:27 +00:00
|
|
|
QMutex* threadsLock();
|
|
|
|
|
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 * );
|
2008-03-15 02:15:16 +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;
|
2007-09-15 11:35:53 +00:00
|
|
|
mutable QMutex *m_mutex;
|
2007-10-08 21:49:27 +00:00
|
|
|
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;
|
2007-12-04 21:36:32 +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;
|
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:
|
|
|
|
PixmapGenerationThread( Generator *generator );
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2008-05-20 15:20:40 +00:00
|
|
|
void startGeneration( PixmapRequest *request, bool calcBoundingRect );
|
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;
|
|
|
|
QImage mImage;
|
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:
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2017-10-20 10:00:30 +00:00
|
|
|
public slots:
|
|
|
|
void startGeneration( Okular::Page *page );
|
|
|
|
|
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
|
|
|
Page *mPage;
|
|
|
|
TextPage *mTextPage;
|
|
|
|
};
|
|
|
|
|
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
|