Skip to content

Commit 1e1ccba

Browse files
committed
Use MutableDisposable in BaseRenderLayer
1 parent 55c5a85 commit 1e1ccba

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

addons/xterm-addon-canvas/src/BaseRenderLayer.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
* @license MIT
44
*/
55

6+
import { ReadonlyColorSet } from 'browser/Types';
7+
import { CellColorResolver } from 'browser/renderer/shared/CellColorResolver';
68
import { acquireTextureAtlas } from 'browser/renderer/shared/CharAtlasCache';
79
import { TEXT_BASELINE } from 'browser/renderer/shared/Constants';
810
import { tryDrawCustomChar } from 'browser/renderer/shared/CustomGlyphs';
911
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
10-
import { IRasterizedGlyph, IRenderDimensions, ISelectionRenderModel, ITextureAtlas } from 'browser/renderer/shared/Types';
1112
import { createSelectionRenderModel } from 'browser/renderer/shared/SelectionRenderModel';
13+
import { IRasterizedGlyph, IRenderDimensions, ISelectionRenderModel, ITextureAtlas } from 'browser/renderer/shared/Types';
1214
import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
13-
import { ReadonlyColorSet } from 'browser/Types';
15+
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
16+
import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
17+
import { isSafari } from 'common/Platform';
18+
import { ICellData } from 'common/Types';
1419
import { CellData } from 'common/buffer/CellData';
1520
import { WHITESPACE_CELL_CODE } from 'common/buffer/Constants';
1621
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
17-
import { ICellData, IDisposable } from 'common/Types';
1822
import { Terminal } from 'xterm';
1923
import { IRenderLayer } from './Types';
20-
import { CellColorResolver } from 'browser/renderer/shared/CellColorResolver';
21-
import { Disposable, toDisposable } from 'common/Lifecycle';
22-
import { isSafari } from 'common/Platform';
23-
import { EventEmitter, forwardEvent } from 'common/EventEmitter';
2424

2525
export abstract class BaseRenderLayer extends Disposable implements IRenderLayer {
2626
private _canvas: HTMLCanvasElement;
@@ -37,7 +37,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
3737
private _bitmapGenerator: (BitmapGenerator | undefined)[] = [];
3838

3939
protected _charAtlas!: ITextureAtlas;
40-
private _charAtlasDisposable?: IDisposable;
40+
protected _charAtlasDisposable = this.register(new MutableDisposable());
4141

4242
public get canvas(): HTMLCanvasElement { return this._canvas; }
4343
public get cacheCanvas(): HTMLCanvasElement { return this._charAtlas?.pages[0].canvas!; }
@@ -122,9 +122,8 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
122122
if (this._deviceCharWidth <= 0 && this._deviceCharHeight <= 0) {
123123
return;
124124
}
125-
this._charAtlasDisposable?.dispose();
126125
this._charAtlas = acquireTextureAtlas(this._terminal, this._optionsService.rawOptions, colorSet, this._deviceCellWidth, this._deviceCellHeight, this._deviceCharWidth, this._deviceCharHeight, this._coreBrowserService.dpr);
127-
this._charAtlasDisposable = forwardEvent(this._charAtlas.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas);
126+
this._charAtlasDisposable.value = forwardEvent(this._charAtlas.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas);
128127
this._charAtlas.warmUp();
129128
for (let i = 0; i < this._charAtlas.pages.length; i++) {
130129
this._bitmapGenerator[i] = new BitmapGenerator(this._charAtlas.pages[i].canvas);

0 commit comments

Comments
 (0)