diff options
Diffstat (limited to 'src/core/hle/service/vi')
-rw-r--r-- | src/core/hle/service/vi/container.cpp | 52 | ||||
-rw-r--r-- | src/core/hle/service/vi/container.h | 3 | ||||
-rw-r--r-- | src/core/hle/service/vi/layer.h | 16 | ||||
-rw-r--r-- | src/core/hle/service/vi/layer_list.h | 6 |
4 files changed, 38 insertions, 39 deletions
diff --git a/src/core/hle/service/vi/container.cpp b/src/core/hle/service/vi/container.cpp index 310a207f1..9074f4ae0 100644 --- a/src/core/hle/service/vi/container.cpp +++ b/src/core/hle/service/vi/container.cpp @@ -43,11 +43,7 @@ void Container::OnTerminate() { m_is_shut_down = true; - m_layers.ForEachLayer([&](auto& layer) { - if (layer.IsOpen()) { - this->DestroyBufferQueueLocked(&layer); - } - }); + m_layers.ForEachLayer([&](auto& layer) { this->DestroyLayerLocked(layer.GetId()); }); m_displays.ForEachDisplay( [&](auto& display) { m_surface_flinger->RemoveDisplay(display.GetId()); }); @@ -161,16 +157,29 @@ Result Container::CreateLayerLocked(u64* out_layer_id, u64 display_id, u64 owner auto* const display = m_displays.GetDisplayById(display_id); R_UNLESS(display != nullptr, VI::ResultNotFound); - auto* const layer = m_layers.CreateLayer(owner_aruid, display); + s32 consumer_binder_id, producer_binder_id; + m_surface_flinger->CreateBufferQueue(&consumer_binder_id, &producer_binder_id); + + auto* const layer = + m_layers.CreateLayer(owner_aruid, display, consumer_binder_id, producer_binder_id); R_UNLESS(layer != nullptr, VI::ResultNotFound); + m_surface_flinger->CreateLayer(consumer_binder_id); + *out_layer_id = layer->GetId(); R_SUCCEED(); } Result Container::DestroyLayerLocked(u64 layer_id) { - R_SUCCEED_IF(m_layers.DestroyLayer(layer_id)); - R_THROW(VI::ResultNotFound); + auto* const layer = m_layers.GetLayerById(layer_id); + R_UNLESS(layer != nullptr, VI::ResultNotFound); + + m_surface_flinger->DestroyLayer(layer->GetConsumerBinderId()); + m_surface_flinger->DestroyBufferQueue(layer->GetConsumerBinderId(), + layer->GetProducerBinderId()); + m_layers.DestroyLayer(layer_id); + + R_SUCCEED(); } Result Container::OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid) { @@ -181,7 +190,12 @@ Result Container::OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 R_UNLESS(!layer->IsOpen(), VI::ResultOperationFailed); R_UNLESS(layer->GetOwnerAruid() == aruid, VI::ResultPermissionDenied); - this->CreateBufferQueueLocked(layer); + layer->Open(); + + if (auto* display = layer->GetDisplay(); display != nullptr) { + m_surface_flinger->AddLayerToDisplayStack(display->GetId(), layer->GetConsumerBinderId()); + } + *out_producer_binder_id = layer->GetProducerBinderId(); R_SUCCEED(); @@ -192,30 +206,14 @@ Result Container::CloseLayerLocked(u64 layer_id) { R_UNLESS(layer != nullptr, VI::ResultNotFound); R_UNLESS(layer->IsOpen(), VI::ResultOperationFailed); - this->DestroyBufferQueueLocked(layer); - - R_SUCCEED(); -} - -void Container::CreateBufferQueueLocked(Layer* layer) { - s32 consumer_binder_id, producer_binder_id; - m_surface_flinger->CreateBufferQueue(&consumer_binder_id, &producer_binder_id); - layer->Open(consumer_binder_id, producer_binder_id); - - if (auto* display = layer->GetDisplay(); display != nullptr) { - m_surface_flinger->AddLayerToDisplayStack(display->GetId(), consumer_binder_id); - } -} - -void Container::DestroyBufferQueueLocked(Layer* layer) { if (auto* display = layer->GetDisplay(); display != nullptr) { m_surface_flinger->RemoveLayerFromDisplayStack(display->GetId(), layer->GetConsumerBinderId()); } layer->Close(); - m_surface_flinger->DestroyBufferQueue(layer->GetConsumerBinderId(), - layer->GetProducerBinderId()); + + R_SUCCEED(); } bool Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, diff --git a/src/core/hle/service/vi/container.h b/src/core/hle/service/vi/container.h index cd0d2ca86..5eac4d77d 100644 --- a/src/core/hle/service/vi/container.h +++ b/src/core/hle/service/vi/container.h @@ -72,9 +72,6 @@ private: Result OpenLayerLocked(s32* out_producer_binder_id, u64 layer_id, u64 aruid); Result CloseLayerLocked(u64 layer_id); - void CreateBufferQueueLocked(Layer* layer); - void DestroyBufferQueueLocked(Layer* layer); - public: bool ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); diff --git a/src/core/hle/service/vi/layer.h b/src/core/hle/service/vi/layer.h index b85c8df61..e4c9c9864 100644 --- a/src/core/hle/service/vi/layer.h +++ b/src/core/hle/service/vi/layer.h @@ -13,29 +13,31 @@ class Layer { public: constexpr Layer() = default; - void Initialize(u64 id, u64 owner_aruid, Display* display) { + void Initialize(u64 id, u64 owner_aruid, Display* display, s32 consumer_binder_id, + s32 producer_binder_id) { m_id = id; m_owner_aruid = owner_aruid; m_display = display; + m_consumer_binder_id = consumer_binder_id; + m_producer_binder_id = producer_binder_id; m_is_initialized = true; } void Finalize() { m_id = {}; + m_owner_aruid = {}; m_display = {}; + m_consumer_binder_id = {}; + m_producer_binder_id = {}; m_is_initialized = {}; } - void Open(s32 consumer_binder_id, s32 producer_binder_id) { - m_consumer_binder_id = consumer_binder_id; - m_producer_binder_id = producer_binder_id; + void Open() { m_is_open = true; } void Close() { - m_producer_binder_id = {}; - m_consumer_binder_id = {}; - m_is_open = {}; + m_is_open = false; } u64 GetId() const { diff --git a/src/core/hle/service/vi/layer_list.h b/src/core/hle/service/vi/layer_list.h index 1738ede9a..4afca6f40 100644 --- a/src/core/hle/service/vi/layer_list.h +++ b/src/core/hle/service/vi/layer_list.h @@ -11,13 +11,15 @@ class LayerList { public: constexpr LayerList() = default; - Layer* CreateLayer(u64 owner_aruid, Display* display) { + Layer* CreateLayer(u64 owner_aruid, Display* display, s32 consumer_binder_id, + s32 producer_binder_id) { Layer* const layer = GetFreeLayer(); if (!layer) { return nullptr; } - layer->Initialize(++m_next_id, owner_aruid, display); + layer->Initialize(++m_next_id, owner_aruid, display, consumer_binder_id, + producer_binder_id); return layer; } |