Skip to content

Commit 3ad68c3

Browse files
authored
Merge pull request microsoft#84440 from microsoft/tyriar/webgl2
Experimental WebGL terminal renderer
2 parents 8b57f40 + 5f471ce commit 3ad68c3

15 files changed

Lines changed: 59 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"xterm": "4.3.0-beta17",
5757
"xterm-addon-search": "0.4.0-beta4",
5858
"xterm-addon-web-links": "0.2.1",
59+
"xterm-addon-webgl": "0.4.0-beta6",
5960
"yauzl": "^2.9.2",
6061
"yazl": "^2.4.3"
6162
},

remote/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"xterm": "4.3.0-beta17",
2424
"xterm-addon-search": "0.4.0-beta4",
2525
"xterm-addon-web-links": "0.2.1",
26+
"xterm-addon-webgl": "0.4.0-beta6",
2627
"yauzl": "^2.9.2",
2728
"yazl": "^2.4.3"
2829
},

remote/web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"vscode-textmate": "^4.3.0",
88
"xterm": "4.3.0-beta17",
99
"xterm-addon-search": "0.4.0-beta4",
10-
"xterm-addon-web-links": "0.2.1"
10+
"xterm-addon-web-links": "0.2.1",
11+
"xterm-addon-webgl": "0.4.0-beta6"
1112
}
1213
}

remote/web/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ xterm-addon-web-links@0.2.1:
4141
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.2.1.tgz#6d1f2ce613e09870badf17615e7a1170a31542b2"
4242
integrity sha512-2KnHtiq0IG7hfwv3jw2/jQeH1RBk2d5CH4zvgwQe00rLofSJqSfgnJ7gwowxxpGHrpbPr6Lv4AmH/joaNw2+HQ==
4343

44+
xterm-addon-webgl@0.4.0-beta6:
45+
version "0.4.0-beta6"
46+
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.4.0-beta6.tgz#23d152a0467d8b1f96ab3da7ac9a49bfa0b08c98"
47+
integrity sha512-gtM8XtRyrNFCtxHBIU3pqTlBeAi5VOoymJAXKQQ7RsHEVJX79OTk1dQ9Q6Ow14+REGwQU/zFECV050jbLTfvrQ==
48+
4449
xterm@4.3.0-beta17:
4550
version "4.3.0-beta17"
4651
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.3.0-beta17.tgz#c038cc00cb5be33d2a5f083255c329d9ed186565"

remote/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,11 @@ xterm-addon-web-links@0.2.1:
428428
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.2.1.tgz#6d1f2ce613e09870badf17615e7a1170a31542b2"
429429
integrity sha512-2KnHtiq0IG7hfwv3jw2/jQeH1RBk2d5CH4zvgwQe00rLofSJqSfgnJ7gwowxxpGHrpbPr6Lv4AmH/joaNw2+HQ==
430430

431+
xterm-addon-webgl@0.4.0-beta6:
432+
version "0.4.0-beta6"
433+
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.4.0-beta6.tgz#23d152a0467d8b1f96ab3da7ac9a49bfa0b08c98"
434+
integrity sha512-gtM8XtRyrNFCtxHBIU3pqTlBeAi5VOoymJAXKQQ7RsHEVJX79OTk1dQ9Q6Ow14+REGwQU/zFECV050jbLTfvrQ==
435+
431436
xterm@4.3.0-beta17:
432437
version "4.3.0-beta17"
433438
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.3.0-beta17.tgz#c038cc00cb5be33d2a5f083255c329d9ed186565"

src/vs/code/browser/workbench/workbench-dev.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
'xterm': `${window.location.origin}/static/remote/web/node_modules/xterm/lib/xterm.js`,
3333
'xterm-addon-search': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
3434
'xterm-addon-web-links': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
35+
'xterm-addon-webgl': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`,
3536
'semver-umd': `${window.location.origin}/static/remote/web/node_modules/semver-umd/lib/semver-umd.js`,
3637
}
3738
};

src/vs/code/browser/workbench/workbench.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'xterm': `${window.location.origin}/static/node_modules/xterm/lib/xterm.js`,
3737
'xterm-addon-search': `${window.location.origin}/static/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
3838
'xterm-addon-web-links': `${window.location.origin}/static/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
39+
'xterm-addon-webgl': `${window.location.origin}/static/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`,
3940
'semver-umd': `${window.location.origin}/static/node_modules/semver-umd/lib/semver-umd.js`,
4041
}
4142
};

src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,12 @@ configurationRegistry.registerConfiguration({
209209
},
210210
'terminal.integrated.rendererType': {
211211
type: 'string',
212-
enum: ['auto', 'canvas', 'dom'],
212+
enum: ['auto', 'canvas', 'dom', 'experimentalWebgl'],
213213
enumDescriptions: [
214214
nls.localize('terminal.integrated.rendererType.auto', "Let VS Code guess which renderer to use."),
215-
nls.localize('terminal.integrated.rendererType.canvas', "Use the standard GPU/canvas-based renderer"),
216-
nls.localize('terminal.integrated.rendererType.dom', "Use the fallback DOM-based renderer.")
215+
nls.localize('terminal.integrated.rendererType.canvas', "Use the standard GPU/canvas-based renderer."),
216+
nls.localize('terminal.integrated.rendererType.dom', "Use the fallback DOM-based renderer."),
217+
nls.localize('terminal.integrated.rendererType.experimentalWebgl', "Use the experimental webgl-based renderer. Note that this has some [known issues](https://github.com/xtermjs/xterm.js/issues?q=is%3Aopen+is%3Aissue+label%3Aarea%2Faddon%2Fwebgl) and this will only be enabled for new terminals (not hot swappable like the other renderers).")
217218
],
218219
default: 'auto',
219220
description: nls.localize('terminal.integrated.rendererType', "Controls how the terminal is rendered.")

src/vs/workbench/contrib/terminal/browser/terminal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Terminal as XTermTerminal } from 'xterm';
77
import { WebLinksAddon as XTermWebLinksAddon } from 'xterm-addon-web-links';
88
import { SearchAddon as XTermSearchAddon } from 'xterm-addon-search';
9+
import { WebglAddon as XTermWebglAddon } from 'xterm-addon-webgl';
910
import { IWindowsShellHelper, ITerminalConfigHelper, ITerminalChildProcess, IShellLaunchConfig, IDefaultShellAndArgsRequest, ISpawnExtHostProcessRequest, IStartExtensionTerminalRequest, IAvailableShellsRequest, ITerminalProcessExtHostProxy, ICommandTracker, INavigationMode, TitleEventSource, ITerminalDimensions } from 'vs/workbench/contrib/terminal/common/terminal';
1011
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
1112
import { IProcessEnvironment, Platform } from 'vs/base/common/platform';
@@ -31,6 +32,7 @@ export interface ITerminalInstanceService {
3132
getXtermConstructor(): Promise<typeof XTermTerminal>;
3233
getXtermWebLinksConstructor(): Promise<typeof XTermWebLinksAddon>;
3334
getXtermSearchConstructor(): Promise<typeof XTermSearchAddon>;
35+
getXtermWebglConstructor(): Promise<typeof XTermWebglAddon>;
3436
createWindowsShellHelper(shellProcessId: number, instance: ITerminalInstance, xterm: XTermTerminal): IWindowsShellHelper;
3537
createTerminalProcess(shellLaunchConfig: IShellLaunchConfig, cwd: string, cols: number, rows: number, env: IProcessEnvironment, windowsEnableConpty: boolean): ITerminalChildProcess;
3638

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
471471
fastScrollModifier: 'alt',
472472
fastScrollSensitivity: editorOptions.fastScrollSensitivity,
473473
scrollSensitivity: editorOptions.mouseWheelScrollSensitivity,
474-
rendererType: config.rendererType === 'auto' ? 'canvas' : config.rendererType
474+
rendererType: config.rendererType === 'auto' || config.rendererType === 'experimentalWebgl' ? 'canvas' : config.rendererType
475475
});
476476
this._xterm = xterm;
477477
this._xtermCore = (xterm as any)._core as XTermCore;
@@ -568,6 +568,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
568568
this._wrapperElement.appendChild(this._xtermElement);
569569
this._container.appendChild(this._wrapperElement);
570570
xterm.open(this._xtermElement);
571+
if (this._configHelper.config.rendererType === 'experimentalWebgl') {
572+
this._terminalInstanceService.getXtermWebglConstructor().then(Addon => {
573+
xterm.loadAddon(new Addon());
574+
});
575+
}
571576

572577
if (!xterm.element || !xterm.textarea) {
573578
throw new Error('xterm elements not set after open');
@@ -1217,7 +1222,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
12171222
this._safeSetOption('macOptionIsMeta', config.macOptionIsMeta);
12181223
this._safeSetOption('macOptionClickForcesSelection', config.macOptionClickForcesSelection);
12191224
this._safeSetOption('rightClickSelectsWord', config.rightClickBehavior === 'selectWord');
1220-
this._safeSetOption('rendererType', config.rendererType === 'auto' ? 'canvas' : config.rendererType);
1225+
if (config.rendererType !== 'experimentalWebgl') {
1226+
// Never set webgl as it's an addon not a rendererType
1227+
this._safeSetOption('rendererType', config.rendererType === 'auto' ? 'canvas' : config.rendererType);
1228+
}
12211229

12221230
const editorOptions = this._configurationService.getValue<IEditorOptions>('editor');
12231231
this._safeSetOption('fastScrollSensitivity', editorOptions.fastScrollSensitivity);

0 commit comments

Comments
 (0)