renderer/metal: convert more

This commit is contained in:
Mitchell Hashimoto
2024-04-05 18:51:26 -07:00
parent d6c048f1e3
commit 329697779a
3 changed files with 14 additions and 13 deletions

View File

@ -9,6 +9,7 @@ const DeferredFace = font.DeferredFace;
const Group = font.Group; const Group = font.Group;
const GroupCache = font.GroupCache; const GroupCache = font.GroupCache;
const Library = font.Library; const Library = font.Library;
const SharedGrid = font.SharedGrid;
const Style = font.Style; const Style = font.Style;
const Presentation = font.Presentation; const Presentation = font.Presentation;
const terminal = @import("../../terminal/main.zig"); const terminal = @import("../../terminal/main.zig");
@ -189,7 +190,7 @@ pub const Shaper = struct {
pub fn runIterator( pub fn runIterator(
self: *Shaper, self: *Shaper,
group: *GroupCache, grid: *SharedGrid,
screen: *const terminal.Screen, screen: *const terminal.Screen,
row: terminal.Pin, row: terminal.Pin,
selection: ?terminal.Selection, selection: ?terminal.Selection,
@ -197,7 +198,7 @@ pub const Shaper = struct {
) font.shape.RunIterator { ) font.shape.RunIterator {
return .{ return .{
.hooks = .{ .shaper = self }, .hooks = .{ .shaper = self },
.group = group, .grid = grid,
.screen = screen, .screen = screen,
.row = row, .row = row,
.selection = selection, .selection = selection,

View File

@ -15,17 +15,17 @@ pub const TextRun = struct {
/// The total number of cells produced by this run. /// The total number of cells produced by this run.
cells: u16, cells: u16,
/// The font group that built this run. /// The font grid that built this run.
group: *font.GroupCache, grid: *font.SharedGrid,
/// The font index to use for the glyphs of this run. /// The font index to use for the glyphs of this run.
font_index: font.Group.FontIndex, font_index: font.Collection.Index,
}; };
/// RunIterator is an iterator that yields text runs. /// RunIterator is an iterator that yields text runs.
pub const RunIterator = struct { pub const RunIterator = struct {
hooks: font.Shaper.RunIteratorHook, hooks: font.Shaper.RunIteratorHook,
group: *font.GroupCache, grid: *font.SharedGrid,
screen: *const terminal.Screen, screen: *const terminal.Screen,
row: terminal.Pin, row: terminal.Pin,
selection: ?terminal.Selection = null, selection: ?terminal.Selection = null,
@ -49,7 +49,7 @@ pub const RunIterator = struct {
if (self.i >= max) return null; if (self.i >= max) return null;
// Track the font for our current run // Track the font for our current run
var current_font: font.Group.FontIndex = .{}; var current_font: font.Collection.Index = .{};
// Allow the hook to prepare // Allow the hook to prepare
try self.hooks.prepare(); try self.hooks.prepare();
@ -117,7 +117,7 @@ pub const RunIterator = struct {
} else emoji: { } else emoji: {
// If we're not a grapheme, our individual char could be // If we're not a grapheme, our individual char could be
// an emoji so we want to check if we expect emoji presentation. // an emoji so we want to check if we expect emoji presentation.
// The font group indexForCodepoint we use below will do this // The font grid indexForCodepoint we use below will do this
// automatically. // automatically.
break :emoji null; break :emoji null;
}; };
@ -160,7 +160,7 @@ pub const RunIterator = struct {
// grapheme, i.e. combining characters), we need to find a font // grapheme, i.e. combining characters), we need to find a font
// that supports all of them. // that supports all of them.
const font_info: struct { const font_info: struct {
idx: font.Group.FontIndex, idx: font.Collection.Index,
fallback: ?u32 = null, fallback: ?u32 = null,
} = font_info: { } = font_info: {
// If we find a font that supports this entire grapheme // If we find a font that supports this entire grapheme
@ -231,7 +231,7 @@ pub const RunIterator = struct {
return TextRun{ return TextRun{
.offset = @intCast(self.i), .offset = @intCast(self.i),
.cells = @intCast(j - self.i), .cells = @intCast(j - self.i),
.group = self.group, .grid = self.grid,
.font_index = current_font, .font_index = current_font,
}; };
} }
@ -248,7 +248,7 @@ pub const RunIterator = struct {
cell: *terminal.Cell, cell: *terminal.Cell,
style: font.Style, style: font.Style,
presentation: ?font.Presentation, presentation: ?font.Presentation,
) !?font.Group.FontIndex { ) !?font.Collection.Index {
// Get the font index for the primary codepoint. // Get the font index for the primary codepoint.
const primary_cp: u32 = if (cell.isEmpty() or cell.codepoint() == 0) ' ' else cell.codepoint(); const primary_cp: u32 = if (cell.isEmpty() or cell.codepoint() == 0) ' ' else cell.codepoint();
const primary = try self.group.indexForCodepoint( const primary = try self.group.indexForCodepoint(
@ -265,7 +265,7 @@ pub const RunIterator = struct {
// If this is a grapheme, we need to find a font that supports // If this is a grapheme, we need to find a font that supports
// all of the codepoints in the grapheme. // all of the codepoints in the grapheme.
const cps = self.row.grapheme(cell) orelse return primary; const cps = self.row.grapheme(cell) orelse return primary;
var candidates = try std.ArrayList(font.Group.FontIndex).initCapacity(alloc, cps.len + 1); var candidates = try std.ArrayList(font.Collection.Index).initCapacity(alloc, cps.len + 1);
defer candidates.deinit(); defer candidates.deinit();
candidates.appendAssumeCapacity(primary); candidates.appendAssumeCapacity(primary);

View File

@ -1649,7 +1649,7 @@ fn rebuildCells(
// Split our row into runs and shape each one. // Split our row into runs and shape each one.
var iter = self.font_shaper.runIterator( var iter = self.font_shaper.runIterator(
self.font_group, self.font_grid,
screen, screen,
row, row,
row_selection, row_selection,