Use polyfill for TypedArray.fill

This commit is contained in:
Daniel Imms
2018-11-23 07:14:56 -08:00
parent 1567b41d6e
commit 128b1b0a48
3 changed files with 11 additions and 8 deletions
+4 -3
View File
@@ -11,6 +11,7 @@ import WebglCharAtlas from './WebglCharAtlas';
import { IWebGL2RenderingContext, IWebGLVertexArrayObject, IRenderModel, IRasterizedGlyph } from './Types';
import { INDICIES_PER_CELL } from './WebglRenderer';
import { COMBINED_CHAR_BIT_MASK } from './RenderModel';
import { fill } from '../../core/TypedArrayUtils';
interface IVertices {
attributes: Float32Array;
@@ -169,7 +170,7 @@ export class GlyphRenderer {
// Exit early if this is a null/space character
if (code === NULL_CELL_CODE || code === undefined/* This is used for the right side of wide chars */) {
array.fill(0, i, i + INDICES_PER_CELL - 1);
fill(array, 0, i, i + INDICES_PER_CELL - 1);
return;
}
@@ -182,7 +183,7 @@ export class GlyphRenderer {
// Fill empty if no glyph was found
if (!rasterizedGlyph) {
array.fill(0, i, i + INDICES_PER_CELL - 1);
fill(array, 0, i, i + INDICES_PER_CELL - 1);
return;
}
@@ -203,7 +204,7 @@ export class GlyphRenderer {
public updateLineEnd(x: number, y: number): void {
// Clears all cells to the right of the line end
const i = (y * this._terminal.cols + x + 1) * INDICES_PER_CELL;
this._vertices.attributes.fill(0, i, i + (this._terminal.cols - this._lineLengths[y]) * INDICES_PER_CELL - 1);
fill(this._vertices.attributes, 0, i, i + (this._terminal.cols - this._lineLengths[y]) * INDICES_PER_CELL - 1);
}
public updateSelection(model: IRenderModel, columnSelectMode: boolean): void {
+4 -3
View File
@@ -9,6 +9,7 @@ import { createProgram, expandFloat32Array, PROJECTION_MATRIX } from './WebglUti
import { IColor } from '../../shared/Types';
import { IRenderModel, IWebGLVertexArrayObject, IWebGL2RenderingContext, ISelectionRenderModel } from './Types';
import { RENDER_INVERTED_DEFAULT_COLOR } from './RenderModel';
import { fill } from '../../core/TypedArrayUtils';
const enum VertexAttribLocations {
POSITION = 0,
@@ -173,7 +174,7 @@ export class RectangleRenderer {
const terminal = this._terminal;
if (!model.hasSelection) {
this._vertices.selection.fill(0, 0);
fill(this._vertices.selection, 0, 0);
return;
}
@@ -190,7 +191,7 @@ export class RectangleRenderer {
height * this._dimensions.scaledCellHeight,
this._selectionFloat
);
this._vertices.selection.fill(0, INDICES_PER_RECTANGLE);
fill(this._vertices.selection, 0, INDICES_PER_RECTANGLE);
} else {
// Draw first row
const startCol = model.viewportStartRow === model.viewportCappedStartRow ? model.startCol : 0;
@@ -231,7 +232,7 @@ export class RectangleRenderer {
this._selectionFloat
);
} else {
this._vertices.selection.fill(0, INDICES_PER_RECTANGLE * 2);
fill(this._vertices.selection, 0, INDICES_PER_RECTANGLE * 2);
}
}
}
+3 -2
View File
@@ -4,6 +4,7 @@
*/
import { IRenderModel, ISelectionRenderModel } from './Types';
import { fill } from '../../core/TypedArrayUtils';
export const RENDER_MODEL_INDICIES_PER_CELL = 4;
@@ -42,8 +43,8 @@ export class RenderModel implements IRenderModel {
}
public clear(): void {
this.cells.fill(0, 0);
this.lineLengths.fill(0, 0);
fill(this.cells, 0, 0);
fill(this.lineLengths, 0, 0);
this.clearSelection();
}