test: stabilize rendering and benchmarks

This commit is contained in:
scawful
2025-12-22 14:53:35 -05:00
parent 2c72709003
commit 572bfe5df7
7 changed files with 176 additions and 38 deletions

View File

@@ -37,6 +37,10 @@ void Arena::QueueTextureCommand(TextureCommandType type, Bitmap* bitmap) {
texture_command_queue_.push_back({type, bitmap, gen});
}
void Arena::ClearTextureQueue() {
texture_command_queue_.clear();
}
bool Arena::ProcessSingleTexture(IRenderer* renderer) {
IRenderer* active_renderer = renderer ? renderer : renderer_;
if (!active_renderer || texture_command_queue_.empty()) {

View File

@@ -60,6 +60,7 @@ class Arena {
void QueueTextureCommand(TextureCommandType type, Bitmap* bitmap);
void ProcessTextureQueue(IRenderer* renderer);
void ClearTextureQueue();
/**
* @brief Check if there are pending textures to process

View File

@@ -28,29 +28,45 @@ static const float ICON_FONT_SIZE = 18.0F;
namespace {
std::string SetFontPath(const std::string& font_path) {
#ifdef __APPLE__
#if TARGET_OS_IOS == 1
const std::string kBundlePath = util::GetBundleResourcePath();
return kBundlePath + font_path;
#else
return absl::StrCat(util::GetBundleResourcePath(), "Contents/Resources/font/",
font_path);
#endif
#else
return absl::StrCat("assets/font/", font_path);
#endif
}
std::string SetFontPath(const std::string& font_path) {
#ifdef __APPLE__
#if TARGET_OS_IOS == 1
const std::string kBundlePath = util::GetBundleResourcePath();
return kBundlePath + font_path;
#else
std::string bundle_path = absl::StrCat(
util::GetBundleResourcePath(), "Contents/Resources/font/", font_path);
if (std::filesystem::exists(bundle_path)) {
return bundle_path;
}
return absl::StrCat("assets/font/", font_path);
#endif
#else
return absl::StrCat("assets/font/", font_path);
#endif
}
absl::Status LoadFont(const FontConfig& font_config) {
ImGuiIO& imgui_io = ImGui::GetIO();
std::string actual_font_path = SetFontPath(font_config.font_path);
// Check if the file exists with std library first, since ImGui IO will assert
// if the file does not exist
if (!std::filesystem::exists(actual_font_path)) {
return absl::InternalError(
absl::StrFormat("Font file %s does not exist", actual_font_path));
}
absl::Status LoadFont(const FontConfig& font_config) {
ImGuiIO& imgui_io = ImGui::GetIO();
std::string actual_font_path = SetFontPath(font_config.font_path);
// Check if the file exists with std library first, since ImGui IO will assert
// if the file does not exist
if (!std::filesystem::exists(actual_font_path)) {
#ifdef __APPLE__
// Allow CLI/test runs to use repo assets when no app bundle is present.
std::string fallback_path =
absl::StrCat("assets/font/", font_config.font_path);
if (std::filesystem::exists(fallback_path)) {
actual_font_path = fallback_path;
} else {
return absl::InternalError(
absl::StrFormat("Font file %s does not exist", actual_font_path));
}
#else
return absl::InternalError(
absl::StrFormat("Font file %s does not exist", actual_font_path));
#endif
}
if (!imgui_io.Fonts->AddFontFromFileTTF(actual_font_path.data(),
font_config.font_size)) {