WIP - VEFontCache: Rendering 3k lines of whitespace ast is 16 ms rn...

This commit is contained in:
2025-01-02 17:49:39 -05:00
parent 560b2a125b
commit 73ba89e7f9
16 changed files with 538 additions and 391 deletions

View File

@ -34,6 +34,8 @@ FontProviderContext :: struct
using render : VE_RenderData,
}
ShapedText :: ve.Shaped_Text
font_provider_startup :: proc( ctx : ^FontProviderContext )
{
profile(#procedure)
@ -116,7 +118,7 @@ font_load :: proc(path_file : string,
Font_Use_Default_Size :: f32(0.0)
font_provider_resolve_draw_id :: proc( id : FontID, size := Font_Use_Default_Size ) -> (ve_id :ve.Font_ID, resolved_size : i32)
font_provider_resolve_draw_id :: #force_inline proc( id : FontID, size := Font_Use_Default_Size ) -> (ve_id :ve.Font_ID, resolved_size : i32)
{
provider_data := get_state().font_provider_ctx; using provider_data
@ -130,7 +132,7 @@ font_provider_resolve_draw_id :: proc( id : FontID, size := Font_Use_Default_Siz
return
}
measure_text_size :: proc( text : string, font : FontID, font_size := Font_Use_Default_Size, spacing : f32 ) -> Vec2
measure_text_size :: #force_inline proc( text : string, font : FontID, font_size := Font_Use_Default_Size, spacing : f32 ) -> Vec2
{
ve_id, size := font_provider_resolve_draw_id( font, font_size )
measured := ve.measure_text_size( & get_state().font_provider_ctx.ve_ctx, ve_id, text )
@ -143,3 +145,10 @@ get_font_vertical_metrics :: #force_inline proc ( font : FontID, font_size := Fo
ascent, descent, line_gap = ve.get_font_vertical_metrics( & get_state().font_provider_ctx.ve_ctx, ve_id )
return
}
shape_text_cached :: #force_inline proc( text : string, font : FontID, font_size := Font_Use_Default_Size, scalar : f32 ) -> ShapedText
{
ve_id, size := font_provider_resolve_draw_id( font, font_size * scalar )
shape := ve.shape_text_advanced( & get_state().font_provider_ctx.ve_ctx, ve_id, text )
return shape
}