Skip to content

Commit

Permalink
Prototype of adding a large atlas page for overflow glyphs
Browse files Browse the repository at this point in the history
Part of xtermjs#5246
  • Loading branch information
Tyriar committed Jan 6, 2025
1 parent 601efc3 commit e882f4a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/browser/renderer/shared/TextureAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export class TextureAtlas implements ITextureAtlas {
private _workAttributeData: AttributeData = new AttributeData();

private _textureSize: number = 512;
// TODO: Use actual value
private _deviceMaxTextureSize: number = 2048;

public static maxAtlasPages: number | undefined;
public static maxTextureSize: number | undefined;
Expand Down Expand Up @@ -431,7 +433,7 @@ export class TextureAtlas implements ITextureAtlas {
// Allow 1 cell width per character, with a minimum of 2 (CJK), plus some padding. This is used
// to draw the glyph to the canvas as well as to restrict the bounding box search to ensure
// giant ligatures (eg. =====>) don't impact overall performance.
const allowedWidth = Math.min(this._config.deviceCellWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2, this._textureSize);
const allowedWidth = Math.min(this._config.deviceCellWidth * Math.max(chars.length, 2) + TMP_CANVAS_GLYPH_PADDING * 2, this._deviceMaxTextureSize);
if (this._tmpCanvas.width < allowedWidth) {
this._tmpCanvas.width = allowedWidth;
}
Expand Down Expand Up @@ -772,6 +774,21 @@ export class TextureAtlas implements ITextureAtlas {
}
}

// Create a new page for oversized glyphs as they come up
if (rasterizedGlyph.size.x > this._textureSize) {
// TODO: Move below after page merging to ensure page limit isn't hit
const newPage = new AtlasPage(this._document, this._deviceMaxTextureSize);
this.pages.push(newPage);

// Request the model to be cleared to refresh all texture pages.
this._requestClearModel = true;
this._onAddTextureAtlasCanvas.fire(newPage.canvas);

newPage.addGlyph(rasterizedGlyph);
activePage.fixedRows.push(newPage.currentRow);
break;
}

// Create a new page if too much vertical space would be wasted or there is not enough room
// left in the page. The previous active row will become fixed in the process as it now has a
// fixed height
Expand Down

0 comments on commit e882f4a

Please sign in to comment.