Skip to content

Commit 349acbb

Browse files
authored
Merge pull request #4131 from Tyriar/idleWarmup
Perform texture atlas warm up in an idle callback
2 parents 1ceec0b + 7812876 commit 349acbb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,20 @@ export class WebglCharAtlas implements IDisposable {
121121

122122
public warmUp(): void {
123123
if (!this._didWarmUp) {
124-
this._doWarmUp();
124+
(typeof requestIdleCallback !== 'function' ? requestIdleCallback : setTimeout)(() => {
125+
this._doWarmUp();
126+
});
125127
this._didWarmUp = true;
126128
}
127129
}
128130

129131
private _doWarmUp(): void {
130132
// Pre-fill with ASCII 33-126
131133
for (let i = 33; i < 126; i++) {
132-
const rasterizedGlyph = this._drawToCache(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT);
133-
this._cacheMap.set(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT, rasterizedGlyph);
134+
if (!this._cacheMap.get(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT)) {
135+
const rasterizedGlyph = this._drawToCache(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT);
136+
this._cacheMap.set(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT, rasterizedGlyph);
137+
}
134138
}
135139
}
136140

0 commit comments

Comments
 (0)