mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-12 20:51:17 +00:00
Change TilesManager::tilesAt use
- The second parameter has changed to an enum - Now Page::tilesAt only returns tiles with pixmaps
This commit is contained in:
parent
66e93136f9
commit
7528fb8c88
|
@ -1104,7 +1104,7 @@ void DocumentPrivate::sendGeneratorPixmapRequest()
|
|||
if ( !r->normalizedRect().isNull() )
|
||||
{
|
||||
NormalizedRect tilesRect;
|
||||
const QList<Tile> tiles = tilesManager->tilesAt( r->normalizedRect() );
|
||||
const QList<Tile> tiles = tilesManager->tilesAt( r->normalizedRect(), TilesManager::TerminalTile );
|
||||
QList<Tile>::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd();
|
||||
while ( tIt != tEnd )
|
||||
{
|
||||
|
@ -1313,7 +1313,7 @@ void DocumentPrivate::refreshPixmaps( int pageNumber )
|
|||
break;
|
||||
}
|
||||
}
|
||||
const QList<Tile> tiles = tilesManager->tilesAt( visibleRect );
|
||||
const QList<Tile> tiles = tilesManager->tilesAt( visibleRect, TilesManager::TerminalTile );
|
||||
QList<Tile>::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd();
|
||||
while ( tIt != tEnd )
|
||||
{
|
||||
|
@ -2551,6 +2551,30 @@ void Document::requestPixmaps( const QLinkedList< PixmapRequest * > & requests,
|
|||
|
||||
request->d->mPage = d->m_pagesVector.value( request->pageNumber() );
|
||||
|
||||
if ( request->isTile() )
|
||||
{
|
||||
// Change the current request rect so that only invalid tiles are
|
||||
// requested. Also make sure the rect is tile-aligned.
|
||||
NormalizedRect tilesRect;
|
||||
const QList<Tile> tiles = request->page()->d->tilesManager()->tilesAt( request->normalizedRect(), TilesManager::TerminalTile );
|
||||
QList<Tile>::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd();
|
||||
while ( tIt != tEnd )
|
||||
{
|
||||
const Tile &tile = *tIt;
|
||||
if ( !tile.isValid() )
|
||||
{
|
||||
if ( tilesRect.isNull() )
|
||||
tilesRect = tile.rect();
|
||||
else
|
||||
tilesRect |= tile.rect();
|
||||
}
|
||||
|
||||
tIt++;
|
||||
}
|
||||
|
||||
request->setNormalizedRect( tilesRect );
|
||||
}
|
||||
|
||||
if ( !request->asynchronous() )
|
||||
request->d->mPriority = 0;
|
||||
|
||||
|
|
|
@ -992,10 +992,10 @@ bool Page::hasTilesManager() const
|
|||
return d->m_tilesManager != 0;
|
||||
}
|
||||
|
||||
QList<Tile> Page::tilesAt( const NormalizedRect &rect, bool allowEmpty ) const
|
||||
QList<Tile> Page::tilesAt( const NormalizedRect &rect ) const
|
||||
{
|
||||
if ( d->m_tilesManager )
|
||||
return d->m_tilesManager->tilesAt( rect, allowEmpty );
|
||||
return d->m_tilesManager->tilesAt( rect, TilesManager::PixmapTile );
|
||||
else
|
||||
return QList<Tile>();
|
||||
}
|
||||
|
|
|
@ -378,11 +378,11 @@ class OKULAR_EXPORT Page
|
|||
/**
|
||||
* Returns a list of all tiles intersecting with @p rect.
|
||||
*
|
||||
* @param allowEmpty If false only tiles with a non null pixmap are returned
|
||||
* The list contains only tiles with a pixmap
|
||||
*
|
||||
* @since 0.16 (KDE 4.10)
|
||||
*/
|
||||
QList<Tile> tilesAt( const NormalizedRect &rect, bool allowEmpty = true ) const;
|
||||
QList<Tile> tilesAt( const NormalizedRect &rect ) const;
|
||||
|
||||
private:
|
||||
PagePrivate* const d;
|
||||
|
|
|
@ -34,7 +34,7 @@ class TilesManager::Private
|
|||
Private();
|
||||
|
||||
bool hasPixmap( const NormalizedRect &rect, const TileNode &tile ) const;
|
||||
void tilesAt( const NormalizedRect &rect, TileNode &tile, QList<Tile> &result, bool allowEmpty );
|
||||
void tilesAt( const NormalizedRect &rect, TileNode &tile, QList<Tile> &result, TileLeaf tileLeaf );
|
||||
void setPixmap( const QPixmap *pixmap, const NormalizedRect &rect, TileNode &tile );
|
||||
|
||||
/**
|
||||
|
@ -335,20 +335,20 @@ bool TilesManager::Private::hasPixmap( const NormalizedRect &rect, const TileNod
|
|||
return true;
|
||||
}
|
||||
|
||||
QList<Tile> TilesManager::tilesAt( const NormalizedRect &rect, bool allowEmpty )
|
||||
QList<Tile> TilesManager::tilesAt( const NormalizedRect &rect, TileLeaf tileLeaf )
|
||||
{
|
||||
QList<Tile> result;
|
||||
|
||||
NormalizedRect rotatedRect = fromRotatedRect( rect, d->rotation );
|
||||
for ( int i = 0; i < 16; ++i )
|
||||
{
|
||||
d->tilesAt( rotatedRect, d->tiles[ i ], result, allowEmpty );
|
||||
d->tilesAt( rotatedRect, d->tiles[ i ], result, tileLeaf );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void TilesManager::Private::tilesAt( const NormalizedRect &rect, TileNode &tile, QList<Tile> &result, bool allowEmpty )
|
||||
void TilesManager::Private::tilesAt( const NormalizedRect &rect, TileNode &tile, QList<Tile> &result, TileLeaf tileLeaf )
|
||||
{
|
||||
if ( !tile.rect.intersects( rect ) )
|
||||
return;
|
||||
|
@ -357,7 +357,7 @@ void TilesManager::Private::tilesAt( const NormalizedRect &rect, TileNode &tile,
|
|||
// requesting huge areas unnecessarily
|
||||
splitBigTiles( tile, rect );
|
||||
|
||||
if ( ( allowEmpty && tile.nTiles == 0 ) || ( !allowEmpty && tile.pixmap ) )
|
||||
if ( ( tileLeaf == TerminalTile && tile.nTiles == 0 ) || ( tileLeaf == PixmapTile && tile.pixmap ) )
|
||||
{
|
||||
NormalizedRect rotatedRect;
|
||||
if ( rotation != Rotation0 )
|
||||
|
@ -365,7 +365,7 @@ void TilesManager::Private::tilesAt( const NormalizedRect &rect, TileNode &tile,
|
|||
else
|
||||
rotatedRect = tile.rect;
|
||||
|
||||
if ( tile.pixmap && !allowEmpty && tile.rotation != rotation )
|
||||
if ( tile.pixmap && tileLeaf == PixmapTile && tile.rotation != rotation )
|
||||
{
|
||||
// Lazy tiles rotation
|
||||
int angleToRotate = (rotation - tile.rotation)*90;
|
||||
|
@ -417,7 +417,7 @@ void TilesManager::Private::tilesAt( const NormalizedRect &rect, TileNode &tile,
|
|||
else
|
||||
{
|
||||
for ( int i = 0; i < tile.nTiles; ++i )
|
||||
tilesAt( rect, tile.tiles[ i ], result, allowEmpty );
|
||||
tilesAt( rect, tile.tiles[ i ], result, tileLeaf );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,12 @@ class TileNode
|
|||
class TilesManager
|
||||
{
|
||||
public:
|
||||
enum TileLeaf
|
||||
{
|
||||
TerminalTile, ///< Return tiles without children
|
||||
PixmapTile ///< Return only tiles with pixmap
|
||||
};
|
||||
|
||||
TilesManager( int pageNumber, int width, int height, Rotation rotation = Rotation0 );
|
||||
~TilesManager();
|
||||
|
||||
|
@ -125,9 +131,9 @@ class TilesManager
|
|||
* As to avoid requests of big areas, each traversed tile is checked
|
||||
* for its size and split if necessary.
|
||||
*
|
||||
* @param allowEmpty If false only tiles with a non null pixmap are returned
|
||||
* @param tileLeaf Indicate the type of tile to return
|
||||
*/
|
||||
QList<Tile> tilesAt( const NormalizedRect &rect, bool allowEmpty = true );
|
||||
QList<Tile> tilesAt( const NormalizedRect &rect, TileLeaf tileLeaf );
|
||||
|
||||
/**
|
||||
* The total memory consumed by the tiles manager
|
||||
|
|
|
@ -244,7 +244,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
|
|||
if ( hasTilesManager )
|
||||
{
|
||||
const Okular::NormalizedRect normalizedLimits( limitsInPixmap, scaledWidth, scaledHeight );
|
||||
const QList<Okular::Tile> tiles = page->tilesAt( normalizedLimits, false );
|
||||
const QList<Okular::Tile> tiles = page->tilesAt( normalizedLimits );
|
||||
QList<Okular::Tile>::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd();
|
||||
while ( tIt != tEnd )
|
||||
{
|
||||
|
@ -299,7 +299,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
|
|||
backImage.fill( paperColor.rgb() );
|
||||
QPainter p( &backImage );
|
||||
const Okular::NormalizedRect normalizedLimits( limitsInPixmap, scaledWidth, scaledHeight );
|
||||
const QList<Okular::Tile> tiles = page->tilesAt( normalizedLimits, false );
|
||||
const QList<Okular::Tile> tiles = page->tilesAt( normalizedLimits );
|
||||
QList<Okular::Tile>::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd();
|
||||
while ( tIt != tEnd )
|
||||
{
|
||||
|
|
|
@ -4112,24 +4112,7 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
|
|||
|
||||
if ( i->page()->hasTilesManager() )
|
||||
{
|
||||
Okular::NormalizedRect tilesRect;
|
||||
const QList<Okular::Tile> tiles = i->page()->tilesAt( expandedVisibleRect );
|
||||
QList<Okular::Tile>::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd();
|
||||
while ( tIt != tEnd )
|
||||
{
|
||||
const Okular::Tile &tile = *tIt;
|
||||
if ( !tile.isValid() )
|
||||
{
|
||||
if ( tilesRect.isNull() )
|
||||
tilesRect = tile.rect();
|
||||
else
|
||||
tilesRect |= tile.rect();
|
||||
}
|
||||
|
||||
tIt++;
|
||||
}
|
||||
|
||||
p->setNormalizedRect( tilesRect );
|
||||
p->setNormalizedRect( expandedVisibleRect );
|
||||
p->setTile( true );
|
||||
}
|
||||
else
|
||||
|
@ -4191,26 +4174,10 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
|
|||
const bool pageHasTilesManager = i->page()->hasTilesManager();
|
||||
if ( pageHasTilesManager && !preRenderRegion.isNull() )
|
||||
{
|
||||
Okular::NormalizedRect tilesRect;
|
||||
const QList<Okular::Tile> tiles = i->page()->tilesAt( preRenderRegion );
|
||||
QList<Okular::Tile>::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd();
|
||||
while ( tIt != tEnd )
|
||||
{
|
||||
const Okular::Tile &tile = *tIt;
|
||||
if ( !tile.isValid() )
|
||||
{
|
||||
if ( tilesRect.isNull() )
|
||||
tilesRect = tile.rect();
|
||||
else
|
||||
tilesRect |= tile.rect();
|
||||
}
|
||||
|
||||
tIt++;
|
||||
}
|
||||
|
||||
Okular::PixmapRequest * p = new Okular::PixmapRequest( PAGEVIEW_ID, i->pageNumber(), i->uncroppedWidth(), i->uncroppedHeight(), PAGEVIEW_PRELOAD_PRIO, true );
|
||||
requestedPixmaps.push_back( p );
|
||||
p->setNormalizedRect( tilesRect );
|
||||
|
||||
p->setNormalizedRect( preRenderRegion );
|
||||
p->setTile( true );
|
||||
}
|
||||
else if ( !pageHasTilesManager )
|
||||
|
@ -4239,26 +4206,10 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
|
|||
const bool pageHasTilesManager = i->page()->hasTilesManager();
|
||||
if ( pageHasTilesManager && !preRenderRegion.isNull() )
|
||||
{
|
||||
Okular::NormalizedRect tilesRect;
|
||||
const QList<Okular::Tile> tiles = i->page()->tilesAt( preRenderRegion );
|
||||
QList<Okular::Tile>::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd();
|
||||
while ( tIt != tEnd )
|
||||
{
|
||||
const Okular::Tile &tile = *tIt;
|
||||
if ( !tile.isValid() )
|
||||
{
|
||||
if ( tilesRect.isNull() )
|
||||
tilesRect = tile.rect();
|
||||
else
|
||||
tilesRect |= tile.rect();
|
||||
}
|
||||
|
||||
tIt++;
|
||||
}
|
||||
|
||||
Okular::PixmapRequest * p = new Okular::PixmapRequest( PAGEVIEW_ID, i->pageNumber(), i->uncroppedWidth(), i->uncroppedHeight(), PAGEVIEW_PRELOAD_PRIO, true );
|
||||
requestedPixmaps.push_back( p );
|
||||
p->setNormalizedRect( tilesRect );
|
||||
|
||||
p->setNormalizedRect( preRenderRegion );
|
||||
p->setTile( true );
|
||||
}
|
||||
else if ( !pageHasTilesManager )
|
||||
|
|
Loading…
Reference in a new issue