Invert the relationship for loading atlas textures

This commit is contained in:
Henrik Rydgård committed 2025-09-15 12:42:11 -06:00
1 parent 947ddf865f
commit daa593bdcb
5 files changed
+69 -20

No files matched your search

+36
View File
@@ -87,6 +87,7 @@
#include "Common/VR/PPSSPPVR.h"
#include "Common/Thread/ThreadManager.h"
#include "Common/Audio/AudioBackend.h"
#include "Common/Render/ManagedTexture.h"
#include "Core/ControlMapper.h"
#include "Core/Config.h"
@@ -820,6 +821,40 @@ static void NativeMixWrapper(float *dest, int framesToWrite, int sampleRateHz, v
}
}
static AtlasData AtlasProvider(Draw::DrawContext *draw, AtlasChoice atlas) {
switch (atlas) {
case AtlasChoice::General:
return {
GetUIAtlas(),
CreateTextureFromFile(draw, "ui_atlas.zim", ImageFileType::ZIM, false)
};
case AtlasChoice::Font:
{
Draw::Texture *fontTexture = nullptr;
// NOTE: This ugly check must be the same as the one in UpdateTheme. This will be fixed.
#if PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
// Don't bother with loading font_atlas.zim
#else
fontTexture = CreateTextureFromFile(draw_, "font_atlas.zim", ImageFileType::ZIM, false);
#endif
if (!fontTexture) {
// Load the smaller ascii font only, like on Android. For debug ui etc.
// NOTE: We better be sure here that the correct metadata is loaded..
fontTexture = CreateTextureFromFile(draw, "asciifont_atlas.zim", ImageFileType::ZIM, false);
if (!fontTexture) {
WARN_LOG(Log::System, "Failed to load font_atlas.zim or asciifont_atlas.zim");
}
}
return {
GetFontAtlas(),
fontTexture,
};
}
default:
return {};
};
}
bool NativeInitGraphics(GraphicsContext *graphicsContext) {
INFO_LOG(Log::System, "NativeInitGraphics");
@@ -843,6 +878,7 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
uiContext = new UIContext();
uiContext->SetTheme(GetTheme());
uiContext->SetAtlasProvider(&AtlasProvider);
UpdateTheme();
ui_draw2d.Init(g_draw, texColorPipeline);