diff --git a/CMakeLists.txt b/CMakeLists.txt index 12c75eaff3..ac021cf474 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -692,6 +692,8 @@ add_library(Common STATIC Common/Render/TextureAtlas.h Common/Render/DrawBuffer.cpp Common/Render/DrawBuffer.h + Common/Render/ManagedTexture.cpp + Common/Render/ManagedTexture.h Common/Render/Text/draw_text.cpp Common/Render/Text/draw_text.h Common/Render/Text/draw_text_android.cpp @@ -710,6 +712,8 @@ add_library(Common STATIC Common/Thread/ThreadUtil.h Common/Thread/ThreadManager.cpp Common/Thread/ThreadManager.h + Common/UI/AsyncImageFileView.cpp + Common/UI/AsyncImageFileView.h Common/UI/Root.cpp Common/UI/Root.h Common/UI/Screen.cpp @@ -1293,8 +1297,6 @@ list(APPEND NativeAppSource UI/MemStickScreen.cpp UI/ProfilerDraw.h UI/ProfilerDraw.cpp - UI/TextureUtil.h - UI/TextureUtil.cpp UI/ComboKeyMappingScreen.h UI/ComboKeyMappingScreen.cpp UI/Theme.h diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index 39e804db79..d59ae3136e 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -477,6 +477,7 @@ + @@ -549,6 +550,7 @@ + @@ -905,6 +907,7 @@ + @@ -988,6 +991,7 @@ + diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index 33468b43d8..ac2fde0155 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -446,6 +446,12 @@ VR + + UI + + + Render + @@ -845,6 +851,12 @@ VR + + UI + + + Render + diff --git a/UI/TextureUtil.cpp b/Common/Render/ManagedTexture.cpp similarity index 83% rename from UI/TextureUtil.cpp rename to Common/Render/ManagedTexture.cpp index 80dfb59e1a..771d4f8a92 100644 --- a/UI/TextureUtil.cpp +++ b/Common/Render/ManagedTexture.cpp @@ -14,8 +14,7 @@ #include "Common/File/VFS/VFS.h" #include "Common/Log.h" #include "Common/TimeUtil.h" -#include "UI/TextureUtil.h" -#include "UI/GameInfoCache.h" +#include "Common/Render/ManagedTexture.h" static Draw::DataFormat ZimToT3DFormat(int zim) { switch (zim) { @@ -217,38 +216,3 @@ std::unique_ptr CreateTextureFromFileData(Draw::DrawContext *dra return std::unique_ptr(); } } - -void GameIconView::GetContentDimensions(const UIContext &dc, float &w, float &h) const { - w = textureWidth_; - h = textureHeight_; -} - -void GameIconView::Draw(UIContext &dc) { - using namespace UI; - std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); - - if (!info->icon.texture) { - return; - } - - textureWidth_ = info->icon.texture->Width() * scale_; - textureHeight_ = info->icon.texture->Height() * scale_; - - // Fade icon with the backgrounds. - double loadTime = info->icon.timeLoaded; - auto pic = info->GetBGPic(); - if (pic) { - loadTime = std::max(loadTime, pic->timeLoaded); - } - uint32_t color = whiteAlpha(ease((time_now_d() - loadTime) * 3)); - - // Adjust size so we don't stretch the image vertically or horizontally. - // Make sure it's not wider than 144 (like Doom Legacy homebrew), ugly in the grid mode. - float nw = std::min(bounds_.h * textureWidth_ / textureHeight_, (float)bounds_.w); - - dc.Flush(); - dc.GetDrawContext()->BindTexture(0, info->icon.texture->GetTexture()); - dc.Draw()->Rect(bounds_.x, bounds_.y, nw, bounds_.h, color); - dc.Flush(); - dc.RebindTexture(); -} diff --git a/UI/TextureUtil.h b/Common/Render/ManagedTexture.h similarity index 73% rename from UI/TextureUtil.h rename to Common/Render/ManagedTexture.h index 19d9b40cb0..ed6e9918f6 100644 --- a/UI/TextureUtil.h +++ b/Common/Render/ManagedTexture.h @@ -43,18 +43,3 @@ private: std::unique_ptr CreateTextureFromFile(Draw::DrawContext *draw, const char *filename, ImageFileType fileType, bool generateMips); std::unique_ptr CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType fileType, bool generateMips, const char *name); -class GameIconView : public UI::InertView { -public: - GameIconView(const Path &gamePath, float scale, UI::LayoutParams *layoutParams = 0) - : InertView(layoutParams), gamePath_(gamePath), scale_(scale) {} - - void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; - void Draw(UIContext &dc) override; - std::string DescribeText() const override { return ""; } - -private: - Path gamePath_; - float scale_ = 1.0f; - int textureWidth_ = 0; - int textureHeight_ = 0; -}; diff --git a/Common/UI/AsyncImageFileView.cpp b/Common/UI/AsyncImageFileView.cpp new file mode 100644 index 0000000000..925d1c9337 --- /dev/null +++ b/Common/UI/AsyncImageFileView.cpp @@ -0,0 +1,113 @@ +#include "Common/UI/View.h" +#include "Common/UI/AsyncImageFileView.h" +#include "Common/UI/Context.h" +#include "Common/Render/DrawBuffer.h" + +AsyncImageFileView::AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams) + : UI::Clickable(layoutParams), canFocus_(true), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {} + +AsyncImageFileView::~AsyncImageFileView() {} + +static float DesiredSize(float sz, float contentSize, UI::MeasureSpec spec) { + float measured; + UI::MeasureBySpec(sz, contentSize, spec, &measured); + return measured; +} + +void AsyncImageFileView::GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const { + if (texture_ && texture_->GetTexture()) { + float texw = (float)texture_->Width(); + float texh = (float)texture_->Height(); + float desiredW = DesiredSize(layoutParams_->width, w, horiz); + float desiredH = DesiredSize(layoutParams_->height, h, vert); + switch (sizeMode_) { + case UI::IS_FIXED: + w = fixedSizeW_; + h = fixedSizeH_; + break; + case UI::IS_KEEP_ASPECT: + w = texw; + h = texh; + if (desiredW != w || desiredH != h) { + float aspect = w / h; + // We need the other dimension based on the desired scale to find the best aspect. + float desiredWOther = DesiredSize(layoutParams_->height, h * (desiredW / w), vert); + float desiredHOther = DesiredSize(layoutParams_->width, w * (desiredH / h), horiz); + + float diffW = fabsf(aspect - desiredW / desiredWOther); + float diffH = fabsf(aspect - desiredH / desiredHOther); + if (diffW < diffH) { + w = desiredW; + h = desiredWOther; + } else { + w = desiredHOther; + h = desiredH; + } + } + break; + case UI::IS_DEFAULT: + default: + w = texw; + h = texh; + break; + } + } else { + w = 16; + h = 16; + } +} + +void AsyncImageFileView::SetFilename(const Path &filename) { + if (filename_ != filename) { + textureFailed_ = false; + filename_ = filename; + texture_.reset(nullptr); + } +} + +void AsyncImageFileView::DeviceLost() { + if (texture_.get()) + texture_->DeviceLost(); +} + +void AsyncImageFileView::DeviceRestored(Draw::DrawContext *draw) { + if (texture_.get()) + texture_->DeviceRestored(draw); +} + +void AsyncImageFileView::Draw(UIContext &dc) { + using namespace Draw; + if (!texture_ && !textureFailed_ && !filename_.empty()) { + texture_ = CreateTextureFromFile(dc.GetDrawContext(), filename_.c_str(), DETECT, true); + if (!texture_.get()) + textureFailed_ = true; + } + + if (HasFocus()) { + dc.FillRect(dc.theme->itemFocusedStyle.background, bounds_.Expand(3)); + } + + // TODO: involve sizemode + if (texture_ && texture_->GetTexture()) { + dc.Flush(); + dc.GetDrawContext()->BindTexture(0, texture_->GetTexture()); + dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color_); + dc.Flush(); + dc.RebindTexture(); + if (!text_.empty()) { + dc.DrawText(text_.c_str(), bounds_.centerX() + 1, bounds_.centerY() + 1, 0x80000000, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); + 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 (!text_.empty()) { + dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); + } + } +} diff --git a/Common/UI/AsyncImageFileView.h b/Common/UI/AsyncImageFileView.h new file mode 100644 index 0000000000..5acaca30a5 --- /dev/null +++ b/Common/UI/AsyncImageFileView.h @@ -0,0 +1,44 @@ +#pragma once + +#include "Common/UI/View.h" +#include "Common/Render/ManagedTexture.h" +#include "Common/File/Path.h" + +class UIContext; + +// AsyncImageFileView loads a texture from a file, and reloads it as necessary. +// TODO: Actually make async, doh. +class AsyncImageFileView : public UI::Clickable { +public: + AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams = 0); + ~AsyncImageFileView(); + + void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const override; + void Draw(UIContext &dc) override; + std::string DescribeText() const override { return text_; } + + void DeviceLost() override; + void DeviceRestored(Draw::DrawContext *draw) override; + + void SetFilename(const Path &filename); + void SetColor(uint32_t color) { color_ = color; } + void SetOverlayText(std::string text) { text_ = text; } + void SetFixedSize(float fixW, float fixH) { fixedSizeW_ = fixW; fixedSizeH_ = fixH; } + void SetCanBeFocused(bool can) { canFocus_ = can; } + + bool CanBeFocused() const override { return canFocus_; } + + const Path &GetFilename() const { return filename_; } + +private: + bool canFocus_; + Path filename_; + std::string text_; + uint32_t color_; + UI::ImageSizeMode sizeMode_; + + std::unique_ptr texture_; + bool textureFailed_; + float fixedSizeW_; + float fixedSizeH_; +}; diff --git a/Common/UI/Context.cpp b/Common/UI/Context.cpp index 21c687bd2b..40bc95c824 100644 --- a/Common/UI/Context.cpp +++ b/Common/UI/Context.cpp @@ -10,9 +10,9 @@ #include "Common/UI/Context.h" #include "Common/Render/DrawBuffer.h" #include "Common/Render/Text/draw_text.h" +#include "Common/Render/ManagedTexture.h" #include "Common/Log.h" #include "Common/LogReporting.h" -#include "UI/TextureUtil.h" UIContext::UIContext() { fontStyle_ = new UI::FontStyle(); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index bfbc7edf8c..dfbb42b79a 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -31,6 +31,7 @@ using namespace std::placeholders; #include "Common/UI/Context.h" #include "Common/UI/Tween.h" #include "Common/UI/View.h" +#include "Common/UI/AsyncImageFileView.h" #include "Common/VR/PPSSPPVR.h" #include "Common/Data/Text/I18n.h" diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index ec4ea77700..b6f0a7cfb7 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -29,6 +29,7 @@ #include "Common/File/Path.h" #include "Common/StringUtils.h" #include "Common/TimeUtil.h" +#include "Common/Render/ManagedTexture.h" #include "Core/FileSystems/ISOFileSystem.h" #include "Core/FileSystems/DirectoryFileSystem.h" #include "Core/FileSystems/VirtualDiscFileSystem.h" @@ -39,7 +40,6 @@ #include "Core/Util/GameManager.h" #include "Core/Config.h" #include "UI/GameInfoCache.h" -#include "UI/TextureUtil.h" GameInfoCache *g_gameInfoCache; diff --git a/UI/GameInfoCache.h b/UI/GameInfoCache.h index a23aa92442..1df4f64ad5 100644 --- a/UI/GameInfoCache.h +++ b/UI/GameInfoCache.h @@ -26,7 +26,7 @@ #include "Common/Thread/Event.h" #include "Core/ELF/ParamSFO.h" #include "Common/File/Path.h" -#include "UI/TextureUtil.h" +#include "Common/Render/ManagedTexture.h" namespace Draw { class DrawContext; diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index edf519f46b..4486bbd9a3 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -43,6 +43,7 @@ #include "UI/MiscScreens.h" #include "UI/MainScreen.h" #include "UI/BackgroundAudio.h" +#include "UI/SavedataScreen.h" #include "Core/Reporting.h" GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 0bea47395a..88c27d4393 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -114,7 +114,6 @@ #include "UI/OnScreenDisplay.h" #include "UI/RemoteISOScreen.h" #include "UI/TiltEventProcessor.h" -#include "UI/TextureUtil.h" #include "UI/Theme.h" #if !defined(MOBILE_DEVICE) && defined(USING_QT_UI) diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 6e3e3d001e..68f55bcc40 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -29,6 +29,7 @@ #include "Common/StringUtils.h" #include "Common/System/System.h" #include "Common/VR/PPSSPPVR.h" +#include "Common/UI/AsyncImageFileView.h" #include "Core/Reporting.h" #include "Core/SaveState.h" @@ -49,115 +50,6 @@ #include "UI/OnScreenDisplay.h" #include "UI/GameInfoCache.h" -AsyncImageFileView::AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams) - : UI::Clickable(layoutParams), canFocus_(true), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {} - -AsyncImageFileView::~AsyncImageFileView() {} - -static float DesiredSize(float sz, float contentSize, UI::MeasureSpec spec) { - float measured; - UI::MeasureBySpec(sz, contentSize, spec, &measured); - return measured; -} - -void AsyncImageFileView::GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const { - if (texture_ && texture_->GetTexture()) { - float texw = (float)texture_->Width(); - float texh = (float)texture_->Height(); - float desiredW = DesiredSize(layoutParams_->width, w, horiz); - float desiredH = DesiredSize(layoutParams_->height, h, vert); - switch (sizeMode_) { - case UI::IS_FIXED: - w = fixedSizeW_; - h = fixedSizeH_; - break; - case UI::IS_KEEP_ASPECT: - w = texw; - h = texh; - if (desiredW != w || desiredH != h) { - float aspect = w / h; - // We need the other dimension based on the desired scale to find the best aspect. - float desiredWOther = DesiredSize(layoutParams_->height, h * (desiredW / w), vert); - float desiredHOther = DesiredSize(layoutParams_->width, w * (desiredH / h), horiz); - - float diffW = fabsf(aspect - desiredW / desiredWOther); - float diffH = fabsf(aspect - desiredH / desiredHOther); - if (diffW < diffH) { - w = desiredW; - h = desiredWOther; - } else { - w = desiredHOther; - h = desiredH; - } - } - break; - case UI::IS_DEFAULT: - default: - w = texw; - h = texh; - break; - } - } else { - w = 16; - h = 16; - } -} - -void AsyncImageFileView::SetFilename(const Path &filename) { - if (filename_ != filename) { - textureFailed_ = false; - filename_ = filename; - texture_.reset(nullptr); - } -} - -void AsyncImageFileView::DeviceLost() { - if (texture_.get()) - texture_->DeviceLost(); -} - -void AsyncImageFileView::DeviceRestored(Draw::DrawContext *draw) { - if (texture_.get()) - texture_->DeviceRestored(draw); -} - -void AsyncImageFileView::Draw(UIContext &dc) { - using namespace Draw; - if (!texture_ && !textureFailed_ && !filename_.empty()) { - texture_ = CreateTextureFromFile(dc.GetDrawContext(), filename_.c_str(), DETECT, true); - if (!texture_.get()) - textureFailed_ = true; - } - - if (HasFocus()) { - dc.FillRect(dc.theme->itemFocusedStyle.background, bounds_.Expand(3)); - } - - // TODO: involve sizemode - if (texture_ && texture_->GetTexture()) { - dc.Flush(); - dc.GetDrawContext()->BindTexture(0, texture_->GetTexture()); - dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color_); - dc.Flush(); - dc.RebindTexture(); - if (!text_.empty()) { - dc.DrawText(text_.c_str(), bounds_.centerX()+1, bounds_.centerY()+1, 0x80000000, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); - 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 (!text_.empty()) { - dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); - } - } -} - static void AfterSaveStateAction(SaveState::Status status, const std::string &message, void *) { if (!message.empty() && (!g_Config.bDumpFrames || !g_Config.bDumpVideoOutput)) { osm.Show(message, status == SaveState::Status::SUCCESS ? 2.0 : 5.0); diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index 6b48f7bdb2..c4180bdd9f 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -24,7 +24,11 @@ #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" #include "UI/MiscScreens.h" -#include "UI/TextureUtil.h" + +enum class PauseScreenMode { + MAIN, + DISPLAY_SETTINGS, +}; class GamePauseScreen : public UIDialogScreenWithGameBackground { public: @@ -64,41 +68,5 @@ private: // hack bool finishNextFrame_ = false; Path gamePath_; -}; - -// AsyncImageFileView loads a texture from a file, and reloads it as necessary. -// TODO: Actually make async, doh. -class AsyncImageFileView : public UI::Clickable { -public: - AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams = 0); - ~AsyncImageFileView(); - - void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const override; - void Draw(UIContext &dc) override; - std::string DescribeText() const override { return text_; } - - void DeviceLost() override; - void DeviceRestored(Draw::DrawContext *draw) override; - - void SetFilename(const Path &filename); - void SetColor(uint32_t color) { color_ = color; } - void SetOverlayText(std::string text) { text_ = text; } - void SetFixedSize(float fixW, float fixH) { fixedSizeW_ = fixW; fixedSizeH_ = fixH; } - void SetCanBeFocused(bool can) { canFocus_ = can; } - - bool CanBeFocused() const override { return canFocus_; } - - const Path &GetFilename() const { return filename_; } - -private: - bool canFocus_; - Path filename_; - std::string text_; - uint32_t color_; - UI::ImageSizeMode sizeMode_; - - std::unique_ptr texture_; - bool textureFailed_; - float fixedSizeW_; - float fixedSizeH_; + PauseScreenMode mode_ = PauseScreenMode::MAIN; }; diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index 101ec4c83b..b1d7de7326 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -20,6 +20,7 @@ // TODO: For text align flags, probably shouldn't be in gfx_es2/... #include "Common/Render/DrawBuffer.h" #include "Common/GPU/thin3d.h" +#include "Common/UI/AsyncImageFileView.h" #include "Common/UI/Context.h" #include "UI/PauseScreen.h" #include "UI/ReportScreen.h" diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 0172b6a19b..0d04ac02b9 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -29,6 +29,7 @@ #include "Common/UI/Context.h" #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" +#include "Common/UI/AsyncImageFileView.h" #include "UI/SavedataScreen.h" #include "UI/MainScreen.h" #include "UI/GameInfoCache.h" @@ -707,3 +708,38 @@ void SavedataScreen::sendMessage(const char *message, const char *value) { stateBrowser_->SetSearchFilter(searchFilter_); } } + +void GameIconView::GetContentDimensions(const UIContext &dc, float &w, float &h) const { + w = textureWidth_; + h = textureHeight_; +} + +void GameIconView::Draw(UIContext &dc) { + using namespace UI; + std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); + + if (!info->icon.texture) { + return; + } + + textureWidth_ = info->icon.texture->Width() * scale_; + textureHeight_ = info->icon.texture->Height() * scale_; + + // Fade icon with the backgrounds. + double loadTime = info->icon.timeLoaded; + auto pic = info->GetBGPic(); + if (pic) { + loadTime = std::max(loadTime, pic->timeLoaded); + } + uint32_t color = whiteAlpha(ease((time_now_d() - loadTime) * 3)); + + // Adjust size so we don't stretch the image vertically or horizontally. + // Make sure it's not wider than 144 (like Doom Legacy homebrew), ugly in the grid mode. + float nw = std::min(bounds_.h * textureWidth_ / textureHeight_, (float)bounds_.w); + + dc.Flush(); + dc.GetDrawContext()->BindTexture(0, info->icon.texture->GetTexture()); + dc.Draw()->Rect(bounds_.x, bounds_.y, nw, bounds_.h, color); + dc.Flush(); + dc.RebindTexture(); +} diff --git a/UI/SavedataScreen.h b/UI/SavedataScreen.h index 1bb2f42140..10cd631250 100644 --- a/UI/SavedataScreen.h +++ b/UI/SavedataScreen.h @@ -27,6 +27,7 @@ #include "Common/UI/ViewGroup.h" #include "UI/MiscScreens.h" +#include "UI/GameInfoCache.h" enum class SavedataSortOption { FILENAME, @@ -88,3 +89,19 @@ protected: SavedataBrowser *stateBrowser_; std::string searchFilter_; }; + +class GameIconView : public UI::InertView { +public: + GameIconView(const Path &gamePath, float scale, UI::LayoutParams *layoutParams = 0) + : InertView(layoutParams), gamePath_(gamePath), scale_(scale) {} + + void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; + void Draw(UIContext &dc) override; + std::string DescribeText() const override { return ""; } + +private: + Path gamePath_; + float scale_ = 1.0f; + int textureWidth_ = 0; + int textureHeight_ = 0; +}; diff --git a/UI/Store.cpp b/UI/Store.cpp index 86a084da95..b6000e9d3b 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -26,12 +26,12 @@ #include "Common/Data/Text/I18n.h" #include "Common/Data/Format/JSONReader.h" #include "Common/StringUtils.h" +#include "Common/Render/ManagedTexture.h" #include "Core/Config.h" #include "Core/System.h" #include "Core/Util/GameManager.h" #include "UI/EmuScreen.h" #include "UI/Store.h" -#include "UI/TextureUtil.h" const std::string storeBaseUrl = "http://store.ppsspp.org/"; diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index 666e35aa02..edf77d026e 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -61,7 +61,6 @@ - @@ -96,7 +95,6 @@ - diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index 2c63641535..3f03e3242f 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -67,7 +67,6 @@ Screens - Screens @@ -81,6 +80,7 @@ Screens + @@ -149,7 +149,6 @@ Screens - Screens @@ -163,6 +162,7 @@ Screens + diff --git a/UWP/CommonUWP/CommonUWP.vcxproj b/UWP/CommonUWP/CommonUWP.vcxproj index 0415092a9d..930306c7f7 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj +++ b/UWP/CommonUWP/CommonUWP.vcxproj @@ -448,6 +448,7 @@ + @@ -495,6 +496,7 @@ + @@ -578,6 +580,7 @@ + @@ -613,6 +616,7 @@ + diff --git a/UWP/CommonUWP/CommonUWP.vcxproj.filters b/UWP/CommonUWP/CommonUWP.vcxproj.filters index 15c00bcbfa..954e21c236 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj.filters +++ b/UWP/CommonUWP/CommonUWP.vcxproj.filters @@ -405,6 +405,12 @@ GPU\Vulkan + + UI + + + Render + @@ -748,6 +754,12 @@ GPU\Vulkan + + UI + + + Render + diff --git a/UWP/UI_UWP/UI_UWP.vcxproj b/UWP/UI_UWP/UI_UWP.vcxproj index c6534b2cd9..57358dde23 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj +++ b/UWP/UI_UWP/UI_UWP.vcxproj @@ -407,7 +407,6 @@ - @@ -444,7 +443,6 @@ - @@ -467,4 +465,4 @@ - + \ No newline at end of file diff --git a/UWP/UI_UWP/UI_UWP.vcxproj.filters b/UWP/UI_UWP/UI_UWP.vcxproj.filters index bae3799bc9..fde9770206 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj.filters +++ b/UWP/UI_UWP/UI_UWP.vcxproj.filters @@ -28,11 +28,12 @@ - + + @@ -63,10 +64,11 @@ - + + - + \ No newline at end of file diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 2f3887c3e2..a8b6090dfe 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -166,6 +166,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/Common/GPU/Shader.cpp \ $(SRC)/Common/GPU/ShaderWriter.cpp \ $(SRC)/Common/GPU/ShaderTranslation.cpp \ + $(SRC)/Common/Render/ManagedTexture.cpp \ $(SRC)/Common/Render/DrawBuffer.cpp \ $(SRC)/Common/Render/TextureAtlas.cpp \ $(SRC)/Common/Render/Text/draw_text.cpp \ @@ -192,6 +193,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/Common/Thread/ThreadUtil.cpp \ $(SRC)/Common/Thread/ThreadManager.cpp \ $(SRC)/Common/Thread/ParallelLoop.cpp \ + $(SRC)/Common/UI/AsyncImageFileView.cpp \ $(SRC)/Common/UI/Root.cpp \ $(SRC)/Common/UI/Screen.cpp \ $(SRC)/Common/UI/UI.cpp \ @@ -713,7 +715,6 @@ LOCAL_SRC_FILES := \ $(SRC)/UI/OnScreenDisplay.cpp \ $(SRC)/UI/ProfilerDraw.cpp \ $(SRC)/UI/NativeApp.cpp \ - $(SRC)/UI/TextureUtil.cpp \ $(SRC)/UI/Theme.cpp \ $(SRC)/UI/ComboKeyMappingScreen.cpp diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 27540dc86f..b310680f1f 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -281,12 +281,14 @@ SOURCES_CXX += \ $(COMMONDIR)/Net/Sinks.cpp \ $(COMMONDIR)/Net/URL.cpp \ $(COMMONDIR)/Net/WebsocketServer.cpp \ + $(COMMONDIR)/Render/ManagedTexture.cpp \ $(COMMONDIR)/Render/DrawBuffer.cpp \ $(COMMONDIR)/Render/TextureAtlas.cpp \ $(COMMONDIR)/Serialize/Serializer.cpp \ $(COMMONDIR)/Thread/ThreadUtil.cpp \ $(COMMONDIR)/Thread/ParallelLoop.cpp \ $(COMMONDIR)/Thread/ThreadManager.cpp \ + $(COMMONDIR)/UI/AsyncImageFileView.cpp \ $(COMMONDIR)/UI/Root.cpp \ $(COMMONDIR)/UI/Screen.cpp \ $(COMMONDIR)/UI/UI.cpp \ @@ -616,8 +618,7 @@ SOURCES_CXX += \ $(COREDIR)/Util/PPGeDraw.cpp \ $(COREDIR)/Util/AudioFormat.cpp \ $(COREDIR)/Util/PortManager.cpp \ - $(CORE_DIR)/UI/TextureUtil.cpp \ - $(CORE_DIR)/UI/GameInfoCache.cpp + $(CORE_DIR)/UI/GameInfoCache.cpp SOURCES_CXX += $(COREDIR)/HLE/__sceAudio.cpp