From 67a06d17b13955cdc332585f8b02146fad6775c1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Dec 2023 10:04:44 -0500 Subject: [PATCH 1/2] GBAWidget: Use std::span with SetVideoBuffer() Previously we were always taking the buffer by value, even if it wasn't being stored anywhere and only read from. We can use a std::span for the same thing. --- Source/Core/DolphinQt/GBAWidget.cpp | 6 +++--- Source/Core/DolphinQt/GBAWidget.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinQt/GBAWidget.cpp b/Source/Core/DolphinQt/GBAWidget.cpp index 0a7ba2b84d..b355efddd3 100644 --- a/Source/Core/DolphinQt/GBAWidget.cpp +++ b/Source/Core/DolphinQt/GBAWidget.cpp @@ -106,7 +106,7 @@ void GBAWidget::GameChanged(const HW::GBA::CoreInfo& info) update(); } -void GBAWidget::SetVideoBuffer(std::vector video_buffer) +void GBAWidget::SetVideoBuffer(std::span video_buffer) { m_previous_frame = std::move(m_last_frame); if (video_buffer.size() == static_cast(m_core_info.width * m_core_info.height)) @@ -608,7 +608,7 @@ void GBAWidgetController::GameChanged(const HW::GBA::CoreInfo& info) m_widget->GameChanged(info); } -void GBAWidgetController::FrameEnded(std::vector video_buffer) +void GBAWidgetController::FrameEnded(std::span video_buffer) { - m_widget->SetVideoBuffer(std::move(video_buffer)); + m_widget->SetVideoBuffer(video_buffer); } diff --git a/Source/Core/DolphinQt/GBAWidget.h b/Source/Core/DolphinQt/GBAWidget.h index 7d90aad37e..f1309a7ae2 100644 --- a/Source/Core/DolphinQt/GBAWidget.h +++ b/Source/Core/DolphinQt/GBAWidget.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -37,7 +38,7 @@ public: ~GBAWidget(); void GameChanged(const HW::GBA::CoreInfo& info); - void SetVideoBuffer(std::vector video_buffer); + void SetVideoBuffer(std::span video_buffer); void SetVolume(int volume); void VolumeDown(); @@ -106,7 +107,7 @@ public: void Create(std::weak_ptr core, const HW::GBA::CoreInfo& info); void GameChanged(const HW::GBA::CoreInfo& info); - void FrameEnded(std::vector video_buffer); + void FrameEnded(std::span video_buffer); private: GBAWidget* m_widget{}; From dfb2783c259ff43ce66a1e795bac87aa47e5f51a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Dec 2023 10:07:17 -0500 Subject: [PATCH 2/2] GBAWidget: Add missing override specifiers --- Source/Core/DolphinQt/GBAWidget.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt/GBAWidget.h b/Source/Core/DolphinQt/GBAWidget.h index f1309a7ae2..8244b77319 100644 --- a/Source/Core/DolphinQt/GBAWidget.h +++ b/Source/Core/DolphinQt/GBAWidget.h @@ -35,7 +35,7 @@ class GBAWidget : public QWidget public: explicit GBAWidget(std::weak_ptr core, const HW::GBA::CoreInfo& info, const std::optional& netplay_pad); - ~GBAWidget(); + ~GBAWidget() override; void GameChanged(const HW::GBA::CoreInfo& info); void SetVideoBuffer(std::span video_buffer); @@ -103,7 +103,7 @@ class GBAWidgetController : public QObject Q_OBJECT public: explicit GBAWidgetController() = default; - ~GBAWidgetController(); + ~GBAWidgetController() override; void Create(std::weak_ptr core, const HW::GBA::CoreInfo& info); void GameChanged(const HW::GBA::CoreInfo& info);