Merge pull request #4101 from JasonXJ/render-bug
WebglRenderer always clears _glyphRenderer if _model is cleared
This commit is contained in:
@@ -238,21 +238,24 @@ export class GlyphRenderer extends Disposable {
|
|||||||
// a_cellpos only changes on resize
|
// a_cellpos only changes on resize
|
||||||
}
|
}
|
||||||
|
|
||||||
public clear(force?: boolean): void {
|
public clear(): void {
|
||||||
const terminal = this._terminal;
|
const terminal = this._terminal;
|
||||||
const newCount = terminal.cols * terminal.rows * INDICES_PER_CELL;
|
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
|
// Clear vertices
|
||||||
this._vertices.count = newCount;
|
if (this._vertices.count !== newCount) {
|
||||||
this._vertices.attributes = new Float32Array(newCount);
|
this._vertices.attributes = new Float32Array(newCount);
|
||||||
for (let i = 0; i < this._vertices.attributesBuffers.length; i++) {
|
} else {
|
||||||
this._vertices.attributesBuffers[i] = new Float32Array(newCount);
|
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;
|
let i = 0;
|
||||||
for (let y = 0; y < terminal.rows; y++) {
|
for (let y = 0; y < terminal.rows; y++) {
|
||||||
for (let x = 0; x < terminal.cols; x++) {
|
for (let x = 0; x < terminal.cols; x++) {
|
||||||
@@ -269,9 +272,6 @@ export class GlyphRenderer extends Disposable {
|
|||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public setColors(): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
public render(renderModel: IRenderModel): void {
|
public render(renderModel: IRenderModel): void {
|
||||||
if (!this._atlas) {
|
if (!this._atlas) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -163,12 +163,11 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._rectangleRenderer.setColors();
|
this._rectangleRenderer.setColors();
|
||||||
this._glyphRenderer.setColors();
|
|
||||||
|
|
||||||
this._refreshCharAtlas();
|
this._refreshCharAtlas();
|
||||||
|
|
||||||
// Force a full refresh
|
// Force a full refresh
|
||||||
this._model.clear();
|
this._clearModel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public onDevicePixelRatioChange(): void {
|
public onDevicePixelRatioChange(): void {
|
||||||
@@ -208,8 +207,9 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
this._refreshCharAtlas();
|
this._refreshCharAtlas();
|
||||||
|
|
||||||
// Force a full refresh
|
// Force a full refresh. Resizing `_glyphRenderer` should clear it already,
|
||||||
this._model.clear();
|
// so there is no need to clear it again here.
|
||||||
|
this._clearModel(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCharSizeChanged(): void {
|
public onCharSizeChanged(): void {
|
||||||
@@ -293,16 +293,27 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
this._glyphRenderer.setAtlas(this._charAtlas);
|
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 {
|
public clearCharAtlas(): void {
|
||||||
this._charAtlas?.clearTexture();
|
this._charAtlas?.clearTexture();
|
||||||
this._model.clear();
|
this._clearModel(true);
|
||||||
this._updateModel(0, this._terminal.rows - 1);
|
this._updateModel(0, this._terminal.rows - 1);
|
||||||
this._requestRedrawViewport();
|
this._requestRedrawViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clear(): void {
|
public clear(): void {
|
||||||
this._model.clear();
|
this._clearModel(true);
|
||||||
this._glyphRenderer.clear(true);
|
|
||||||
for (const l of this._renderLayers) {
|
for (const l of this._renderLayers) {
|
||||||
l.reset(this._terminal);
|
l.reset(this._terminal);
|
||||||
}
|
}
|
||||||
@@ -334,7 +345,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
// Tell renderer the frame is beginning
|
// Tell renderer the frame is beginning
|
||||||
if (this._glyphRenderer.beginFrame()) {
|
if (this._glyphRenderer.beginFrame()) {
|
||||||
this._model.clear();
|
this._clearModel(true);
|
||||||
this._updateSelectionModel(undefined, undefined);
|
this._updateSelectionModel(undefined, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user