diff --git a/addons/xterm-addon-webgl/src/Constants.ts b/addons/xterm-addon-webgl/src/Constants.ts index ab18b97ab..bf39ec989 100644 --- a/addons/xterm-addon-webgl/src/Constants.ts +++ b/addons/xterm-addon-webgl/src/Constants.ts @@ -3,13 +3,5 @@ * @license MIT */ -// TODO: Should be removed after chardata workaround is fixed -export const enum FLAGS { - BOLD = 1, - UNDERLINE = 2, - BLINK = 4, - INVERSE = 8, - INVISIBLE = 16, - DIM = 32, - ITALIC = 64 -} +export const MODEL_BG_OFFSET = 2; +export const MODEL_FG_OFFSET = 3; diff --git a/addons/xterm-addon-webgl/src/GlyphRenderer.ts b/addons/xterm-addon-webgl/src/GlyphRenderer.ts index 00b216295..a28d5c10a 100644 --- a/addons/xterm-addon-webgl/src/GlyphRenderer.ts +++ b/addons/xterm-addon-webgl/src/GlyphRenderer.ts @@ -260,9 +260,6 @@ export class GlyphRenderer { let line: IBufferLine | undefined; for (let x = startCol; x < endCol; x++) { const offset = (y * this._terminal.cols + x) * INDICIES_PER_CELL; - // Because the cache uses attr as a lookup key it needs to contain the selection colors as well - let attr = model.cells[offset + 1]; - attr = attr & ~0x3ffff | bg << 9 | fg; const code = model.cells[offset]; if (code & COMBINED_CHAR_BIT_MASK) { if (!line) { diff --git a/addons/xterm-addon-webgl/src/RectangleRenderer.ts b/addons/xterm-addon-webgl/src/RectangleRenderer.ts index 70b5ee3c1..3a5f64170 100644 --- a/addons/xterm-addon-webgl/src/RectangleRenderer.ts +++ b/addons/xterm-addon-webgl/src/RectangleRenderer.ts @@ -6,12 +6,11 @@ import { createProgram, expandFloat32Array, PROJECTION_MATRIX, throwIfFalsy } from './WebglUtils'; import { IRenderModel, IWebGLVertexArrayObject, IWebGL2RenderingContext, ISelectionRenderModel } from './Types'; import { fill } from 'common/TypedArrayUtils'; -import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants'; -import { is256Color } from './atlas/CharAtlasUtils'; import { DEFAULT_COLOR, Attributes, FgFlags } from 'common/buffer/Constants'; import { Terminal } from 'xterm'; import { IColorSet, IColor } from 'browser/Types'; import { IRenderDimensions } from 'browser/renderer/Types'; +import { MODEL_FG_OFFSET, MODEL_BG_OFFSET } from './Constants'; const enum VertexAttribLocations { POSITION = 0, @@ -251,8 +250,8 @@ export class RectangleRenderer { let currentFg = DEFAULT_COLOR; for (let x = 0; x < terminal.cols; x++) { const modelIndex = ((y * terminal.cols) + x) * 4; - const bg = model.cells[modelIndex + 2]; - const fg = model.cells[modelIndex + 1]; + const bg = model.cells[modelIndex + MODEL_BG_OFFSET]; + const fg = model.cells[modelIndex + MODEL_FG_OFFSET]; if (bg !== currentBg) { // A rectangle needs to be drawn if going from non-default to another color // TODO: DEFAULT_COLOR probably isn't right anymore? diff --git a/addons/xterm-addon-webgl/src/RenderModel.ts b/addons/xterm-addon-webgl/src/RenderModel.ts index a9ee24e9a..f55111d4d 100644 --- a/addons/xterm-addon-webgl/src/RenderModel.ts +++ b/addons/xterm-addon-webgl/src/RenderModel.ts @@ -6,7 +6,7 @@ import { IRenderModel, ISelectionRenderModel } from './Types'; import { fill } from 'common/TypedArrayUtils'; -export const RENDER_MODEL_INDICIES_PER_CELL = 4; +export const RENDER_MODEL_INDICIES_PER_CELL = 3; export const COMBINED_CHAR_BIT_MASK = 0x80000000; diff --git a/addons/xterm-addon-webgl/src/WebglRenderer.ts b/addons/xterm-addon-webgl/src/WebglRenderer.ts index 9acbc8df8..8bbd1b64d 100644 --- a/addons/xterm-addon-webgl/src/WebglRenderer.ts +++ b/addons/xterm-addon-webgl/src/WebglRenderer.ts @@ -22,6 +22,7 @@ import { IRenderDimensions, IRenderer, IRequestRefreshRowsEvent } from 'browser/ import { IColorSet } from 'browser/Types'; import { EventEmitter } from 'common/EventEmitter'; import { CellData } from 'common/buffer/CellData'; +import { MODEL_BG_OFFSET, MODEL_FG_OFFSET } from './Constants'; export const INDICIES_PER_CELL = 4; @@ -273,7 +274,9 @@ export class WebglRenderer extends Disposable implements IRenderer { let fg = this._workCell.fg; // Nothing has changed, no updates needed - if (this._model.cells[i] === code && this._model.cells[i + 2] === bg && this._model.cells[i + 3] === fg) { + if (this._model.cells[i] === code && + this._model.cells[i + MODEL_BG_OFFSET] === bg && + this._model.cells[i + MODEL_FG_OFFSET] === fg) { continue; } @@ -301,11 +304,9 @@ export class WebglRenderer extends Disposable implements IRenderer { } // Cache the results in the model - this._model.cells[i ] = code; - // TODO: Remove attr from model - this._model.cells[i + 1] = 0; - this._model.cells[i + 2] = bg; - this._model.cells[i + 3] = fg; + this._model.cells[i] = code; + this._model.cells[i + MODEL_BG_OFFSET] = bg; + this._model.cells[i + MODEL_FG_OFFSET] = fg; this._glyphRenderer.updateCell(x, y, code, bg, fg, chars); } diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 9d8eb286e..b9c4a827d 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -6,11 +6,10 @@ import { ICharAtlasConfig } from './Types'; import { DIM_OPACITY } from 'browser/renderer/atlas/Constants'; import { IRasterizedGlyph, IBoundingBox, IRasterizedGlyphSet } from '../Types'; -import { DEFAULT_COLOR, DEFAULT_ATTR, FgFlags, Attributes, BgFlags } from 'common/buffer/Constants'; +import { DEFAULT_COLOR, FgFlags, Attributes, BgFlags } from 'common/buffer/Constants'; import { is256Color } from './CharAtlasUtils'; import { throwIfFalsy } from '../WebglUtils'; import { IColor } from 'browser/Types'; -import { FLAGS } from '../Constants'; import { IDisposable } from 'xterm'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes,