From e3402cef4dcc4e61d68fd8c2cc652063414882b2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 6 Apr 2024 20:00:22 -0700 Subject: [PATCH] address many fontmem todos --- src/font/SharedGrid.zig | 3 --- src/font/face/Metrics.zig | 10 ++++------ src/renderer/Metal.zig | 15 --------------- src/renderer/OpenGL.zig | 12 ------------ 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/src/font/SharedGrid.zig b/src/font/SharedGrid.zig index 3f4d3599a..03f364570 100644 --- a/src/font/SharedGrid.zig +++ b/src/font/SharedGrid.zig @@ -18,9 +18,6 @@ //! reinitialized and all surfaces should switch over to using that one. const SharedGrid = @This(); -// TODO(fontmem): -// - consider config changes and how they affect the shared grid. - const std = @import("std"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; diff --git a/src/font/face/Metrics.zig b/src/font/face/Metrics.zig index 621f0ddbf..df96d5a6d 100644 --- a/src/font/face/Metrics.zig +++ b/src/font/face/Metrics.zig @@ -174,12 +174,10 @@ pub const Modifier = union(enum) { const autoHash = std.hash.autoHash; autoHash(hasher, std.meta.activeTag(self)); switch (self) { - // floats can't be hashed directly so we round it to the - // nearest int and then hash that. This is not perfect but - // hash collisions due to the modifier being wrong are really - // rare so we should fix this up later. - // TODO(fontmem): make better - .percent => |v| autoHash(hasher, @as(i64, @intFromFloat(v))), + // floats can't be hashed directly so we bitcast to i64. + // for the purpose of what we're trying to do this seems + // good enough but I would prefer value hashing. + .percent => |v| autoHash(hasher, @as(i64, @bitCast(v))), .absolute => |v| autoHash(hasher, v), } } diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index e9465db40..a5e87b59b 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1363,21 +1363,6 @@ fn prepKittyGraphics( /// Update the configuration. pub fn changeConfig(self: *Metal, config: *DerivedConfig) !void { - // On configuration change we always reset our font group. There - // are a variety of configurations that can change font settings - // so to be safe we just always reset it. This has a performance hit - // when its not necessary but config reloading shouldn't be so - // common to cause a problem. - // - // TODO(fontmem): we no longer do this. the surface should handle - // font changes, create a new grid for us, and send it via message - // passing or something. - // - // self.font_group.reset(); - // self.font_group.group.styles = config.font_styles; - // self.font_group.atlas_greyscale.clear(); - // self.font_group.atlas_color.clear(); - // We always redo the font shaper in case font features changed. We // could check to see if there was an actual config change but this is // easier and rare enough to not cause performance issues. diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 83eb2d752..d6669ccfa 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -1530,18 +1530,6 @@ fn gridSize(self: *const OpenGL, screen_size: renderer.ScreenSize) renderer.Grid /// Update the configuration. pub fn changeConfig(self: *OpenGL, config: *DerivedConfig) !void { - // On configuration change we always reset our font group. There - // are a variety of configurations that can change font settings - // so to be safe we just always reset it. This has a performance hit - // when its not necessary but config reloading shouldn't be so - // common to cause a problem. - // - // TODO(fontmem): see Metal - // self.font_group.reset(); - // self.font_group.group.styles = config.font_styles; - // self.font_group.atlas_greyscale.clear(); - // self.font_group.atlas_color.clear(); - // We always redo the font shaper in case font features changed. We // could check to see if there was an actual config change but this is // easier and rare enough to not cause performance issues.