@xterm/addon-webgl 0.18.0-beta.1 → 0.18.0-beta.10
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/package.json +1 -1
- package/src/GlyphRenderer.ts +15 -5
- package/src/WebglRenderer.ts +7 -4
package/package.json
CHANGED
package/src/GlyphRenderer.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
|
|
6
|
+
import { allowRescaling, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
|
|
7
7
|
import { TextureAtlas } from 'browser/renderer/shared/TextureAtlas';
|
|
8
8
|
import { IRasterizedGlyph, IRenderDimensions, ITextureAtlas } from 'browser/renderer/shared/Types';
|
|
9
9
|
import { NULL_CELL_CODE } from 'common/buffer/Constants';
|
|
@@ -11,6 +11,7 @@ import { Disposable, toDisposable } from 'common/Lifecycle';
|
|
|
11
11
|
import { Terminal } from '@xterm/xterm';
|
|
12
12
|
import { IRenderModel, IWebGL2RenderingContext, IWebGLVertexArrayObject } from './Types';
|
|
13
13
|
import { createProgram, GLTexture, PROJECTION_MATRIX } from './WebglUtils';
|
|
14
|
+
import type { IOptionsService } from 'common/services/Services';
|
|
14
15
|
|
|
15
16
|
interface IVertices {
|
|
16
17
|
attributes: Float32Array;
|
|
@@ -111,7 +112,8 @@ export class GlyphRenderer extends Disposable {
|
|
|
111
112
|
constructor(
|
|
112
113
|
private readonly _terminal: Terminal,
|
|
113
114
|
private readonly _gl: IWebGL2RenderingContext,
|
|
114
|
-
private _dimensions: IRenderDimensions
|
|
115
|
+
private _dimensions: IRenderDimensions,
|
|
116
|
+
private readonly _optionsService: IOptionsService
|
|
115
117
|
) {
|
|
116
118
|
super();
|
|
117
119
|
|
|
@@ -212,15 +214,15 @@ export class GlyphRenderer extends Disposable {
|
|
|
212
214
|
return this._atlas ? this._atlas.beginFrame() : true;
|
|
213
215
|
}
|
|
214
216
|
|
|
215
|
-
public updateCell(x: number, y: number, code: number, bg: number, fg: number, ext: number, chars: string, lastBg: number): void {
|
|
217
|
+
public updateCell(x: number, y: number, code: number, bg: number, fg: number, ext: number, chars: string, width: number, lastBg: number): void {
|
|
216
218
|
// Since this function is called for every cell (`rows*cols`), it must be very optimized. It
|
|
217
219
|
// should not instantiate any variables unless a new glyph is drawn to the cache where the
|
|
218
220
|
// slight slowdown is acceptable for the developer ergonomics provided as it's a once of for
|
|
219
221
|
// each glyph.
|
|
220
|
-
this._updateCell(this._vertices.attributes, x, y, code, bg, fg, ext, chars, lastBg);
|
|
222
|
+
this._updateCell(this._vertices.attributes, x, y, code, bg, fg, ext, chars, width, lastBg);
|
|
221
223
|
}
|
|
222
224
|
|
|
223
|
-
private _updateCell(array: Float32Array, x: number, y: number, code: number | undefined, bg: number, fg: number, ext: number, chars: string, lastBg: number): void {
|
|
225
|
+
private _updateCell(array: Float32Array, x: number, y: number, code: number | undefined, bg: number, fg: number, ext: number, chars: string, width: number, lastBg: number): void {
|
|
224
226
|
$i = (y * this._terminal.cols + x) * INDICES_PER_CELL;
|
|
225
227
|
|
|
226
228
|
// Exit early if this is a null character, allow space character to continue as it may have
|
|
@@ -275,6 +277,14 @@ export class GlyphRenderer extends Disposable {
|
|
|
275
277
|
array[$i + 8] = $glyph.sizeClipSpace.y;
|
|
276
278
|
}
|
|
277
279
|
// a_cellpos only changes on resize
|
|
280
|
+
|
|
281
|
+
// Reduce scale horizontally for wide glyphs printed in cells that would overlap with the
|
|
282
|
+
// following cell (ie. the width is not 2).
|
|
283
|
+
if (this._optionsService.rawOptions.rescaleOverlappingGlyphs) {
|
|
284
|
+
if (allowRescaling(code, width, $glyph.size.x, this._dimensions.device.cell.width)) {
|
|
285
|
+
array[$i + 2] = (this._dimensions.device.cell.width - 1) / this._dimensions.device.canvas.width; // - 1 to improve readability
|
|
286
|
+
}
|
|
287
|
+
}
|
|
278
288
|
}
|
|
279
289
|
|
|
280
290
|
public clear(): void {
|
package/src/WebglRenderer.ts
CHANGED
|
@@ -36,7 +36,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|
|
36
36
|
private _observerDisposable = this.register(new MutableDisposable());
|
|
37
37
|
|
|
38
38
|
private _model: RenderModel = new RenderModel();
|
|
39
|
-
private _workCell:
|
|
39
|
+
private _workCell: ICellData = new CellData();
|
|
40
|
+
private _workCell2: ICellData = new CellData();
|
|
40
41
|
private _cellColorResolver: CellColorResolver;
|
|
41
42
|
|
|
42
43
|
private _canvas: HTMLCanvasElement;
|
|
@@ -245,7 +246,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|
|
245
246
|
*/
|
|
246
247
|
private _initializeWebGLState(): [RectangleRenderer, GlyphRenderer] {
|
|
247
248
|
this._rectangleRenderer.value = new RectangleRenderer(this._terminal, this._gl, this.dimensions, this._themeService);
|
|
248
|
-
this._glyphRenderer.value = new GlyphRenderer(this._terminal, this._gl, this.dimensions);
|
|
249
|
+
this._glyphRenderer.value = new GlyphRenderer(this._terminal, this._gl, this.dimensions, this._optionsService);
|
|
249
250
|
|
|
250
251
|
// Update dimensions and acquire char atlas
|
|
251
252
|
this.handleCharSizeChanged();
|
|
@@ -388,6 +389,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|
|
388
389
|
let range: [number, number];
|
|
389
390
|
let chars: string;
|
|
390
391
|
let code: number;
|
|
392
|
+
let width: number;
|
|
391
393
|
let i: number;
|
|
392
394
|
let x: number;
|
|
393
395
|
let j: number;
|
|
@@ -500,7 +502,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|
|
500
502
|
this._model.cells[i + RENDER_MODEL_FG_OFFSET] = this._cellColorResolver.result.fg;
|
|
501
503
|
this._model.cells[i + RENDER_MODEL_EXT_OFFSET] = this._cellColorResolver.result.ext;
|
|
502
504
|
|
|
503
|
-
|
|
505
|
+
width = cell.getWidth();
|
|
506
|
+
this._glyphRenderer.value!.updateCell(x, y, code, this._cellColorResolver.result.bg, this._cellColorResolver.result.fg, this._cellColorResolver.result.ext, chars, width, lastBg);
|
|
504
507
|
|
|
505
508
|
if (isJoined) {
|
|
506
509
|
// Restore work cell
|
|
@@ -509,7 +512,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|
|
509
512
|
// Null out non-first cells
|
|
510
513
|
for (x++; x < lastCharX; x++) {
|
|
511
514
|
j = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
|
|
512
|
-
this._glyphRenderer.value!.updateCell(x, y, NULL_CELL_CODE, 0, 0, 0, NULL_CELL_CHAR, 0);
|
|
515
|
+
this._glyphRenderer.value!.updateCell(x, y, NULL_CELL_CODE, 0, 0, 0, NULL_CELL_CHAR, 0, 0);
|
|
513
516
|
this._model.cells[j] = NULL_CELL_CODE;
|
|
514
517
|
this._model.cells[j + RENDER_MODEL_BG_OFFSET] = this._cellColorResolver.result.bg;
|
|
515
518
|
this._model.cells[j + RENDER_MODEL_FG_OFFSET] = this._cellColorResolver.result.fg;
|