diff --git a/core/document.cpp b/core/document.cpp --- a/core/document.cpp +++ b/core/document.cpp @@ -1309,7 +1309,7 @@ delete r; } // If the requested area is above 8000000 pixels, switch on the tile manager - else if ( !tilesManager && m_generator->hasFeature( Generator::TiledRendering ) && (long)r->width() * (long)r->height() > 8000000L ) + else if ( !tilesManager && requestWillCreateTileManager( r->width(), r->height() ) ) { // if the image is too big. start using tiles qCDebug(OkularCoreDebug).nospace() << "Start using tiles on page " << r->pageNumber() @@ -2131,6 +2131,11 @@ m_pagesVector[i]->setSourceReferences( refRects.at(i) ); } +bool DocumentPrivate::requestWillCreateTileManager( int width, int height ) const +{ + return m_generator->hasFeature( Generator::TiledRendering ) && (long)width * (long)height > 8000000L; +} + Document::Document( QWidget *widget ) : QObject( nullptr ), d( new DocumentPrivate( this ) ) { @@ -3155,17 +3160,17 @@ request->d->mPage = d->m_pagesVector.value( request->pageNumber() ); - if ( request->isTile() ) + if ( request->isTile() && request->d->tilesManager() ) { - // Change the current request rect so that only invalid tiles are + // Change the current request rect so that only tiles we really need are // requested. Also make sure the rect is tile-aligned. NormalizedRect tilesRect; const QList tiles = request->d->tilesManager()->tilesAt( request->normalizedRect(), TilesManager::TerminalTile ); QList::const_iterator tIt = tiles.constBegin(), tEnd = tiles.constEnd(); while ( tIt != tEnd ) { const Tile &tile = *tIt; - if ( !tile.isValid() ) + if ( !tile.isValid() ) // no pixmap or pixmap is dirty { if ( tilesRect.isNull() ) tilesRect = tile.rect(); diff --git a/core/document_p.h b/core/document_p.h --- a/core/document_p.h +++ b/core/document_p.h @@ -190,6 +190,10 @@ // For sync files void loadSyncFile( const QString & filePath ); + static DocumentPrivate *get( Document *doc ) { return doc->d; } + + OKULARCORE_EXPORT bool requestWillCreateTileManager( int width, int height ) const; + // member variables Document *m_parent; QPointer m_widget; diff --git a/core/generator.cpp b/core/generator.cpp --- a/core/generator.cpp +++ b/core/generator.cpp @@ -715,7 +715,7 @@ .arg( req.height() ) .arg( req.priority() ) .arg( req.pageNumber() ); - str << qPrintable( s ); + str << qPrintable( s ) << req.normalizedRect(); return str; } diff --git a/ui/pageview.cpp b/ui/pageview.cpp --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -1821,6 +1821,7 @@ if ( d->items.isEmpty() ) { resizeContentArea( e->size() ); + d->delayResizeEventTimer->start( 200 ); return; } @@ -4615,6 +4616,10 @@ if ( d->blockPixmapsRequest || d->viewportMoveActive ) return; + // if we are in the middle of a resize storm, exit, the timer will call us back in a moment + if ( d->delayResizeEventTimer->isActive() ) + return; + // precalc view limits for intersecting with page coords inside the loop const bool isEvent = newValue != -1 && !d->blockViewport; const QRect viewportRect( horizontalScrollBar()->value(), @@ -4683,7 +4688,10 @@ #endif Okular::NormalizedRect expandedVisibleRect = vItem->rect; - if ( i->page()->hasTilesManager( this ) && Okular::Settings::memoryLevel() != Okular::Settings::EnumMemoryLevel::Low ) + Okular::DocumentPrivate *docPriv = Okular::DocumentPrivate::get( d->document ); + const bool requestWillCreateTileManager = docPriv->requestWillCreateTileManager( i->uncroppedWidth(), i->uncroppedHeight() ); + if ( Okular::Settings::memoryLevel() != Okular::Settings::EnumMemoryLevel::Low && + ( i->page()->hasTilesManager( this ) || requestWillCreateTileManager ) ) { double rectMargin = pixelsToExpand/(double)i->uncroppedHeight(); expandedVisibleRect.left = qMax( 0.0, vItem->rect.left - rectMargin ); @@ -4701,7 +4709,7 @@ Okular::PixmapRequest * p = new Okular::PixmapRequest( this, i->pageNumber(), i->uncroppedWidth(), i->uncroppedHeight(), PAGEVIEW_PRIO, Okular::PixmapRequest::Asynchronous ); requestedPixmaps.push_back( p ); - if ( i->page()->hasTilesManager( this ) ) + if ( i->page()->hasTilesManager( this ) || requestWillCreateTileManager ) { p->setNormalizedRect( expandedVisibleRect ); p->setTile( true );