FullscreenUI: Fix invalidating images with size hints
This commit is contained in:
parent
e8a4296fd6
commit
c34dda39b7
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
|
||||||
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -85,6 +85,25 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Pred>
|
||||||
|
std::size_t RemoveMatchingItems(const Pred& pred)
|
||||||
|
{
|
||||||
|
std::size_t removed_count = 0;
|
||||||
|
for (auto iter = m_items.begin(); iter != m_items.end();)
|
||||||
|
{
|
||||||
|
if (pred(iter->first))
|
||||||
|
{
|
||||||
|
iter = m_items.erase(iter);
|
||||||
|
removed_count++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return removed_count;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename KeyT>
|
template<typename KeyT>
|
||||||
bool Remove(const KeyT& key)
|
bool Remove(const KeyT& key)
|
||||||
{
|
{
|
||||||
|
|
|
@ -413,9 +413,11 @@ GPUTexture* ImGuiFullscreen::GetCachedTextureAsync(std::string_view name)
|
||||||
return tex_ptr->get();
|
return tex_ptr->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGuiFullscreen::InvalidateCachedTexture(const std::string& path)
|
bool ImGuiFullscreen::InvalidateCachedTexture(std::string_view path)
|
||||||
{
|
{
|
||||||
return s_state.texture_cache.Remove(path);
|
// need to do a partial match on this because SVG
|
||||||
|
return (s_state.texture_cache.RemoveMatchingItems([&path](const std::string& key) { return key.starts_with(path); }) >
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiFullscreen::UploadAsyncTextures()
|
void ImGuiFullscreen::UploadAsyncTextures()
|
||||||
|
|
|
@ -141,7 +141,7 @@ std::shared_ptr<GPUTexture> LoadTexture(std::string_view path, u32 svg_width = 0
|
||||||
GPUTexture* GetCachedTexture(std::string_view name);
|
GPUTexture* GetCachedTexture(std::string_view name);
|
||||||
GPUTexture* GetCachedTexture(std::string_view name, u32 svg_width, u32 svg_height);
|
GPUTexture* GetCachedTexture(std::string_view name, u32 svg_width, u32 svg_height);
|
||||||
GPUTexture* GetCachedTextureAsync(std::string_view name);
|
GPUTexture* GetCachedTextureAsync(std::string_view name);
|
||||||
bool InvalidateCachedTexture(const std::string& path);
|
bool InvalidateCachedTexture(std::string_view path);
|
||||||
void UploadAsyncTextures();
|
void UploadAsyncTextures();
|
||||||
|
|
||||||
void BeginLayout();
|
void BeginLayout();
|
||||||
|
|
Loading…
Reference in New Issue