Skip to content

Commit

Permalink
Merge pull request xtermjs#4131 from Tyriar/idleWarmup
Browse files Browse the repository at this point in the history
Perform texture atlas warm up in an idle callback
  • Loading branch information
Tyriar committed Sep 22, 2022
2 parents 1ceec0b + 7812876 commit 349acbb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,20 @@ export class WebglCharAtlas implements IDisposable {

public warmUp(): void {
if (!this._didWarmUp) {
this._doWarmUp();
(typeof requestIdleCallback !== 'function' ? requestIdleCallback : setTimeout)(() => {
this._doWarmUp();
});
this._didWarmUp = true;
}
}

private _doWarmUp(): void {
// Pre-fill with ASCII 33-126
for (let i = 33; i < 126; i++) {
const rasterizedGlyph = this._drawToCache(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT);
this._cacheMap.set(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT, rasterizedGlyph);
if (!this._cacheMap.get(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT)) {
const rasterizedGlyph = this._drawToCache(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT);
this._cacheMap.set(i, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_EXT, rasterizedGlyph);
}
}
}

Expand Down

0 comments on commit 349acbb

Please sign in to comment.