diff --git a/addons/xterm-addon-webgl/src/GlyphRenderer.ts b/addons/xterm-addon-webgl/src/GlyphRenderer.ts index 9e60a7fc..28b37c29 100644 --- a/addons/xterm-addon-webgl/src/GlyphRenderer.ts +++ b/addons/xterm-addon-webgl/src/GlyphRenderer.ts @@ -192,9 +192,11 @@ export class GlyphRenderer extends Disposable { // Get the glyph if (chars && chars.length > 1) { - rasterizedGlyph = this._atlas.getRasterizedGlyphCombinedChar(chars, bg, fg); + // TODO: Use actual ext + rasterizedGlyph = this._atlas.getRasterizedGlyphCombinedChar(chars, bg, fg, 0); } else { - rasterizedGlyph = this._atlas.getRasterizedGlyph(code, bg, fg); + // TODO: Use actual ext + rasterizedGlyph = this._atlas.getRasterizedGlyph(code, bg, fg, 0); } // Fill empty if no glyph was found diff --git a/addons/xterm-addon-webgl/src/Types.d.ts b/addons/xterm-addon-webgl/src/Types.d.ts index d8a27aa7..c803d3e4 100644 --- a/addons/xterm-addon-webgl/src/Types.d.ts +++ b/addons/xterm-addon-webgl/src/Types.d.ts @@ -4,7 +4,7 @@ */ export interface IRasterizedGlyphSet { - [bg: number]: { [fg: number]: IRasterizedGlyph } | undefined; + [bg: number]: { [fg: number]: { [ext: number]: IRasterizedGlyph } } | undefined; } /** diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index 05751c42..642c0e83 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -6,12 +6,12 @@ import { ICharAtlasConfig } from './Types'; import { DIM_OPACITY, TEXT_BASELINE } from 'browser/renderer/atlas/Constants'; import { IRasterizedGlyph, IBoundingBox, IRasterizedGlyphSet } from '../Types'; -import { DEFAULT_COLOR, Attributes } from 'common/buffer/Constants'; +import { DEFAULT_COLOR, Attributes, DEFAULT_EXT } from 'common/buffer/Constants'; import { throwIfFalsy } from '../WebglUtils'; import { IColor } from 'common/Types'; import { IDisposable } from 'xterm'; import { AttributeData } from 'common/buffer/AttributeData'; -import { channels, color, rgba } from 'common/Color'; +import { color, rgba } from 'common/Color'; import { tryDrawCustomChar } from 'browser/renderer/CustomGlyphs'; import { excludeFromContrastRatioDemands, isPowerlineGlyph } from 'browser/renderer/RendererUtils'; @@ -109,7 +109,9 @@ export class WebglCharAtlas implements IDisposable { const rasterizedGlyph = this._drawToCache(i, DEFAULT_COLOR, DEFAULT_COLOR); this._cacheMap[i] = { [DEFAULT_COLOR]: { - [DEFAULT_COLOR]: rasterizedGlyph + [DEFAULT_COLOR]: { + [DEFAULT_EXT]: rasterizedGlyph + } } }; } @@ -137,48 +139,50 @@ export class WebglCharAtlas implements IDisposable { this._didWarmUp = false; } - public getRasterizedGlyphCombinedChar(chars: string, bg: number, fg: number): IRasterizedGlyph { - let rasterizedGlyphSet = this._cacheMapCombined[chars]; - if (!rasterizedGlyphSet) { - rasterizedGlyphSet = {}; - this._cacheMapCombined[chars] = rasterizedGlyphSet; - } - let rasterizedGlyph: IRasterizedGlyph | undefined; - const rasterizedGlyphSetBg = rasterizedGlyphSet[bg]; - if (rasterizedGlyphSetBg) { - rasterizedGlyph = rasterizedGlyphSetBg[fg]; - } - if (!rasterizedGlyph) { - rasterizedGlyph = this._drawToCache(chars, bg, fg); - if (!rasterizedGlyphSet[bg]) { - rasterizedGlyphSet[bg] = {}; - } - rasterizedGlyphSet[bg]![fg] = rasterizedGlyph; - } - return rasterizedGlyph; + public getRasterizedGlyphCombinedChar(chars: string, bg: number, fg: number, ext: number): IRasterizedGlyph { + return this._getFromCacheMap(this._cacheMapCombined, chars, bg, fg, ext); + } + + public getRasterizedGlyph(code: number, bg: number, fg: number, ext: number): IRasterizedGlyph { + return this._getFromCacheMap(this._cacheMap, code, bg, fg, ext); } /** * Gets the glyphs texture coords, drawing the texture if it's not already */ - public getRasterizedGlyph(code: number, bg: number, fg: number): IRasterizedGlyph { - let rasterizedGlyphSet = this._cacheMap[code]; + private _getFromCacheMap( + cacheMap: { [key: string | number]: IRasterizedGlyphSet }, + key: string | number, + bg: number, + fg: number, + ext: number + ): IRasterizedGlyph { + let rasterizedGlyphSet = cacheMap[key]; if (!rasterizedGlyphSet) { rasterizedGlyphSet = {}; - this._cacheMap[code] = rasterizedGlyphSet; + this._cacheMapCombined[key] = rasterizedGlyphSet; } + + let rasterizedGlyphSetBg = rasterizedGlyphSet[bg]; + if (!rasterizedGlyphSetBg) { + rasterizedGlyphSetBg = {}; + rasterizedGlyphSet[bg] = rasterizedGlyphSetBg; + } + let rasterizedGlyph: IRasterizedGlyph | undefined; - const rasterizedGlyphSetBg = rasterizedGlyphSet[bg]; - if (rasterizedGlyphSetBg) { - rasterizedGlyph = rasterizedGlyphSetBg[fg]; + let rasterizedGlyphSetFg = rasterizedGlyphSetBg[fg]; + if (!rasterizedGlyphSetFg) { + rasterizedGlyphSetFg = {}; + rasterizedGlyphSetBg[fg] = rasterizedGlyphSetFg; + } else { + rasterizedGlyph = rasterizedGlyphSetFg[ext]; } + if (!rasterizedGlyph) { - rasterizedGlyph = this._drawToCache(code, bg, fg); - if (!rasterizedGlyphSet[bg]) { - rasterizedGlyphSet[bg] = {}; - } - rasterizedGlyphSet[bg]![fg] = rasterizedGlyph; + rasterizedGlyph = this._drawToCache(key, bg, fg); + rasterizedGlyphSetFg[ext] = rasterizedGlyph; } + return rasterizedGlyph; } @@ -308,8 +312,6 @@ export class WebglCharAtlas implements IDisposable { return color; } - private _drawToCache(code: number, bg: number, fg: number): IRasterizedGlyph; - private _drawToCache(chars: string, bg: number, fg: number): IRasterizedGlyph; private _drawToCache(codeOrChars: number | string, bg: number, fg: number): IRasterizedGlyph { const chars = typeof codeOrChars === 'number' ? String.fromCharCode(codeOrChars) : codeOrChars; diff --git a/src/common/buffer/Constants.ts b/src/common/buffer/Constants.ts index a2c1b884..13dec2c1 100644 --- a/src/common/buffer/Constants.ts +++ b/src/common/buffer/Constants.ts @@ -5,6 +5,7 @@ export const DEFAULT_COLOR = 256; export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0); +export const DEFAULT_EXT = 0; export const CHAR_DATA_ATTR_INDEX = 0; export const CHAR_DATA_CHAR_INDEX = 1;