From f2435393622c3b1da815152090b35d97cb6bdd88 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 3 Feb 2023 04:32:07 +0300 Subject: [PATCH] rsx/overlays: Make animation caching possible --- rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp | 6 ++++++ rpcs3/Emu/RSX/Overlays/overlay_animated_icon.h | 1 + rpcs3/Emu/RSX/Overlays/overlay_loading_icon.hpp | 15 ++++++++++++++- rpcs3/Emu/RSX/Overlays/overlay_message.cpp | 8 ++++---- rpcs3/Emu/RSX/Overlays/overlay_message.h | 10 +++++----- .../overlay_shader_compile_notification.cpp | 2 +- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp b/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp index f8c35592a3..00f1e1bd13 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.cpp @@ -15,6 +15,12 @@ namespace rsx set_raw_image(m_icon.get()); } + animated_icon::animated_icon(const std::vector& icon_data) + { + m_icon = std::make_unique(icon_data); + set_raw_image(m_icon.get()); + } + void animated_icon::update_animation_frame(compiled_resource& result) { if (m_last_update_timestamp_us == 0) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.h b/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.h index 1136600550..71add8e9ce 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_animated_icon.h @@ -10,6 +10,7 @@ namespace rsx { public: animated_icon(const char* icon_name); + animated_icon(const std::vector& icon_data); void update_animation_frame(compiled_resource& result); compiled_resource& get_compiled() override; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_loading_icon.hpp b/rpcs3/Emu/RSX/Overlays/overlay_loading_icon.hpp index f012346a0d..28db156e02 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_loading_icon.hpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_loading_icon.hpp @@ -6,10 +6,23 @@ namespace rsx { namespace overlays { - struct loading_icon24 : public animated_icon + class loading_icon24 : public animated_icon { + public: loading_icon24() : animated_icon("spinner-24.png") + { + init_params(); + } + + loading_icon24(const std::vector& icon_data) + : animated_icon(icon_data) + { + init_params(); + } + + private: + void init_params() { m_frame_width = m_frame_height = 24; m_spacing_x = m_spacing_y = 6; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message.cpp index ac30367075..0dc21cfc70 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message.cpp @@ -17,7 +17,7 @@ namespace rsx } template - message_item::message_item(T msg_id, u64 expiration, std::shared_ptr> refs, std::unique_ptr icon) + message_item::message_item(T msg_id, u64 expiration, std::shared_ptr> refs, std::shared_ptr icon) { m_visible_duration = expiration; m_refs = std::move(refs); @@ -42,7 +42,7 @@ namespace rsx if (icon) { - m_icon = std::move(icon); + m_icon = icon; m_icon->set_pos(m_text.x + m_text.w + 8, m_text.y); set_size(m_margin + m_text.w + m_icon->w + m_margin, m_margin + std::max(m_text.h, m_icon->h) + m_margin); @@ -52,8 +52,8 @@ namespace rsx set_size(m_text.w + m_margin + m_margin, m_text.h + m_margin + m_margin); } } - template message_item::message_item(std::string msg_id, u64, std::shared_ptr>, std::unique_ptr); - template message_item::message_item(localized_string_id msg_id, u64, std::shared_ptr>, std::unique_ptr); + template message_item::message_item(std::string msg_id, u64, std::shared_ptr>, std::shared_ptr); + template message_item::message_item(localized_string_id msg_id, u64, std::shared_ptr>, std::shared_ptr); u64 message_item::get_expiration() const { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message.h b/rpcs3/Emu/RSX/Overlays/overlay_message.h index a6758ca2e3..83d6a7cef7 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_message.h @@ -17,7 +17,7 @@ namespace rsx { public: template - message_item(T msg_id, u64 expiration, std::shared_ptr> refs, std::unique_ptr icon = {}); + message_item(T msg_id, u64 expiration, std::shared_ptr> refs, std::shared_ptr icon = {}); void update(usz index, u64 time, u16 y_offset); void set_pos(u16 _x, u16 _y) override; @@ -28,7 +28,7 @@ namespace rsx private: label m_text{}; - std::unique_ptr m_icon{}; + std::shared_ptr m_icon{}; animation_color_interpolate m_fade_in_animation; animation_color_interpolate m_fade_out_animation; @@ -52,7 +52,7 @@ namespace rsx u64 expiration, std::shared_ptr> refs, message_pin_location location = message_pin_location::top, - std::unique_ptr icon = {}) + std::shared_ptr icon = {}) { std::lock_guard lock(m_mutex_queue); @@ -72,7 +72,7 @@ namespace rsx } else if (!message_exists(location, msg_id)) { - queue.emplace_back(msg_id, expiration, std::move(refs), std::move(icon)); + queue.emplace_back(msg_id, expiration, std::move(refs), icon); } visible = true; @@ -104,7 +104,7 @@ namespace rsx u64 expiration = 5'000'000, std::shared_ptr> refs = {}, message_pin_location location = message_pin_location::top, - std::unique_ptr icon = {}) + std::shared_ptr icon = {}) { if (auto manager = g_fxo->try_get()) { diff --git a/rpcs3/Emu/RSX/Overlays/overlay_shader_compile_notification.cpp b/rpcs3/Emu/RSX/Overlays/overlay_shader_compile_notification.cpp index 77a3d82748..d1d4cd7e6a 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_shader_compile_notification.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_shader_compile_notification.cpp @@ -14,7 +14,7 @@ namespace rsx 5'000'000, {}, message_pin_location::bottom, - std::make_unique()); + std::make_shared()); } } }