Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require canvas/webgl use to enable image support #187621

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { SuggestAddon } from 'vs/workbench/contrib/terminal/browser/xterm/sugges
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { debounce } from 'vs/base/common/decorators';

const enum RenderConstants {
/**
Expand Down Expand Up @@ -262,7 +263,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID

// Load addons
this._updateUnicodeVersion();
this._refreshImageAddon();
this._markNavigationAddon = this._instantiationService.createInstance(MarkNavigationAddon, _capabilities);
this.raw.loadAddon(this._markNavigationAddon);
this._decorationAddon = this._instantiationService.createInstance(DecorationAddon, this._capabilities);
Expand Down Expand Up @@ -405,7 +405,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
}
}
}
this._refreshImageAddon();
}

private _shouldLoadWebgl(): boolean {
Expand Down Expand Up @@ -640,6 +639,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
this._logService.info(`Webgl lost context, disposing of webgl renderer`);
this._disposeOfWebglRenderer();
});
this._refreshImageAddon();
// Uncomment to add the texture atlas to the DOM
// setTimeout(() => {
// if (this._webglAddon?.textureAtlas) {
Expand Down Expand Up @@ -679,6 +679,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
XtermTerminal._suggestedRendererType = 'dom';
this._disposeOfCanvasRenderer();
}
this._refreshImageAddon();
}

protected async _getCanvasAddonConstructor(): Promise<typeof CanvasAddonType> {
Expand All @@ -688,8 +689,10 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
return CanvasAddon;
}

@debounce(100)
private async _refreshImageAddon(): Promise<void> {
if (this._configHelper.config.enableImages) {
// Only allow the image addon when a canvas is being used to avoid possible GPU issues
if (this._configHelper.config.enableImages && (this._canvasAddon || this._webglAddon)) {
if (!this._imageAddon) {
const AddonCtor = await this._getImageAddonConstructor();
this._imageAddon = new AddonCtor();
Expand Down Expand Up @@ -747,6 +750,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
// ignore
}
this._canvasAddon = undefined;
this._refreshImageAddon();
}

private _disposeOfWebglRenderer(): void {
Expand All @@ -756,6 +760,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
// ignore
}
this._webglAddon = undefined;
this._refreshImageAddon();
}

private async _measureRenderTime(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ const terminalConfiguration: IConfigurationNode = {
},
[TerminalSettingId.EnableImages]: {
restricted: true,
markdownDescription: localize('terminal.integrated.enableImages', "Enables image support in the terminal. Both sixel and iTerm's inline image protocol are supported on Linux and macOS, Windows support will light up automatically when ConPTY passes through the sequences. Images will currently not be restored between window reloads/reconnects."),
markdownDescription: localize('terminal.integrated.enableImages', "Enables image support in the terminal, this will only work when {0} is enabled. Both sixel and iTerm's inline image protocol are supported on Linux and macOS, Windows support will light up automatically when ConPTY passes through the sequences. Images will currently not be restored between window reloads/reconnects.", `\`#${TerminalSettingId.GpuAcceleration}#\``),
type: 'boolean',
default: true
},
Expand Down