@xterm/addon-webgl 0.20.0-beta.213 → 0.20.0-beta.215

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.213",
3
+ "version": "0.20.0-beta.215",
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": "a2e51e8d36114119d5f2c174eb45be1fbc92cbfa",
26
+ "commit": "6ba731d73bfbe074e84b57abb62080bed2f4db03",
27
27
  "peerDependencies": {
28
- "@xterm/xterm": "^6.1.0-beta.214"
28
+ "@xterm/xterm": "^6.1.0-beta.216"
29
29
  }
30
30
  }
@@ -78,9 +78,11 @@ void main() {
78
78
  }`);
79
79
  }
80
80
 
81
- const INDICES_PER_CELL = 11;
82
- const BYTES_PER_CELL = INDICES_PER_CELL * Float32Array.BYTES_PER_ELEMENT;
83
- const CELL_POSITION_INDICES = 2;
81
+ const enum Constants {
82
+ INDICES_PER_CELL = 11,
83
+ BYTES_PER_CELL = INDICES_PER_CELL * 4/* Float32Array.BYTES_PER_ELEMENT */,
84
+ CELL_POSITION_INDICES = 2
85
+ }
84
86
 
85
87
  // Work variables to avoid garbage collection
86
88
  let $i = 0;
@@ -160,22 +162,22 @@ export class GlyphRenderer extends Disposable {
160
162
  this._register(toDisposable(() => gl.deleteBuffer(this._attributesBuffer)));
161
163
  gl.bindBuffer(gl.ARRAY_BUFFER, this._attributesBuffer);
162
164
  gl.enableVertexAttribArray(VertexAttribLocations.OFFSET);
163
- gl.vertexAttribPointer(VertexAttribLocations.OFFSET, 2, gl.FLOAT, false, BYTES_PER_CELL, 0);
165
+ gl.vertexAttribPointer(VertexAttribLocations.OFFSET, 2, gl.FLOAT, false, Constants.BYTES_PER_CELL, 0);
164
166
  gl.vertexAttribDivisor(VertexAttribLocations.OFFSET, 1);
165
167
  gl.enableVertexAttribArray(VertexAttribLocations.SIZE);
166
- gl.vertexAttribPointer(VertexAttribLocations.SIZE, 2, gl.FLOAT, false, BYTES_PER_CELL, 2 * Float32Array.BYTES_PER_ELEMENT);
168
+ gl.vertexAttribPointer(VertexAttribLocations.SIZE, 2, gl.FLOAT, false, Constants.BYTES_PER_CELL, 2 * Float32Array.BYTES_PER_ELEMENT);
167
169
  gl.vertexAttribDivisor(VertexAttribLocations.SIZE, 1);
168
170
  gl.enableVertexAttribArray(VertexAttribLocations.TEXPAGE);
169
- gl.vertexAttribPointer(VertexAttribLocations.TEXPAGE, 1, gl.FLOAT, false, BYTES_PER_CELL, 4 * Float32Array.BYTES_PER_ELEMENT);
171
+ gl.vertexAttribPointer(VertexAttribLocations.TEXPAGE, 1, gl.FLOAT, false, Constants.BYTES_PER_CELL, 4 * Float32Array.BYTES_PER_ELEMENT);
170
172
  gl.vertexAttribDivisor(VertexAttribLocations.TEXPAGE, 1);
171
173
  gl.enableVertexAttribArray(VertexAttribLocations.TEXCOORD);
172
- gl.vertexAttribPointer(VertexAttribLocations.TEXCOORD, 2, gl.FLOAT, false, BYTES_PER_CELL, 5 * Float32Array.BYTES_PER_ELEMENT);
174
+ gl.vertexAttribPointer(VertexAttribLocations.TEXCOORD, 2, gl.FLOAT, false, Constants.BYTES_PER_CELL, 5 * Float32Array.BYTES_PER_ELEMENT);
173
175
  gl.vertexAttribDivisor(VertexAttribLocations.TEXCOORD, 1);
174
176
  gl.enableVertexAttribArray(VertexAttribLocations.TEXSIZE);
175
- gl.vertexAttribPointer(VertexAttribLocations.TEXSIZE, 2, gl.FLOAT, false, BYTES_PER_CELL, 7 * Float32Array.BYTES_PER_ELEMENT);
177
+ gl.vertexAttribPointer(VertexAttribLocations.TEXSIZE, 2, gl.FLOAT, false, Constants.BYTES_PER_CELL, 7 * Float32Array.BYTES_PER_ELEMENT);
176
178
  gl.vertexAttribDivisor(VertexAttribLocations.TEXSIZE, 1);
177
179
  gl.enableVertexAttribArray(VertexAttribLocations.CELL_POSITION);
178
- gl.vertexAttribPointer(VertexAttribLocations.CELL_POSITION, 2, gl.FLOAT, false, BYTES_PER_CELL, 9 * Float32Array.BYTES_PER_ELEMENT);
180
+ gl.vertexAttribPointer(VertexAttribLocations.CELL_POSITION, 2, gl.FLOAT, false, Constants.BYTES_PER_CELL, 9 * Float32Array.BYTES_PER_ELEMENT);
179
181
  gl.vertexAttribDivisor(VertexAttribLocations.CELL_POSITION, 1);
180
182
 
181
183
  // Setup static uniforms
@@ -222,12 +224,12 @@ export class GlyphRenderer extends Disposable {
222
224
  }
223
225
 
224
226
  private _updateCell(array: Float32Array, x: number, y: number, code: number | undefined, bg: number, fg: number, ext: number, chars: string, width: number, lastBg: number): void {
225
- $i = (y * this._terminal.cols + x) * INDICES_PER_CELL;
227
+ $i = (y * this._terminal.cols + x) * Constants.INDICES_PER_CELL;
226
228
 
227
229
  // Exit early if this is a null character, allow space character to continue as it may have
228
230
  // underline/strikethrough styles
229
231
  if (code === NULL_CELL_CODE || code === undefined/* This is used for the right side of wide chars */) {
230
- array.fill(0, $i, $i + INDICES_PER_CELL - 1 - CELL_POSITION_INDICES);
232
+ array.fill(0, $i, $i + Constants.INDICES_PER_CELL - 1 - Constants.CELL_POSITION_INDICES);
231
233
  return;
232
234
  }
233
235
 
@@ -288,7 +290,7 @@ export class GlyphRenderer extends Disposable {
288
290
 
289
291
  public clear(): void {
290
292
  const terminal = this._terminal;
291
- const newCount = terminal.cols * terminal.rows * INDICES_PER_CELL;
293
+ const newCount = terminal.cols * terminal.rows * Constants.INDICES_PER_CELL;
292
294
 
293
295
  // Clear vertices
294
296
  if (this._vertices.count !== newCount) {
@@ -310,7 +312,7 @@ export class GlyphRenderer extends Disposable {
310
312
  for (let x = 0; x < terminal.cols; x++) {
311
313
  this._vertices.attributes[i + 9] = x / terminal.cols;
312
314
  this._vertices.attributes[i + 10] = y / terminal.rows;
313
- i += INDICES_PER_CELL;
315
+ i += Constants.INDICES_PER_CELL;
314
316
  }
315
317
  }
316
318
  }
@@ -346,8 +348,8 @@ export class GlyphRenderer extends Disposable {
346
348
  // - So we don't send vertices for all the line-ending whitespace to the GPU
347
349
  let bufferLength = 0;
348
350
  for (let y = 0; y < renderModel.lineLengths.length; y++) {
349
- const si = y * this._terminal.cols * INDICES_PER_CELL;
350
- const sub = this._vertices.attributes.subarray(si, si + renderModel.lineLengths[y] * INDICES_PER_CELL);
351
+ const si = y * this._terminal.cols * Constants.INDICES_PER_CELL;
352
+ const sub = this._vertices.attributes.subarray(si, si + renderModel.lineLengths[y] * Constants.INDICES_PER_CELL);
351
353
  activeBuffer.set(sub, bufferLength);
352
354
  bufferLength += sub.length;
353
355
  }
@@ -364,7 +366,7 @@ export class GlyphRenderer extends Disposable {
364
366
  }
365
367
 
366
368
  // Draw the viewport
367
- gl.drawElementsInstanced(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_BYTE, 0, bufferLength / INDICES_PER_CELL);
369
+ gl.drawElementsInstanced(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_BYTE, 0, bufferLength / Constants.INDICES_PER_CELL);
368
370
  }
369
371
 
370
372
  public setAtlas(atlas: ITextureAtlas): void {
@@ -10,7 +10,7 @@ import { Attributes, FgFlags } from 'common/buffer/Constants';
10
10
  import { Disposable, toDisposable } from 'common/Lifecycle';
11
11
  import { IColor } from 'common/Types';
12
12
  import { Terminal } from '@xterm/xterm';
13
- import { RENDER_MODEL_BG_OFFSET, RENDER_MODEL_FG_OFFSET, RENDER_MODEL_INDICIES_PER_CELL } from './RenderModel';
13
+ import { RenderModelConstants } from './RenderModel';
14
14
  import { IRenderModel, IWebGL2RenderingContext, IWebGLVertexArrayObject } from './Types';
15
15
  import { createProgram, expandFloat32Array, PROJECTION_MATRIX } from './WebglUtils';
16
16
  import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
@@ -217,9 +217,9 @@ export class RectangleRenderer extends Disposable {
217
217
  currentFg = 0;
218
218
  currentInverse = false;
219
219
  for (x = 0; x < terminal.cols; x++) {
220
- modelIndex = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
221
- bg = model.cells[modelIndex + RENDER_MODEL_BG_OFFSET];
222
- fg = model.cells[modelIndex + RENDER_MODEL_FG_OFFSET];
220
+ modelIndex = ((y * terminal.cols) + x) * RenderModelConstants.INDICIES_PER_CELL;
221
+ bg = model.cells[modelIndex + RenderModelConstants.BG_OFFSET];
222
+ fg = model.cells[modelIndex + RenderModelConstants.FG_OFFSET];
223
223
  inverse = !!(fg & FgFlags.INVERSE);
224
224
  if (bg !== currentBg || (fg !== currentFg && (currentInverse || inverse))) {
225
225
  // A rectangle needs to be drawn if going from non-default to another color
@@ -7,10 +7,12 @@ import { ICursorRenderModel, IRenderModel } from './Types';
7
7
  import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
8
8
  import { createSelectionRenderModel } from 'browser/renderer/shared/SelectionRenderModel';
9
9
 
10
- export const RENDER_MODEL_INDICIES_PER_CELL = 4;
11
- export const RENDER_MODEL_BG_OFFSET = 1;
12
- export const RENDER_MODEL_FG_OFFSET = 2;
13
- export const RENDER_MODEL_EXT_OFFSET = 3;
10
+ export const enum RenderModelConstants {
11
+ INDICIES_PER_CELL = 4,
12
+ BG_OFFSET = 1,
13
+ FG_OFFSET = 2,
14
+ EXT_OFFSET = 3
15
+ }
14
16
 
15
17
  export const COMBINED_CHAR_BIT_MASK = 0x80000000;
16
18
 
@@ -27,7 +29,7 @@ export class RenderModel implements IRenderModel {
27
29
  }
28
30
 
29
31
  public resize(cols: number, rows: number): void {
30
- const indexCount = cols * rows * RENDER_MODEL_INDICIES_PER_CELL;
32
+ const indexCount = cols * rows * RenderModelConstants.INDICIES_PER_CELL;
31
33
  if (indexCount !== this.cells.length) {
32
34
  this.cells = new Uint32Array(indexCount);
33
35
  this.lineLengths = new Uint32Array(rows);
@@ -19,7 +19,7 @@ import { ICoreService, IDecorationService, IOptionsService } from 'common/servic
19
19
  import { Terminal } from '@xterm/xterm';
20
20
  import { GlyphRenderer } from './GlyphRenderer';
21
21
  import { RectangleRenderer } from './RectangleRenderer';
22
- 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';
22
+ import { COMBINED_CHAR_BIT_MASK, RenderModel, RenderModelConstants } from './RenderModel';
23
23
  import { IWebGL2RenderingContext, type ITextureAtlas } from './Types';
24
24
  import { LinkRenderLayer } from './renderLayer/LinkRenderLayer';
25
25
  import { IRenderLayer } from './renderLayer/Types';
@@ -493,7 +493,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
493
493
 
494
494
  chars = cell.getChars();
495
495
  code = cell.getCode();
496
- i = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
496
+ i = ((y * terminal.cols) + x) * RenderModelConstants.INDICIES_PER_CELL;
497
497
 
498
498
  if (!rowHasBlinkingCells && cell.isBlink()) {
499
499
  rowHasBlinkingCells = true;
@@ -538,9 +538,9 @@ export class WebglRenderer extends Disposable implements IRenderer {
538
538
 
539
539
  // Nothing has changed, no updates needed
540
540
  if (this._model.cells[i] === code &&
541
- this._model.cells[i + RENDER_MODEL_BG_OFFSET] === this._cellColorResolver.result.bg &&
542
- this._model.cells[i + RENDER_MODEL_FG_OFFSET] === this._cellColorResolver.result.fg &&
543
- this._model.cells[i + RENDER_MODEL_EXT_OFFSET] === this._cellColorResolver.result.ext) {
541
+ this._model.cells[i + RenderModelConstants.BG_OFFSET] === this._cellColorResolver.result.bg &&
542
+ this._model.cells[i + RenderModelConstants.FG_OFFSET] === this._cellColorResolver.result.fg &&
543
+ this._model.cells[i + RenderModelConstants.EXT_OFFSET] === this._cellColorResolver.result.ext) {
544
544
  continue;
545
545
  }
546
546
 
@@ -553,9 +553,9 @@ export class WebglRenderer extends Disposable implements IRenderer {
553
553
 
554
554
  // Cache the results in the model
555
555
  this._model.cells[i] = code;
556
- this._model.cells[i + RENDER_MODEL_BG_OFFSET] = this._cellColorResolver.result.bg;
557
- this._model.cells[i + RENDER_MODEL_FG_OFFSET] = this._cellColorResolver.result.fg;
558
- this._model.cells[i + RENDER_MODEL_EXT_OFFSET] = this._cellColorResolver.result.ext;
556
+ this._model.cells[i + RenderModelConstants.BG_OFFSET] = this._cellColorResolver.result.bg;
557
+ this._model.cells[i + RenderModelConstants.FG_OFFSET] = this._cellColorResolver.result.fg;
558
+ this._model.cells[i + RenderModelConstants.EXT_OFFSET] = this._cellColorResolver.result.ext;
559
559
 
560
560
  width = cell.getWidth();
561
561
  this._glyphRenderer.value!.updateCell(x, y, code, this._cellColorResolver.result.bg, this._cellColorResolver.result.fg, this._cellColorResolver.result.ext, chars, width, lastBg);
@@ -566,14 +566,14 @@ export class WebglRenderer extends Disposable implements IRenderer {
566
566
 
567
567
  // Null out non-first cells
568
568
  for (x++; x <= lastCharX; x++) {
569
- j = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
569
+ j = ((y * terminal.cols) + x) * RenderModelConstants.INDICIES_PER_CELL;
570
570
  this._glyphRenderer.value!.updateCell(x, y, NULL_CELL_CODE, 0, 0, 0, NULL_CELL_CHAR, 0, 0);
571
571
  this._model.cells[j] = NULL_CELL_CODE;
572
572
  // Don't re-resolve the cell color since multi-colored ligature backgrounds are not
573
573
  // supported
574
- this._model.cells[j + RENDER_MODEL_BG_OFFSET] = this._cellColorResolver.result.bg;
575
- this._model.cells[j + RENDER_MODEL_FG_OFFSET] = this._cellColorResolver.result.fg;
576
- this._model.cells[j + RENDER_MODEL_EXT_OFFSET] = this._cellColorResolver.result.ext;
574
+ this._model.cells[j + RenderModelConstants.BG_OFFSET] = this._cellColorResolver.result.bg;
575
+ this._model.cells[j + RenderModelConstants.FG_OFFSET] = this._cellColorResolver.result.fg;
576
+ this._model.cells[j + RenderModelConstants.EXT_OFFSET] = this._cellColorResolver.result.ext;
577
577
  }
578
578
  x--; // Go back to the previous update cell for next iteration
579
579
  }