ImGuiOverlays: Draw larger status indicator icons

Always bugged me, but couldn't justify the rasterization time before
dynamic fonts.
This commit is contained in:
Stenzek 2025-06-14 13:25:11 +10:00
parent bf4a89e82e
commit b98d521ff9
No known key found for this signature in database
3 changed files with 17 additions and 6 deletions

View File

@ -272,7 +272,6 @@ void ImGuiManager::RenderTextOverlays(const GPUBackend* gpu)
const float spacing = ImCeil(5.0f * scale);
float position_y = ImFloor(f_margin);
DrawPerformanceOverlay(gpu, position_y, scale, margin, spacing);
DrawFrameTimeOverlay(position_y, scale, margin, spacing);
DrawMediaCaptureOverlay(position_y, scale, margin, spacing);
if (g_gpu_settings.display_show_enhancements && !paused)
@ -321,12 +320,15 @@ static void DrawPerformanceStat(ImDrawList* dl, float& position_y, ImFont* font,
const size_t len = sv.length();
for (; pos < len; pos++)
{
if (sv[pos] <= '\x04')
if (sv[pos] > 0 && sv[pos] <= '\x04')
break;
}
return pos;
};
if (text.empty())
return;
constexpr ImU32 color = IM_COL32(255, 255, 255, 255);
constexpr float default_weight = 0.0f;
std::string_view::size_type pos = 0;
@ -426,10 +428,10 @@ void ImGuiManager::DrawPerformanceOverlay(const GPUBackend* gpu, float& position
}
const float shadow_offset = std::ceil(1.0f * scale);
const float status_size = std::ceil(40.0f * scale);
ImFont* const fixed_font = ImGuiManager::GetFixedFont();
const float fixed_font_size = ImGuiManager::GetFixedFontSize();
ImFont* ui_font = ImGuiManager::GetTextFont();
const float ui_font_size = ImGuiManager::GetOSDFontSize();
const float rbound = ImGui::GetIO().DisplaySize.x - margin;
ImDrawList* dl = ImGui::GetBackgroundDrawList();
SmallString text;
@ -598,17 +600,18 @@ void ImGuiManager::DrawPerformanceOverlay(const GPUBackend* gpu, float& position
position_y += spacing;
}
DrawFrameTimeOverlay(position_y, scale, margin, spacing);
if (g_gpu_settings.display_show_status_indicators)
{
SetStatusIndicatorIcons(text, false);
if (!text.empty())
DRAW_LINE(ui_font, text, IM_COL32(255, 255, 255, 255));
DrawPerformanceStat(dl, position_y, ui_font, status_size, 0.0f, 0, shadow_offset, rbound, text);
}
}
else if (g_gpu_settings.display_show_status_indicators && !FullscreenUI::HasActiveWindow())
{
SetStatusIndicatorIcons(text, true);
DRAW_LINE(ui_font, text, IM_COL32(255, 255, 255, 255));
DrawPerformanceStat(dl, position_y, ui_font, status_size, 0.0f, 0, shadow_offset, rbound, text);
}
#undef DRAW_LINE

View File

@ -1264,6 +1264,11 @@ float ImGuiManager::GetOSDFontSize()
return std::ceil(17.0f * s_state.global_scale);
}
float ImGuiManager::OSDScale(float size)
{
return std::ceil(size * s_state.global_scale);
}
bool ImGuiManager::WantsTextInput()
{
return s_state.imgui_wants_keyboard.load(std::memory_order_acquire);

View File

@ -140,6 +140,9 @@ float GetDebugFontSize(float window_scale);
/// Returns the font size for rendering the OSD.
float GetOSDFontSize();
/// Multiplies an arbitrary size by the OSD scale.
float OSDScale(float size);
/// Returns true if imgui wants to intercept text input.
bool WantsTextInput();