Merge pull request #4137 from Tyriar/willReadFrequently

Optimize contexts for reading frequently
This commit is contained in:
Daniel Imms
2022-09-24 10:40:39 -07:00
committed by GitHub
2 changed files with 7 additions and 2 deletions
@@ -110,7 +110,10 @@ export class WebglCharAtlas implements IDisposable {
this._tmpCanvas = document.createElement('canvas');
this._tmpCanvas.width = this._config.scaledCellWidth * 4 + TMP_CANVAS_GLYPH_PADDING * 2;
this._tmpCanvas.height = this._config.scaledCellHeight + TMP_CANVAS_GLYPH_PADDING * 2;
this._tmpCtx = throwIfFalsy(this._tmpCanvas.getContext('2d', { alpha: this._config.allowTransparency }));
this._tmpCtx = throwIfFalsy(this._tmpCanvas.getContext('2d', {
alpha: this._config.allowTransparency,
willReadFrequently: true
}));
}
public dispose(): void {
+3 -1
View File
@@ -89,7 +89,9 @@ export class ColorManager implements IColorManager {
const canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
const ctx = canvas.getContext('2d');
const ctx = canvas.getContext('2d', {
willReadFrequently: true
});
if (!ctx) {
throw new Error('Could not get rendering context');
}