summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/vi/display
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-12-10 18:32:44 +0100
committerLiam <byteslice@airmail.cc>2023-12-12 18:14:23 +0100
commitadc307961357243a67ed4400d18ec9979a0c55db (patch)
treec1a143b2be065e4a7cf7bd03918b77576c1e0507 /src/core/hle/service/vi/display
parentMerge pull request #12296 from liamwhite/client-session (diff)
downloadyuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar
yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.gz
yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.bz2
yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.lz
yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.xz
yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.zst
yuzu-adc307961357243a67ed4400d18ec9979a0c55db.zip
Diffstat (limited to 'src/core/hle/service/vi/display')
-rw-r--r--src/core/hle/service/vi/display/vi_display.cpp25
-rw-r--r--src/core/hle/service/vi/display/vi_display.h15
2 files changed, 26 insertions, 14 deletions
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp
index d30f49877..71ce9be50 100644
--- a/src/core/hle/service/vi/display/vi_display.cpp
+++ b/src/core/hle/service/vi/display/vi_display.cpp
@@ -51,11 +51,24 @@ Display::~Display() {
}
Layer& Display::GetLayer(std::size_t index) {
- return *layers.at(index);
+ size_t i = 0;
+ for (auto& layer : layers) {
+ if (!layer->IsOpen()) {
+ continue;
+ }
+
+ if (i == index) {
+ return *layer;
+ }
+
+ i++;
+ }
+
+ UNREACHABLE();
}
-const Layer& Display::GetLayer(std::size_t index) const {
- return *layers.at(index);
+size_t Display::GetNumLayers() const {
+ return std::ranges::count_if(layers, [](auto& l) { return l->IsOpen(); });
}
Result Display::GetVSyncEvent(Kernel::KReadableEvent** out_vsync_event) {
@@ -92,7 +105,11 @@ void Display::CreateLayer(u64 layer_id, u32 binder_id,
hos_binder_driver_server.RegisterProducer(std::move(producer));
}
-void Display::CloseLayer(u64 layer_id) {
+void Display::DestroyLayer(u64 layer_id) {
+ if (auto* layer = this->FindLayer(layer_id); layer != nullptr) {
+ layer->GetConsumer().Abandon();
+ }
+
std::erase_if(layers,
[layer_id](const auto& layer) { return layer->GetLayerId() == layer_id; });
}
diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h
index 101cbce20..1d9360b96 100644
--- a/src/core/hle/service/vi/display/vi_display.h
+++ b/src/core/hle/service/vi/display/vi_display.h
@@ -66,18 +66,13 @@ public:
/// Whether or not this display has any layers added to it.
bool HasLayers() const {
- return !layers.empty();
+ return GetNumLayers() > 0;
}
/// Gets a layer for this display based off an index.
Layer& GetLayer(std::size_t index);
- /// Gets a layer for this display based off an index.
- const Layer& GetLayer(std::size_t index) const;
-
- std::size_t GetNumLayers() const {
- return layers.size();
- }
+ std::size_t GetNumLayers() const;
/**
* Gets the internal vsync event.
@@ -100,11 +95,11 @@ public:
///
void CreateLayer(u64 layer_id, u32 binder_id, Service::Nvidia::NvCore::Container& core);
- /// Closes and removes a layer from this display with the given ID.
+ /// Removes a layer from this display with the given ID.
///
- /// @param layer_id The ID assigned to the layer to close.
+ /// @param layer_id The ID assigned to the layer to destroy.
///
- void CloseLayer(u64 layer_id);
+ void DestroyLayer(u64 layer_id);
/// Resets the display for a new connection.
void Reset() {