Do not evict visible tiles

Also avoid trying to evict more tiles if the tiles manager is empty (all
tiles were previously removed)
remotes/origin/KDE/4.10
Mailson Menezes 14 years ago
parent 3c71dbbcf3
commit 1bfe8610c9
  1. 2
      core/document.cpp
  2. 17
      core/tilesmanager.cpp
  3. 11
      core/tilesmanager_p.h
  4. 10
      ui/pageview.cpp

@ -260,7 +260,7 @@ void DocumentPrivate::cleanupPixmapMemory( qulonglong memoryToFree )
AllocatedPixmap * p = *pIt;
TilesManager *tilesManager = m_pagesVector.at( p->page )->tilesManager( p->id );
if ( tilesManager )
if ( tilesManager && tilesManager->totalMemory() > 0 )
{
tilesManager->cleanupPixmapMemory( memoryToFree );
m_allocatedPixmapsTotalMemory -= p->memory;

@ -64,6 +64,7 @@ class TilesManager::Private
int height;
long totalPixels;
Rotation rotation;
NormalizedRect visibleRect;
QList<Tile*> rankedTiles;
QSize tileSize;
@ -166,6 +167,19 @@ void TilesManager::Private::markDirty( Tile &tile )
}
}
void TilesManager::setVisibleRect( const NormalizedRect &rect )
{
if ( d->visibleRect == rect )
return;
d->visibleRect = rect;
}
NormalizedRect TilesManager::visibleRect() const
{
return d->visibleRect;
}
void TilesManager::setPixmap( const QPixmap *pixmap, const NormalizedRect &rect )
{
for ( int i = 0; i < 16; ++i )
@ -385,6 +399,9 @@ void TilesManager::cleanupPixmapMemory( qulonglong numberOfBytes )
if ( !tile->pixmap )
continue;
if ( tile->rect.intersects( d->visibleRect ) )
continue;
long pixels = tile->pixmap->width()*tile->pixmap->height();
d->totalPixels -= pixels;
if ( numberOfBytes < 4*pixels )

@ -109,7 +109,6 @@ class OKULAR_EXPORT TilesManager
*/
void cleanupPixmapMemory( qulonglong numberOfBytes = 1 );
/**
* Inform the new width of the page and mark all tiles to repaint
*/
@ -124,6 +123,16 @@ class OKULAR_EXPORT TilesManager
void setRotation( Rotation rotation );
Rotation rotation() const;
/**
* Sets the visible area of the page
*/
void setVisibleRect( const NormalizedRect &rect );
/**
* Returns the visible area of the page
*/
NormalizedRect visibleRect() const;
/**
* Returns a rotated NormalizedRect given a @p rotation
*/

@ -3989,7 +3989,12 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
// if the item doesn't intersect the viewport, skip it
QRect intersectionRect = viewportRect.intersect( i->croppedGeometry() );
if ( intersectionRect.isEmpty() )
{
Okular::TilesManager *tilesManager = i->page()->tilesManager( PAGEVIEW_ID );
if ( tilesManager )
tilesManager->setVisibleRect( Okular::NormalizedRect() );
continue;
}
// add the item to the 'visible list'
d->visibleItems.push_back( i );
@ -4001,6 +4006,10 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
#endif
visibleRect = vItem->rect;
Okular::TilesManager *tilesManager = i->page()->tilesManager( PAGEVIEW_ID );
if ( tilesManager )
tilesManager->setVisibleRect( vItem->rect );
Okular::NormalizedRect expandedVisibleRect = vItem->rect;
if ( Okular::Settings::memoryLevel() != Okular::Settings::EnumMemoryLevel::Low )
{
@ -4021,7 +4030,6 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
PAGEVIEW_ID, i->pageNumber(), i->uncroppedWidth(), i->uncroppedHeight(), PAGEVIEW_PRIO, true );
requestedPixmaps.push_back( p );
Okular::TilesManager *tilesManager = i->page()->tilesManager( PAGEVIEW_ID );
if ( tilesManager )
{
Okular::NormalizedRect tilesRect;

Loading…
Cancel
Save