From a9e887315afe795693fa57bf037e916ed38b8d72 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 5 Apr 2022 20:17:08 -0700 Subject: [PATCH] note perf todo --- src/FontAtlas.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/FontAtlas.zig b/src/FontAtlas.zig index 30c440946..48ca8a2c6 100644 --- a/src/FontAtlas.zig +++ b/src/FontAtlas.zig @@ -145,6 +145,9 @@ pub fn addGlyph(self: *FontAtlas, alloc: Allocator, v: anytype) !void { const region = try self.atlas.reserve(alloc, tgt_w, tgt_h); // Build our buffer + // + // TODO(perf): we can avoid a buffer copy here in some cases where + // tgt_w == bitmap.width and bitmap.width == bitmap.pitch const buffer = try alloc.alloc(u8, tgt_w * tgt_h); defer alloc.free(buffer); var dst_ptr = buffer; @@ -178,7 +181,7 @@ pub fn addGlyph(self: *FontAtlas, alloc: Allocator, v: anytype) !void { /// Convert 26.6 pixel format to f32 fn f26dot6ToFloat(v: ftc.FT_F26Dot6) f32 { - return @intToFloat(f32, v) / 64.0; + return @intToFloat(f32, v >> 6); } /// Returns the UTF-32 codepoint for the given value.