Minor adjustment / cleanup (VEFontCache)

This commit is contained in:
Edward R. Gonzalez 2024-12-29 18:26:34 -05:00
parent 7488a6828e
commit 9da86c1f4b
3 changed files with 6 additions and 24 deletions

View File

@ -207,9 +207,6 @@ lru_reload :: #force_inline proc( cache : ^LRU_Cache, allocator : Allocator ) {
}
lru_clear :: proc ( cache : ^LRU_Cache ) {
for key, value in cache.table {
cache.table[key] = {}
}
pool_list_clear( & cache.key_queue )
clear(& cache.table)
cache.num = 0

View File

@ -391,14 +391,10 @@ cache_glyph_to_atlas :: proc( ctx : ^Context,
// Draw oversized glyph to glyph render target (FBO)
glyph_draw_scale := over_sample * entry.size_scale
glyph_draw_translate := -1 * vbounds_0 * glyph_draw_scale + vec2( glyph_padding )
// glyph_draw_translate.x = cast(f32) (i32(glyph_draw_translate.x + 0.9999999))
// glyph_draw_translate.y = cast(f32) (i32(glyph_draw_translate.y + 0.9999999))
// glyph_draw_translate = floor(glyph_draw_translate)
// glyph_draw_translate = ceil(glyph_draw_translate)
// Allocate a glyph glyph render target region (FBO)
gwidth_scaled_px := bounds_size.x * glyph_draw_scale.x + over_sample.x * glyph_padding + 1.0
if i32(f32(glyph_buffer.batch_x) + gwidth_scaled_px) >= i32(glyph_buffer.width) {
if i32(f32(glyph_buffer.batch_x) + gwidth_scaled_px) >= i32(glyph_buffer.width) {
flush_glyph_buffer_to_atlas( ctx )
}
@ -406,7 +402,7 @@ cache_glyph_to_atlas :: proc( ctx : ^Context,
slot_position, slot_size := atlas_bbox( atlas, region_kind, atlas_index )
dst_glyph_position := slot_position
dst_glyph_size := ceil(bounds_size * entry.size_scale + glyph_padding)
dst_glyph_size := (bounds_size * entry.size_scale + glyph_padding)
dst_size := (slot_size)
screenspace_x_form( & dst_glyph_position, & dst_glyph_size, atlas_size )
screenspace_x_form( & slot_position, & dst_size, atlas_size )
@ -530,7 +526,7 @@ directly_draw_massive_glyph :: proc( ctx : ^Context,
glyph_size += bounds_scaled * over_sample
// Figure out the destination rect.
bounds_0_scaled := floor(bounds_0 * entry.size_scale - 0.5)
bounds_0_scaled := (bounds_0 * entry.size_scale)
dst := position + scale * bounds_0_scaled - glyph_padding * scale
dst_size := glyph_dst_size * scale
textspace_x_form( & glyph_position, & glyph_size, glyph_buffer_size )

View File

@ -554,30 +554,19 @@ clear_atlas_region_caches :: proc(ctx : ^Context)
// Can be used with hot-reload
clear_shape_cache :: proc (ctx : ^Context)
{
lru_clear(& ctx.shape_cache.state)
using ctx
for idx : i32 = 0; idx < cast(i32) cap(shape_cache.storage); idx += 1 {
lru_clear(& shape_cache.state)
for idx : i32 = 0; idx < cast(i32) cap(shape_cache.storage); idx += 1
{
stroage_entry := & shape_cache.storage[idx]
using stroage_entry
end_cursor_pos = {}
size = {}
clear(& glyphs)
// fill(glyphs[:], 0)
clear(& positions)
// fill(positions[:], 0)
clear(& draw_list.calls)
// fill(draw_list.calls[:], Draw_Call{})
clear(& draw_list.indices)
// fill(draw_list.indices[:], 0)
clear(& draw_list.vertices)
// fill(draw_list.vertices[:], Vertex{})
}
ctx.shape_cache.next_cache_id = 0
}