Skip to content

Commit

Permalink
Reduce flicker on savestate screenshot load
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 13, 2023
1 parent d549817 commit 1ac780a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Common/Render/ManagedTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class ManagedTexture {
void DeviceLost();
void DeviceRestored(Draw::DrawContext *draw);

bool Failed() const {
return state_ == LoadState::FAILED;
}

enum class LoadState {
PENDING,
FAILED,
Expand Down
14 changes: 8 additions & 6 deletions Common/UI/AsyncImageFileView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ void AsyncImageFileView::Draw(UIContext &dc) {
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
}
} else {
if (!filename_.empty()) {
// draw a black rectangle to represent the missing screenshot.
dc.FillRect(UI::Drawable(0xFF000000), GetBounds());
} else {
// draw a dark gray rectangle to represent no save state.
dc.FillRect(UI::Drawable(0x50202020), GetBounds());
if (!texture_ || texture_->Failed()) {
if (!filename_.empty()) {
// draw a black rectangle to represent the missing screenshot.
dc.FillRect(UI::Drawable(0xFF000000), GetBounds());
} else {
// draw a dark gray rectangle to represent no save state.
dc.FillRect(UI::Drawable(0x50202020), GetBounds());
}
}
if (!text_.empty()) {
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
Expand Down

0 comments on commit 1ac780a

Please sign in to comment.