@xterm/addon-webgl 0.20.0-beta.2 → 0.20.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xterm/addon-webgl",
3
- "version": "0.20.0-beta.2",
3
+ "version": "0.20.0-beta.21",
4
4
  "author": {
5
5
  "name": "The xterm.js authors",
6
6
  "url": "https://xtermjs.org/"
@@ -23,8 +23,8 @@
23
23
  "prepublishOnly": "npm run package",
24
24
  "start": "node ../../demo/start"
25
25
  },
26
- "commit": "937deb9f4ba0dbfb8d99eb0ea75cffdd2ecabc06",
26
+ "commit": "c04806fc92bea3b2402071905b157df8cf9a92ea",
27
27
  "peerDependencies": {
28
- "@xterm/xterm": "^6.1.0-beta.2"
28
+ "@xterm/xterm": "^6.1.0-beta.22"
29
29
  }
30
30
  }
@@ -32,9 +32,10 @@ export function acquireTextureAtlas(
32
32
  deviceCharWidth: number,
33
33
  deviceCharHeight: number,
34
34
  devicePixelRatio: number,
35
- deviceMaxTextureSize: number
35
+ deviceMaxTextureSize: number,
36
+ customGlyphs: boolean = true
36
37
  ): ITextureAtlas {
37
- const newConfig = generateConfig(deviceCellWidth, deviceCellHeight, deviceCharWidth, deviceCharHeight, options, colors, devicePixelRatio, deviceMaxTextureSize);
38
+ const newConfig = generateConfig(deviceCellWidth, deviceCellHeight, deviceCharWidth, deviceCharHeight, options, colors, devicePixelRatio, deviceMaxTextureSize, customGlyphs);
38
39
 
39
40
  // Check to see if the terminal already owns this config
40
41
  for (let i = 0; i < charAtlasCache.length; i++) {
@@ -9,7 +9,7 @@ import { ITerminalOptions } from '@xterm/xterm';
9
9
  import { IColorSet, ReadonlyColorSet } from 'browser/Types';
10
10
  import { NULL_COLOR } from 'common/Color';
11
11
 
12
- export function generateConfig(deviceCellWidth: number, deviceCellHeight: number, deviceCharWidth: number, deviceCharHeight: number, options: Required<ITerminalOptions>, colors: ReadonlyColorSet, devicePixelRatio: number, deviceMaxTextureSize: number): ICharAtlasConfig {
12
+ export function generateConfig(deviceCellWidth: number, deviceCellHeight: number, deviceCharWidth: number, deviceCharHeight: number, options: Required<ITerminalOptions>, colors: ReadonlyColorSet, devicePixelRatio: number, deviceMaxTextureSize: number, customGlyphs: boolean = true): ICharAtlasConfig {
13
13
  // null out some fields that don't matter
14
14
  const clonedColors: IColorSet = {
15
15
  foreground: colors.foreground,
@@ -32,7 +32,7 @@ export function generateConfig(deviceCellWidth: number, deviceCellHeight: number
32
32
  halfContrastCache: colors.halfContrastCache
33
33
  };
34
34
  return {
35
- customGlyphs: options.customGlyphs,
35
+ customGlyphs,
36
36
  devicePixelRatio,
37
37
  deviceMaxTextureSize,
38
38
  letterSpacing: options.letterSpacing,
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { IColorContrastCache } from 'browser/Types';
7
7
  import { DIM_OPACITY, TEXT_BASELINE } from './Constants';
8
- import { tryDrawCustomChar } from './CustomGlyphs';
8
+ import { tryDrawCustomGlyph } from './customGlyphs/CustomGlyphRasterizer';
9
9
  import { computeNextVariantOffset, treatGlyphAsBackgroundColor, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
10
10
  import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas } from './Types';
11
11
  import { NULL_COLOR, channels, color, rgba } from 'common/Color';
@@ -514,7 +514,7 @@ export class TextureAtlas implements ITextureAtlas {
514
514
  // Draw custom characters if applicable
515
515
  let customGlyph = false;
516
516
  if (this._config.customGlyphs !== false) {
517
- customGlyph = tryDrawCustomChar(this._tmpCtx, chars, padding, padding, this._config.deviceCellWidth, this._config.deviceCellHeight, this._config.fontSize, this._config.devicePixelRatio);
517
+ customGlyph = tryDrawCustomGlyph(this._tmpCtx, chars, padding, padding, this._config.deviceCellWidth, this._config.deviceCellHeight, this._config.deviceCharWidth, this._config.deviceCharHeight, this._config.fontSize, this._config.devicePixelRatio, backgroundColor.css);
518
518
  }
519
519
 
520
520
  // Whether to clear pixels based on a threshold difference between the glyph color and the
package/src/WebglAddon.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { ITerminalAddon, Terminal } from '@xterm/xterm';
7
- import type { WebglAddon as IWebglApi } from '@xterm/addon-webgl';
7
+ import type { IWebglAddonOptions, WebglAddon as IWebglApi } from '@xterm/addon-webgl';
8
8
  import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
9
9
  import { ITerminal } from 'browser/Types';
10
10
  import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
@@ -28,9 +28,10 @@ export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi
28
28
  private readonly _onContextLoss = this._register(new Emitter<void>());
29
29
  public readonly onContextLoss = this._onContextLoss.event;
30
30
 
31
- constructor(
32
- private _preserveDrawingBuffer?: boolean
33
- ) {
31
+ private readonly _customGlyphs: boolean;
32
+ private readonly _preserveDrawingBuffer?: boolean;
33
+
34
+ constructor(options?: IWebglAddonOptions) {
34
35
  if (isSafari && getSafariVersion() < 16) {
35
36
  // Perform an extra check to determine if Webgl2 is manually enabled in developer settings
36
37
  const contextAttributes = {
@@ -44,6 +45,8 @@ export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi
44
45
  }
45
46
  }
46
47
  super();
48
+ this._customGlyphs = options?.customGlyphs ?? true;
49
+ this._preserveDrawingBuffer = options?.preserveDrawingBuffer;
47
50
  }
48
51
 
49
52
  public activate(terminal: Terminal): void {
@@ -79,6 +82,7 @@ export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi
79
82
  decorationService,
80
83
  optionsService,
81
84
  themeService,
85
+ this._customGlyphs,
82
86
  this._preserveDrawingBuffer
83
87
  ));
84
88
  this._register(Event.forward(this._renderer.onContextLoss, this._onContextLoss));
@@ -72,6 +72,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
72
72
  private readonly _decorationService: IDecorationService,
73
73
  private readonly _optionsService: IOptionsService,
74
74
  private readonly _themeService: IThemeService,
75
+ private readonly _customGlyphs: boolean = true,
75
76
  preserveDrawingBuffer?: boolean
76
77
  ) {
77
78
  super();
@@ -278,7 +279,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
278
279
  this.dimensions.device.char.width,
279
280
  this.dimensions.device.char.height,
280
281
  this._coreBrowserService.dpr,
281
- this._deviceMaxTextureSize
282
+ this._deviceMaxTextureSize,
283
+ this._customGlyphs
282
284
  );
283
285
  if (this._charAtlas !== atlas) {
284
286
  this._onChangeTextureAtlas.fire(atlas.pages[0].canvas);