Merge pull request #4101 from JasonXJ/render-bug

WebglRenderer always clears _glyphRenderer if _model is cleared
This commit is contained in:
Daniel Imms
2022-09-07 09:01:41 -07:00
committed by GitHub
2 changed files with 32 additions and 21 deletions
+13 -13
View File
@@ -238,21 +238,24 @@ export class GlyphRenderer extends Disposable {
// a_cellpos only changes on resize
}
public clear(force?: boolean): void {
public clear(): void {
const terminal = this._terminal;
const newCount = terminal.cols * terminal.rows * INDICES_PER_CELL;
// Don't clear if not forced and the array length is correct
if (!force && this._vertices.count === newCount) {
return;
}
// Clear vertices
this._vertices.count = newCount;
this._vertices.attributes = new Float32Array(newCount);
for (let i = 0; i < this._vertices.attributesBuffers.length; i++) {
this._vertices.attributesBuffers[i] = new Float32Array(newCount);
if (this._vertices.count !== newCount) {
this._vertices.attributes = new Float32Array(newCount);
} else {
this._vertices.attributes.fill(0);
}
for (let i = 0; i < this._vertices.attributesBuffers.length; i++) {
if (this._vertices.count !== newCount) {
this._vertices.attributesBuffers[i] = new Float32Array(newCount);
} else {
this._vertices.attributesBuffers[i].fill(0);
}
}
this._vertices.count = newCount;
let i = 0;
for (let y = 0; y < terminal.rows; y++) {
for (let x = 0; x < terminal.cols; x++) {
@@ -269,9 +272,6 @@ export class GlyphRenderer extends Disposable {
this.clear();
}
public setColors(): void {
}
public render(renderModel: IRenderModel): void {
if (!this._atlas) {
return;
+19 -8
View File
@@ -163,12 +163,11 @@ export class WebglRenderer extends Disposable implements IRenderer {
}
this._rectangleRenderer.setColors();
this._glyphRenderer.setColors();
this._refreshCharAtlas();
// Force a full refresh
this._model.clear();
this._clearModel(true);
}
public onDevicePixelRatioChange(): void {
@@ -208,8 +207,9 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._refreshCharAtlas();
// Force a full refresh
this._model.clear();
// Force a full refresh. Resizing `_glyphRenderer` should clear it already,
// so there is no need to clear it again here.
this._clearModel(false);
}
public onCharSizeChanged(): void {
@@ -293,16 +293,27 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._glyphRenderer.setAtlas(this._charAtlas);
}
/**
* Clear the model.
* @param clearGlyphRenderer Whether to also clear the glyph renderer. This
* should be true generally to make sure it is in the same state as the model.
*/
private _clearModel(clearGlyphRenderer: boolean): void {
this._model.clear();
if (clearGlyphRenderer) {
this._glyphRenderer.clear();
}
}
public clearCharAtlas(): void {
this._charAtlas?.clearTexture();
this._model.clear();
this._clearModel(true);
this._updateModel(0, this._terminal.rows - 1);
this._requestRedrawViewport();
}
public clear(): void {
this._model.clear();
this._glyphRenderer.clear(true);
this._clearModel(true);
for (const l of this._renderLayers) {
l.reset(this._terminal);
}
@@ -334,7 +345,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
// Tell renderer the frame is beginning
if (this._glyphRenderer.beginFrame()) {
this._model.clear();
this._clearModel(true);
this._updateSelectionModel(undefined, undefined);
}