Remove deprecated prop
This commit is contained in:
@@ -39,7 +39,8 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
|
|||||||
protected _charAtlas!: ITextureAtlas;
|
protected _charAtlas!: ITextureAtlas;
|
||||||
|
|
||||||
public get canvas(): HTMLCanvasElement { return this._canvas; }
|
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(
|
constructor(
|
||||||
private readonly _terminal: Terminal,
|
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 = acquireTextureAtlas(this._terminal, colorSet, this._deviceCellWidth, this._deviceCellHeight, this._deviceCharWidth, this._deviceCharHeight, this._coreBrowserService.dpr);
|
||||||
this._charAtlas.warmUp();
|
this._charAtlas.warmUp();
|
||||||
this._bitmapGenerator = new BitmapGenerator(this._charAtlas.cacheCanvas);
|
this._bitmapGenerator = new BitmapGenerator(this._charAtlas.pages[0].canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
public resize(dim: IRenderDimensions): void {
|
public resize(dim: IRenderDimensions): void {
|
||||||
@@ -372,7 +373,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
|
|||||||
this._charAtlas.hasCanvasChanged = false;
|
this._charAtlas.hasCanvasChanged = false;
|
||||||
}
|
}
|
||||||
this._ctx.drawImage(
|
this._ctx.drawImage(
|
||||||
this._bitmapGenerator?.bitmap || this._charAtlas!.cacheCanvas,
|
this._bitmapGenerator?.bitmap || this._charAtlas!.pages[0].canvas,
|
||||||
glyph.texturePosition.x,
|
glyph.texturePosition.x,
|
||||||
glyph.texturePosition.y,
|
glyph.texturePosition.y,
|
||||||
glyph.size.x,
|
glyph.size.x,
|
||||||
|
|||||||
@@ -232,10 +232,10 @@ export class GlyphRenderer extends Disposable {
|
|||||||
// a_texpage
|
// a_texpage
|
||||||
array[$i + 4] = $glyph.texturePage;
|
array[$i + 4] = $glyph.texturePage;
|
||||||
// a_texcoord
|
// 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;
|
array[$i + 6] = $glyph.texturePositionClipSpace.y;
|
||||||
// a_texsize
|
// 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;
|
array[$i + 8] = $glyph.sizeClipSpace.y;
|
||||||
} else {
|
} else {
|
||||||
// a_origin
|
// a_origin
|
||||||
@@ -331,14 +331,14 @@ export class GlyphRenderer extends Disposable {
|
|||||||
gl.uniform1iv(this._textureLocation, layerTextureUnits);
|
gl.uniform1iv(this._textureLocation, layerTextureUnits);
|
||||||
gl.activeTexture(gl.TEXTURE0 + 0);
|
gl.activeTexture(gl.TEXTURE0 + 0);
|
||||||
gl.bindTexture(gl.TEXTURE_2D, this._atlasTextures[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);
|
gl.generateMipmap(gl.TEXTURE_2D);
|
||||||
|
|
||||||
if (this._atlas.pages.length > 1) {
|
if (this._atlas.pages.length > 1) {
|
||||||
// TODO: Check if the particular texture page changed
|
// TODO: Check if the particular texture page changed
|
||||||
gl.activeTexture(gl.TEXTURE0 + 1);
|
gl.activeTexture(gl.TEXTURE0 + 1);
|
||||||
gl.bindTexture(gl.TEXTURE_2D, this._atlasTextures[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);
|
gl.generateMipmap(gl.TEXTURE_2D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,7 +360,7 @@ export class GlyphRenderer extends Disposable {
|
|||||||
gl.bindTexture(gl.TEXTURE_2D, this._atlasTextures[0]);
|
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_S, gl.CLAMP_TO_EDGE);
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, 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);
|
gl.generateMipmap(gl.TEXTURE_2D);
|
||||||
|
|
||||||
if (atlas.pages.length > 1) {
|
if (atlas.pages.length > 1) {
|
||||||
@@ -368,7 +368,7 @@ export class GlyphRenderer extends Disposable {
|
|||||||
gl.bindTexture(gl.TEXTURE_2D, this._atlasTextures[1]);
|
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_S, gl.CLAMP_TO_EDGE);
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, 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);
|
gl.generateMipmap(gl.TEXTURE_2D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get textureAtlas(): HTMLCanvasElement | undefined {
|
public get textureAtlas(): HTMLCanvasElement | undefined {
|
||||||
return this._charAtlas?.cacheCanvas;
|
return this._charAtlas?.pages[0].canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleColorChange(): void {
|
private _handleColorChange(): void {
|
||||||
@@ -261,7 +261,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
this._coreBrowserService.dpr
|
this._coreBrowserService.dpr
|
||||||
);
|
);
|
||||||
if (this._charAtlas !== atlas) {
|
if (this._charAtlas !== atlas) {
|
||||||
this._onChangeTextureAtlas.fire(atlas.cacheCanvas);
|
this._onChangeTextureAtlas.fire(atlas.pages[0].canvas);
|
||||||
}
|
}
|
||||||
this._charAtlas = atlas;
|
this._charAtlas = atlas;
|
||||||
this._charAtlas.warmUp();
|
this._charAtlas.warmUp();
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|||||||
|
|
||||||
// The texture that the atlas is drawn to
|
// The texture that the atlas is drawn to
|
||||||
private _pages: AtlasPage[] = [];
|
private _pages: AtlasPage[] = [];
|
||||||
public get pages(): HTMLCanvasElement[] { return this._pages.map(e => e.canvas); }
|
public get pages(): { canvas: HTMLCanvasElement }[] { return this._pages; }
|
||||||
|
|
||||||
public get cacheCanvas(): HTMLCanvasElement { return this._pages[0].canvas; }
|
|
||||||
|
|
||||||
private _tmpCanvas: HTMLCanvasElement;
|
private _tmpCanvas: HTMLCanvasElement;
|
||||||
// A temporary context that glyphs are drawn to before being transfered to the atlas.
|
// 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 {
|
public dispose(): void {
|
||||||
if (this.cacheCanvas.parentElement) {
|
for (const page of this.pages) {
|
||||||
this.cacheCanvas.parentElement.removeChild(this.cacheCanvas);
|
page.canvas.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -87,10 +87,7 @@ export interface IRenderer extends IDisposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ITextureAtlas extends IDisposable {
|
export interface ITextureAtlas extends IDisposable {
|
||||||
/** @deprecated */
|
readonly pages: { canvas: HTMLCanvasElement }[];
|
||||||
readonly cacheCanvas: HTMLCanvasElement;
|
|
||||||
|
|
||||||
readonly pages: HTMLCanvasElement[];
|
|
||||||
|
|
||||||
hasCanvasChanged: boolean;
|
hasCanvasChanged: boolean;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user