nvnflinger: ensure display abandonment considers all layers and future layers

master
Liam 2024-01-17 18:45:39 +07:00
parent 915efa4236
commit ce89580749
3 changed files with 15 additions and 3 deletions

@ -112,9 +112,7 @@ void Nvnflinger::ShutdownLayers() {
{
const auto lock_guard = Lock();
for (auto& display : displays) {
for (size_t layer = 0; layer < display.GetNumLayers(); ++layer) {
display.GetLayer(layer).GetConsumer().Abandon();
}
display.Abandon();
}
is_abandoned = true;

@ -91,6 +91,10 @@ void Display::CreateLayer(u64 layer_id, u32 binder_id,
layers.emplace_back(std::make_unique<Layer>(layer_id, binder_id, *core, *producer,
std::move(buffer_item_consumer)));
if (is_abandoned) {
this->FindLayer(layer_id)->GetConsumer().Abandon();
}
hos_binder_driver_server.RegisterProducer(std::move(producer));
}
@ -103,6 +107,13 @@ void Display::DestroyLayer(u64 layer_id) {
[layer_id](const auto& layer) { return layer->GetLayerId() == layer_id; });
}
void Display::Abandon() {
for (auto& layer : layers) {
layer->GetConsumer().Abandon();
}
is_abandoned = true;
}
Layer* Display::FindLayer(u64 layer_id) {
const auto itr =
std::find_if(layers.begin(), layers.end(), [layer_id](const std::unique_ptr<Layer>& layer) {

@ -98,6 +98,8 @@ public:
layers.clear();
}
void Abandon();
/// Attempts to find a layer with the given ID.
///
/// @param layer_id The layer ID.
@ -124,6 +126,7 @@ private:
std::vector<std::unique_ptr<Layer>> layers;
Kernel::KEvent* vsync_event{};
bool is_abandoned{};
};
} // namespace Service::VI