From 227c249d7f61d3393914d83a5af6b152cc36db60 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 18 Jan 2025 22:56:15 +1000 Subject: [PATCH] FullscreenUI: Skip SVG prefix if image is not a SVG --- src/util/imgui_fullscreen.cpp | 9 +++++++++ src/util/imgui_fullscreen.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/util/imgui_fullscreen.cpp b/src/util/imgui_fullscreen.cpp index 24c7c849c..1b614ab39 100644 --- a/src/util/imgui_fullscreen.cpp +++ b/src/util/imgui_fullscreen.cpp @@ -374,6 +374,10 @@ GPUTexture* ImGuiFullscreen::GetCachedTexture(std::string_view name) GPUTexture* ImGuiFullscreen::GetCachedTexture(std::string_view name, u32 svg_width, u32 svg_height) { + // ignore size hints if it's not needed, don't duplicate + if (!TextureNeedsSVGDimensions(name)) + return GetCachedTexture(name); + svg_width = static_cast(std::ceil(LayoutScale(static_cast(svg_width)))); svg_height = static_cast(std::ceil(LayoutScale(static_cast(svg_height)))); @@ -420,6 +424,11 @@ bool ImGuiFullscreen::InvalidateCachedTexture(std::string_view path) 0); } +bool ImGuiFullscreen::TextureNeedsSVGDimensions(std::string_view path) +{ + return StringUtil::EndsWithNoCase(Path::GetExtension(path), "svg"); +} + void ImGuiFullscreen::UploadAsyncTextures() { std::unique_lock lock(s_state.shared_state_mutex); diff --git a/src/util/imgui_fullscreen.h b/src/util/imgui_fullscreen.h index 7303aef5e..0016a7b29 100644 --- a/src/util/imgui_fullscreen.h +++ b/src/util/imgui_fullscreen.h @@ -142,6 +142,7 @@ GPUTexture* GetCachedTexture(std::string_view name); GPUTexture* GetCachedTexture(std::string_view name, u32 svg_width, u32 svg_height); GPUTexture* GetCachedTextureAsync(std::string_view name); bool InvalidateCachedTexture(std::string_view path); +bool TextureNeedsSVGDimensions(std::string_view path); void UploadAsyncTextures(); void BeginLayout();