@xterm/addon-webgl 0.19.0-beta.91 → 0.19.0-beta.93

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/src/Types.ts CHANGED
@@ -3,8 +3,11 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
+ import { FontWeight } from '@xterm/xterm';
7
+ import { IColorSet } from 'browser/Types';
6
8
  import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
7
- import { CursorInactiveStyle, CursorStyle } from 'common/Types';
9
+ import { CursorInactiveStyle, CursorStyle, type IDisposable } from 'common/Types';
10
+ import type { Event } from 'vs/base/common/event';
8
11
 
9
12
  export interface IRenderModel {
10
13
  cells: Uint32Array;
@@ -31,3 +34,93 @@ export interface IWebGL2RenderingContext extends WebGLRenderingContext {
31
34
 
32
35
  export interface IWebGLVertexArrayObject {
33
36
  }
37
+
38
+ export interface ICharAtlasConfig {
39
+ customGlyphs: boolean;
40
+ devicePixelRatio: number;
41
+ deviceMaxTextureSize: number;
42
+ letterSpacing: number;
43
+ lineHeight: number;
44
+ fontSize: number;
45
+ fontFamily: string;
46
+ fontWeight: FontWeight;
47
+ fontWeightBold: FontWeight;
48
+ deviceCellWidth: number;
49
+ deviceCellHeight: number;
50
+ deviceCharWidth: number;
51
+ deviceCharHeight: number;
52
+ allowTransparency: boolean;
53
+ drawBoldTextInBrightColors: boolean;
54
+ minimumContrastRatio: number;
55
+ colors: IColorSet;
56
+ }
57
+
58
+ export interface ITextureAtlas extends IDisposable {
59
+ readonly pages: { canvas: HTMLCanvasElement, version: number }[];
60
+
61
+ onAddTextureAtlasCanvas: Event<HTMLCanvasElement>;
62
+ onRemoveTextureAtlasCanvas: Event<HTMLCanvasElement>;
63
+
64
+ /**
65
+ * Warm up the texture atlas, adding common glyphs to avoid slowing early frame.
66
+ */
67
+ warmUp(): void;
68
+
69
+ /**
70
+ * Call when a frame is being drawn, this will return true if the atlas was cleared to make room
71
+ * for a new set of glyphs.
72
+ */
73
+ beginFrame(): boolean;
74
+
75
+ /**
76
+ * Clear all glyphs from the texture atlas.
77
+ */
78
+ clearTexture(): void;
79
+ getRasterizedGlyph(code: number, bg: number, fg: number, ext: number, restrictToCellHeight: boolean, domContainer: HTMLElement | undefined): IRasterizedGlyph;
80
+ getRasterizedGlyphCombinedChar(chars: string, bg: number, fg: number, ext: number, restrictToCellHeight: boolean, domContainer: HTMLElement | undefined): IRasterizedGlyph;
81
+ }
82
+
83
+ /**
84
+ * Represents a rasterized glyph within a texture atlas. Some numbers are
85
+ * tracked in CSS pixels as well in order to reduce calculations during the
86
+ * render loop.
87
+ */
88
+ export interface IRasterizedGlyph {
89
+ /**
90
+ * The x and y offset between the glyph's top/left and the top/left of a cell
91
+ * in pixels.
92
+ */
93
+ offset: IVector;
94
+ /**
95
+ * The index of the texture page that the glyph is on.
96
+ */
97
+ texturePage: number;
98
+ /**
99
+ * the x and y position of the glyph in the texture in pixels.
100
+ */
101
+ texturePosition: IVector;
102
+ /**
103
+ * the x and y position of the glyph in the texture in clip space coordinates.
104
+ */
105
+ texturePositionClipSpace: IVector;
106
+ /**
107
+ * The width and height of the glyph in the texture in pixels.
108
+ */
109
+ size: IVector;
110
+ /**
111
+ * The width and height of the glyph in the texture in clip space coordinates.
112
+ */
113
+ sizeClipSpace: IVector;
114
+ }
115
+
116
+ export interface IVector {
117
+ x: number;
118
+ y: number;
119
+ }
120
+
121
+ export interface IBoundingBox {
122
+ top: number;
123
+ left: number;
124
+ right: number;
125
+ bottom: number;
126
+ }
@@ -4,12 +4,11 @@
4
4
  */
5
5
 
6
6
  import { ITerminal } from 'browser/Types';
7
- import { CellColorResolver } from 'browser/renderer/shared/CellColorResolver';
8
- import { acquireTextureAtlas, removeTerminalFromCache } from 'browser/renderer/shared/CharAtlasCache';
9
- import { CursorBlinkStateManager } from 'browser/renderer/shared/CursorBlinkStateManager';
10
- import { observeDevicePixelDimensions } from 'browser/renderer/shared/DevicePixelObserver';
11
- import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
12
- import { IRenderDimensions, IRenderer, IRequestRedrawEvent, ITextureAtlas } from 'browser/renderer/shared/Types';
7
+ import { CellColorResolver } from './CellColorResolver';
8
+ import { acquireTextureAtlas, removeTerminalFromCache } from './CharAtlasCache';
9
+ import { CursorBlinkStateManager } from './CursorBlinkStateManager';
10
+ import { observeDevicePixelDimensions } from './DevicePixelObserver';
11
+ import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/shared/Types';
13
12
  import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
14
13
  import { CharData, IBufferLine, ICellData } from 'common/Types';
15
14
  import { AttributeData } from 'common/buffer/AttributeData';
@@ -20,12 +19,13 @@ import { Terminal } from '@xterm/xterm';
20
19
  import { GlyphRenderer } from './GlyphRenderer';
21
20
  import { RectangleRenderer } from './RectangleRenderer';
22
21
  import { COMBINED_CHAR_BIT_MASK, RENDER_MODEL_BG_OFFSET, RENDER_MODEL_EXT_OFFSET, RENDER_MODEL_FG_OFFSET, RENDER_MODEL_INDICIES_PER_CELL, RenderModel } from './RenderModel';
23
- import { IWebGL2RenderingContext } from './Types';
22
+ import { IWebGL2RenderingContext, type ITextureAtlas } from './Types';
24
23
  import { LinkRenderLayer } from './renderLayer/LinkRenderLayer';
25
24
  import { IRenderLayer } from './renderLayer/Types';
26
25
  import { Emitter, Event } from 'vs/base/common/event';
27
26
  import { addDisposableListener } from 'vs/base/browser/dom';
28
27
  import { combinedDisposable, Disposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
28
+ import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
29
29
 
30
30
  export class WebglRenderer extends Disposable implements IRenderer {
31
31
  private _renderLayers: IRenderLayer[];
@@ -4,16 +4,17 @@
4
4
  */
5
5
 
6
6
  import { ReadonlyColorSet } from 'browser/Types';
7
- import { acquireTextureAtlas } from 'browser/renderer/shared/CharAtlasCache';
8
- import { TEXT_BASELINE } from 'browser/renderer/shared/Constants';
9
- import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
10
- import { IRenderDimensions, ITextureAtlas } from 'browser/renderer/shared/Types';
7
+ import { acquireTextureAtlas } from '../CharAtlasCache';
8
+ import { IRenderDimensions } from 'browser/renderer/shared/Types';
11
9
  import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
12
10
  import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
13
11
  import { CellData } from 'common/buffer/CellData';
14
12
  import { IOptionsService } from 'common/services/Services';
15
13
  import { Terminal } from '@xterm/xterm';
16
14
  import { IRenderLayer } from './Types';
15
+ import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
16
+ import { TEXT_BASELINE } from '../Constants';
17
+ import type { ITextureAtlas } from '../Types';
17
18
 
18
19
  export abstract class BaseRenderLayer extends Disposable implements IRenderLayer {
19
20
  private _canvas: HTMLCanvasElement;
@@ -3,7 +3,7 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { is256Color } from 'browser/renderer/shared/CharAtlasUtils';
6
+ import { is256Color } from '../CharAtlasUtils';
7
7
  import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/shared/Constants';
8
8
  import { IRenderDimensions } from 'browser/renderer/shared/Types';
9
9
  import { ICoreBrowserService, IThemeService } from 'browser/services/Services';