未验证 提交 8652a547 编写于 作者: M Megan Rogge 提交者: GitHub

support setting the canvas renderer (#126068)

上级 b58db902
......@@ -532,14 +532,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const font = this._configHelper.getFont(undefined, true);
const config = this._configHelper.config;
const editorOptions = this._configurationService.getValue<IEditorOptions>('editor');
let xtermRendererType: RendererType;
if (config.gpuAcceleration === 'auto') {
// Set the builtin renderer to canvas, even when webgl is being used since it's an addon
const suggestedRendererType = this._storageService.get(SUGGESTED_RENDERER_TYPE, StorageScope.GLOBAL);
xtermRendererType = suggestedRendererType === 'dom' ? 'dom' : 'canvas';
} else {
xtermRendererType = config.gpuAcceleration === 'on' ? 'canvas' : 'dom';
}
const xterm = new Terminal({
// TODO: Replace null with undefined when https://github.com/xtermjs/xterm.js/issues/3329 is resolved
......@@ -563,7 +555,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
fastScrollModifier: 'alt',
fastScrollSensitivity: editorOptions.fastScrollSensitivity,
scrollSensitivity: editorOptions.mouseWheelScrollSensitivity,
rendererType: xtermRendererType,
rendererType: this._getBuiltInXtermRenderer(config.gpuAcceleration, this._storageService.get(SUGGESTED_RENDERER_TYPE, StorageScope.GLOBAL)),
wordSeparator: config.wordSeparators
});
this._xterm = xterm;
......@@ -1442,16 +1434,25 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._safeSetOption('macOptionClickForcesSelection', config.macOptionClickForcesSelection);
this._safeSetOption('rightClickSelectsWord', config.rightClickBehavior === 'selectWord');
this._safeSetOption('wordSeparator', config.wordSeparators);
const suggestedRendererType = this._storageService.get(SUGGESTED_RENDERER_TYPE, StorageScope.GLOBAL);
if ((config.gpuAcceleration === 'auto' && suggestedRendererType === undefined) || config.gpuAcceleration === 'on') {
this._enableWebglRenderer();
} else {
this._disposeOfWebglRenderer();
this._safeSetOption('rendererType', (config.gpuAcceleration === 'auto' && suggestedRendererType === 'dom') ? 'dom' : (config.gpuAcceleration === 'off' ? 'dom' : 'canvas'));
this._safeSetOption('rendererType', this._getBuiltInXtermRenderer(config.gpuAcceleration, suggestedRendererType));
}
this._refreshEnvironmentVariableInfoWidgetState(this._processManager.environmentVariableInfo);
}
private _getBuiltInXtermRenderer(gpuAcceleration: string, suggestedRendererType?: string): RendererType {
let rendererType: RendererType = 'canvas';
if (gpuAcceleration === 'off' || (gpuAcceleration === 'auto' && suggestedRendererType === 'dom')) {
rendererType = 'dom';
}
return rendererType;
}
private async _enableWebglRenderer(): Promise<void> {
if (!this._xterm || this._webglAddon) {
return;
......
......@@ -155,7 +155,7 @@ export interface ITerminalConfiguration {
altClickMovesCursor: boolean;
macOptionIsMeta: boolean;
macOptionClickForcesSelection: boolean;
gpuAcceleration: 'auto' | 'on' | 'off';
gpuAcceleration: 'auto' | 'on' | 'canvas' | 'off';
rightClickBehavior: 'default' | 'copyPaste' | 'paste' | 'selectWord';
cursorBlinking: boolean;
cursorStyle: string;
......
......@@ -210,11 +210,12 @@ const terminalConfiguration: IConfigurationNode = {
},
[TerminalSettingId.GpuAcceleration]: {
type: 'string',
enum: ['auto', 'on', 'off'],
enum: ['auto', 'on', 'off', 'canvas'],
markdownEnumDescriptions: [
localize('terminal.integrated.gpuAcceleration.auto', "Let VS Code detect which renderer will give the best experience."),
localize('terminal.integrated.gpuAcceleration.on', "Enable GPU acceleration within the terminal."),
localize('terminal.integrated.gpuAcceleration.off', "Disable GPU acceleration within the terminal.")
localize('terminal.integrated.gpuAcceleration.off', "Disable GPU acceleration within the terminal."),
localize('terminal.integrated.gpuAcceleration.canvas', "Use the fallback canvas renderer within the terminal. This uses a 2d context instead of webgl and may be better on some systems.")
],
default: 'auto',
description: localize('terminal.integrated.gpuAcceleration', "Controls whether the terminal will leverage the GPU to do its rendering.")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册