Skip to content
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

Editor GPU: Create an inline decoration style cache #234473

Open
Tyriar opened this issue Nov 23, 2024 · 0 comments
Open

Editor GPU: Create an inline decoration style cache #234473

Tyriar opened this issue Nov 23, 2024 · 0 comments
Assignees
Labels
editor-gpu Editor GPU rendering related issues plan-item VS Code - planned item for upcoming

Comments

@Tyriar
Copy link
Member

Tyriar commented Nov 23, 2024

With #234127 there is a new charMetadata that is passed along to the rasterizer and used as a key for the glyph:

if (charMetadata) {
this._ctx.fillStyle = `#${charMetadata.toString(16).padStart(8, '0')}`;
} else {
this._ctx.fillStyle = colorMap[TokenMetadata.getForeground(metadata)];
}

this._glyphMap.set(chars, tokenMetadata, charMetadata, rasterizer.cacheKey, glyph);

This isn't scalable to the amount of CSS rules that we want to cover, so I think the solution there is to allow creating a set of styles which would turn into a single number. A kind of similar system is used right now for the rasterizer which creates the unique key cacheKey out of the font size and family:

// Save the glyph
this._glyphMap.set(chars, tokenMetadata, charMetadata, rasterizer.cacheKey, glyph);

So in the end we want to turn it into something like this:

this._glyphMap.set(chars, tokenMetadata, rasterizer.cacheKey, styleId, glyph);

Each styleId would map to a cached object like:

interface IDecorationStyleSet {
  fontSize?: number;
  fontFamily?: string;
  color?: Color;
  colorCss?: string; // avoid converting color whenever we need it for ctx.fillStyle
  textDecorationStyle?: string;
  // etc.
}

We can add as many things to that as we want which will then uniquely identify the set of styles. It's unclear whether we want to roll rasterizer.cacheKey (ie. default editor font family+size) into this. If we do not this could be exclusively for inline decorations which might be easier to understand.

@Tyriar Tyriar added editor-gpu Editor GPU rendering related issues plan-item VS Code - planned item for upcoming labels Nov 23, 2024
@Tyriar Tyriar self-assigned this Nov 23, 2024
@Tyriar Tyriar changed the title Editor GPU: Create a with a inline decoration style cache Editor GPU: Create an inline decoration style cache Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-gpu Editor GPU rendering related issues plan-item VS Code - planned item for upcoming
Projects
Status: Todo
Development

No branches or pull requests

1 participant