Skip to content

Commit

Permalink
FullscreenUI: Skip SVG prefix if image is not a SVG
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jan 18, 2025
1 parent c34dda3 commit 227c249
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/util/imgui_fullscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>(std::ceil(LayoutScale(static_cast<float>(svg_width))));
svg_height = static_cast<u32>(std::ceil(LayoutScale(static_cast<float>(svg_height))));

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/util/imgui_fullscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 227c249

Please sign in to comment.