Skip to content

Commit

Permalink
Log the screen tag when logging scissor errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 16, 2022
1 parent 9f38516 commit 0b9d6f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Common/UI/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion Common/UI/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class UIContext {
const UI::Theme *theme;

// Utility methods

TextDrawer *Text() const { return textDrawer_; }

void SetFontStyle(const UI::FontStyle &style);
Expand Down Expand Up @@ -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_;
Expand All @@ -126,4 +129,6 @@ class UIContext {

std::string lastUIAtlas_;
std::string UIAtlas_ = "ui_atlas.zim";

const char *screenTag_ = nullptr;
};
3 changes: 3 additions & 0 deletions Common/UI/UIScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_});
Expand Down

0 comments on commit 0b9d6f9

Please sign in to comment.