This commit is contained in:
2024-07-02 01:42:32 -04:00
parent 9d18a43f64
commit 0f4ad9bdd1
6 changed files with 43 additions and 26 deletions

View File

@@ -707,7 +707,7 @@ etiam dignissim diam quis enim. Convallis convallis tellus id interdum.`
cleanup :: proc "c" () { cleanup :: proc "c" () {
context = runtime.default_context() context = runtime.default_context()
// ve.shutdown( & demo_ctx.ve_ctx ) ve.shutdown( & demo_ctx.ve_ctx )
gfx.shutdown() gfx.shutdown()
} }

View File

@@ -94,11 +94,11 @@ function build-SokolBackendDemo
# $build_args += $flag_micro_architecture_native # $build_args += $flag_micro_architecture_native
$build_args += $flag_use_separate_modules $build_args += $flag_use_separate_modules
$build_args += $flag_thread_count + $CoreCount_Physical $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_minimal
# $build_args += $flag_optimize_speed # $build_args += $flag_optimize_speed
# $build_args += $falg_optimize_aggressive $build_args += $falg_optimize_aggressive
$build_args += $flag_debug # $build_args += $flag_debug
$build_args += $flag_pdb_name + $pdb $build_args += $flag_pdb_name + $pdb
$build_args += $flag_subsystem + 'windows' $build_args += $flag_subsystem + 'windows'
# $build_args += ($flag_extra_linker_flags + $linker_args ) # $build_args += ($flag_extra_linker_flags + $linker_args )

View File

@@ -54,7 +54,8 @@ pool_list_init :: proc( pool : ^PoolList, capacity : i32, dbg_name : string = ""
} }
pool_list_free :: proc( pool : ^PoolList ) { pool_list_free :: proc( pool : ^PoolList ) {
// TODO(Ed): Implement delete( pool.items)
delete( pool.free_list)
} }
pool_list_reload :: proc( pool : ^PoolList, allocator : Allocator ) { 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 ) { 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 ) { LRU_reload :: #force_inline proc( cache : ^LRU_Cache, allocator : Allocator ) {

View File

@@ -198,9 +198,10 @@ cache_glyph_freetype :: proc(ctx: ^Context, font: FontID, glyph_index: Glyph, en
if idx < end_index - 1 if idx < end_index - 1
{ {
// perform interp from prev_point to current_pos via midpoint // 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 } ) append( path, Vertex{ pos = bezier_point } )
} }
} }

View File

@@ -13,7 +13,6 @@ ShaperKind :: enum {
ShaperContext :: struct { ShaperContext :: struct {
hb_buffer : harfbuzz.Buffer, hb_buffer : harfbuzz.Buffer,
// infos : HMapChained(ShaperInfo),
} }
ShaperInfo :: struct { ShaperInfo :: struct {
@@ -26,10 +25,6 @@ shaper_init :: proc( ctx : ^ShaperContext )
{ {
ctx.hb_buffer = harfbuzz.buffer_create() ctx.hb_buffer = harfbuzz.buffer_create()
assert( ctx.hb_buffer != nil, "VEFontCache.shaper_init: Failed to create harfbuzz buffer") 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 ) shaper_shutdown :: proc( ctx : ^ShaperContext )
@@ -37,20 +32,10 @@ shaper_shutdown :: proc( ctx : ^ShaperContext )
if ctx.hb_buffer != nil { if ctx.hb_buffer != nil {
harfbuzz.buffer_destroy( ctx.hb_buffer ) harfbuzz.buffer_destroy( ctx.hb_buffer )
} }
// delete(& ctx.infos)
} }
shaper_load_font :: proc( ctx : ^ShaperContext, label : string, data : []byte, user_data : rawptr ) -> (info : ShaperInfo) 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 using info
blob = harfbuzz.blob_create( raw_data(data), cast(c.uint) len(data), harfbuzz.Memory_Mode.READONLY, user_data, nil ) 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 ) face = harfbuzz.face_create( blob, 0 )

View File

@@ -322,9 +322,38 @@ shutdown :: proc( ctx : ^Context )
unload_font( ctx, entry.id ) 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 // ve_fontcache_load