1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

rsx/overlays: Make animation caching possible

This commit is contained in:
kd-11 2023-02-03 04:32:07 +03:00 committed by kd-11
parent ec33891f6f
commit f243539362
6 changed files with 31 additions and 11 deletions

View File

@ -15,6 +15,12 @@ namespace rsx
set_raw_image(m_icon.get()); set_raw_image(m_icon.get());
} }
animated_icon::animated_icon(const std::vector<u8>& icon_data)
{
m_icon = std::make_unique<image_info>(icon_data);
set_raw_image(m_icon.get());
}
void animated_icon::update_animation_frame(compiled_resource& result) void animated_icon::update_animation_frame(compiled_resource& result)
{ {
if (m_last_update_timestamp_us == 0) if (m_last_update_timestamp_us == 0)

View File

@ -10,6 +10,7 @@ namespace rsx
{ {
public: public:
animated_icon(const char* icon_name); animated_icon(const char* icon_name);
animated_icon(const std::vector<u8>& icon_data);
void update_animation_frame(compiled_resource& result); void update_animation_frame(compiled_resource& result);
compiled_resource& get_compiled() override; compiled_resource& get_compiled() override;

View File

@ -6,10 +6,23 @@ namespace rsx
{ {
namespace overlays namespace overlays
{ {
struct loading_icon24 : public animated_icon class loading_icon24 : public animated_icon
{ {
public:
loading_icon24() loading_icon24()
: animated_icon("spinner-24.png") : animated_icon("spinner-24.png")
{
init_params();
}
loading_icon24(const std::vector<u8>& icon_data)
: animated_icon(icon_data)
{
init_params();
}
private:
void init_params()
{ {
m_frame_width = m_frame_height = 24; m_frame_width = m_frame_height = 24;
m_spacing_x = m_spacing_y = 6; m_spacing_x = m_spacing_y = 6;

View File

@ -17,7 +17,7 @@ namespace rsx
} }
template <typename T> template <typename T>
message_item::message_item(T msg_id, u64 expiration, std::shared_ptr<atomic_t<u32>> refs, std::unique_ptr<overlay_element> icon) message_item::message_item(T msg_id, u64 expiration, std::shared_ptr<atomic_t<u32>> refs, std::shared_ptr<overlay_element> icon)
{ {
m_visible_duration = expiration; m_visible_duration = expiration;
m_refs = std::move(refs); m_refs = std::move(refs);
@ -42,7 +42,7 @@ namespace rsx
if (icon) if (icon)
{ {
m_icon = std::move(icon); m_icon = icon;
m_icon->set_pos(m_text.x + m_text.w + 8, m_text.y); 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); 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); 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<atomic_t<u32>>, std::unique_ptr<overlay_element>); template message_item::message_item(std::string msg_id, u64, std::shared_ptr<atomic_t<u32>>, std::shared_ptr<overlay_element>);
template message_item::message_item(localized_string_id msg_id, u64, std::shared_ptr<atomic_t<u32>>, std::unique_ptr<overlay_element>); template message_item::message_item(localized_string_id msg_id, u64, std::shared_ptr<atomic_t<u32>>, std::shared_ptr<overlay_element>);
u64 message_item::get_expiration() const u64 message_item::get_expiration() const
{ {

View File

@ -17,7 +17,7 @@ namespace rsx
{ {
public: public:
template <typename T> template <typename T>
message_item(T msg_id, u64 expiration, std::shared_ptr<atomic_t<u32>> refs, std::unique_ptr<overlay_element> icon = {}); message_item(T msg_id, u64 expiration, std::shared_ptr<atomic_t<u32>> refs, std::shared_ptr<overlay_element> icon = {});
void update(usz index, u64 time, u16 y_offset); void update(usz index, u64 time, u16 y_offset);
void set_pos(u16 _x, u16 _y) override; void set_pos(u16 _x, u16 _y) override;
@ -28,7 +28,7 @@ namespace rsx
private: private:
label m_text{}; label m_text{};
std::unique_ptr<overlay_element> m_icon{}; std::shared_ptr<overlay_element> m_icon{};
animation_color_interpolate m_fade_in_animation; animation_color_interpolate m_fade_in_animation;
animation_color_interpolate m_fade_out_animation; animation_color_interpolate m_fade_out_animation;
@ -52,7 +52,7 @@ namespace rsx
u64 expiration, u64 expiration,
std::shared_ptr<atomic_t<u32>> refs, std::shared_ptr<atomic_t<u32>> refs,
message_pin_location location = message_pin_location::top, message_pin_location location = message_pin_location::top,
std::unique_ptr<overlay_element> icon = {}) std::shared_ptr<overlay_element> icon = {})
{ {
std::lock_guard lock(m_mutex_queue); std::lock_guard lock(m_mutex_queue);
@ -72,7 +72,7 @@ namespace rsx
} }
else if (!message_exists(location, msg_id)) 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; visible = true;
@ -104,7 +104,7 @@ namespace rsx
u64 expiration = 5'000'000, u64 expiration = 5'000'000,
std::shared_ptr<atomic_t<u32>> refs = {}, std::shared_ptr<atomic_t<u32>> refs = {},
message_pin_location location = message_pin_location::top, message_pin_location location = message_pin_location::top,
std::unique_ptr<overlay_element> icon = {}) std::shared_ptr<overlay_element> icon = {})
{ {
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>()) if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
{ {

View File

@ -14,7 +14,7 @@ namespace rsx
5'000'000, 5'000'000,
{}, {},
message_pin_location::bottom, message_pin_location::bottom,
std::make_unique<loading_icon24>()); std::make_shared<loading_icon24>());
} }
} }
} }