Skip to content

Commit

Permalink
Merge pull request #106203 from microsoft/tyriar/webgl
Browse files Browse the repository at this point in the history
Hot swap support and force redraw on resume with webgl renderer
  • Loading branch information
Tyriar committed Sep 7, 2020
2 parents 0d8cc5e + fee2d36 commit a4befc3
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 44 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
"vscode-ripgrep": "^1.8.0",
"vscode-sqlite3": "4.0.10",
"vscode-textmate": "5.2.0",
"xterm": "4.9.0-beta.24",
"xterm": "4.9.0-beta.25",
"xterm-addon-search": "0.7.0",
"xterm-addon-unicode11": "0.2.0",
"xterm-addon-webgl": "0.8.0",
"xterm-addon-webgl": "0.9.0-beta.1",
"yauzl": "^2.9.2",
"yazl": "^2.4.3"
},
Expand Down
4 changes: 2 additions & 2 deletions remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"vscode-proxy-agent": "^0.5.2",
"vscode-ripgrep": "^1.8.0",
"vscode-textmate": "5.2.0",
"xterm": "4.9.0-beta.24",
"xterm": "4.9.0-beta.25",
"xterm-addon-search": "0.7.0",
"xterm-addon-unicode11": "0.2.0",
"xterm-addon-webgl": "0.8.0",
"xterm-addon-webgl": "0.9.0-beta.1",
"yauzl": "^2.9.2",
"yazl": "^2.4.3"
},
Expand Down
4 changes: 2 additions & 2 deletions remote/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"semver-umd": "^5.5.7",
"vscode-oniguruma": "1.3.1",
"vscode-textmate": "5.2.0",
"xterm": "4.9.0-beta.24",
"xterm": "4.9.0-beta.25",
"xterm-addon-search": "0.7.0",
"xterm-addon-unicode11": "0.2.0",
"xterm-addon-webgl": "0.8.0"
"xterm-addon-webgl": "0.9.0-beta.1"
}
}
18 changes: 9 additions & 9 deletions remote/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ xterm-addon-unicode11@0.2.0:
resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.2.0.tgz#9ed0c482b353908bba27778893ca80823382737c"
integrity sha512-rjFDItPc/IDoSiEnoDFwKroNwLD/7t9vYKENjrcKVZg5tgJuuUj8D4rZtP6iVCjSB1LTLYmUs4L/EmCqIyLR/Q==

xterm-addon-webgl@0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.8.0.tgz#4bc6bb4dbfea5b0d2d7978d6c5cef922d584fb4f"
integrity sha512-dlpYPsv0C9S6v6+T/h/d/otSbdUTizMJdxvSoS34tUpMOHev6iW7Zqt5KRFqYxl4vCqpDk9Wmhb3fKL3kwX5fQ==

xterm@4.9.0-beta.24:
version "4.9.0-beta.24"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.9.0-beta.24.tgz#48f0990c6d32ad3a9bcc4fb49531d7effdaccea5"
integrity sha512-CIVxxxbBiSw1WOMkIjjivaiIC9jNgih4klfWsRGx0qiDF5nbzHuLXkPTt+yAQUu9FCyTUwECm9Pkl3gUsSaGKg==
xterm-addon-webgl@0.9.0-beta.1:
version "0.9.0-beta.1"
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.9.0-beta.1.tgz#e0a4e9b71db7ef8182064236844caf32833214c2"
integrity sha512-yyIYfehzaqaOTOTjSapA3sEcaGDIPn0xAiWyRIWyW5zwTZIo7FA+O4IzhgAT9b7ioJWLcPoHPUA0OFNHAx20vQ==

xterm@4.9.0-beta.25:
version "4.9.0-beta.25"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.9.0-beta.25.tgz#c229a144184ab7b3c3afdaff76f9d81bac58933b"
integrity sha512-NJHwuS7Qsoq/Yuobl+Au4rgol/oBNj4pGoR2R6IRnXODS5RDE4spHDofWKiUkDMlNZtPPku1W7k1kFnonDIhhg==
18 changes: 9 additions & 9 deletions remote/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ xterm-addon-unicode11@0.2.0:
resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.2.0.tgz#9ed0c482b353908bba27778893ca80823382737c"
integrity sha512-rjFDItPc/IDoSiEnoDFwKroNwLD/7t9vYKENjrcKVZg5tgJuuUj8D4rZtP6iVCjSB1LTLYmUs4L/EmCqIyLR/Q==

xterm-addon-webgl@0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.8.0.tgz#4bc6bb4dbfea5b0d2d7978d6c5cef922d584fb4f"
integrity sha512-dlpYPsv0C9S6v6+T/h/d/otSbdUTizMJdxvSoS34tUpMOHev6iW7Zqt5KRFqYxl4vCqpDk9Wmhb3fKL3kwX5fQ==

xterm@4.9.0-beta.24:
version "4.9.0-beta.24"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.9.0-beta.24.tgz#48f0990c6d32ad3a9bcc4fb49531d7effdaccea5"
integrity sha512-CIVxxxbBiSw1WOMkIjjivaiIC9jNgih4klfWsRGx0qiDF5nbzHuLXkPTt+yAQUu9FCyTUwECm9Pkl3gUsSaGKg==
xterm-addon-webgl@0.9.0-beta.1:
version "0.9.0-beta.1"
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.9.0-beta.1.tgz#e0a4e9b71db7ef8182064236844caf32833214c2"
integrity sha512-yyIYfehzaqaOTOTjSapA3sEcaGDIPn0xAiWyRIWyW5zwTZIo7FA+O4IzhgAT9b7ioJWLcPoHPUA0OFNHAx20vQ==

xterm@4.9.0-beta.25:
version "4.9.0-beta.25"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.9.0-beta.25.tgz#c229a144184ab7b3c3afdaff76f9d81bac58933b"
integrity sha512-NJHwuS7Qsoq/Yuobl+Au4rgol/oBNj4pGoR2R6IRnXODS5RDE4spHDofWKiUkDMlNZtPPku1W7k1kFnonDIhhg==

yauzl@^2.9.2:
version "2.10.0"
Expand Down
24 changes: 19 additions & 5 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { TerminalProcessManager } from 'vs/workbench/contrib/terminal/browser/te
import type { Terminal as XTermTerminal, IBuffer, ITerminalAddon } from 'xterm';
import type { SearchAddon, ISearchOptions } from 'xterm-addon-search';
import type { Unicode11Addon } from 'xterm-addon-unicode11';
import type { WebglAddon } from 'xterm-addon-webgl';
import { CommandTrackerAddon } from 'vs/workbench/contrib/terminal/browser/addons/commandTrackerAddon';
import { NavigationModeAddon } from 'vs/workbench/contrib/terminal/browser/addons/navigationModeAddon';
import { XTermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private';
Expand Down Expand Up @@ -105,6 +106,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _widgetManager: TerminalWidgetManager = this._instantiationService.createInstance(TerminalWidgetManager);
private _linkManager: TerminalLinkManager | undefined;
private _environmentInfo: { widget: EnvironmentVariableInfoWidget, disposable: IDisposable } | undefined;
private _webglAddon: WebglAddon | undefined;
private _commandTrackerAddon: CommandTrackerAddon | undefined;
private _navigationModeAddon: INavigationMode & ITerminalAddon | undefined;

Expand Down Expand Up @@ -496,9 +498,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._container.appendChild(this._wrapperElement);
xterm.open(this._xtermElement);
if (this._configHelper.config.rendererType === 'experimentalWebgl') {
this._terminalInstanceService.getXtermWebglConstructor().then(Addon => {
xterm.loadAddon(new Addon());
});
this._enableWebglRenderer();
}

if (!xterm.element || !xterm.textarea) {
Expand Down Expand Up @@ -767,7 +767,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
if (!this._xterm) {
return;
}
this._xterm.refresh(0, this._xterm.rows - 1);
this._webglAddon?.clearTextureAtlas();
// TODO: Do canvas renderer too?
}

public focus(force?: boolean): void {
Expand Down Expand Up @@ -1227,13 +1228,26 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._safeSetOption('macOptionClickForcesSelection', config.macOptionClickForcesSelection);
this._safeSetOption('rightClickSelectsWord', config.rightClickBehavior === 'selectWord');
this._safeSetOption('wordSeparator', config.wordSeparators);
if (config.rendererType !== 'experimentalWebgl') {
if (config.rendererType === 'experimentalWebgl') {
this._enableWebglRenderer();
} else {
this._webglAddon?.dispose();
this._webglAddon = undefined;
// Never set webgl as it's an addon not a rendererType
this._safeSetOption('rendererType', config.rendererType === 'auto' ? 'canvas' : config.rendererType);
}
this._refreshEnvironmentVariableInfoWidgetState(this._processManager.environmentVariableInfo);
}

private async _enableWebglRenderer(): Promise<void> {
if (!this._xterm || this._webglAddon) {
return;
}
const Addon = await this._terminalInstanceService.getXtermWebglConstructor();
this._webglAddon = new Addon();
this._xterm.loadAddon(this._webglAddon);
}

private async _updateUnicodeVersion(): Promise<void> {
if (!this._xterm) {
throw new Error('Cannot update unicode version before xterm has been initialized');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class TerminalWidgetManager implements IDisposable {
dispose: () => {
const current = this._attached.get(widget.id);
if (current === widget) {
console.log('widget dispose', widget);
this._attached.delete(widget.id);
widget.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ export class TerminalNativeContribution extends Disposable implements IWorkbench
}

private _onOsResume(): void {
const activeTab = this._terminalService.getActiveTab();
if (!activeTab) {
return;
}
activeTab.terminalInstances.forEach(instance => instance.forceRedraw());
this._terminalService.terminalInstances.forEach(instance => instance.forceRedraw());
}

private async _onOpenFileRequest(request: INativeOpenFileRequest): Promise<void> {
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10045,15 +10045,15 @@ xterm-addon-unicode11@0.2.0:
resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.2.0.tgz#9ed0c482b353908bba27778893ca80823382737c"
integrity sha512-rjFDItPc/IDoSiEnoDFwKroNwLD/7t9vYKENjrcKVZg5tgJuuUj8D4rZtP6iVCjSB1LTLYmUs4L/EmCqIyLR/Q==

xterm-addon-webgl@0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.8.0.tgz#4bc6bb4dbfea5b0d2d7978d6c5cef922d584fb4f"
integrity sha512-dlpYPsv0C9S6v6+T/h/d/otSbdUTizMJdxvSoS34tUpMOHev6iW7Zqt5KRFqYxl4vCqpDk9Wmhb3fKL3kwX5fQ==

xterm@4.9.0-beta.24:
version "4.9.0-beta.24"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.9.0-beta.24.tgz#48f0990c6d32ad3a9bcc4fb49531d7effdaccea5"
integrity sha512-CIVxxxbBiSw1WOMkIjjivaiIC9jNgih4klfWsRGx0qiDF5nbzHuLXkPTt+yAQUu9FCyTUwECm9Pkl3gUsSaGKg==
xterm-addon-webgl@0.9.0-beta.1:
version "0.9.0-beta.1"
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.9.0-beta.1.tgz#e0a4e9b71db7ef8182064236844caf32833214c2"
integrity sha512-yyIYfehzaqaOTOTjSapA3sEcaGDIPn0xAiWyRIWyW5zwTZIo7FA+O4IzhgAT9b7ioJWLcPoHPUA0OFNHAx20vQ==

xterm@4.9.0-beta.25:
version "4.9.0-beta.25"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.9.0-beta.25.tgz#c229a144184ab7b3c3afdaff76f9d81bac58933b"
integrity sha512-NJHwuS7Qsoq/Yuobl+Au4rgol/oBNj4pGoR2R6IRnXODS5RDE4spHDofWKiUkDMlNZtPPku1W7k1kFnonDIhhg==

y18n@^3.2.1:
version "3.2.1"
Expand Down

0 comments on commit a4befc3

Please sign in to comment.