From 0b9d6f9cb07167066e3746210639452f9af40e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 16 Sep 2022 10:23:32 +0200 Subject: [PATCH] Log the screen tag when logging scissor errors. --- Common/UI/Context.cpp | 2 +- Common/UI/Context.h | 7 ++++++- Common/UI/UIScreen.cpp | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Common/UI/Context.cpp b/Common/UI/Context.cpp index e9fe8ed0c500..21c687bd2b7d 100644 --- a/Common/UI/Context.cpp +++ b/Common/UI/Context.cpp @@ -170,7 +170,7 @@ void UIContext::ActivateTopScissor() { int h = std::max(0.0f, ceilf(scale_y * bounds.h)); if (x < 0 || y < 0 || x + w > pixel_xres || y + h > pixel_yres) { // This won't actually report outside a game, but we can try. - ERROR_LOG_REPORT(G3D, "UI scissor out of bounds: %d,%d-%d,%d / %d,%d", x, y, w, h, pixel_xres, pixel_yres); + ERROR_LOG_REPORT(G3D, "UI scissor out of bounds in %sScreen: %d,%d-%d,%d / %d,%d", screenTag_ ? screenTag_ : "N/A", x, y, w, h, pixel_xres, pixel_yres); x = std::max(0, x); y = std::max(0, y); w = std::min(w, pixel_xres - x); diff --git a/Common/UI/Context.h b/Common/UI/Context.h index ad02b4027c81..ac26ab0202e1 100644 --- a/Common/UI/Context.h +++ b/Common/UI/Context.h @@ -74,7 +74,6 @@ class UIContext { const UI::Theme *theme; // Utility methods - TextDrawer *Text() const { return textDrawer_; } void SetFontStyle(const UI::FontStyle &style); @@ -103,6 +102,10 @@ class UIContext { void setUIAtlas(const std::string &name); + void SetScreenTag(const char *tag) { + screenTag_ = tag; + } + private: Draw::DrawContext *draw_ = nullptr; Bounds bounds_; @@ -126,4 +129,6 @@ class UIContext { std::string lastUIAtlas_; std::string UIAtlas_ = "ui_atlas.zim"; + + const char *screenTag_ = nullptr; }; diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 8026de37bcba..ecebae3a814a 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -117,6 +117,9 @@ void UIScreen::render() { if (root_) { UIContext *uiContext = screenManager()->getUIContext(); + + uiContext->SetScreenTag(tag()); + UI::LayoutViewHierarchy(*uiContext, root_, ignoreInsets_); uiContext->PushTransform({translation_, scale_, alpha_});