Plumb through a ScreenRenderMode parameter

This commit is contained in:
Henrik Rydgård 2023-12-10 13:05:17 +01:00
parent 600fb7cc22
commit 22295a6412
17 changed files with 38 additions and 30 deletions

View File

@ -174,12 +174,12 @@ void ScreenManager::render() {
// when screens are "compatible" (both are UIScreens, for example).
first->screen->preRender();
while (iter < last) {
iter->screen->render();
iter->screen->render(ScreenRenderMode::TOP);
iter++;
}
stack_.back().screen->render();
stack_.back().screen->render(ScreenRenderMode::TOP);
if (overlayScreen_) {
overlayScreen_->render();
overlayScreen_->render(ScreenRenderMode::TOP);
}
if (postRenderCb_) {
// Really can't render anything after this! Will crash the screenshot mechanism if we do.
@ -191,9 +191,9 @@ void ScreenManager::render() {
default:
_assert_(stack_.back().screen);
stack_.back().screen->preRender();
stack_.back().screen->render();
stack_.back().screen->render(ScreenRenderMode::TOP);
if (overlayScreen_) {
overlayScreen_->render();
overlayScreen_->render(ScreenRenderMode::TOP);
}
if (postRenderCb_) {
// Really can't render anything after this! Will crash the screenshot mechanism if we do.

View File

@ -47,6 +47,14 @@ enum class ScreenFocusChange {
FOCUS_BECAME_TOP, // Became the top screen again
};
enum class ScreenRenderMode {
FIRST = 1,
BACKGROUND = 2,
BEHIND = 4,
TOP = 8,
};
ENUM_CLASS_BITOPS(ScreenRenderMode);
class Screen {
public:
Screen() : screenManager_(nullptr) { }
@ -57,7 +65,7 @@ public:
virtual void onFinish(DialogResult reason) {}
virtual void update() {}
virtual void preRender() {}
virtual void render() {}
virtual void render(ScreenRenderMode mode) {}
virtual void postRender() {}
virtual void resized() {}
virtual void dialogFinished(const Screen *dialog, DialogResult result) {}

View File

@ -216,7 +216,7 @@ void UIScreen::postRender() {
screenManager()->getUIContext()->Flush();
}
void UIScreen::render() {
void UIScreen::render(ScreenRenderMode mode) {
DoRecreateViews();
if (root_) {

View File

@ -37,7 +37,7 @@ public:
void update() override;
void preRender() override;
void render() override;
void render(ScreenRenderMode mode) override;
void postRender() override;
void deviceLost() override;
void deviceRestored() override;

View File

@ -713,8 +713,8 @@ void TouchTestScreen::axis(const AxisInput &axis) {
UpdateLogView();
}
void TouchTestScreen::render() {
UIDialogScreenWithGameBackground::render();
void TouchTestScreen::render(ScreenRenderMode mode) {
UIDialogScreenWithGameBackground::render(mode);
UIContext *ui_context = screenManager()->getUIContext();
Bounds bounds = ui_context->GetLayoutBounds();

View File

@ -147,7 +147,7 @@ public:
}
void touch(const TouchInput &touch) override;
void render() override;
void render(ScreenRenderMode mode) override;
bool key(const KeyInput &key) override;
void axis(const AxisInput &axis) override;

View File

@ -1447,7 +1447,7 @@ void EmuScreen::postRender() {
draw->WipeQueue();
}
void EmuScreen::render() {
void EmuScreen::render(ScreenRenderMode mode) {
using namespace Draw;
DrawContext *thin3d = screenManager()->getDrawContext();

View File

@ -42,7 +42,7 @@ public:
const char *tag() const override { return "Emu"; }
void update() override;
void render() override;
void render(ScreenRenderMode mode) override;
void preRender() override;
void postRender() override;
void dialogFinished(const Screen *dialog, DialogResult result) override;

View File

@ -630,9 +630,9 @@ void GPUDriverTestScreen::ShaderTest() {
}
void GPUDriverTestScreen::render() {
void GPUDriverTestScreen::render(ScreenRenderMode mode) {
using namespace Draw;
UIScreen::render();
UIScreen::render(mode);
switch (tabHolder_->GetCurrentTab()) {
case 0:

View File

@ -15,7 +15,7 @@ public:
~GPUDriverTestScreen();
void CreateViews() override;
void render() override;
void render(ScreenRenderMode mode) override;
const char *tag() const override { return "GPUDriverTest"; }

View File

@ -274,8 +274,8 @@ UI::EventReturn GameScreen::OnDeleteConfig(UI::EventParams &e)
return UI::EVENT_DONE;
}
void GameScreen::render() {
UIScreen::render();
void GameScreen::render(ScreenRenderMode mode) {
UIScreen::render(mode);
auto ga = GetI18NCategory(I18NCat::GAME);

View File

@ -38,7 +38,7 @@ public:
void update() override;
void render() override;
void render(ScreenRenderMode mode) override;
const char *tag() const override { return "Game"; }

View File

@ -52,11 +52,11 @@ protected:
void dialogFinished(const Screen *dialog, DialogResult result) override;
void update() override;
void render() override {
void render(ScreenRenderMode mode) override {
// Simple anti-flicker due to delayed finish.
if (!done_) {
// render as usual.
UIDialogScreenWithBackground::render();
UIDialogScreenWithBackground::render(mode);
} else {
// no render. black frame insertion is better than flicker.
}

View File

@ -756,10 +756,10 @@ void LogoScreen::touch(const TouchInput &touch) {
}
}
void LogoScreen::render() {
void LogoScreen::render(ScreenRenderMode mode) {
using namespace Draw;
UIScreen::render();
UIScreen::render(mode);
UIContext &dc = *screenManager()->getUIContext();
const Bounds &bounds = dc.GetBounds();
@ -895,8 +895,8 @@ void CreditsScreen::update() {
UpdateUIState(UISTATE_MENU);
}
void CreditsScreen::render() {
UIScreen::render();
void CreditsScreen::render(ScreenRenderMode mode) {
UIScreen::render(mode);
auto cr = GetI18NCategory(I18NCat::PSPCREDITS);

View File

@ -140,7 +140,7 @@ public:
bool key(const KeyInput &key) override;
void touch(const TouchInput &touch) override;
void update() override;
void render() override;
void render(ScreenRenderMode mode) override;
void sendMessage(UIMessage message, const char *value) override;
void CreateViews() override {}
@ -158,7 +158,7 @@ class CreditsScreen : public UIDialogScreenWithBackground {
public:
CreditsScreen();
void update() override;
void render() override;
void render(ScreenRenderMode mode) override;
void CreateViews() override;

View File

@ -517,8 +517,8 @@ void OSDOverlayScreen::CreateViews() {
osmView_ = root_->Add(new OnScreenMessagesView(new UI::AnchorLayoutParams(0.0f, 0.0f, 0.0f, 0.0f)));
}
void OSDOverlayScreen::render() {
UIScreen::render();
void OSDOverlayScreen::render(ScreenRenderMode mode) {
UIScreen::render(mode);
DebugOverlay debugOverlay = (DebugOverlay)g_Config.iDebugOverlay;

View File

@ -41,7 +41,7 @@ public:
bool UnsyncTouch(const TouchInput &touch) override;
void CreateViews() override;
void render() override;
void render(ScreenRenderMode mode) override;
void update() override;
private: