Change rendererType to gpuAcceleration

Fixes #106202
This commit is contained in:
Daniel Imms 2021-03-29 14:15:45 -07:00
parent 31fd94b660
commit f02e4853c3
No known key found for this signature in database
GPG key ID: D12BE8272D6284CC
5 changed files with 20 additions and 20 deletions

View file

@ -18,7 +18,7 @@ import { assertNoRpc } from '../utils';
// Disable exit alerts as tests may trigger then and we're not testing the notifications
await config.update('showExitAlert', false, ConfigurationTarget.Global);
// Canvas may cause problems when running in a container
await config.update('rendererType', 'dom', ConfigurationTarget.Global);
await config.update('gpuAcceleration', 'off', ConfigurationTarget.Global);
// Disable env var relaunch for tests to prevent terminals relaunching themselves
await config.update('environmentChangesRelaunch', false, ConfigurationTarget.Global);
});

View file

@ -139,7 +139,7 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
this._lastFontMeasurement.charHeight = Math.ceil(rect.height);
// Char width is calculated differently for DOM and the other renderer types. Refer to
// how each renderer updates their dimensions in xterm.js
if (this.config.rendererType === 'dom') {
if (this.config.gpuAcceleration === 'off') {
this._lastFontMeasurement.charWidth = rect.width;
} else {
const scaledCharWidth = Math.floor(rect.width * window.devicePixelRatio);

View file

@ -270,7 +270,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
if (e.affectsConfiguration('editor.accessibilitySupport')) {
this.updateAccessibilitySupport();
}
if (e.affectsConfiguration('terminal.integrated.rendererType')) {
if (e.affectsConfiguration('terminal.integrated.gpuAcceleration')) {
this._storageService.remove(SUGGESTED_RENDERER_TYPE, StorageScope.GLOBAL);
}
}));
@ -420,12 +420,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const config = this._configHelper.config;
const editorOptions = this._configurationService.getValue<IEditorOptions>('editor');
let xtermRendererType: RendererType;
if (config.rendererType === 'auto') {
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.rendererType === 'experimentalWebgl' ? 'canvas' : config.rendererType;
xtermRendererType = config.gpuAcceleration === 'on' ? 'canvas' : 'dom';
}
const xterm = new Terminal({
@ -554,7 +554,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
xterm.open(this._xtermElement);
const suggestedRendererType = this._storageService.get(SUGGESTED_RENDERER_TYPE, StorageScope.GLOBAL);
if (this._configHelper.config.rendererType === 'auto' && (suggestedRendererType === 'auto' || suggestedRendererType === undefined) || this._configHelper.config.rendererType === 'experimentalWebgl') {
if (this._configHelper.config.gpuAcceleration === 'auto' && (suggestedRendererType === 'auto' || suggestedRendererType === undefined)
|| this._configHelper.config.gpuAcceleration === 'on') {
this._enableWebglRenderer();
}
@ -703,14 +704,14 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const medianTime = frameTimes.sort((a, b) => a - b)[Math.floor(frameTimes.length / 2)];
if (medianTime > SLOW_CANVAS_RENDER_THRESHOLD) {
if (this._configHelper.config.rendererType === 'auto') {
if (this._configHelper.config.gpuAcceleration === 'auto') {
this._storageService.store(SUGGESTED_RENDERER_TYPE, 'dom', StorageScope.GLOBAL, StorageTarget.MACHINE);
this.updateConfig();
} else {
const promptChoices: IPromptChoice[] = [
{
label: nls.localize('yes', "Yes"),
run: () => this._configurationService.updateValue('terminal.integrated.rendererType', 'dom', ConfigurationTarget.USER)
run: () => this._configurationService.updateValue('terminal.integrated.gpuAcceleration', 'off', ConfigurationTarget.USER)
} as IPromptChoice,
{
label: nls.localize('no', "No"),
@ -724,7 +725,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
];
this._notificationService.prompt(
Severity.Warning,
nls.localize('terminal.slowRendering', 'The standard renderer for the integrated terminal appears to be slow on your computer. Would you like to switch to the alternative DOM-based renderer which may improve performance? [Read more about terminal settings](https://code.visualstudio.com/docs/editor/integrated-terminal#_changing-how-the-terminal-is-rendered).'),
nls.localize('terminal.slowRendering', 'Terminal GPU acceleration appears to be slow on your computer. Would you like to switch to disable it which may improve performance? [Read more about terminal settings](https://code.visualstudio.com/docs/editor/integrated-terminal#_changing-how-the-terminal-is-rendered).'),
promptChoices
);
}
@ -1284,11 +1285,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._safeSetOption('rightClickSelectsWord', config.rightClickBehavior === 'selectWord');
this._safeSetOption('wordSeparator', config.wordSeparators);
const suggestedRendererType = this._storageService.get(SUGGESTED_RENDERER_TYPE, StorageScope.GLOBAL);
if ((config.rendererType === 'auto' && suggestedRendererType === undefined) || config.rendererType === 'experimentalWebgl') {
if ((config.gpuAcceleration === 'auto' && suggestedRendererType === undefined) || config.gpuAcceleration === 'on') {
this._enableWebglRenderer();
} else {
this._disposeOfWebglRenderer();
this._safeSetOption('rendererType', (config.rendererType === 'auto' && suggestedRendererType === 'dom') ? 'dom' : (config.rendererType === 'dom' ? 'dom' : 'canvas'));
this._safeSetOption('rendererType', (config.gpuAcceleration === 'auto' && suggestedRendererType === 'dom') ? 'dom' : (config.gpuAcceleration === 'off' ? 'dom' : 'canvas'));
}
this._refreshEnvironmentVariableInfoWidgetState(this._processManager.environmentVariableInfo);
}
@ -1306,7 +1307,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._logService.warn(`Webgl could not be loaded. Falling back to the canvas renderer type.`, e);
const neverMeasureRenderTime = this._storageService.getBoolean(NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, StorageScope.GLOBAL, false);
// if it's already set to dom, no need to measure render time
if (!neverMeasureRenderTime && this._configHelper.config.rendererType !== 'dom') {
if (!neverMeasureRenderTime && this._configHelper.config.gpuAcceleration !== 'off') {
this._measureRenderTime();
}
this._safeSetOption('rendererType', 'canvas');

View file

@ -106,7 +106,7 @@ export interface ITerminalConfiguration {
altClickMovesCursor: boolean;
macOptionIsMeta: boolean;
macOptionClickForcesSelection: boolean;
rendererType: 'auto' | 'canvas' | 'dom' | 'experimentalWebgl';
gpuAcceleration: 'auto' | 'on' | 'off';
rightClickBehavior: 'default' | 'copyPaste' | 'paste' | 'selectWord';
cursorBlinking: boolean;
cursorStyle: string;

View file

@ -356,17 +356,16 @@ export const terminalConfiguration: IConfigurationNode = {
],
default: 'auto'
},
'terminal.integrated.rendererType': {
'terminal.integrated.gpuAcceleration': {
type: 'string',
enum: ['auto', 'canvas', 'dom', 'experimentalWebgl'],
enum: ['auto', 'on', 'off'],
markdownEnumDescriptions: [
localize('terminal.integrated.rendererType.auto', "Let VS Code guess which renderer to use."),
localize('terminal.integrated.rendererType.canvas', "Use the standard GPU/canvas-based renderer."),
localize('terminal.integrated.rendererType.dom', "Use the fallback DOM-based renderer."),
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).")
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.")
],
default: 'auto',
description: localize('terminal.integrated.rendererType', "Controls how the terminal is rendered.")
description: localize('terminal.integrated.gpuAcceleration', "Controls whether the terminal will leverage the GPU to do its rendering.")
},
'terminal.integrated.rightClickBehavior': {
type: 'string',