Files
ppsspp/UI/GameScreen.h
T
Henrik RydgårdandClaude Opus 5.5 f6f9a00eb7 UI: Move file I/O off the render thread in a few screens
On Android the render thread runs the UI, and surfaceDestroyed waits for
it, so slow storage (SAF especially) there stutters and can become an ANR.

- Store: only check whether the game is installed when an install or
  uninstall finishes, not every frame.
- Savedata: read the modification time with SIZE on the GameInfo worker.
  The popup asked for it every frame, and each button on first draw.
- FirmwareScreen: scan the NAND, and erase it, on a worker thread. It
  rescanned on every RecreateViews, which is after every popup.
- GameScreen: look up the installed update, plugins and what the firmware
  can play on a worker thread. They ran on every RecreateViews, which
  happens as each piece of game info arrives.
- LaunchFile: wait only for the file type, and for PARAM.SFO just in the
  cases that use it.

Also add --start-screen=firmware.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 12:01:36 +01:00

116 lines
3.6 KiB
C++

// Copyright (c) 2013- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include <atomic>
#include <functional>
#include <memory>
#include <vector>
#include "UI/BaseScreens.h"
#include "Common/UI/UIScreen.h"
#include "Common/File/Path.h"
#include "UI/GameInfoCache.h"
#include "Core/HLE/Plugins.h"
#include "Core/Util/PkgUnpack.h"
#include "UI/SimpleDialogScreen.h"
class NoticeView;
// Game screen: Allows you to start a game, delete saves, delete the game,
// set game specific settings, etc.
// Uses GameInfoCache heavily to implement the functionality.
// Should possibly merge this with the PauseScreen.
class GameScreen : public UITwoPaneBaseDialogScreen {
public:
GameScreen(const Path &gamePath, bool inGame);
~GameScreen();
void update() override;
const char *tag() const override { return "Game"; }
// The game was deleted or removed from recents, so the screen we return to should refresh.
bool GameRemoved() const { return gameRemoved_; }
protected:
void BeforeCreateViews() override;
void CreateContentViews(UI::ViewGroup *parent) override;
void CreateSettingsViews(UI::ViewGroup *parent) override;
void CreateContextMenu(UI::ViewGroup *parent) override;
void dialogFinished(const Screen *dialog, DialogResult result) override;
std::string_view GetTitle() const override;
// The progress bar of a pack running in the background.
void DrawForeground(UIContext &dc) override;
private:
// Event handlers
void OnGameSettings(UI::EventParams &e);
void OnDeleteSaveData(UI::EventParams &e);
void OnDeleteGame(UI::EventParams &e);
void OnCreateConfig(UI::EventParams &e);
void OnDeleteConfig(UI::EventParams &e);
void OnSetBackground(UI::EventParams &e);
void OnDeleteGameUpdate(UI::EventParams &e);
// What's known about the game from outside its file: an installed update, plugins, and whether
// the installed firmware can play it. All disk access, so it's looked up on a worker thread,
// and the views are recreated when it's in.
struct Lookups {
bool hasInstalledUpdate = false;
InstalledGameUpdate installedUpdate;
std::vector<HLEPlugins::PluginInfo> plugins;
Path umdVideoVSHPath;
bool firmwareRunsPS1Discs = false;
};
struct LookupTask {
std::atomic<bool> done{};
Lookups result;
};
void StartLookups();
std::string CRC32string;
bool isHomebrew_ = false;
bool inGame_ = false;
bool gameRemoved_ = false;
bool finishRequested_ = false;
// Keep track of progressive loading of metadata.
GameInfoFlags knownFlags_ = GameInfoFlags::EMPTY;
bool knownHasCRC_ = false;
// GamePacker state the views were made for.
int packGeneration_ = 0;
bool packBarShown_ = false;
// installedUpdate is a game update in PSP/GAME/<DISC_ID>, which is what actually runs when there is one.
Lookups lookups_;
std::shared_ptr<LookupTask> lookupTask_; // While one runs.
bool lookupsStarted_ = false;
bool lookupsPending_ = false;
std::shared_ptr<GameInfo> info_;
mutable std::string titleCache_;
};