Skip to content

Commit 4792217

Browse files
author
Chris Lord
committed
Don't expand the current area when we aren't keeping up with dehydration
If we can't keep up with tile rehydration (which occurs commonly when dragging the scroll handle to cover a large distance quickly), don't expand the current area. This reduces the amount of dehydration work required and lets us push out more frames. Signed-off-by: Chris Lord <chris.lord@collabora.com> Change-Id: I29c223985a63da815ff0a600694c8aaef7afca52
1 parent 22363c4 commit 4792217

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

browser/src/app/TilesMiddleware.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ class TileManager {
243243
// updating during scrolling
244244
private static directionalTileExpansion: number = 2;
245245
private static pausedForDehydration: boolean = false;
246+
private static shrinkCurrentId: any = null;
246247

247248
//private static _debugTime: any = {}; Reserved for future.
248249

@@ -1477,9 +1478,10 @@ class TileManager {
14771478
for (var rangeIdx = 0; rangeIdx < tileRanges.length; ++rangeIdx) {
14781479
// Expand the 'current' area to add a small buffer around the visible area that
14791480
// helps us avoid visible tile updates.
1480-
const tileRange = isCurrent
1481-
? this.expandTileRange(tileRanges[rangeIdx])
1482-
: tileRanges[rangeIdx];
1481+
const tileRange =
1482+
isCurrent && !this.shrinkCurrentId
1483+
? this.expandTileRange(tileRanges[rangeIdx])
1484+
: tileRanges[rangeIdx];
14831485

14841486
for (var j = tileRange.min.y; j <= tileRange.max.y; ++j) {
14851487
for (var i = tileRange.min.x; i <= tileRange.max.x; ++i) {
@@ -2112,8 +2114,7 @@ class TileManager {
21122114
if (app.map._docLayer.isCalc() && !app.map._docLayer._gotFirstCellCursor)
21132115
return;
21142116

2115-
// be sure canvas is initialized already, has correct size and that we aren't
2116-
// currently processing a transaction
2117+
// be sure canvas is initialized already and has the correct size.
21172118
const size: any = map.getSize();
21182119
if (size.x === 0 || size.y === 0) {
21192120
setTimeout(
@@ -2125,6 +2126,16 @@ class TileManager {
21252126
return;
21262127
}
21272128

2129+
// If an update occurs while we're paused for dehydration, we haven't been able to
2130+
// keep up with scrolling. In this case, we should stop expanding the current area
2131+
// so that it takes less time to dehydrate it.
2132+
if (this.pausedForDehydration) {
2133+
if (this.shrinkCurrentId) clearTimeout(this.shrinkCurrentId);
2134+
this.shrinkCurrentId = setTimeout(() => {
2135+
this.shrinkCurrentId = null;
2136+
}, 100);
2137+
}
2138+
21282139
if (app.file.fileBasedView) {
21292140
this.updateFileBasedView();
21302141
return;

0 commit comments

Comments
 (0)