2007-01-24 15:06:45 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2007 Tobias Koenig <tokoe@kde.org> *
|
|
|
|
* *
|
|
|
|
* 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
|
|
|
|
|
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
|
|
|
|
2007-01-24 15:06:45 +00:00
|
|
|
namespace Okular {
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
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;
|
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();
|
|
|
|
|
2007-09-30 21:44:31 +00:00
|
|
|
int mId;
|
|
|
|
int mPageNumber;
|
|
|
|
int mWidth;
|
|
|
|
int mHeight;
|
|
|
|
int mPriority;
|
|
|
|
bool mAsynchronous;
|
|
|
|
Page *mPage;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
void startGeneration( PixmapRequest *request );
|
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;
|
2007-01-24 15:06:45 +00:00
|
|
|
|
2007-04-20 17:17:44 +00:00
|
|
|
protected:
|
|
|
|
virtual void run();
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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 startGeneration( Page *page );
|
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
|
|
|
|
|
|
|
protected:
|
2007-04-20 17:17:44 +00:00
|
|
|
virtual void run();
|
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:
|
|
|
|
virtual void run();
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|