@xterm/addon-webgl 0.20.0-beta.218 → 0.20.0-beta.219
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 +5 -5
- package/lib/addon-webgl.mjs.map +3 -3
- package/package.json +3 -3
- package/src/GlyphRenderer.ts +7 -1
- package/src/RectangleRenderer.ts +3 -2
- package/src/TextureAtlas.ts +13 -7
- package/src/WebglRenderer.ts +17 -0
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.219",
|
|
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": "e749cb61253b9ca886a0ad9bf15f5d95c70eadf6",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@xterm/xterm": "^6.1.0-beta.
|
|
28
|
+
"@xterm/xterm": "^6.1.0-beta.220"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/GlyphRenderer.ts
CHANGED
|
@@ -358,7 +358,9 @@ export class GlyphRenderer extends Disposable {
|
|
|
358
358
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._attributesBuffer);
|
|
359
359
|
gl.bufferData(gl.ARRAY_BUFFER, activeBuffer.subarray(0, bufferLength), gl.STREAM_DRAW);
|
|
360
360
|
|
|
361
|
-
// Bind the atlas page texture if they have changed
|
|
361
|
+
// Bind the atlas page texture if they have changed. AtlasPage.version is globally
|
|
362
|
+
// monotonic, so a page object swap at the same index (which happens after a page merge)
|
|
363
|
+
// is detected by the same comparison.
|
|
362
364
|
for (let i = 0; i < this._atlas.pages.length; i++) {
|
|
363
365
|
if (this._atlas.pages[i].version !== this._atlasTextures[i].version) {
|
|
364
366
|
this._bindAtlasPageTexture(gl, this._atlas, i);
|
|
@@ -371,6 +373,10 @@ export class GlyphRenderer extends Disposable {
|
|
|
371
373
|
|
|
372
374
|
public setAtlas(atlas: ITextureAtlas): void {
|
|
373
375
|
this._atlas = atlas;
|
|
376
|
+
this.invalidateAtlasTextures();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
public invalidateAtlasTextures(): void {
|
|
374
380
|
for (const glTexture of this._atlasTextures) {
|
|
375
381
|
glTexture.version = -1;
|
|
376
382
|
}
|
package/src/RectangleRenderer.ts
CHANGED
|
@@ -336,8 +336,9 @@ export class RectangleRenderer extends Disposable {
|
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
if (vertices.attributes.length < offset +
|
|
340
|
-
|
|
339
|
+
if (vertices.attributes.length < offset + INDICES_PER_RECTANGLE) {
|
|
340
|
+
// +1 for the viewport-clear rectangle at offset 0.
|
|
341
|
+
vertices.attributes = expandFloat32Array(vertices.attributes, (this._terminal.rows * this._terminal.cols + 1) * INDICES_PER_RECTANGLE);
|
|
341
342
|
}
|
|
342
343
|
$x1 = startX * this._dimensions.device.cell.width;
|
|
343
344
|
$y1 = y * this._dimensions.device.cell.height;
|
package/src/TextureAtlas.ts
CHANGED
|
@@ -133,7 +133,9 @@ export class TextureAtlas implements ITextureAtlas {
|
|
|
133
133
|
|
|
134
134
|
private _requestClearModel = false;
|
|
135
135
|
public beginFrame(): boolean {
|
|
136
|
-
|
|
136
|
+
const result = this._requestClearModel;
|
|
137
|
+
this._requestClearModel = false;
|
|
138
|
+
return result;
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
public clearTexture(): void {
|
|
@@ -193,7 +195,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|
|
193
195
|
|
|
194
196
|
// Merge into the new page
|
|
195
197
|
const mergedPage = this._mergePages(mergingPages, mergedPageIndex);
|
|
196
|
-
mergedPage.version
|
|
198
|
+
mergedPage.version = ++AtlasPage.nextVersion;
|
|
197
199
|
|
|
198
200
|
// Delete the pages, shifting glyph texture pages as needed
|
|
199
201
|
for (let i = sortedMergingPagesIndexes.length - 1; i >= 0; i--) {
|
|
@@ -251,7 +253,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|
|
251
253
|
for (const g of adjustingPage.glyphs) {
|
|
252
254
|
g.texturePage--;
|
|
253
255
|
}
|
|
254
|
-
adjustingPage.version
|
|
256
|
+
adjustingPage.version = ++AtlasPage.nextVersion;
|
|
255
257
|
}
|
|
256
258
|
}
|
|
257
259
|
|
|
@@ -937,7 +939,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|
|
937
939
|
rasterizedGlyph.size.y
|
|
938
940
|
);
|
|
939
941
|
activePage.addGlyph(rasterizedGlyph);
|
|
940
|
-
activePage.version
|
|
942
|
+
activePage.version = ++AtlasPage.nextVersion;
|
|
941
943
|
|
|
942
944
|
return rasterizedGlyph;
|
|
943
945
|
}
|
|
@@ -1047,9 +1049,13 @@ class AtlasPage {
|
|
|
1047
1049
|
}
|
|
1048
1050
|
|
|
1049
1051
|
/**
|
|
1050
|
-
*
|
|
1052
|
+
* Monotonically increasing across all atlas pages globally. Used to detect when the texture
|
|
1053
|
+
* unit at a given index needs to be re-uploaded — both for content changes within the same
|
|
1054
|
+
* page and for a page object swap at the same index (which happens after a page merge,
|
|
1055
|
+
* where a per-page counter could coincide with the previously-bound page's value).
|
|
1051
1056
|
*/
|
|
1052
|
-
public
|
|
1057
|
+
public static nextVersion: number = 0;
|
|
1058
|
+
public version = ++AtlasPage.nextVersion;
|
|
1053
1059
|
|
|
1054
1060
|
// Texture atlas current positioning data. The texture packing strategy used is to fill from
|
|
1055
1061
|
// left-to-right and top-to-bottom. When the glyph being written is less than half of the current
|
|
@@ -1092,7 +1098,7 @@ class AtlasPage {
|
|
|
1092
1098
|
this.currentRow.y = 0;
|
|
1093
1099
|
this.currentRow.height = 0;
|
|
1094
1100
|
this.fixedRows.length = 0;
|
|
1095
|
-
this.version
|
|
1101
|
+
this.version = ++AtlasPage.nextVersion;
|
|
1096
1102
|
}
|
|
1097
1103
|
}
|
|
1098
1104
|
|
package/src/WebglRenderer.ts
CHANGED
|
@@ -28,6 +28,10 @@ import { addDisposableListener } from 'browser/Dom';
|
|
|
28
28
|
import { combinedDisposable, Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
|
|
29
29
|
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
|
|
30
30
|
|
|
31
|
+
const enum Constants {
|
|
32
|
+
MERGE_RETRY_LIMIT = 32
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
export class WebglRenderer extends Disposable implements IRenderer {
|
|
32
36
|
private _renderLayers: IRenderLayer[];
|
|
33
37
|
private _cursorBlinkStateManager: MutableDisposable<CursorBlinkStateManager> = this._register(new MutableDisposable());
|
|
@@ -375,6 +379,19 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|
|
375
379
|
this._updateModel(start, end);
|
|
376
380
|
}
|
|
377
381
|
|
|
382
|
+
// A mid-update atlas page merge invalidates vertex data and may not bump the host
|
|
383
|
+
// page's version, so re-run the update and force a full texture rebind.
|
|
384
|
+
let merged = false;
|
|
385
|
+
let mergeRetries = 0;
|
|
386
|
+
while (this._charAtlas && this._glyphRenderer.value.beginFrame() && mergeRetries++ < Constants.MERGE_RETRY_LIMIT) {
|
|
387
|
+
merged = true;
|
|
388
|
+
this._clearModel(true);
|
|
389
|
+
this._updateModel(0, this._terminal.rows - 1);
|
|
390
|
+
}
|
|
391
|
+
if (merged) {
|
|
392
|
+
this._glyphRenderer.value.invalidateAtlasTextures();
|
|
393
|
+
}
|
|
394
|
+
|
|
378
395
|
// Render
|
|
379
396
|
this._rectangleRenderer.value.renderBackgrounds();
|
|
380
397
|
this._glyphRenderer.value.render(this._model);
|