From 205f8a64796217da779bbf67f6054b8dc3077e03 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Thu, 2 Feb 2023 03:12:30 +0300 Subject: [PATCH] rsx: Fix message queue order and positioning --- rpcs3/Emu/RSX/Overlays/overlay_message.cpp | 55 +++++++++++++++------- rpcs3/Emu/RSX/Overlays/overlay_message.h | 9 ++-- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message.cpp index 26d6efa924..f17f9030cc 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message.cpp @@ -28,10 +28,15 @@ namespace rsx m_text.auto_resize(); m_text.back_color.a = 0.f; - m_fade_animation.current = color4f(1.f); - m_fade_animation.end = color4f(1.0f, 1.0f, 1.0f, 0.f); - m_fade_animation.duration = 2.f; - m_fade_animation.active = true; + m_fade_in_animation.current = color4f(0.f); + m_fade_in_animation.end = color4f(1.0f); + m_fade_in_animation.duration = 1.f; + m_fade_in_animation.active = true; + + m_fade_out_animation.current = color4f(1.f); + m_fade_out_animation.end = color4f(0.f); + m_fade_out_animation.duration = 2.f; + m_fade_out_animation.active = true; back_color.a = 0.15; @@ -69,7 +74,11 @@ namespace rsx compiled_resource& message_item::get_compiled() { - if (!m_processed || !m_fade_animation.active) + auto& current_animation = m_fade_in_animation.active + ? m_fade_in_animation + : m_fade_out_animation; + + if (!m_processed || !current_animation.active) { compiled_resources = {}; return compiled_resources; @@ -84,32 +93,37 @@ namespace rsx { compiled_resources.add(m_icon->get_compiled()); } - m_fade_animation.apply(compiled_resources); + current_animation.apply(compiled_resources); return compiled_resources; } - void message_item::update(usz index, u64 time, u16 origin, int grow_direction) + void message_item::update(usz index, u64 time, u16 y_offset) { if (m_cur_pos != index) { m_cur_pos = index; - set_pos(10, static_cast(origin + (index * 18 * grow_direction))); + set_pos(10, y_offset); } if (!m_processed) { m_expiration_time = get_expiration_time(m_visible_duration); } + + if (m_fade_in_animation.active) + { + m_fade_in_animation.update(rsx::get_current_renderer()->vblank_count); + } else if (time + 2'000'000 > m_expiration_time) { - m_fade_animation.update(rsx::get_current_renderer()->vblank_count); + m_fade_out_animation.update(rsx::get_current_renderer()->vblank_count); } m_processed = true; } - void message::update_queue(std::deque& vis_set, std::deque& ready_set, u16 origin, int grow_direction) + void message::update_queue(std::deque& vis_set, std::deque& ready_set, message_pin_location origin) { const u64 cur_time = rsx::uclock(); @@ -129,11 +143,20 @@ namespace rsx return; } - usz index = 0; - for (auto& item : vis_set) + // Render reversed list. Oldest entries are furthest from the border + u16 y_offset = 8, margin = 4, index = 0; + for (auto it = vis_set.rbegin(); it != vis_set.rend(); ++it, ++index) { - item.update(index, cur_time, origin, grow_direction); - index++; + if (origin == message_pin_location::top) [[ likely ]] + { + it->update(index, cur_time, y_offset); + y_offset += (margin + it->h); + } + else + { + y_offset += (margin + it->h); + it->update(index, cur_time, virtual_height - y_offset); + } } } @@ -146,8 +169,8 @@ namespace rsx std::lock_guard lock(m_mutex_queue); - update_queue(m_vis_items_top, m_ready_queue_top, 10, 1); - update_queue(m_vis_items_bottom, m_ready_queue_bottom, virtual_height - 18, -1); + update_queue(m_vis_items_top, m_ready_queue_top, message_pin_location::top); + update_queue(m_vis_items_bottom, m_ready_queue_bottom, message_pin_location::bottom); visible = !m_vis_items_top.empty() || !m_vis_items_bottom.empty(); } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message.h b/rpcs3/Emu/RSX/Overlays/overlay_message.h index 62d0b7cb8c..3e0638fb94 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_message.h @@ -7,7 +7,7 @@ namespace rsx { namespace overlays { - enum message_pin_location + enum class message_pin_location { top, bottom @@ -18,7 +18,7 @@ namespace rsx public: template message_item(T msg_id, u64 expiration, std::shared_ptr> refs, std::unique_ptr icon = {}); - void update(usz index, u64 time, u16 origin, int grow_direction); + void update(usz index, u64 time, u16 y_offset); void set_pos(u16 _x, u16 _y) override; u64 get_expiration() const; @@ -27,7 +27,8 @@ namespace rsx private: label m_text{}; std::unique_ptr m_icon{}; - animation_color_interpolate m_fade_animation; + animation_color_interpolate m_fade_in_animation; + animation_color_interpolate m_fade_out_animation; u64 m_expiration_time = 0; u64 m_visible_duration = 0; @@ -84,7 +85,7 @@ namespace rsx std::deque m_vis_items_top; std::deque m_vis_items_bottom; - void update_queue(std::deque& vis_set, std::deque& ready_set, u16 origin, int grow_direction); + void update_queue(std::deque& vis_set, std::deque& ready_set, message_pin_location origin); }; template