From fa4dc2cf427ddb464d73d532ba941513828b9b7a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 21 Feb 2019 10:43:26 -0500 Subject: service/nvflinger: Move display specifics over to vi_display With the display and layer structures relocated to the vi service, we can begin giving these a proper interface before beginning to properly support the display types. This converts the display struct into a class and provides it with the necessary functions to preserve behavior within the NVFlinger class. --- src/core/hle/service/vi/display/vi_display.cpp | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/core/hle/service/vi/display/vi_display.cpp') diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index a108e468f..4d77c3353 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -2,8 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include + #include +#include "common/assert.h" #include "core/core.h" #include "core/hle/kernel/readable_event.h" #include "core/hle/service/vi/display/vi_display.h" @@ -19,4 +23,49 @@ Display::Display(u64 id, std::string name) : id{id}, name{std::move(name)} { Display::~Display() = default; +Layer& Display::GetLayer(std::size_t index) { + return layers.at(index); +} + +const Layer& Display::GetLayer(std::size_t index) const { + return layers.at(index); +} + +Kernel::SharedPtr Display::GetVSyncEvent() const { + return vsync_event.readable; +} + +void Display::SignalVSyncEvent() { + vsync_event.writable->Signal(); +} + +void Display::CreateLayer(u64 id, std::shared_ptr 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, std::move(buffer_queue)); +} + +Layer* Display::FindLayer(u64 id) { + const auto itr = std::find_if(layers.begin(), layers.end(), + [id](const VI::Layer& layer) { return layer.id == id; }); + + if (itr == layers.end()) { + return nullptr; + } + + return &*itr; +} + +const Layer* Display::FindLayer(u64 id) const { + const auto itr = std::find_if(layers.begin(), layers.end(), + [id](const VI::Layer& layer) { return layer.id == id; }); + + if (itr == layers.end()) { + return nullptr; + } + + return &*itr; +} + } // namespace Service::VI -- cgit v1.2.3