Consolidate constants, fix rectangle rendering
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const MODEL_BG_OFFSET = 2;
|
|
||||||
export const MODEL_FG_OFFSET = 3;
|
|
||||||
@@ -6,8 +6,7 @@
|
|||||||
import { createProgram, PROJECTION_MATRIX, throwIfFalsy } from './WebglUtils';
|
import { createProgram, PROJECTION_MATRIX, throwIfFalsy } from './WebglUtils';
|
||||||
import { WebglCharAtlas } from './atlas/WebglCharAtlas';
|
import { WebglCharAtlas } from './atlas/WebglCharAtlas';
|
||||||
import { IWebGL2RenderingContext, IWebGLVertexArrayObject, IRenderModel, IRasterizedGlyph } from './Types';
|
import { IWebGL2RenderingContext, IWebGLVertexArrayObject, IRenderModel, IRasterizedGlyph } from './Types';
|
||||||
import { INDICIES_PER_CELL } from './WebglRenderer';
|
import { COMBINED_CHAR_BIT_MASK, RENDER_MODEL_INDICIES_PER_CELL } from './RenderModel';
|
||||||
import { COMBINED_CHAR_BIT_MASK } from './RenderModel';
|
|
||||||
import { fill } from 'common/TypedArrayUtils';
|
import { fill } from 'common/TypedArrayUtils';
|
||||||
import { slice } from './TypedArray';
|
import { slice } from './TypedArray';
|
||||||
import { NULL_CELL_CODE, WHITESPACE_CELL_CODE, Attributes } from 'common/buffer/Constants';
|
import { NULL_CELL_CODE, WHITESPACE_CELL_CODE, Attributes } from 'common/buffer/Constants';
|
||||||
@@ -259,7 +258,7 @@ export class GlyphRenderer {
|
|||||||
const row = y + terminal.buffer.viewportY;
|
const row = y + terminal.buffer.viewportY;
|
||||||
let line: IBufferLine | undefined;
|
let line: IBufferLine | undefined;
|
||||||
for (let x = startCol; x < endCol; x++) {
|
for (let x = startCol; x < endCol; x++) {
|
||||||
const offset = (y * this._terminal.cols + x) * INDICIES_PER_CELL;
|
const offset = (y * this._terminal.cols + x) * RENDER_MODEL_INDICIES_PER_CELL;
|
||||||
const code = model.cells[offset];
|
const code = model.cells[offset];
|
||||||
if (code & COMBINED_CHAR_BIT_MASK) {
|
if (code & COMBINED_CHAR_BIT_MASK) {
|
||||||
if (!line) {
|
if (!line) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { DEFAULT_COLOR, Attributes, FgFlags } from 'common/buffer/Constants';
|
|||||||
import { Terminal } from 'xterm';
|
import { Terminal } from 'xterm';
|
||||||
import { IColorSet, IColor } from 'browser/Types';
|
import { IColorSet, IColor } from 'browser/Types';
|
||||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||||
import { MODEL_FG_OFFSET, MODEL_BG_OFFSET } from './Constants';
|
import { RENDER_MODEL_BG_OFFSET, RENDER_MODEL_FG_OFFSET, RENDER_MODEL_INDICIES_PER_CELL } from './RenderModel';
|
||||||
|
|
||||||
const enum VertexAttribLocations {
|
const enum VertexAttribLocations {
|
||||||
POSITION = 0,
|
POSITION = 0,
|
||||||
@@ -249,9 +249,9 @@ export class RectangleRenderer {
|
|||||||
let currentBg = DEFAULT_COLOR;
|
let currentBg = DEFAULT_COLOR;
|
||||||
let currentFg = DEFAULT_COLOR;
|
let currentFg = DEFAULT_COLOR;
|
||||||
for (let x = 0; x < terminal.cols; x++) {
|
for (let x = 0; x < terminal.cols; x++) {
|
||||||
const modelIndex = ((y * terminal.cols) + x) * 4;
|
const modelIndex = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
|
||||||
const bg = model.cells[modelIndex + MODEL_BG_OFFSET];
|
const bg = model.cells[modelIndex + RENDER_MODEL_BG_OFFSET];
|
||||||
const fg = model.cells[modelIndex + MODEL_FG_OFFSET];
|
const fg = model.cells[modelIndex + RENDER_MODEL_FG_OFFSET];
|
||||||
if (bg !== currentBg) {
|
if (bg !== currentBg) {
|
||||||
// A rectangle needs to be drawn if going from non-default to another color
|
// A rectangle needs to be drawn if going from non-default to another color
|
||||||
// TODO: DEFAULT_COLOR probably isn't right anymore?
|
// TODO: DEFAULT_COLOR probably isn't right anymore?
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { IRenderModel, ISelectionRenderModel } from './Types';
|
|||||||
import { fill } from 'common/TypedArrayUtils';
|
import { fill } from 'common/TypedArrayUtils';
|
||||||
|
|
||||||
export const RENDER_MODEL_INDICIES_PER_CELL = 3;
|
export const RENDER_MODEL_INDICIES_PER_CELL = 3;
|
||||||
|
export const RENDER_MODEL_BG_OFFSET = 1;
|
||||||
|
export const RENDER_MODEL_FG_OFFSET = 2;
|
||||||
|
|
||||||
export const COMBINED_CHAR_BIT_MASK = 0x80000000;
|
export const COMBINED_CHAR_BIT_MASK = 0x80000000;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { WebglCharAtlas } from './atlas/WebglCharAtlas';
|
|||||||
import { RectangleRenderer } from './RectangleRenderer';
|
import { RectangleRenderer } from './RectangleRenderer';
|
||||||
import { IWebGL2RenderingContext } from './Types';
|
import { IWebGL2RenderingContext } from './Types';
|
||||||
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
|
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
|
||||||
import { RenderModel, COMBINED_CHAR_BIT_MASK } from './RenderModel';
|
import { RenderModel, COMBINED_CHAR_BIT_MASK, RENDER_MODEL_BG_OFFSET, RENDER_MODEL_FG_OFFSET, RENDER_MODEL_INDICIES_PER_CELL } from './RenderModel';
|
||||||
import { Disposable } from 'common/Lifecycle';
|
import { Disposable } from 'common/Lifecycle';
|
||||||
import { DEFAULT_COLOR, NULL_CELL_CODE, FgFlags } from 'common/buffer/Constants';
|
import { DEFAULT_COLOR, NULL_CELL_CODE, FgFlags } from 'common/buffer/Constants';
|
||||||
import { Terminal, IEvent } from 'xterm';
|
import { Terminal, IEvent } from 'xterm';
|
||||||
@@ -22,9 +22,6 @@ import { IRenderDimensions, IRenderer, IRequestRefreshRowsEvent } from 'browser/
|
|||||||
import { IColorSet } from 'browser/Types';
|
import { IColorSet } from 'browser/Types';
|
||||||
import { EventEmitter } from 'common/EventEmitter';
|
import { EventEmitter } from 'common/EventEmitter';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
import { MODEL_BG_OFFSET, MODEL_FG_OFFSET } from './Constants';
|
|
||||||
|
|
||||||
export const INDICIES_PER_CELL = 4;
|
|
||||||
|
|
||||||
export class WebglRenderer extends Disposable implements IRenderer {
|
export class WebglRenderer extends Disposable implements IRenderer {
|
||||||
private _renderLayers: IRenderLayer[];
|
private _renderLayers: IRenderLayer[];
|
||||||
@@ -263,7 +260,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
const chars = this._workCell.getChars();
|
const chars = this._workCell.getChars();
|
||||||
let code = this._workCell.getCode();
|
let code = this._workCell.getCode();
|
||||||
const i = ((y * terminal.cols) + x) * INDICIES_PER_CELL;
|
const i = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
|
||||||
|
|
||||||
if (code !== NULL_CELL_CODE) {
|
if (code !== NULL_CELL_CODE) {
|
||||||
this._model.lineLengths[y] = x + 1;
|
this._model.lineLengths[y] = x + 1;
|
||||||
@@ -275,8 +272,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
// Nothing has changed, no updates needed
|
// Nothing has changed, no updates needed
|
||||||
if (this._model.cells[i] === code &&
|
if (this._model.cells[i] === code &&
|
||||||
this._model.cells[i + MODEL_BG_OFFSET] === bg &&
|
this._model.cells[i + RENDER_MODEL_BG_OFFSET] === bg &&
|
||||||
this._model.cells[i + MODEL_FG_OFFSET] === fg) {
|
this._model.cells[i + RENDER_MODEL_FG_OFFSET] === fg) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,8 +302,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
// Cache the results in the model
|
// Cache the results in the model
|
||||||
this._model.cells[i] = code;
|
this._model.cells[i] = code;
|
||||||
this._model.cells[i + MODEL_BG_OFFSET] = bg;
|
this._model.cells[i + RENDER_MODEL_BG_OFFSET] = bg;
|
||||||
this._model.cells[i + MODEL_FG_OFFSET] = fg;
|
this._model.cells[i + RENDER_MODEL_FG_OFFSET] = fg;
|
||||||
|
|
||||||
this._glyphRenderer.updateCell(x, y, code, bg, fg, chars);
|
this._glyphRenderer.updateCell(x, y, code, bg, fg, chars);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user