mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-06 16:09:12 +00:00
when generating the page image in an internal secondary thread (started by the base generator), then also calculate the page bounding box in the thread
svn path=/trunk/KDE/kdegraphics/okular/; revision=810380
This commit is contained in:
parent
20fc951749
commit
6725e71340
|
@ -98,8 +98,8 @@ void GeneratorPrivate::pixmapGenerationFinished()
|
|||
}
|
||||
|
||||
const QImage& img = mPixmapGenerationThread->image();
|
||||
if ( !request->page()->isBoundingBoxKnown() )
|
||||
q->updatePageBoundingBox( request->page()->number(), Utils::imageBoundingBox( &img ) );
|
||||
if ( mPixmapGenerationThread->calcBoundingBox() )
|
||||
q->updatePageBoundingBox( request->page()->number(), mPixmapGenerationThread->boundingBox() );
|
||||
request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( img ) ) );
|
||||
|
||||
q->signalPixmapRequestDone( request );
|
||||
|
@ -218,7 +218,7 @@ void Generator::generatePixmap( PixmapRequest *request )
|
|||
|
||||
if ( hasFeature( Threaded ) )
|
||||
{
|
||||
d->pixmapGenerationThread()->startGeneration( request );
|
||||
d->pixmapGenerationThread()->startGeneration( request, !request->page()->isBoundingBoxKnown() );
|
||||
|
||||
/**
|
||||
* We create the text page for every page that is visible to the
|
||||
|
|
|
@ -13,17 +13,19 @@
|
|||
|
||||
#include "fontinfo.h"
|
||||
#include "generator.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
PixmapGenerationThread::PixmapGenerationThread( Generator *generator )
|
||||
: mGenerator( generator ), mRequest( 0 )
|
||||
: mGenerator( generator ), mRequest( 0 ), mCalcBoundingBox( false )
|
||||
{
|
||||
}
|
||||
|
||||
void PixmapGenerationThread::startGeneration( PixmapRequest *request )
|
||||
void PixmapGenerationThread::startGeneration( PixmapRequest *request, bool calcBoundingBox )
|
||||
{
|
||||
mRequest = request;
|
||||
mCalcBoundingBox = calcBoundingBox;
|
||||
|
||||
start( QThread::InheritPriority );
|
||||
}
|
||||
|
@ -43,12 +45,26 @@ QImage PixmapGenerationThread::image() const
|
|||
return mImage;
|
||||
}
|
||||
|
||||
bool PixmapGenerationThread::calcBoundingBox() const
|
||||
{
|
||||
return mCalcBoundingBox;
|
||||
}
|
||||
|
||||
NormalizedRect PixmapGenerationThread::boundingBox() const
|
||||
{
|
||||
return mBoundingBox;
|
||||
}
|
||||
|
||||
void PixmapGenerationThread::run()
|
||||
{
|
||||
mImage = QImage();
|
||||
|
||||
if ( mRequest )
|
||||
{
|
||||
mImage = mGenerator->image( mRequest );
|
||||
if ( mCalcBoundingBox )
|
||||
mBoundingBox = Utils::imageBoundingBox( &mImage );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#ifndef OKULAR_THREADEDGENERATOR_P_H
|
||||
#define OKULAR_THREADEDGENERATOR_P_H
|
||||
|
||||
#include "area.h"
|
||||
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtGui/QImage>
|
||||
|
@ -87,13 +89,15 @@ class PixmapGenerationThread : public QThread
|
|||
public:
|
||||
PixmapGenerationThread( Generator *generator );
|
||||
|
||||
void startGeneration( PixmapRequest *request );
|
||||
void startGeneration( PixmapRequest *request, bool calcBoundingRect );
|
||||
|
||||
void endGeneration();
|
||||
|
||||
PixmapRequest *request() const;
|
||||
|
||||
QImage image() const;
|
||||
bool calcBoundingBox() const;
|
||||
NormalizedRect boundingBox() const;
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
|
@ -102,6 +106,8 @@ class PixmapGenerationThread : public QThread
|
|||
Generator *mGenerator;
|
||||
PixmapRequest *mRequest;
|
||||
QImage mImage;
|
||||
NormalizedRect mBoundingBox;
|
||||
bool mCalcBoundingBox : 1;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue