diff --git a/examples/sokol_demo/sokol_demo.odin b/examples/sokol_demo/sokol_demo.odin index 0ba03c7..da47211 100644 --- a/examples/sokol_demo/sokol_demo.odin +++ b/examples/sokol_demo/sokol_demo.odin @@ -707,7 +707,7 @@ etiam dignissim diam quis enim. Convallis convallis tellus id interdum.` cleanup :: proc "c" () { context = runtime.default_context() - // ve.shutdown( & demo_ctx.ve_ctx ) + ve.shutdown( & demo_ctx.ve_ctx ) gfx.shutdown() } diff --git a/scripts/build_sokol_demo.ps1 b/scripts/build_sokol_demo.ps1 index 6ca8021..d9cdbde 100644 --- a/scripts/build_sokol_demo.ps1 +++ b/scripts/build_sokol_demo.ps1 @@ -94,11 +94,11 @@ function build-SokolBackendDemo # $build_args += $flag_micro_architecture_native $build_args += $flag_use_separate_modules $build_args += $flag_thread_count + $CoreCount_Physical - $build_args += $flag_optimize_none + # $build_args += $flag_optimize_none # $build_args += $flag_optimize_minimal # $build_args += $flag_optimize_speed - # $build_args += $falg_optimize_aggressive - $build_args += $flag_debug + $build_args += $falg_optimize_aggressive + # $build_args += $flag_debug $build_args += $flag_pdb_name + $pdb $build_args += $flag_subsystem + 'windows' # $build_args += ($flag_extra_linker_flags + $linker_args ) diff --git a/vefontcache/LRU.odin b/vefontcache/LRU.odin index 1e624d0..69b2615 100644 --- a/vefontcache/LRU.odin +++ b/vefontcache/LRU.odin @@ -54,7 +54,8 @@ pool_list_init :: proc( pool : ^PoolList, capacity : i32, dbg_name : string = "" } pool_list_free :: proc( pool : ^PoolList ) { - // TODO(Ed): Implement + delete( pool.items) + delete( pool.free_list) } pool_list_reload :: proc( pool : ^PoolList, allocator : Allocator ) { @@ -174,7 +175,8 @@ LRU_init :: proc( cache : ^LRU_Cache, capacity : i32, dbg_name : string = "" ) { } LRU_free :: proc( cache : ^LRU_Cache ) { - // TODO(Ed): Implement + pool_list_free( & cache.key_queue ) + delete( cache.table ) } LRU_reload :: #force_inline proc( cache : ^LRU_Cache, allocator : Allocator ) { diff --git a/vefontcache/draw.odin b/vefontcache/draw.odin index 85922d5..0641a6b 100644 --- a/vefontcache/draw.odin +++ b/vefontcache/draw.odin @@ -98,7 +98,7 @@ cache_glyph_freetype :: proc(ctx: ^Context, font: FontID, glyph_index: Glyph, en debug_print_verbose : b32 = false ) { - if debug_print_verbose { + if debug_print_verbose { log("outline_path:") for point in path { vec := point.pos * scale + translate @@ -198,9 +198,10 @@ cache_glyph_freetype :: proc(ctx: ^Context, font: FontID, glyph_index: Glyph, en if idx < end_index - 1 { // perform interp from prev_point to current_pos via midpoint - for t : f32 = 0.0; t <= 1.0; t += 1.0 / f32(entry.curve_quality) + step := 1.0 / entry.curve_quality + for alpha : f32 = 0.0; alpha <= 1.0; alpha += step { - bezier_point := eval_point_on_bezier3( prev_point, midpoint, current_pos, t ) + bezier_point := eval_point_on_bezier3( prev_point, midpoint, current_pos, alpha ) append( path, Vertex{ pos = bezier_point } ) } } diff --git a/vefontcache/shaper.odin b/vefontcache/shaper.odin index 78ba086..ecc8495 100644 --- a/vefontcache/shaper.odin +++ b/vefontcache/shaper.odin @@ -13,7 +13,6 @@ ShaperKind :: enum { ShaperContext :: struct { hb_buffer : harfbuzz.Buffer, - // infos : HMapChained(ShaperInfo), } ShaperInfo :: struct { @@ -26,10 +25,6 @@ shaper_init :: proc( ctx : ^ShaperContext ) { ctx.hb_buffer = harfbuzz.buffer_create() assert( ctx.hb_buffer != nil, "VEFontCache.shaper_init: Failed to create harfbuzz buffer") - - // error : AllocatorError - // ctx.infos, error = make( HMapChained(ShaperInfo), 256 ) - // assert( error == .None, "VEFontCache.shaper_init: Failed to create shaper infos map" ) } shaper_shutdown :: proc( ctx : ^ShaperContext ) @@ -37,20 +32,10 @@ shaper_shutdown :: proc( ctx : ^ShaperContext ) if ctx.hb_buffer != nil { harfbuzz.buffer_destroy( ctx.hb_buffer ) } - - // delete(& ctx.infos) } shaper_load_font :: proc( ctx : ^ShaperContext, label : string, data : []byte, user_data : rawptr ) -> (info : ShaperInfo) { - // key := font_key_from_label( label ) - // info = get( ctx.infos, key ) - // if info != nil do return - - // error : AllocatorError - // info, error = set( ctx.infos, key, ShaperInfo {} ) - // assert( error == .None, "VEFontCache.parser_load_font: Failed to set a new shaper info" ) - using info blob = harfbuzz.blob_create( raw_data(data), cast(c.uint) len(data), harfbuzz.Memory_Mode.READONLY, user_data, nil ) face = harfbuzz.face_create( blob, 0 ) diff --git a/vefontcache/vefontcache.odin b/vefontcache/vefontcache.odin index 234349b..6475326 100644 --- a/vefontcache/vefontcache.odin +++ b/vefontcache/vefontcache.odin @@ -322,9 +322,38 @@ shutdown :: proc( ctx : ^Context ) unload_font( ctx, entry.id ) } - shaper_shutdown( & shaper_ctx ) + delete( entries ) + delete( temp_path ) + delete( temp_codepoint_seen ) - // TODO(Ed): Finish implementing, there is quite a few resource not released here. + delete( draw_list.vertices ) + delete( draw_list.indices ) + delete( draw_list.calls ) + + LRU_free( & atlas.region_a.state ) + LRU_free( & atlas.region_b.state ) + LRU_free( & atlas.region_c.state ) + LRU_free( & atlas.region_d.state ) + + for idx : i32 = 0; idx < i32(len(shape_cache.storage)); idx += 1 { + stroage_entry := & shape_cache.storage[idx] + using stroage_entry + + delete( glyphs ) + delete( positions ) + } + LRU_free( & shape_cache.state ) + + delete( glyph_buffer.draw_list.vertices ) + delete( glyph_buffer.draw_list.indices ) + delete( glyph_buffer.draw_list.calls ) + + delete( glyph_buffer.clear_draw_list.vertices ) + delete( glyph_buffer.clear_draw_list.indices ) + delete( glyph_buffer.clear_draw_list.calls ) + + shaper_shutdown( & shaper_ctx ) + parser_shutdown( & parser_ctx ) } // ve_fontcache_load