diff options
author | bunnei <bunneidev@gmail.com> | 2020-01-04 06:45:06 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2020-01-04 06:45:06 +0100 |
commit | 64c56315793d2b6dbf7a55f99d4bcc51929f03cb (patch) | |
tree | 4cd4a922499783c6369a60068442dee51cdfffe3 /src/core/hle/service/vi/display | |
parent | Merge pull request #3247 from FernandoS27/remap-fix (diff) | |
download | yuzu-64c56315793d2b6dbf7a55f99d4bcc51929f03cb.tar yuzu-64c56315793d2b6dbf7a55f99d4bcc51929f03cb.tar.gz yuzu-64c56315793d2b6dbf7a55f99d4bcc51929f03cb.tar.bz2 yuzu-64c56315793d2b6dbf7a55f99d4bcc51929f03cb.tar.lz yuzu-64c56315793d2b6dbf7a55f99d4bcc51929f03cb.tar.xz yuzu-64c56315793d2b6dbf7a55f99d4bcc51929f03cb.tar.zst yuzu-64c56315793d2b6dbf7a55f99d4bcc51929f03cb.zip |
Diffstat (limited to 'src/core/hle/service/vi/display')
-rw-r--r-- | src/core/hle/service/vi/display/vi_display.cpp | 27 | ||||
-rw-r--r-- | src/core/hle/service/vi/display/vi_display.h | 9 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index cd18c1610..5a202ac81 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -24,11 +24,11 @@ Display::Display(u64 id, std::string name, Core::System& system) : id{id}, name{ Display::~Display() = default; Layer& Display::GetLayer(std::size_t index) { - return layers.at(index); + return *layers.at(index); } const Layer& Display::GetLayer(std::size_t index) const { - return layers.at(index); + return *layers.at(index); } std::shared_ptr<Kernel::ReadableEvent> Display::GetVSyncEvent() const { @@ -43,29 +43,38 @@ void Display::CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue) { // TODO(Subv): Support more than 1 layer. ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); - layers.emplace_back(id, buffer_queue); + layers.emplace_back(std::make_shared<Layer>(id, buffer_queue)); +} + +void Display::CloseLayer(u64 id) { + layers.erase( + std::remove_if(layers.begin(), layers.end(), + [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }), + layers.end()); } Layer* Display::FindLayer(u64 id) { - const auto itr = std::find_if(layers.begin(), layers.end(), - [id](const VI::Layer& layer) { return layer.GetID() == id; }); + const auto itr = + std::find_if(layers.begin(), layers.end(), + [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }); if (itr == layers.end()) { return nullptr; } - return &*itr; + return itr->get(); } const Layer* Display::FindLayer(u64 id) const { - const auto itr = std::find_if(layers.begin(), layers.end(), - [id](const VI::Layer& layer) { return layer.GetID() == id; }); + const auto itr = + std::find_if(layers.begin(), layers.end(), + [id](const std::shared_ptr<Layer>& layer) { return layer->GetID() == id; }); if (itr == layers.end()) { return nullptr; } - return &*itr; + return itr->get(); } } // namespace Service::VI diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 8bb966a85..a3855d8cd 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -4,6 +4,7 @@ #pragma once +#include <memory> #include <string> #include <vector> @@ -69,6 +70,12 @@ public: /// void CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue); + /// Closes and removes a layer from this display with the given ID. + /// + /// @param id The ID assigned to the layer to close. + /// + void CloseLayer(u64 id); + /// Attempts to find a layer with the given ID. /// /// @param id The layer ID. @@ -91,7 +98,7 @@ private: u64 id; std::string name; - std::vector<Layer> layers; + std::vector<std::shared_ptr<Layer>> layers; Kernel::EventPair vsync_event; }; |