mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
Removed background image caching
This commit is contained in:
parent
be979a535d
commit
224aece029
@ -162,6 +162,7 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If background images are hidden, clear the background image
|
||||||
if (!Config::getShowBackgroundImage()) {
|
if (!Config::getShowBackgroundImage()) {
|
||||||
backgroundImage = QImage();
|
backgroundImage = QImage();
|
||||||
RefreshGridBackgroundImage();
|
RefreshGridBackgroundImage();
|
||||||
@ -170,31 +171,11 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
|||||||
|
|
||||||
const auto& game = (*m_games_shared)[itemID];
|
const auto& game = (*m_games_shared)[itemID];
|
||||||
const int opacity = Config::getBackgroundImageOpacity();
|
const int opacity = Config::getBackgroundImageOpacity();
|
||||||
const auto cache_path = Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
|
|
||||||
game.serial / fmt::format("pic1_{}.png", opacity);
|
|
||||||
|
|
||||||
// Fast path - try to load cached version first
|
|
||||||
if (std::filesystem::exists(cache_path)) {
|
|
||||||
backgroundImage = QImage(QString::fromStdString(cache_path.string()));
|
|
||||||
if (!backgroundImage.isNull()) {
|
|
||||||
RefreshGridBackgroundImage();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache miss - generate and store
|
|
||||||
m_game_list_utils.CleanupOldOpacityImages(cache_path.parent_path());
|
|
||||||
QImage original_image(QString::fromStdString(game.pic_path.string()));
|
QImage original_image(QString::fromStdString(game.pic_path.string()));
|
||||||
if (!original_image.isNull()) {
|
if (!original_image.isNull()) {
|
||||||
std::filesystem::create_directories(cache_path.parent_path());
|
|
||||||
backgroundImage = m_game_list_utils.ChangeImageOpacity(
|
backgroundImage = m_game_list_utils.ChangeImageOpacity(
|
||||||
original_image, original_image.rect(), opacity / 100.0f);
|
original_image, original_image.rect(), opacity / 100.0f);
|
||||||
if (!backgroundImage.isNull()) {
|
|
||||||
// Save the image to the cache asynchronously
|
|
||||||
QFuture<void> future = QtConcurrent::run([this, cache_path]() {
|
|
||||||
backgroundImage.save(QString::fromStdString(cache_path.string()), "PNG");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshGridBackgroundImage();
|
RefreshGridBackgroundImage();
|
||||||
|
@ -176,31 +176,11 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
|||||||
|
|
||||||
const auto& game = m_game_info->m_games[item->row()];
|
const auto& game = m_game_info->m_games[item->row()];
|
||||||
const int opacity = Config::getBackgroundImageOpacity();
|
const int opacity = Config::getBackgroundImageOpacity();
|
||||||
const auto cache_path = Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
|
|
||||||
game.serial / fmt::format("pic1_{}.png", opacity);
|
|
||||||
|
|
||||||
// Fast path - try to load cached version first
|
|
||||||
if (std::filesystem::exists(cache_path)) {
|
|
||||||
backgroundImage = QImage(QString::fromStdString(cache_path.string()));
|
|
||||||
if (!backgroundImage.isNull()) {
|
|
||||||
RefreshListBackgroundImage();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache miss - generate and store
|
|
||||||
m_game_list_utils.CleanupOldOpacityImages(cache_path.parent_path());
|
|
||||||
QImage original_image(QString::fromStdString(game.pic_path.string()));
|
QImage original_image(QString::fromStdString(game.pic_path.string()));
|
||||||
if (!original_image.isNull()) {
|
if (!original_image.isNull()) {
|
||||||
std::filesystem::create_directories(cache_path.parent_path());
|
|
||||||
backgroundImage = m_game_list_utils.ChangeImageOpacity(
|
backgroundImage = m_game_list_utils.ChangeImageOpacity(
|
||||||
original_image, original_image.rect(), opacity / 100.0f);
|
original_image, original_image.rect(), opacity / 100.0f);
|
||||||
if (!backgroundImage.isNull()) {
|
|
||||||
// Save the image to the cache asynchronously
|
|
||||||
QFuture<void> future = QtConcurrent::run([this, cache_path]() {
|
|
||||||
backgroundImage.save(QString::fromStdString(cache_path.string()), "PNG");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshListBackgroundImage();
|
RefreshListBackgroundImage();
|
||||||
|
@ -227,17 +227,4 @@ public:
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanupOldOpacityImages(const std::filesystem::path& dir) {
|
|
||||||
if (!std::filesystem::exists(dir)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(dir)) {
|
|
||||||
const auto& path = entry.path();
|
|
||||||
if (path.filename().string().starts_with("pic1") && path.extension() == ".png") {
|
|
||||||
std::filesystem::remove(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user