Skip to content

Remove StaticCharAtlas support (fixes #1576) #1580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function initOptions(term) {
bellSound: null,
bellStyle: ['none', 'sound'],
cursorStyle: ['block', 'underline', 'bar'],
experimentalCharAtlas: ['none', 'static', 'dynamic'],
experimentalCharAtlas: ['none', 'dynamic'],
fontFamily: null,
fontWeight: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
fontWeightBold: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900']
Expand Down
2 changes: 1 addition & 1 deletion src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const DEFAULT_OPTIONS: ITerminalOptions = {
bellStyle: 'none',
drawBoldTextInBrightColors: true,
enableBold: true,
experimentalCharAtlas: 'static',
experimentalCharAtlas: 'dynamic',
fontFamily: 'courier-new, courier, monospace',
fontSize: 15,
fontWeight: 'normal',
Expand Down
22 changes: 22 additions & 0 deletions src/renderer/atlas/BaseCharAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { IGlyphIdentifier } from './Types';
import { IColor } from '../../shared/Types';

export default abstract class BaseCharAtlas {
private _didWarmUp: boolean = false;
Expand Down Expand Up @@ -51,3 +52,24 @@ export default abstract class BaseCharAtlas {
y: number
): boolean;
}

/**
* Makes a partiicular rgb color in an ImageData completely transparent.
* @returns True if the result is "empty", meaning all pixels are fully transparent.
*/
export function clearColor(imageData: ImageData, color: IColor): boolean {
let isEmpty = true;
const r = color.rgba >>> 24;
const g = color.rgba >>> 16 & 0xFF;
const b = color.rgba >>> 8 & 0xFF;
for (let offset = 0; offset < imageData.data.length; offset += 4) {
if (imageData.data[offset] === r &&
imageData.data[offset + 1] === g &&
imageData.data[offset + 2] === b) {
imageData.data[offset + 3] = 0;
} else {
isEmpty = false;
}
}
return isEmpty;
}
2 changes: 0 additions & 2 deletions src/renderer/atlas/CharAtlasCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import { generateConfig, configEquals } from './CharAtlasUtils';
import BaseCharAtlas from './BaseCharAtlas';
import DynamicCharAtlas from './DynamicCharAtlas';
import NoneCharAtlas from './NoneCharAtlas';
import StaticCharAtlas from './StaticCharAtlas';

const charAtlasImplementations = {
'none': NoneCharAtlas,
'static': StaticCharAtlas,
'dynamic': DynamicCharAtlas
};

Expand Down
3 changes: 1 addition & 2 deletions src/renderer/atlas/DynamicCharAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR } from './Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { IColor } from '../../shared/Types';
import BaseCharAtlas from './BaseCharAtlas';
import BaseCharAtlas, { clearColor } from './BaseCharAtlas';
import { DEFAULT_ANSI_COLORS } from '../ColorManager';
import { clearColor } from '../../shared/atlas/CharAtlasGenerator';
import LRUMap from './LRUMap';

// In practice we're probably never going to exhaust a texture this large. For debugging purposes,
Expand Down
100 changes: 0 additions & 100 deletions src/renderer/atlas/StaticCharAtlas.ts

This file was deleted.

143 changes: 0 additions & 143 deletions src/shared/atlas/CharAtlasGenerator.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/shared/atlas/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IColorSet } from '../Types';
export const CHAR_ATLAS_CELL_SPACING = 1;

export interface ICharAtlasConfig {
type: 'none' | 'static' | 'dynamic';
type: 'none' | 'dynamic';
devicePixelRatio: number;
fontSize: number;
fontFamily: string;
Expand Down
19 changes: 6 additions & 13 deletions typings/xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,10 @@ declare module 'xterm' {
* artifacts.
*
* - 'none': Don't use an atlas.
* - 'static': Generate an atlas when the terminal starts or is reconfigured. This atlas will
* only contain ASCII characters in 16 colors.
* - 'dynamic': Generate an atlas using a LRU cache as characters are requested. Limited to
* ASCII characters (for now), but supports 256 colors. For characters covered by the static
* cache, it's slightly slower in comparison, since there's more overhead involved in
* managing the cache.
*
* Currently defaults to 'static'. This option may be removed in the future. If it is, passed
* parameters will be ignored.
* ASCII characters (for now), but supports 256 colors. (recommended)
*/
experimentalCharAtlas?: 'none' | 'static' | 'dynamic';
experimentalCharAtlas?: 'none' | 'dynamic';

/**
* The font size used to render text.
Expand Down Expand Up @@ -474,7 +467,7 @@ declare module 'xterm' {
* (EXPERIMENTAL) Registers a character joiner, allowing custom sequences of
* characters to be rendered as a single unit. This is useful in particular
* for rendering ligatures and graphemes, among other things.
*
*
* Each registered character joiner is called with a string of text
* representing a portion of a line in the terminal that can be rendered as
* a single unit. The joiner must return a sorted array, where each entry is
Expand All @@ -483,16 +476,16 @@ declare module 'xterm' {
* a single unit. When multiple joiners are provided, the results of each
* are collected. If there are any overlapping substrings between them, they
* are combined into one larger unit that is drawn together.
*
*
* All character joiners that are registered get called every time a line is
* rendered in the terminal, so it is essential for the handler function to
* run as quickly as possible to avoid slowdowns when rendering. Similarly,
* joiners should strive to return the smallest possible substrings to
* render together, since they aren't drawn as optimally as individual
* characters.
*
*
* NOTE: character joiners are only used by the canvas renderer.
*
*
* @param handler The function that determines character joins. It is called
* with a string of text that is eligible for joining and returns an array
* where each entry is an array containing the start (inclusive) and end
Expand Down