Remove deprecated prop

This commit is contained in:
Daniel Imms
2022-10-28 19:12:01 -07:00
parent 6b37187b4d
commit 975d52fab9
5 changed files with 16 additions and 20 deletions
@@ -39,7 +39,8 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
protected _charAtlas!: ITextureAtlas;
public get canvas(): HTMLCanvasElement { return this._canvas; }
public get cacheCanvas(): HTMLCanvasElement { return this._charAtlas?.cacheCanvas!; }
// TODO: Support multiple pages
public get cacheCanvas(): HTMLCanvasElement { return this._charAtlas?.pages[0].canvas!; }
constructor(
private readonly _terminal: Terminal,
@@ -118,7 +119,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
}
this._charAtlas = acquireTextureAtlas(this._terminal, colorSet, this._deviceCellWidth, this._deviceCellHeight, this._deviceCharWidth, this._deviceCharHeight, this._coreBrowserService.dpr);
this._charAtlas.warmUp();
this._bitmapGenerator = new BitmapGenerator(this._charAtlas.cacheCanvas);
this._bitmapGenerator = new BitmapGenerator(this._charAtlas.pages[0].canvas);
}
public resize(dim: IRenderDimensions): void {
@@ -372,7 +373,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
this._charAtlas.hasCanvasChanged = false;
}
this._ctx.drawImage(
this._bitmapGenerator?.bitmap || this._charAtlas!.cacheCanvas,
this._bitmapGenerator?.bitmap || this._charAtlas!.pages[0].canvas,
glyph.texturePosition.x,
glyph.texturePosition.y,
glyph.size.x,
@@ -232,10 +232,10 @@ export class GlyphRenderer extends Disposable {
// a_texpage
array[$i + 4] = $glyph.texturePage;
// a_texcoord
array[$i + 5] = $glyph.texturePositionClipSpace.x + $clippedPixels / this._atlas.cacheCanvas.width;
array[$i + 5] = $glyph.texturePositionClipSpace.x + $clippedPixels / this._atlas.pages[0].canvas.width;
array[$i + 6] = $glyph.texturePositionClipSpace.y;
// a_texsize
array[$i + 7] = $glyph.sizeClipSpace.x - $clippedPixels / this._atlas.cacheCanvas.width;
array[$i + 7] = $glyph.sizeClipSpace.x - $clippedPixels / this._atlas.pages[0].canvas.width;
array[$i + 8] = $glyph.sizeClipSpace.y;
} else {
// a_origin
@@ -331,14 +331,14 @@ export class GlyphRenderer extends Disposable {
gl.uniform1iv(this._textureLocation, layerTextureUnits);
gl.activeTexture(gl.TEXTURE0 + 0);
gl.bindTexture(gl.TEXTURE_2D, this._atlasTextures[0]);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._atlas.cacheCanvas);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._atlas.pages[0].canvas);
gl.generateMipmap(gl.TEXTURE_2D);
if (this._atlas.pages.length > 1) {
// TODO: Check if the particular texture page changed
gl.activeTexture(gl.TEXTURE0 + 1);
gl.bindTexture(gl.TEXTURE_2D, this._atlasTextures[1]);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._atlas.pages[1]);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._atlas.pages[1].canvas);
gl.generateMipmap(gl.TEXTURE_2D);
}
}
@@ -360,7 +360,7 @@ export class GlyphRenderer extends Disposable {
gl.bindTexture(gl.TEXTURE_2D, this._atlasTextures[0]);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, atlas.cacheCanvas);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, atlas.pages[0].canvas);
gl.generateMipmap(gl.TEXTURE_2D);
if (atlas.pages.length > 1) {
@@ -368,7 +368,7 @@ export class GlyphRenderer extends Disposable {
gl.bindTexture(gl.TEXTURE_2D, this._atlasTextures[1]);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, atlas.pages[1]);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, atlas.pages[1].canvas);
gl.generateMipmap(gl.TEXTURE_2D);
}
}
@@ -135,7 +135,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
}
public get textureAtlas(): HTMLCanvasElement | undefined {
return this._charAtlas?.cacheCanvas;
return this._charAtlas?.pages[0].canvas;
}
private _handleColorChange(): void {
@@ -261,7 +261,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._coreBrowserService.dpr
);
if (this._charAtlas !== atlas) {
this._onChangeTextureAtlas.fire(atlas.cacheCanvas);
this._onChangeTextureAtlas.fire(atlas.pages[0].canvas);
}
this._charAtlas = atlas;
this._charAtlas.warmUp();
+3 -5
View File
@@ -57,9 +57,7 @@ export class TextureAtlas implements ITextureAtlas {
// The texture that the atlas is drawn to
private _pages: AtlasPage[] = [];
public get pages(): HTMLCanvasElement[] { return this._pages.map(e => e.canvas); }
public get cacheCanvas(): HTMLCanvasElement { return this._pages[0].canvas; }
public get pages(): { canvas: HTMLCanvasElement }[] { return this._pages; }
private _tmpCanvas: HTMLCanvasElement;
// A temporary context that glyphs are drawn to before being transfered to the atlas.
@@ -105,8 +103,8 @@ export class TextureAtlas implements ITextureAtlas {
}
public dispose(): void {
if (this.cacheCanvas.parentElement) {
this.cacheCanvas.parentElement.removeChild(this.cacheCanvas);
for (const page of this.pages) {
page.canvas.remove();
}
}
+1 -4
View File
@@ -87,10 +87,7 @@ export interface IRenderer extends IDisposable {
}
export interface ITextureAtlas extends IDisposable {
/** @deprecated */
readonly cacheCanvas: HTMLCanvasElement;
readonly pages: HTMLCanvasElement[];
readonly pages: { canvas: HTMLCanvasElement }[];
hasCanvasChanged: boolean;