From d437e95efbf9e469787bdf951e699d42fc55f0c2 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Thu, 27 Jun 2024 00:00:07 -0400 Subject: [PATCH] misc changes to ve font cache after starting to make the standalone repo --- code/font/VEFontCache/VEFontCache.odin | 10 -------- code/font/VEFontCache/draw.odin | 2 +- code/font/VEFontCache/mappings.odin | 2 +- code/font/VEFontCache/misc.odin | 33 ++++++++++++++++++++++++++ code/font/VEFontCache/shaper.odin | 2 +- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/code/font/VEFontCache/VEFontCache.odin b/code/font/VEFontCache/VEFontCache.odin index 4e2d80c..2a8c710 100644 --- a/code/font/VEFontCache/VEFontCache.odin +++ b/code/font/VEFontCache/VEFontCache.odin @@ -16,16 +16,6 @@ import "base:runtime" Advance_Snap_Smallfont_Size :: 0 -Colour :: [4]f32 -Vec2 :: [2]f32 -Vec2i :: [2]i32 -Vec2_64 :: [2]f64 - -vec2_from_scalar :: #force_inline proc "contextless" ( scalar : f32 ) -> Vec2 { return { scalar, scalar }} -vec2_64_from_vec2 :: #force_inline proc "contextless" ( v2 : Vec2 ) -> Vec2_64 { return { f64(v2.x), f64(v2.y) }} -vec2_from_vec2i :: #force_inline proc "contextless" ( v2i : Vec2i ) -> Vec2 { return { f32(v2i.x), f32(v2i.y) }} -vec2i_from_vec2 :: #force_inline proc "contextless" ( v2 : Vec2 ) -> Vec2i { return { i32(v2.x), i32(v2.y) }} - FontID :: distinct i64 Glyph :: distinct i32 diff --git a/code/font/VEFontCache/draw.odin b/code/font/VEFontCache/draw.odin index 04f96a2..752b9f2 100644 --- a/code/font/VEFontCache/draw.odin +++ b/code/font/VEFontCache/draw.odin @@ -624,7 +624,7 @@ draw_text_shape :: proc( ctx : ^Context, // flush_glyph_buffer_to_atlas(ctx) draw_text_batch( ctx, entry, shaped, batch_start_idx, cast(i32) len(shaped.glyphs), position, scale, snap_width , snap_height ) reset_batch_codepoint_state( ctx ) - cursor_pos = shaped.end_cursor_pos + cursor_pos = position + shaped.end_cursor_pos * scae return } diff --git a/code/font/VEFontCache/mappings.odin b/code/font/VEFontCache/mappings.odin index 2ba2b78..e575c15 100644 --- a/code/font/VEFontCache/mappings.odin +++ b/code/font/VEFontCache/mappings.odin @@ -47,7 +47,7 @@ ceil :: proc { math.ceil_f64le, math.ceil_f64be, - grime.ceil_vec2, + ceil_vec2, } clear :: proc { diff --git a/code/font/VEFontCache/misc.odin b/code/font/VEFontCache/misc.odin index 17a91b8..7cc52a0 100644 --- a/code/font/VEFontCache/misc.odin +++ b/code/font/VEFontCache/misc.odin @@ -1,6 +1,39 @@ package VEFontCache import "base:runtime" +// import core_log "core:log" + +Colour :: [4]f32 +Vec2 :: [2]f32 +Vec2i :: [2]i32 +Vec2_64 :: [2]f64 + +vec2_from_scalar :: #force_inline proc "contextless" ( scalar : f32 ) -> Vec2 { return { scalar, scalar }} +vec2_64_from_vec2 :: #force_inline proc "contextless" ( v2 : Vec2 ) -> Vec2_64 { return { f64(v2.x), f64(v2.y) }} +vec2_from_vec2i :: #force_inline proc "contextless" ( v2i : Vec2i ) -> Vec2 { return { f32(v2i.x), f32(v2i.y) }} +vec2i_from_vec2 :: #force_inline proc "contextless" ( v2 : Vec2 ) -> Vec2i { return { i32(v2.x), i32(v2.y) }} + +@(require_results) ceil_vec2 :: proc "contextless" ( v : Vec2 ) -> Vec2 { return { ceil_f32(v.x), ceil_f32(v.y) } } + +// This buffer is used below excluisvely to prevent any allocator recusion when verbose logging from allocators. +// This means a single line is limited to 32k buffer (increase naturally if this SOMEHOW becomes a bottleneck...) +// Logger_Allocator_Buffer : [32 * Kilobyte]u8 + +// log :: proc( msg : string, level := core_log.Level.Info, loc := #caller_location ) { +// temp_arena : Arena; arena_init(& temp_arena, Logger_Allocator_Buffer[:]) +// context.allocator = arena_allocator(& temp_arena) +// context.temp_allocator = arena_allocator(& temp_arena) + +// core_log.log( level, msg, location = loc ) +// } + +// logf :: proc( fmt : string, args : ..any, level := core_log.Level.Info, loc := #caller_location ) { +// temp_arena : Arena; arena_init(& temp_arena, Logger_Allocator_Buffer[:]) +// context.allocator = arena_allocator(& temp_arena) +// context.temp_allocator = arena_allocator(& temp_arena) + +// core_log.logf( level, fmt, ..args, location = loc ) +// } reload_array :: proc( self : ^[dynamic]$Type, allocator : Allocator ) { raw := transmute( ^runtime.Raw_Dynamic_Array) self diff --git a/code/font/VEFontCache/shaper.odin b/code/font/VEFontCache/shaper.odin index d06941d..18a5014 100644 --- a/code/font/VEFontCache/shaper.odin +++ b/code/font/VEFontCache/shaper.odin @@ -69,7 +69,7 @@ shaper_unload_font :: proc( ctx : ^ShaperInfo ) shaper_shape_from_text :: proc( ctx : ^ShaperContext, info : ^ShaperInfo, output :^ShapedText, text_utf8 : string, ascent, descent, line_gap : i32, size, size_scale : f32 ) { - profile(#procedure) + // profile(#procedure) current_script := harfbuzz.Script.UNKNOWN hb_ucfunc := harfbuzz.unicode_funcs_get_default() harfbuzz.buffer_clear_contents( ctx.hb_buffer )