Skip to content

Commit

Permalink
Fix glyph caching order
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Mar 24, 2024
1 parent bcb90fc commit 738438c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
21 changes: 2 additions & 19 deletions src/vs/editor/browser/view/gpu/gpuViewLayer.ts
Expand Up @@ -445,7 +445,7 @@ export class GpuViewLayerRenderer<T extends IVisibleLine> {
// TODO: Handle tab

chars = content[x];
// TODO: Get glyph
const glyph = this._textureAtlas.getGlyph(content, x);

// TODO: Move math to gpu
// TODO: Render using a line offset for partial line scrolling
Expand All @@ -462,30 +462,13 @@ export class GpuViewLayerRenderer<T extends IVisibleLine> {
dataBuffer[charCount * Constants.IndicesPerCell + 1] = -wgslY; // y
dataBuffer[charCount * Constants.IndicesPerCell + 2] = 0;
dataBuffer[charCount * Constants.IndicesPerCell + 3] = 0;
dataBuffer[charCount * Constants.IndicesPerCell + 4] = 1; // textureIndex
dataBuffer[charCount * Constants.IndicesPerCell + 4] = glyph.id; // textureIndex
dataBuffer[charCount * Constants.IndicesPerCell + 5] = 0;

charCount++;
}
}
// console.log('charCount: ' + charCount);
return charCount;




// screenAbsoluteX = 100;
// screenAbsoluteY = 100;


// const offset = 0;
// const objectCount = 1;
// const data = new Float32Array(objectCount * Constants.IndicesPerCell);
// data[offset] = wgslX; // x
// data[offset + 1] = -wgslY; // y
// data[offset + 2] = 1; // textureIndex

// storageValues.set(data);
// return objectCount;
}
}
11 changes: 6 additions & 5 deletions src/vs/editor/browser/view/gpu/textureAtlas.ts
Expand Up @@ -45,6 +45,10 @@ export class TextureAtlas extends Disposable {
// TODO: Color, style etc.
public getGlyph(lineContent: string, glyphIndex: number): ITextureAtlasGlyph {
const chars = lineContent.charAt(glyphIndex);
let glyph: ITextureAtlasGlyph | undefined = this._glyphMap.get(chars);
if (glyph) {
return glyph;
}
const rasterizedGlyph = this._glyphRasterizer.rasterizeGlyph(chars);
this._ctx.drawImage(
rasterizedGlyph.source,
Expand All @@ -59,13 +63,10 @@ export class TextureAtlas extends Disposable {
rasterizedGlyph.boundingBox.right - rasterizedGlyph.boundingBox.left,
rasterizedGlyph.boundingBox.bottom - rasterizedGlyph.boundingBox.top
);
let glyph: ITextureAtlasGlyph | undefined = this._glyphMap.get(chars);
if (glyph) {
return glyph;
}
// TODO: Implement allocation
glyph = {
id: this._nextId++,
// TODO: Set real id
id: 1, //this._nextId++,
x: 0,
y: 0,
w: rasterizedGlyph.boundingBox.right - rasterizedGlyph.boundingBox.left,
Expand Down

0 comments on commit 738438c

Please sign in to comment.