2 * Copyright (c) 2017 The xterm.js authors. All rights reserved.
6 import { IGlyphIdentifier } from 'browser/renderer/atlas/Types';
7 import { IDisposable } from 'common/Types';
9 export abstract class BaseCharAtlas implements IDisposable {
10 private _didWarmUp: boolean = false;
12 public dispose(): void { }
15 * Perform any work needed to warm the cache before it can be used. May be called multiple times.
16 * Implement _doWarmUp instead if you only want to get called once.
18 public warmUp(): void {
19 if (!this._didWarmUp) {
21 this._didWarmUp = true;
26 * Perform any work needed to warm the cache before it can be used. Used by the default
27 * implementation of warmUp(), and will only be called once.
29 protected _doWarmUp(): void { }
32 * Called when we start drawing a new frame.
34 * TODO: We rely on this getting called by TextRenderLayer. This should really be called by
35 * Renderer instead, but we need to make Renderer the source-of-truth for the char atlas, instead
38 public beginFrame(): void { }
41 * May be called before warmUp finishes, however it is okay for the implementation to
42 * do nothing and return false in that case.
44 * @param ctx Where to draw the character onto.
45 * @param glyph Information about what to draw
46 * @param x The position on the context to start drawing at
47 * @param y The position on the context to start drawing at
48 * @returns The success state. True if we drew the character.
51 ctx: CanvasRenderingContext2D,
52 glyph: IGlyphIdentifier,