From 2bc2d9c6f97d17744c04157a019b9f4c30709a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 21 Oct 2025 14:49:55 +0200 Subject: [PATCH 1/4] Minor UIAtlas code cleanup --- Common/Render/AtlasGen.cpp | 10 +++++----- Common/Render/AtlasGen.h | 31 ++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Common/Render/AtlasGen.cpp b/Common/Render/AtlasGen.cpp index a66c494367..20d92bff4a 100644 --- a/Common/Render/AtlasGen.cpp +++ b/Common/Render/AtlasGen.cpp @@ -123,14 +123,14 @@ std::vector Bucket::Resolve(int image_width, Image &dest) { } // Brute force packing. int sz = (int)data[i].w; - auto &masq_ty = masq.dat[ty]; - auto &masq_idy = masq.dat[ty + idy - 1]; + const auto *masq_ty = masq.line(ty); + const auto *masq_idy = masq.line(ty + idy - 1); for (int tx = 0; tx < image_width - sz; tx++) { bool valid = !(masq_ty[tx] || masq_idy[tx] || masq_ty[tx + idx - 1] || masq_idy[tx + idx - 1]); if (valid) { for (int ity = 0; ity < idy && valid; ity++) { for (int itx = 0; itx < idx && valid; itx++) { - if (masq.dat[ty + ity][tx + itx]) { + if (masq.get(tx + itx, ty + ity)) { goto skip; } } @@ -176,8 +176,8 @@ AtlasImage ToAtlasImage(int id, std::string_view name, float tw, float th, const img.u2 = results[i].ex / tw - toffx; img.v2 = results[i].ey / th - toffy; // The w and h here is the UI-pixels width/height. So if we rasterized at another DPI than 1.0f, we need to scale here. - img.w = results[i].w / results[i].scale; - img.h = results[i].h / results[i].scale; + img.w = (int)((float)results[i].w / results[i].scale); + img.h = (int)((float)results[i].h / results[i].scale); truncate_cpy(img.name, name); return img; } diff --git a/Common/Render/AtlasGen.h b/Common/Render/AtlasGen.h index 8328a62fed..ee2d4026fd 100644 --- a/Common/Render/AtlasGen.h +++ b/Common/Render/AtlasGen.h @@ -8,22 +8,35 @@ #include "Common/Render/TextureAtlas.h" struct ImageU8 { - std::vector> dat; void resize(int x, int y) { - dat.resize(y); - for (int i = 0; i < y; i++) - dat[i].resize(x); + data.resize(x * y); + w = x; + h = y; } int width() const { - return (int)dat[0].size(); + return w; } int height() const { - return (int)dat.size(); + return h; } - void set(int sx, int sy, int ex, int ey, unsigned char fil) { - for (int y = sy; y < ey; y++) - std::fill(dat[y].begin() + sx, dat[y].begin() + ex, fil); + u8 get(int x, int y) const { + return data[y * w + x]; } + void set(int sx, int sy, int ex, int ey, unsigned char value) { + for (int y = sy; y < ey; y++) { + std::fill(data.begin() + (y * w + sx), data.begin() + (y * w + ex), value); + } + } + u8 *line(int y) { + return data.data() + y * w; + } + const u8 *line(int y) const { + return data.data() + y * w; + } +private: + std::vector data; + int w; + int h; }; struct Image { From 9467643bd4952f986ef0d2c6c4e8b71a5d024c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 21 Oct 2025 15:04:15 +0200 Subject: [PATCH 2/4] Fix formatting string bug in debug overlay --- UI/DebugOverlay.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UI/DebugOverlay.cpp b/UI/DebugOverlay.cpp index 4f31d4b6e6..0a9e4386f2 100644 --- a/UI/DebugOverlay.cpp +++ b/UI/DebugOverlay.cpp @@ -143,8 +143,8 @@ static void DrawFrameTiming(UIContext *ctx, const Bounds &bounds) { "Presentation mode: %s Needs skip: %s\n" "Actual presentation mode: %s", Draw::PresentModeToString(g_frameTiming.PresentMode()), - g_frameTiming.FastForwardNeedsSkipFlip() ? "true" : "false"), - Draw::PresentModeToString(draw->GetCurrentPresentMode()); + g_frameTiming.FastForwardNeedsSkipFlip() ? "true" : "false", + Draw::PresentModeToString(draw->GetCurrentPresentMode())); ctx->Draw()->DrawTextRect(ubuntu24, statBuf, bounds.x + 10, bounds.y + 50, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); From 630529e25faeb7f85310c625228bc8eb27cca8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 22 Oct 2025 00:12:41 +0200 Subject: [PATCH 3/4] build.gradle: Don't set platform version for NDK, it's automatic --- android/build.gradle | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 0793753dd4..f9ce8a8759 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -12,7 +12,9 @@ androidGitVersion { } dependencies { - // 1.2.0 is the newest version we can use that won't complain about minSdk version. + // 1.6.1 is the newest version we can use that won't complain about minSdk version, + // and also doesn't collide kotlin versions with com.gladed.androidgitversion. Should probably + // fork and upgrade that. implementation "androidx.appcompat:appcompat:1.6.1" // Convenient wrapper around DocumentContract. Might look into writing our own @@ -133,7 +135,6 @@ android { cmake { // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html arguments '-DANDROID=true', - '-DANDROID_PLATFORM=android-21', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static' @@ -150,7 +151,6 @@ android { cmake { // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html arguments '-DANDROID=true', - '-DANDROID_PLATFORM=android-21', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', @@ -170,7 +170,6 @@ android { cmake { // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html arguments '-DANDROID=true', - '-DANDROID_PLATFORM=android-21', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', @@ -190,7 +189,6 @@ android { cmake { // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html arguments '-DANDROID=true', - '-DANDROID_PLATFORM=android-21', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', From 353bc9d8bf4bfa7f548530e7f7b22a6c3fa30dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 22 Oct 2025 00:13:00 +0200 Subject: [PATCH 4/4] Fix display of some pinned paths on Android --- UI/MainScreen.cpp | 27 ++------------------------- UI/MainScreen.h | 1 - 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 6d06cb5ae8..21e2bea382 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -920,8 +920,8 @@ void GameBrowser::Refresh() { // Add any pinned paths before other directories. auto pinnedPaths = GetPinnedPaths(); - for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) { - DirButton *pinnedDir = gameList_->Add(new DirButton(*it, GetBaseName((*it).ToString()), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT))); + for (const auto &pinnedPath : pinnedPaths) { + DirButton *pinnedDir = gameList_->Add(new DirButton(pinnedPath, pinnedPath.GetFilename(), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT))); pinnedDir->OnClick.Handle(this, &GameBrowser::NavigateClick); pinnedDir->SetPinned(true); } @@ -1008,29 +1008,6 @@ std::vector GameBrowser::GetPinnedPaths() const { return results; } -std::string GameBrowser::GetBaseName(const std::string &path) const { -#ifndef _WIN32 - static const std::string sepChars = "/"; -#else - static const std::string sepChars = "/\\"; -#endif - - auto trailing = path.find_last_not_of(sepChars); - if (trailing != path.npos) { - size_t start = path.find_last_of(sepChars, trailing); - if (start != path.npos) { - return path.substr(start + 1, trailing - start); - } - return path.substr(0, trailing); - } - - size_t start = path.find_last_of(sepChars); - if (start != path.npos) { - return path.substr(start + 1); - } - return path; -} - void GameBrowser::GameButtonClick(UI::EventParams &e) { GameButton *button = static_cast(e.v); UI::EventParams e2{}; diff --git a/UI/MainScreen.h b/UI/MainScreen.h index 4d7e653e14..2f02794510 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -74,7 +74,6 @@ protected: private: bool IsCurrentPathPinned(); std::vector GetPinnedPaths() const; - std::string GetBaseName(const std::string &path) const; void GameButtonClick(UI::EventParams &e); void GameButtonHoldClick(UI::EventParams &e);