Pre-render *one* additional page when spreadModes are enabled

Please note that we (obviously) don't want to unconditionally pre-render more than one page all the time, since that could very easily lead to overall worse performance in some documents.[1]
However, when spreadModes are enabled it does make sense to attempt to pre-render both of the pages of the next/previous spread.

---
[1] Since it may cause pre-rendering to unnecessarily compete for parsing resources, on the worker-thread, with "regular" rendering.
This commit is contained in:
Jonas Jenwald 2021-10-02 11:43:58 +02:00
parent fb6c807ba2
commit e4794a678a
2 changed files with 19 additions and 6 deletions

View file

@ -1250,10 +1250,16 @@ class BaseViewer {
const scrollAhead = this._isScrollModeHorizontal
? this.scroll.right
: this.scroll.down;
const preRenderExtra =
this._scrollMode === ScrollMode.VERTICAL &&
this._spreadMode !== SpreadMode.NONE &&
!this.isInPresentationMode;
const pageView = this.renderingQueue.getHighestPriority(
visiblePages,
this._pages,
scrollAhead
scrollAhead,
preRenderExtra
);
if (pageView) {
this._ensurePdfPageLoaded(pageView).then(() => {