@xterm/addon-webgl 0.20.0-beta.2 → 0.20.0-beta.20
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/lib/addon-webgl.js +1 -1
- package/lib/addon-webgl.js.map +1 -1
- package/lib/addon-webgl.mjs +16 -16
- package/lib/addon-webgl.mjs.map +4 -4
- package/package.json +3 -3
- package/src/CharAtlasCache.ts +3 -2
- package/src/CharAtlasUtils.ts +2 -2
- package/src/TextureAtlas.ts +2 -2
- package/src/WebglAddon.ts +8 -4
- package/src/WebglRenderer.ts +3 -1
- package/src/customGlyphs/CustomGlyphDefinitions.ts +869 -0
- package/src/customGlyphs/CustomGlyphRasterizer.ts +712 -0
- package/src/customGlyphs/Types.ts +85 -0
- package/typings/addon-webgl.d.ts +26 -1
- package/src/CustomGlyphs.ts +0 -839
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/addon-webgl",
|
|
3
|
-
"version": "0.20.0-beta.
|
|
3
|
+
"version": "0.20.0-beta.20",
|
|
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": "
|
|
26
|
+
"commit": "edf100a24ba540665083b24e2edcf4c3958deca3",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@xterm/xterm": "^6.1.0-beta.
|
|
28
|
+
"@xterm/xterm": "^6.1.0-beta.21"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/CharAtlasCache.ts
CHANGED
|
@@ -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++) {
|
package/src/CharAtlasUtils.ts
CHANGED
|
@@ -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
|
|
35
|
+
customGlyphs,
|
|
36
36
|
devicePixelRatio,
|
|
37
37
|
deviceMaxTextureSize,
|
|
38
38
|
letterSpacing: options.letterSpacing,
|
package/src/TextureAtlas.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { IColorContrastCache } from 'browser/Types';
|
|
7
7
|
import { DIM_OPACITY, TEXT_BASELINE } from './Constants';
|
|
8
|
-
import {
|
|
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 =
|
|
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
|
-
|
|
32
|
-
|
|
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));
|
package/src/WebglRenderer.ts
CHANGED
|
@@ -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);
|