Move scaledCharWidth/Height into base render layer

This commit is contained in:
Daniel Imms
2017-08-31 22:48:08 -07:00
parent 6588e9e01b
commit 9323833fcc
5 changed files with 19 additions and 30 deletions
+4
View File
@@ -5,6 +5,8 @@ import { COLORS } from './Color';
export abstract class BaseRenderLayer implements IRenderLayer {
protected _canvas: HTMLCanvasElement;
protected _ctx: CanvasRenderingContext2D;
protected scaledCharWidth: number;
protected scaledCharHeight: number;
// TODO: This will apply to all terminals, should it be per-terminal?
protected static _charAtlas: ImageBitmap;
@@ -26,6 +28,8 @@ export abstract class BaseRenderLayer implements IRenderLayer {
}
public resize(terminal: ITerminal, canvasWidth: number, canvasHeight: number, charSizeChanged: boolean): void {
this.scaledCharWidth = Math.ceil(terminal.charMeasure.width) * window.devicePixelRatio;
this.scaledCharHeight = Math.ceil(terminal.charMeasure.height) * window.devicePixelRatio;
this._canvas.width = canvasWidth * window.devicePixelRatio;
this._canvas.height = canvasHeight * window.devicePixelRatio;
this._canvas.style.width = `${canvasWidth}px`;