mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-21 11:14:59 -07:00
eliminate a bit of duplicate font cache lookups in code view build, + eliminate unnecessary per-box color lookups
This commit is contained in:
@@ -849,7 +849,10 @@ e_irtree_from_bundle(E_CacheBundle *bundle)
|
||||
bundle->flags |= E_CacheBundleFlag_IRTree;
|
||||
E_IRTreeAndType parent = e_irtree_from_key(bundle->parent_key);
|
||||
E_Parse parse = e_parse_from_bundle(bundle);
|
||||
bundle->irtree = e_push_irtree_and_type_from_expr(e_cache->arena, &parent, &e_default_identifier_resolution_rule, 0, 0, parse.expr);
|
||||
ProfScope("irtree generation for '%.*s'", str8_varg(bundle->string))
|
||||
{
|
||||
bundle->irtree = e_push_irtree_and_type_from_expr(e_cache->arena, &parent, &e_default_identifier_resolution_rule, 0, 0, parse.expr);
|
||||
}
|
||||
E_MsgList msgs_copy = e_msg_list_copy(e_cache->arena, &bundle->irtree.msgs);
|
||||
e_msg_list_concat_in_place(&bundle->msgs, &msgs_copy);
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ fp_font_open(String8 path)
|
||||
DWORD data_size = sizeof(data);
|
||||
DWORD type = 0;
|
||||
status = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Fonts", 0, KEY_QUERY_VALUE, ®_key);
|
||||
status = RegEnumValueA(reg_key, 0, name, &name_size, 0, &type, data, &data_size);
|
||||
status = RegEnumValueA(reg_key, 0, name, &name_size, 0, &type, (unsigned char *)data, &data_size);
|
||||
String8 user_fonts_path = str8_cstring(data);
|
||||
PathTask *task = push_array(scratch.arena, PathTask, 1);
|
||||
task->path = push_str8f(scratch.arena, "%s/%S", user_fonts_path, path);
|
||||
|
||||
@@ -1443,7 +1443,7 @@ win32_exception_filter(EXCEPTION_POINTERS* exception_ptrs)
|
||||
buflen += wnsprintfW(buffer + buflen, ArrayCount(buffer) - buflen, L"A fatal exception (code 0x%x) occurred. The process is terminating.\n", exception_code);
|
||||
|
||||
// load dbghelp dynamically just in case if it is missing
|
||||
BOOL (WINAPI *dbg_MiniDumpWriteDump)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE DumpType, PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
BOOL (WINAPI *dbg_MiniDumpWriteDump)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE DumpType, PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, PMINIDUMP_CALLBACK_INFORMATION CallbackParam) = 0;
|
||||
HMODULE dbghelp = LoadLibraryA("dbghelp.dll");
|
||||
if(dbghelp)
|
||||
{
|
||||
|
||||
+68
-64
@@ -1241,6 +1241,71 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
||||
pop_color = ui_color_from_name(str8_lit("background"));
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: produce fancy strings for each line
|
||||
//
|
||||
DR_FStrList *lines_fstrs = push_array(scratch.arena, DR_FStrList, dim_1s64(params->line_num_range)+1);
|
||||
{
|
||||
DR_FStrParams fstr_params =
|
||||
{
|
||||
params->font,
|
||||
rd_raster_flags_from_slot(RD_FontSlot_Code),
|
||||
rd_rgba_from_code_color_slot(RD_CodeColorSlot_CodeDefault),
|
||||
params->font_size,
|
||||
};
|
||||
U64 line_idx = 0;
|
||||
for(S64 line_num = params->line_num_range.min;
|
||||
line_num < params->line_num_range.max;
|
||||
line_num += 1, line_idx += 1)
|
||||
{
|
||||
String8 line_string = params->line_text[line_idx];
|
||||
Rng1U64 line_range = params->line_ranges[line_idx];
|
||||
TXT_TokenArray *line_tokens = ¶ms->line_tokens[line_idx];
|
||||
DR_FStrList fstrs = {0};
|
||||
if(line_tokens->count == 0)
|
||||
{
|
||||
dr_fstrs_push_new(scratch.arena, &fstrs, &fstr_params, line_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
TXT_Token *line_tokens_first = line_tokens->v;
|
||||
TXT_Token *line_tokens_opl = line_tokens->v + line_tokens->count;
|
||||
for(TXT_Token *token = line_tokens_first; token < line_tokens_opl; token += 1)
|
||||
{
|
||||
// rjf: token -> token string
|
||||
String8 token_string = {0};
|
||||
{
|
||||
Rng1U64 token_range = r1u64(0, line_string.size);
|
||||
if(token->range.min > line_range.min)
|
||||
{
|
||||
token_range.min += token->range.min-line_range.min;
|
||||
}
|
||||
if(token->range.max < line_range.max)
|
||||
{
|
||||
token_range.max = token->range.max-line_range.min;
|
||||
}
|
||||
token_string = str8_substr(line_string, token_range);
|
||||
}
|
||||
|
||||
// rjf: token -> token color
|
||||
RD_CodeColorSlot token_color_slot = rd_code_color_slot_from_txt_token_kind(token->kind);
|
||||
RD_CodeColorSlot lookup_color_slot = rd_code_color_slot_from_txt_token_kind_lookup_string(token->kind, token_string);
|
||||
Vec4F32 token_color = rd_rgba_from_code_color_slot(token_color_slot);
|
||||
if(lookup_color_slot != RD_CodeColorSlot_CodeDefault)
|
||||
{
|
||||
Vec4F32 lookup_color = rd_rgba_from_code_color_slot(lookup_color_slot);
|
||||
F32 lookup_color_mix_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "%S_lookup", token_string), 1.f);
|
||||
token_color = mix_4f32(token_color, lookup_color, lookup_color_mix_t);
|
||||
}
|
||||
|
||||
// rjf: push fancy string
|
||||
dr_fstrs_push_new(scratch.arena, &fstrs, &fstr_params, token_string, .color = token_color);
|
||||
}
|
||||
}
|
||||
lines_fstrs[line_idx] = fstrs;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: build top-level container
|
||||
//
|
||||
@@ -1885,8 +1950,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
||||
line_num < params->line_num_range.max;
|
||||
line_num += 1, line_idx += 1)
|
||||
{
|
||||
String8 line_text = params->line_text[line_idx];
|
||||
F32 line_text_dim = fnt_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, line_text).x + params->line_num_width_px + params->catchall_margin_width_px + params->priority_margin_width_px;
|
||||
DR_FStrList line_fstrs = lines_fstrs[line_idx];
|
||||
F32 line_text_dim = dr_dim_from_fstrs(&line_fstrs).x + params->line_num_width_px + params->catchall_margin_width_px + params->priority_margin_width_px;
|
||||
line_extras_off[line_idx] = Max(line_text_dim, params->font_size*30);
|
||||
}
|
||||
}
|
||||
@@ -2445,7 +2510,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
||||
{
|
||||
String8 line_string = params->line_text[line_idx];
|
||||
Rng1U64 line_range = params->line_ranges[line_idx];
|
||||
TXT_TokenArray *line_tokens = ¶ms->line_tokens[line_idx];
|
||||
DR_FStrList line_fstrs = lines_fstrs[line_idx];
|
||||
ui_set_next_text_padding(line_num_padding_px);
|
||||
UI_Key line_key = ui_key_from_stringf(top_container_box->key, "ln_%I64x", line_num);
|
||||
Vec4F32 line_bg_color = line_bg_colors[line_idx];
|
||||
@@ -2458,67 +2523,6 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
||||
UI_Box *line_box = ui_build_box_from_key(UI_BoxFlag_DisableTextTrunc|UI_BoxFlag_DrawText|UI_BoxFlag_DisableIDString, line_key);
|
||||
DR_Bucket *line_bucket = dr_bucket_make();
|
||||
dr_push_bucket(line_bucket);
|
||||
|
||||
// rjf: string * tokens -> fancy string list
|
||||
DR_FStrList line_fstrs = {0};
|
||||
{
|
||||
if(line_tokens->count == 0)
|
||||
{
|
||||
DR_FStrParams fstr_params =
|
||||
{
|
||||
params->font,
|
||||
ui_top_text_raster_flags(),
|
||||
rd_rgba_from_code_color_slot(RD_CodeColorSlot_CodeDefault),
|
||||
params->font_size,
|
||||
};
|
||||
dr_fstrs_push_new(scratch.arena, &line_fstrs, &fstr_params, line_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
TXT_Token *line_tokens_first = line_tokens->v;
|
||||
TXT_Token *line_tokens_opl = line_tokens->v + line_tokens->count;
|
||||
for(TXT_Token *token = line_tokens_first; token < line_tokens_opl; token += 1)
|
||||
{
|
||||
// rjf: token -> token string
|
||||
String8 token_string = {0};
|
||||
{
|
||||
Rng1U64 token_range = r1u64(0, line_string.size);
|
||||
if(token->range.min > line_range.min)
|
||||
{
|
||||
token_range.min += token->range.min-line_range.min;
|
||||
}
|
||||
if(token->range.max < line_range.max)
|
||||
{
|
||||
token_range.max = token->range.max-line_range.min;
|
||||
}
|
||||
token_string = str8_substr(line_string, token_range);
|
||||
}
|
||||
|
||||
// rjf: token -> token color
|
||||
RD_CodeColorSlot token_color_slot = rd_code_color_slot_from_txt_token_kind(token->kind);
|
||||
RD_CodeColorSlot lookup_color_slot = rd_code_color_slot_from_txt_token_kind_lookup_string(token->kind, token_string);
|
||||
Vec4F32 token_color = rd_rgba_from_code_color_slot(token_color_slot);
|
||||
if(lookup_color_slot != RD_CodeColorSlot_CodeDefault)
|
||||
{
|
||||
Vec4F32 lookup_color = rd_rgba_from_code_color_slot(lookup_color_slot);
|
||||
F32 lookup_color_mix_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "%S_lookup", token_string), 1.f);
|
||||
token_color = mix_4f32(token_color, lookup_color, lookup_color_mix_t);
|
||||
}
|
||||
|
||||
// rjf: push fancy string
|
||||
DR_FStrParams fstr_params =
|
||||
{
|
||||
params->font,
|
||||
ui_top_text_raster_flags(),
|
||||
token_color,
|
||||
params->font_size,
|
||||
};
|
||||
dr_fstrs_push_new(scratch.arena, &line_fstrs, &fstr_params, token_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: equip fancy strings to line box
|
||||
ui_box_equip_display_fstrs(line_box, &line_fstrs);
|
||||
|
||||
// rjf: extra rendering for strings that are currently being searched for
|
||||
|
||||
+18
-12
@@ -2584,21 +2584,27 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key)
|
||||
{
|
||||
box->tags_key = ui_state->tags_key_stack_top->key;
|
||||
}
|
||||
if(ui_state->background_color_stack.top != &ui_state->background_color_nil_stack_top)
|
||||
if(box->flags & UI_BoxFlag_DrawBackground)
|
||||
{
|
||||
box->background_color = ui_state->background_color_stack.top->v;
|
||||
if(ui_state->background_color_stack.top != &ui_state->background_color_nil_stack_top)
|
||||
{
|
||||
box->background_color = ui_state->background_color_stack.top->v;
|
||||
}
|
||||
else
|
||||
{
|
||||
box->background_color = ui_color_from_name(str8_lit("background"));
|
||||
}
|
||||
}
|
||||
else
|
||||
if(box->flags & UI_BoxFlag_DrawText)
|
||||
{
|
||||
box->background_color = ui_color_from_name(str8_lit("background"));
|
||||
}
|
||||
if(ui_state->text_color_stack.top != &ui_state->text_color_nil_stack_top)
|
||||
{
|
||||
box->text_color = ui_state->text_color_stack.top->v;
|
||||
}
|
||||
else
|
||||
{
|
||||
box->text_color = ui_color_from_name(str8_lit("text"));
|
||||
if(ui_state->text_color_stack.top != &ui_state->text_color_nil_stack_top)
|
||||
{
|
||||
box->text_color = ui_state->text_color_stack.top->v;
|
||||
}
|
||||
else
|
||||
{
|
||||
box->text_color = ui_color_from_name(str8_lit("text"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user