diff options
| author | 2024-02-18 23:36:53 -0600 | |
|---|---|---|
| committer | 2024-02-18 23:36:53 -0600 | |
| commit | 8615509c4054f497fbd6ed9a7adee5a998597905 (patch) | |
| tree | 293bff8e944c2ca632524e39bbfba33d6475af16 /src/core/hle/service/am | |
| parent | Merge pull request #13048 from liamwhite/new-shell (diff) | |
| parent | nvnflinger: check for layers before compose (diff) | |
| download | yuzu-8615509c4054f497fbd6ed9a7adee5a998597905.tar.gz yuzu-8615509c4054f497fbd6ed9a7adee5a998597905.tar.xz yuzu-8615509c4054f497fbd6ed9a7adee5a998597905.zip | |
Merge pull request #13035 from liamwhite/vi2
vi: manage resources independently of nvnflinger and refactor
Diffstat (limited to 'src/core/hle/service/am')
24 files changed, 280 insertions, 317 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 9dc710ba9..8c4e14f08 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -8,13 +8,13 @@ | |||
| 8 | 8 | ||
| 9 | namespace Service::AM { | 9 | namespace Service::AM { |
| 10 | 10 | ||
| 11 | void LoopProcess(Nvnflinger::Nvnflinger& nvnflinger, Core::System& system) { | 11 | void LoopProcess(Core::System& system) { |
| 12 | auto server_manager = std::make_unique<ServerManager>(system); | 12 | auto server_manager = std::make_unique<ServerManager>(system); |
| 13 | 13 | ||
| 14 | server_manager->RegisterNamedService( | 14 | server_manager->RegisterNamedService("appletAE", |
| 15 | "appletAE", std::make_shared<IAllSystemAppletProxiesService>(system, nvnflinger)); | 15 | std::make_shared<IAllSystemAppletProxiesService>(system)); |
| 16 | server_manager->RegisterNamedService( | 16 | server_manager->RegisterNamedService("appletOE", |
| 17 | "appletOE", std::make_shared<IApplicationProxyService>(system, nvnflinger)); | 17 | std::make_shared<IApplicationProxyService>(system)); |
| 18 | ServerManager::RunServer(std::move(server_manager)); | 18 | ServerManager::RunServer(std::move(server_manager)); |
| 19 | } | 19 | } |
| 20 | 20 | ||
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 4a2d797bd..1afe253ae 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::Nvnflinger { | ||
| 11 | class Nvnflinger; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::AM { | 10 | namespace Service::AM { |
| 15 | 11 | ||
| 16 | void LoopProcess(Nvnflinger::Nvnflinger& nvnflinger, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::AM | 14 | } // namespace Service::AM |
diff --git a/src/core/hle/service/am/applet.h b/src/core/hle/service/am/applet.h index 4f34d4811..ad602153e 100644 --- a/src/core/hle/service/am/applet.h +++ b/src/core/hle/service/am/applet.h | |||
| @@ -14,10 +14,9 @@ | |||
| 14 | 14 | ||
| 15 | #include "core/hle/service/am/am_types.h" | 15 | #include "core/hle/service/am/am_types.h" |
| 16 | #include "core/hle/service/am/applet_message_queue.h" | 16 | #include "core/hle/service/am/applet_message_queue.h" |
| 17 | #include "core/hle/service/am/display_layer_manager.h" | ||
| 17 | #include "core/hle/service/am/hid_registration.h" | 18 | #include "core/hle/service/am/hid_registration.h" |
| 18 | #include "core/hle/service/am/managed_layer_holder.h" | ||
| 19 | #include "core/hle/service/am/process.h" | 19 | #include "core/hle/service/am/process.h" |
| 20 | #include "core/hle/service/am/system_buffer_manager.h" | ||
| 21 | 20 | ||
| 22 | namespace Service::AM { | 21 | namespace Service::AM { |
| 23 | 22 | ||
| @@ -54,8 +53,7 @@ struct Applet { | |||
| 54 | HidRegistration hid_registration; | 53 | HidRegistration hid_registration; |
| 55 | 54 | ||
| 56 | // vi state | 55 | // vi state |
| 57 | SystemBufferManager system_buffer_manager{}; | 56 | DisplayLayerManager display_layer_manager{}; |
| 58 | ManagedLayerHolder managed_layer_holder{}; | ||
| 59 | 57 | ||
| 60 | // Applet common functions | 58 | // Applet common functions |
| 61 | Result terminate_result{}; | 59 | Result terminate_result{}; |
diff --git a/src/core/hle/service/am/display_layer_manager.cpp b/src/core/hle/service/am/display_layer_manager.cpp new file mode 100644 index 000000000..85ff6fb88 --- /dev/null +++ b/src/core/hle/service/am/display_layer_manager.cpp | |||
| @@ -0,0 +1,151 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/core.h" | ||
| 5 | #include "core/hle/service/am/display_layer_manager.h" | ||
| 6 | #include "core/hle/service/sm/sm.h" | ||
| 7 | #include "core/hle/service/vi/application_display_service.h" | ||
| 8 | #include "core/hle/service/vi/container.h" | ||
| 9 | #include "core/hle/service/vi/manager_display_service.h" | ||
| 10 | #include "core/hle/service/vi/manager_root_service.h" | ||
| 11 | #include "core/hle/service/vi/shared_buffer_manager.h" | ||
| 12 | #include "core/hle/service/vi/vi_results.h" | ||
| 13 | #include "core/hle/service/vi/vi_types.h" | ||
| 14 | |||
| 15 | namespace Service::AM { | ||
| 16 | |||
| 17 | DisplayLayerManager::DisplayLayerManager() = default; | ||
| 18 | DisplayLayerManager::~DisplayLayerManager() { | ||
| 19 | this->Finalize(); | ||
| 20 | } | ||
| 21 | |||
| 22 | void DisplayLayerManager::Initialize(Core::System& system, Kernel::KProcess* process, | ||
| 23 | AppletId applet_id, LibraryAppletMode mode) { | ||
| 24 | R_ASSERT(system.ServiceManager() | ||
| 25 | .GetService<VI::IManagerRootService>("vi:m", true) | ||
| 26 | ->GetDisplayService(&m_display_service, VI::Policy::Compositor)); | ||
| 27 | R_ASSERT(m_display_service->GetManagerDisplayService(&m_manager_display_service)); | ||
| 28 | |||
| 29 | m_process = process; | ||
| 30 | m_system_shared_buffer_id = 0; | ||
| 31 | m_system_shared_layer_id = 0; | ||
| 32 | m_applet_id = applet_id; | ||
| 33 | m_buffer_sharing_enabled = false; | ||
| 34 | m_blending_enabled = mode == LibraryAppletMode::PartialForeground || | ||
| 35 | mode == LibraryAppletMode::PartialForegroundIndirectDisplay; | ||
| 36 | } | ||
| 37 | |||
| 38 | void DisplayLayerManager::Finalize() { | ||
| 39 | if (!m_manager_display_service) { | ||
| 40 | return; | ||
| 41 | } | ||
| 42 | |||
| 43 | // Clean up managed layers. | ||
| 44 | for (const auto& layer : m_managed_display_layers) { | ||
| 45 | m_manager_display_service->DestroyManagedLayer(layer); | ||
| 46 | } | ||
| 47 | |||
| 48 | for (const auto& layer : m_managed_display_recording_layers) { | ||
| 49 | m_manager_display_service->DestroyManagedLayer(layer); | ||
| 50 | } | ||
| 51 | |||
| 52 | // Clean up shared layers. | ||
| 53 | if (m_buffer_sharing_enabled) { | ||
| 54 | m_manager_display_service->DestroySharedLayerSession(m_process); | ||
| 55 | } | ||
| 56 | |||
| 57 | m_manager_display_service = nullptr; | ||
| 58 | m_display_service = nullptr; | ||
| 59 | } | ||
| 60 | |||
| 61 | Result DisplayLayerManager::CreateManagedDisplayLayer(u64* out_layer_id) { | ||
| 62 | R_UNLESS(m_manager_display_service != nullptr, VI::ResultOperationFailed); | ||
| 63 | |||
| 64 | // TODO(Subv): Find out how AM determines the display to use, for now just | ||
| 65 | // create the layer in the Default display. | ||
| 66 | u64 display_id; | ||
| 67 | R_TRY(m_display_service->OpenDisplay(&display_id, VI::DisplayName{"Default"})); | ||
| 68 | R_TRY(m_manager_display_service->CreateManagedLayer( | ||
| 69 | out_layer_id, 0, display_id, Service::AppletResourceUserId{m_process->GetProcessId()})); | ||
| 70 | |||
| 71 | m_manager_display_service->SetLayerVisibility(m_visible, *out_layer_id); | ||
| 72 | m_managed_display_layers.emplace(*out_layer_id); | ||
| 73 | |||
| 74 | R_SUCCEED(); | ||
| 75 | } | ||
| 76 | |||
| 77 | Result DisplayLayerManager::CreateManagedDisplaySeparableLayer(u64* out_layer_id, | ||
| 78 | u64* out_recording_layer_id) { | ||
| 79 | R_UNLESS(m_manager_display_service != nullptr, VI::ResultOperationFailed); | ||
| 80 | |||
| 81 | // TODO(Subv): Find out how AM determines the display to use, for now just | ||
| 82 | // create the layer in the Default display. | ||
| 83 | // This calls nn::vi::CreateRecordingLayer() which creates another layer. | ||
| 84 | // Currently we do not support more than 1 layer per display, output 1 layer id for now. | ||
| 85 | // Outputting 1 layer id instead of the expected 2 has not been observed to cause any adverse | ||
| 86 | // side effects. | ||
| 87 | *out_recording_layer_id = 0; | ||
| 88 | R_RETURN(this->CreateManagedDisplayLayer(out_layer_id)); | ||
| 89 | } | ||
| 90 | |||
| 91 | Result DisplayLayerManager::IsSystemBufferSharingEnabled() { | ||
| 92 | // Succeed if already enabled. | ||
| 93 | R_SUCCEED_IF(m_buffer_sharing_enabled); | ||
| 94 | |||
| 95 | // Ensure we can access shared layers. | ||
| 96 | R_UNLESS(m_manager_display_service != nullptr, VI::ResultOperationFailed); | ||
| 97 | R_UNLESS(m_applet_id != AppletId::Application, VI::ResultPermissionDenied); | ||
| 98 | |||
| 99 | // Create the shared layer. | ||
| 100 | u64 display_id; | ||
| 101 | R_TRY(m_display_service->OpenDisplay(&display_id, VI::DisplayName{"Default"})); | ||
| 102 | R_TRY(m_manager_display_service->CreateSharedLayerSession(m_process, &m_system_shared_buffer_id, | ||
| 103 | &m_system_shared_layer_id, display_id, | ||
| 104 | m_blending_enabled)); | ||
| 105 | |||
| 106 | // We succeeded, so set up remaining state. | ||
| 107 | m_buffer_sharing_enabled = true; | ||
| 108 | m_manager_display_service->SetLayerVisibility(m_visible, m_system_shared_layer_id); | ||
| 109 | R_SUCCEED(); | ||
| 110 | } | ||
| 111 | |||
| 112 | Result DisplayLayerManager::GetSystemSharedLayerHandle(u64* out_system_shared_buffer_id, | ||
| 113 | u64* out_system_shared_layer_id) { | ||
| 114 | R_TRY(this->IsSystemBufferSharingEnabled()); | ||
| 115 | |||
| 116 | *out_system_shared_buffer_id = m_system_shared_buffer_id; | ||
| 117 | *out_system_shared_layer_id = m_system_shared_layer_id; | ||
| 118 | |||
| 119 | R_SUCCEED(); | ||
| 120 | } | ||
| 121 | |||
| 122 | void DisplayLayerManager::SetWindowVisibility(bool visible) { | ||
| 123 | if (m_visible == visible) { | ||
| 124 | return; | ||
| 125 | } | ||
| 126 | |||
| 127 | m_visible = visible; | ||
| 128 | |||
| 129 | if (m_manager_display_service) { | ||
| 130 | if (m_system_shared_layer_id) { | ||
| 131 | m_manager_display_service->SetLayerVisibility(m_visible, m_system_shared_layer_id); | ||
| 132 | } | ||
| 133 | |||
| 134 | for (const auto layer_id : m_managed_display_layers) { | ||
| 135 | m_manager_display_service->SetLayerVisibility(m_visible, layer_id); | ||
| 136 | } | ||
| 137 | } | ||
| 138 | } | ||
| 139 | |||
| 140 | bool DisplayLayerManager::GetWindowVisibility() const { | ||
| 141 | return m_visible; | ||
| 142 | } | ||
| 143 | |||
| 144 | Result DisplayLayerManager::WriteAppletCaptureBuffer(bool* out_was_written, | ||
| 145 | s32* out_fbshare_layer_index) { | ||
| 146 | R_UNLESS(m_buffer_sharing_enabled, VI::ResultPermissionDenied); | ||
| 147 | R_RETURN(m_display_service->GetContainer()->GetSharedBufferManager()->WriteAppletCaptureBuffer( | ||
| 148 | out_was_written, out_fbshare_layer_index)); | ||
| 149 | } | ||
| 150 | |||
| 151 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/display_layer_manager.h b/src/core/hle/service/am/display_layer_manager.h new file mode 100644 index 000000000..a66509c04 --- /dev/null +++ b/src/core/hle/service/am/display_layer_manager.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <set> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "core/hle/result.h" | ||
| 10 | #include "core/hle/service/am/am_types.h" | ||
| 11 | |||
| 12 | namespace Core { | ||
| 13 | class System; | ||
| 14 | } | ||
| 15 | |||
| 16 | namespace Kernel { | ||
| 17 | class KProcess; | ||
| 18 | } | ||
| 19 | |||
| 20 | namespace Service::VI { | ||
| 21 | class IApplicationDisplayService; | ||
| 22 | class IManagerDisplayService; | ||
| 23 | } // namespace Service::VI | ||
| 24 | |||
| 25 | namespace Service::AM { | ||
| 26 | |||
| 27 | class DisplayLayerManager { | ||
| 28 | public: | ||
| 29 | explicit DisplayLayerManager(); | ||
| 30 | ~DisplayLayerManager(); | ||
| 31 | |||
| 32 | void Initialize(Core::System& system, Kernel::KProcess* process, AppletId applet_id, | ||
| 33 | LibraryAppletMode mode); | ||
| 34 | void Finalize(); | ||
| 35 | |||
| 36 | Result CreateManagedDisplayLayer(u64* out_layer_id); | ||
| 37 | Result CreateManagedDisplaySeparableLayer(u64* out_layer_id, u64* out_recording_layer_id); | ||
| 38 | |||
| 39 | Result IsSystemBufferSharingEnabled(); | ||
| 40 | Result GetSystemSharedLayerHandle(u64* out_system_shared_buffer_id, | ||
| 41 | u64* out_system_shared_layer_id); | ||
| 42 | |||
| 43 | void SetWindowVisibility(bool visible); | ||
| 44 | bool GetWindowVisibility() const; | ||
| 45 | |||
| 46 | Result WriteAppletCaptureBuffer(bool* out_was_written, s32* out_fbshare_layer_index); | ||
| 47 | |||
| 48 | private: | ||
| 49 | Kernel::KProcess* m_process{}; | ||
| 50 | std::shared_ptr<VI::IApplicationDisplayService> m_display_service{}; | ||
| 51 | std::shared_ptr<VI::IManagerDisplayService> m_manager_display_service{}; | ||
| 52 | std::set<u64> m_managed_display_layers{}; | ||
| 53 | std::set<u64> m_managed_display_recording_layers{}; | ||
| 54 | u64 m_system_shared_buffer_id{}; | ||
| 55 | u64 m_system_shared_layer_id{}; | ||
| 56 | AppletId m_applet_id{}; | ||
| 57 | bool m_buffer_sharing_enabled{}; | ||
| 58 | bool m_blending_enabled{}; | ||
| 59 | bool m_visible{true}; | ||
| 60 | }; | ||
| 61 | |||
| 62 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/managed_layer_holder.cpp b/src/core/hle/service/am/managed_layer_holder.cpp deleted file mode 100644 index 61eb8641a..000000000 --- a/src/core/hle/service/am/managed_layer_holder.cpp +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/am/managed_layer_holder.h" | ||
| 5 | #include "core/hle/service/nvnflinger/nvnflinger.h" | ||
| 6 | |||
| 7 | namespace Service::AM { | ||
| 8 | |||
| 9 | ManagedLayerHolder::ManagedLayerHolder() = default; | ||
| 10 | ManagedLayerHolder::~ManagedLayerHolder() { | ||
| 11 | if (!m_nvnflinger) { | ||
| 12 | return; | ||
| 13 | } | ||
| 14 | |||
| 15 | for (const auto& layer : m_managed_display_layers) { | ||
| 16 | m_nvnflinger->DestroyLayer(layer); | ||
| 17 | } | ||
| 18 | |||
| 19 | for (const auto& layer : m_managed_display_recording_layers) { | ||
| 20 | m_nvnflinger->DestroyLayer(layer); | ||
| 21 | } | ||
| 22 | |||
| 23 | m_nvnflinger = nullptr; | ||
| 24 | } | ||
| 25 | |||
| 26 | void ManagedLayerHolder::Initialize(Nvnflinger::Nvnflinger* nvnflinger) { | ||
| 27 | m_nvnflinger = nvnflinger; | ||
| 28 | } | ||
| 29 | |||
| 30 | void ManagedLayerHolder::CreateManagedDisplayLayer(u64* out_layer) { | ||
| 31 | // TODO(Subv): Find out how AM determines the display to use, for now just | ||
| 32 | // create the layer in the Default display. | ||
| 33 | const auto display_id = m_nvnflinger->OpenDisplay("Default"); | ||
| 34 | const auto layer_id = m_nvnflinger->CreateLayer(*display_id); | ||
| 35 | |||
| 36 | m_managed_display_layers.emplace(*layer_id); | ||
| 37 | |||
| 38 | *out_layer = *layer_id; | ||
| 39 | } | ||
| 40 | |||
| 41 | void ManagedLayerHolder::CreateManagedDisplaySeparableLayer(u64* out_layer, | ||
| 42 | u64* out_recording_layer) { | ||
| 43 | // TODO(Subv): Find out how AM determines the display to use, for now just | ||
| 44 | // create the layer in the Default display. | ||
| 45 | // This calls nn::vi::CreateRecordingLayer() which creates another layer. | ||
| 46 | // Currently we do not support more than 1 layer per display, output 1 layer id for now. | ||
| 47 | // Outputting 1 layer id instead of the expected 2 has not been observed to cause any adverse | ||
| 48 | // side effects. | ||
| 49 | // TODO: Support multiple layers | ||
| 50 | const auto display_id = m_nvnflinger->OpenDisplay("Default"); | ||
| 51 | const auto layer_id = m_nvnflinger->CreateLayer(*display_id); | ||
| 52 | |||
| 53 | m_managed_display_layers.emplace(*layer_id); | ||
| 54 | |||
| 55 | *out_layer = *layer_id; | ||
| 56 | *out_recording_layer = 0; | ||
| 57 | } | ||
| 58 | |||
| 59 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/managed_layer_holder.h b/src/core/hle/service/am/managed_layer_holder.h deleted file mode 100644 index f7fe03f24..000000000 --- a/src/core/hle/service/am/managed_layer_holder.h +++ /dev/null | |||
| @@ -1,32 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <set> | ||
| 7 | |||
| 8 | #include "common/common_funcs.h" | ||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | namespace Service::Nvnflinger { | ||
| 12 | class Nvnflinger; | ||
| 13 | } | ||
| 14 | |||
| 15 | namespace Service::AM { | ||
| 16 | |||
| 17 | class ManagedLayerHolder { | ||
| 18 | public: | ||
| 19 | ManagedLayerHolder(); | ||
| 20 | ~ManagedLayerHolder(); | ||
| 21 | |||
| 22 | void Initialize(Nvnflinger::Nvnflinger* nvnflinger); | ||
| 23 | void CreateManagedDisplayLayer(u64* out_layer); | ||
| 24 | void CreateManagedDisplaySeparableLayer(u64* out_layer, u64* out_recording_layer); | ||
| 25 | |||
| 26 | private: | ||
| 27 | Nvnflinger::Nvnflinger* m_nvnflinger{}; | ||
| 28 | std::set<u64> m_managed_display_layers{}; | ||
| 29 | std::set<u64> m_managed_display_recording_layers{}; | ||
| 30 | }; | ||
| 31 | |||
| 32 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp b/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp index eebd90ba2..21747783a 100644 --- a/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp +++ b/src/core/hle/service/am/service/all_system_applet_proxies_service.cpp | |||
| @@ -10,9 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | namespace Service::AM { | 11 | namespace Service::AM { |
| 12 | 12 | ||
| 13 | IAllSystemAppletProxiesService::IAllSystemAppletProxiesService(Core::System& system_, | 13 | IAllSystemAppletProxiesService::IAllSystemAppletProxiesService(Core::System& system_) |
| 14 | Nvnflinger::Nvnflinger& nvnflinger) | 14 | : ServiceFramework{system_, "appletAE"} { |
| 15 | : ServiceFramework{system_, "appletAE"}, m_nvnflinger{nvnflinger} { | ||
| 16 | // clang-format off | 15 | // clang-format off |
| 17 | static const FunctionInfo functions[] = { | 16 | static const FunctionInfo functions[] = { |
| 18 | {100, D<&IAllSystemAppletProxiesService::OpenSystemAppletProxy>, "OpenSystemAppletProxy"}, | 17 | {100, D<&IAllSystemAppletProxiesService::OpenSystemAppletProxy>, "OpenSystemAppletProxy"}, |
| @@ -37,8 +36,8 @@ Result IAllSystemAppletProxiesService::OpenSystemAppletProxy( | |||
| 37 | LOG_DEBUG(Service_AM, "called"); | 36 | LOG_DEBUG(Service_AM, "called"); |
| 38 | 37 | ||
| 39 | if (const auto applet = this->GetAppletFromProcessId(pid); applet) { | 38 | if (const auto applet = this->GetAppletFromProcessId(pid); applet) { |
| 40 | *out_system_applet_proxy = std::make_shared<ISystemAppletProxy>( | 39 | *out_system_applet_proxy = |
| 41 | system, applet, process_handle.Get(), m_nvnflinger); | 40 | std::make_shared<ISystemAppletProxy>(system, applet, process_handle.Get()); |
| 42 | R_SUCCEED(); | 41 | R_SUCCEED(); |
| 43 | } else { | 42 | } else { |
| 44 | UNIMPLEMENTED(); | 43 | UNIMPLEMENTED(); |
| @@ -53,8 +52,8 @@ Result IAllSystemAppletProxiesService::OpenLibraryAppletProxy( | |||
| 53 | LOG_DEBUG(Service_AM, "called"); | 52 | LOG_DEBUG(Service_AM, "called"); |
| 54 | 53 | ||
| 55 | if (const auto applet = this->GetAppletFromProcessId(pid); applet) { | 54 | if (const auto applet = this->GetAppletFromProcessId(pid); applet) { |
| 56 | *out_library_applet_proxy = std::make_shared<ILibraryAppletProxy>( | 55 | *out_library_applet_proxy = |
| 57 | system, applet, process_handle.Get(), m_nvnflinger); | 56 | std::make_shared<ILibraryAppletProxy>(system, applet, process_handle.Get()); |
| 58 | R_SUCCEED(); | 57 | R_SUCCEED(); |
| 59 | } else { | 58 | } else { |
| 60 | UNIMPLEMENTED(); | 59 | UNIMPLEMENTED(); |
diff --git a/src/core/hle/service/am/service/all_system_applet_proxies_service.h b/src/core/hle/service/am/service/all_system_applet_proxies_service.h index 38b1ca2ea..0e2dcb86d 100644 --- a/src/core/hle/service/am/service/all_system_applet_proxies_service.h +++ b/src/core/hle/service/am/service/all_system_applet_proxies_service.h | |||
| @@ -8,10 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | namespace Service { | 9 | namespace Service { |
| 10 | 10 | ||
| 11 | namespace Nvnflinger { | ||
| 12 | class Nvnflinger; | ||
| 13 | } | ||
| 14 | |||
| 15 | namespace AM { | 11 | namespace AM { |
| 16 | 12 | ||
| 17 | struct Applet; | 13 | struct Applet; |
| @@ -22,8 +18,7 @@ class ISystemAppletProxy; | |||
| 22 | class IAllSystemAppletProxiesService final | 18 | class IAllSystemAppletProxiesService final |
| 23 | : public ServiceFramework<IAllSystemAppletProxiesService> { | 19 | : public ServiceFramework<IAllSystemAppletProxiesService> { |
| 24 | public: | 20 | public: |
| 25 | explicit IAllSystemAppletProxiesService(Core::System& system_, | 21 | explicit IAllSystemAppletProxiesService(Core::System& system_); |
| 26 | Nvnflinger::Nvnflinger& nvnflinger); | ||
| 27 | ~IAllSystemAppletProxiesService() override; | 22 | ~IAllSystemAppletProxiesService() override; |
| 28 | 23 | ||
| 29 | private: | 24 | private: |
| @@ -40,7 +35,6 @@ private: | |||
| 40 | 35 | ||
| 41 | private: | 36 | private: |
| 42 | std::shared_ptr<Applet> GetAppletFromProcessId(ProcessId pid); | 37 | std::shared_ptr<Applet> GetAppletFromProcessId(ProcessId pid); |
| 43 | Nvnflinger::Nvnflinger& m_nvnflinger; | ||
| 44 | }; | 38 | }; |
| 45 | 39 | ||
| 46 | } // namespace AM | 40 | } // namespace AM |
diff --git a/src/core/hle/service/am/service/application_proxy.cpp b/src/core/hle/service/am/service/application_proxy.cpp index 776f4552b..19d6a3b89 100644 --- a/src/core/hle/service/am/service/application_proxy.cpp +++ b/src/core/hle/service/am/service/application_proxy.cpp | |||
| @@ -17,9 +17,9 @@ | |||
| 17 | namespace Service::AM { | 17 | namespace Service::AM { |
| 18 | 18 | ||
| 19 | IApplicationProxy::IApplicationProxy(Core::System& system_, std::shared_ptr<Applet> applet, | 19 | IApplicationProxy::IApplicationProxy(Core::System& system_, std::shared_ptr<Applet> applet, |
| 20 | Kernel::KProcess* process, Nvnflinger::Nvnflinger& nvnflinger) | 20 | Kernel::KProcess* process) |
| 21 | : ServiceFramework{system_, "IApplicationProxy"}, | 21 | : ServiceFramework{system_, "IApplicationProxy"}, m_process{process}, m_applet{ |
| 22 | m_nvnflinger{nvnflinger}, m_process{process}, m_applet{std::move(applet)} { | 22 | std::move(applet)} { |
| 23 | // clang-format off | 23 | // clang-format off |
| 24 | static const FunctionInfo functions[] = { | 24 | static const FunctionInfo functions[] = { |
| 25 | {0, D<&IApplicationProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, | 25 | {0, D<&IApplicationProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, |
| @@ -77,8 +77,7 @@ Result IApplicationProxy::GetWindowController( | |||
| 77 | Result IApplicationProxy::GetSelfController( | 77 | Result IApplicationProxy::GetSelfController( |
| 78 | Out<SharedPointer<ISelfController>> out_self_controller) { | 78 | Out<SharedPointer<ISelfController>> out_self_controller) { |
| 79 | LOG_DEBUG(Service_AM, "called"); | 79 | LOG_DEBUG(Service_AM, "called"); |
| 80 | *out_self_controller = | 80 | *out_self_controller = std::make_shared<ISelfController>(system, m_applet, m_process); |
| 81 | std::make_shared<ISelfController>(system, m_applet, m_process, m_nvnflinger); | ||
| 82 | R_SUCCEED(); | 81 | R_SUCCEED(); |
| 83 | } | 82 | } |
| 84 | 83 | ||
diff --git a/src/core/hle/service/am/service/application_proxy.h b/src/core/hle/service/am/service/application_proxy.h index 1ebc593ba..6da350df7 100644 --- a/src/core/hle/service/am/service/application_proxy.h +++ b/src/core/hle/service/am/service/application_proxy.h | |||
| @@ -22,7 +22,7 @@ class IWindowController; | |||
| 22 | class IApplicationProxy final : public ServiceFramework<IApplicationProxy> { | 22 | class IApplicationProxy final : public ServiceFramework<IApplicationProxy> { |
| 23 | public: | 23 | public: |
| 24 | explicit IApplicationProxy(Core::System& system_, std::shared_ptr<Applet> applet, | 24 | explicit IApplicationProxy(Core::System& system_, std::shared_ptr<Applet> applet, |
| 25 | Kernel::KProcess* process, Nvnflinger::Nvnflinger& nvnflinger); | 25 | Kernel::KProcess* process); |
| 26 | ~IApplicationProxy(); | 26 | ~IApplicationProxy(); |
| 27 | 27 | ||
| 28 | private: | 28 | private: |
| @@ -40,7 +40,6 @@ private: | |||
| 40 | Out<SharedPointer<IApplicationFunctions>> out_application_functions); | 40 | Out<SharedPointer<IApplicationFunctions>> out_application_functions); |
| 41 | 41 | ||
| 42 | private: | 42 | private: |
| 43 | Nvnflinger::Nvnflinger& m_nvnflinger; | ||
| 44 | Kernel::KProcess* const m_process; | 43 | Kernel::KProcess* const m_process; |
| 45 | const std::shared_ptr<Applet> m_applet; | 44 | const std::shared_ptr<Applet> m_applet; |
| 46 | }; | 45 | }; |
diff --git a/src/core/hle/service/am/service/application_proxy_service.cpp b/src/core/hle/service/am/service/application_proxy_service.cpp index 36d4478df..fd66e77b9 100644 --- a/src/core/hle/service/am/service/application_proxy_service.cpp +++ b/src/core/hle/service/am/service/application_proxy_service.cpp | |||
| @@ -10,9 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | namespace Service::AM { | 11 | namespace Service::AM { |
| 12 | 12 | ||
| 13 | IApplicationProxyService::IApplicationProxyService(Core::System& system_, | 13 | IApplicationProxyService::IApplicationProxyService(Core::System& system_) |
| 14 | Nvnflinger::Nvnflinger& nvnflinger) | 14 | : ServiceFramework{system_, "appletOE"} { |
| 15 | : ServiceFramework{system_, "appletOE"}, m_nvnflinger{nvnflinger} { | ||
| 16 | static const FunctionInfo functions[] = { | 15 | static const FunctionInfo functions[] = { |
| 17 | {0, D<&IApplicationProxyService::OpenApplicationProxy>, "OpenApplicationProxy"}, | 16 | {0, D<&IApplicationProxyService::OpenApplicationProxy>, "OpenApplicationProxy"}, |
| 18 | }; | 17 | }; |
| @@ -28,7 +27,7 @@ Result IApplicationProxyService::OpenApplicationProxy( | |||
| 28 | 27 | ||
| 29 | if (const auto applet = this->GetAppletFromProcessId(pid)) { | 28 | if (const auto applet = this->GetAppletFromProcessId(pid)) { |
| 30 | *out_application_proxy = | 29 | *out_application_proxy = |
| 31 | std::make_shared<IApplicationProxy>(system, applet, process_handle.Get(), m_nvnflinger); | 30 | std::make_shared<IApplicationProxy>(system, applet, process_handle.Get()); |
| 32 | R_SUCCEED(); | 31 | R_SUCCEED(); |
| 33 | } else { | 32 | } else { |
| 34 | UNIMPLEMENTED(); | 33 | UNIMPLEMENTED(); |
diff --git a/src/core/hle/service/am/service/application_proxy_service.h b/src/core/hle/service/am/service/application_proxy_service.h index 1c1d32d0b..8efafa31a 100644 --- a/src/core/hle/service/am/service/application_proxy_service.h +++ b/src/core/hle/service/am/service/application_proxy_service.h | |||
| @@ -8,10 +8,6 @@ | |||
| 8 | 8 | ||
| 9 | namespace Service { | 9 | namespace Service { |
| 10 | 10 | ||
| 11 | namespace Nvnflinger { | ||
| 12 | class Nvnflinger; | ||
| 13 | } | ||
| 14 | |||
| 15 | namespace AM { | 11 | namespace AM { |
| 16 | 12 | ||
| 17 | struct Applet; | 13 | struct Applet; |
| @@ -19,7 +15,7 @@ class IApplicationProxy; | |||
| 19 | 15 | ||
| 20 | class IApplicationProxyService final : public ServiceFramework<IApplicationProxyService> { | 16 | class IApplicationProxyService final : public ServiceFramework<IApplicationProxyService> { |
| 21 | public: | 17 | public: |
| 22 | explicit IApplicationProxyService(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger); | 18 | explicit IApplicationProxyService(Core::System& system_); |
| 23 | ~IApplicationProxyService() override; | 19 | ~IApplicationProxyService() override; |
| 24 | 20 | ||
| 25 | private: | 21 | private: |
| @@ -28,7 +24,6 @@ private: | |||
| 28 | 24 | ||
| 29 | private: | 25 | private: |
| 30 | std::shared_ptr<Applet> GetAppletFromProcessId(ProcessId pid); | 26 | std::shared_ptr<Applet> GetAppletFromProcessId(ProcessId pid); |
| 31 | Nvnflinger::Nvnflinger& m_nvnflinger; | ||
| 32 | }; | 27 | }; |
| 33 | 28 | ||
| 34 | } // namespace AM | 29 | } // namespace AM |
diff --git a/src/core/hle/service/am/service/display_controller.cpp b/src/core/hle/service/am/service/display_controller.cpp index 249c73dfb..ed71f9093 100644 --- a/src/core/hle/service/am/service/display_controller.cpp +++ b/src/core/hle/service/am/service/display_controller.cpp | |||
| @@ -69,7 +69,7 @@ Result IDisplayController::ClearCaptureBuffer(bool unknown0, s32 fbshare_layer_i | |||
| 69 | Result IDisplayController::AcquireLastForegroundCaptureSharedBuffer( | 69 | Result IDisplayController::AcquireLastForegroundCaptureSharedBuffer( |
| 70 | Out<bool> out_was_written, Out<s32> out_fbshare_layer_index) { | 70 | Out<bool> out_was_written, Out<s32> out_fbshare_layer_index) { |
| 71 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 71 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 72 | R_RETURN(applet->system_buffer_manager.WriteAppletCaptureBuffer(out_was_written, | 72 | R_RETURN(applet->display_layer_manager.WriteAppletCaptureBuffer(out_was_written, |
| 73 | out_fbshare_layer_index)); | 73 | out_fbshare_layer_index)); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| @@ -81,7 +81,7 @@ Result IDisplayController::ReleaseLastForegroundCaptureSharedBuffer() { | |||
| 81 | Result IDisplayController::AcquireCallerAppletCaptureSharedBuffer( | 81 | Result IDisplayController::AcquireCallerAppletCaptureSharedBuffer( |
| 82 | Out<bool> out_was_written, Out<s32> out_fbshare_layer_index) { | 82 | Out<bool> out_was_written, Out<s32> out_fbshare_layer_index) { |
| 83 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 83 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 84 | R_RETURN(applet->system_buffer_manager.WriteAppletCaptureBuffer(out_was_written, | 84 | R_RETURN(applet->display_layer_manager.WriteAppletCaptureBuffer(out_was_written, |
| 85 | out_fbshare_layer_index)); | 85 | out_fbshare_layer_index)); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| @@ -93,7 +93,7 @@ Result IDisplayController::ReleaseCallerAppletCaptureSharedBuffer() { | |||
| 93 | Result IDisplayController::AcquireLastApplicationCaptureSharedBuffer( | 93 | Result IDisplayController::AcquireLastApplicationCaptureSharedBuffer( |
| 94 | Out<bool> out_was_written, Out<s32> out_fbshare_layer_index) { | 94 | Out<bool> out_was_written, Out<s32> out_fbshare_layer_index) { |
| 95 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 95 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 96 | R_RETURN(applet->system_buffer_manager.WriteAppletCaptureBuffer(out_was_written, | 96 | R_RETURN(applet->display_layer_manager.WriteAppletCaptureBuffer(out_was_written, |
| 97 | out_fbshare_layer_index)); | 97 | out_fbshare_layer_index)); |
| 98 | } | 98 | } |
| 99 | 99 | ||
diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index 166637d60..c97358d81 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp | |||
| @@ -135,7 +135,7 @@ std::shared_ptr<ILibraryAppletAccessor> CreateGuestApplet(Core::System& system, | |||
| 135 | case LibraryAppletMode::AllForegroundInitiallyHidden: | 135 | case LibraryAppletMode::AllForegroundInitiallyHidden: |
| 136 | applet->hid_registration.EnableAppletToGetInput(false); | 136 | applet->hid_registration.EnableAppletToGetInput(false); |
| 137 | applet->focus_state = FocusState::NotInFocus; | 137 | applet->focus_state = FocusState::NotInFocus; |
| 138 | applet->system_buffer_manager.SetWindowVisibility(false); | 138 | applet->display_layer_manager.SetWindowVisibility(false); |
| 139 | applet->message_queue.PushMessage(AppletMessage::ChangeIntoBackground); | 139 | applet->message_queue.PushMessage(AppletMessage::ChangeIntoBackground); |
| 140 | break; | 140 | break; |
| 141 | } | 141 | } |
diff --git a/src/core/hle/service/am/service/library_applet_proxy.cpp b/src/core/hle/service/am/service/library_applet_proxy.cpp index bcb44a71c..58e709347 100644 --- a/src/core/hle/service/am/service/library_applet_proxy.cpp +++ b/src/core/hle/service/am/service/library_applet_proxy.cpp | |||
| @@ -19,10 +19,9 @@ | |||
| 19 | namespace Service::AM { | 19 | namespace Service::AM { |
| 20 | 20 | ||
| 21 | ILibraryAppletProxy::ILibraryAppletProxy(Core::System& system_, std::shared_ptr<Applet> applet, | 21 | ILibraryAppletProxy::ILibraryAppletProxy(Core::System& system_, std::shared_ptr<Applet> applet, |
| 22 | Kernel::KProcess* process, | 22 | Kernel::KProcess* process) |
| 23 | Nvnflinger::Nvnflinger& nvnflinger) | 23 | : ServiceFramework{system_, "ILibraryAppletProxy"}, m_process{process}, m_applet{ |
| 24 | : ServiceFramework{system_, "ILibraryAppletProxy"}, | 24 | std::move(applet)} { |
| 25 | m_nvnflinger{nvnflinger}, m_process{process}, m_applet{std::move(applet)} { | ||
| 26 | // clang-format off | 25 | // clang-format off |
| 27 | static const FunctionInfo functions[] = { | 26 | static const FunctionInfo functions[] = { |
| 28 | {0, D<&ILibraryAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, | 27 | {0, D<&ILibraryAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, |
| @@ -83,8 +82,7 @@ Result ILibraryAppletProxy::GetWindowController( | |||
| 83 | Result ILibraryAppletProxy::GetSelfController( | 82 | Result ILibraryAppletProxy::GetSelfController( |
| 84 | Out<SharedPointer<ISelfController>> out_self_controller) { | 83 | Out<SharedPointer<ISelfController>> out_self_controller) { |
| 85 | LOG_DEBUG(Service_AM, "called"); | 84 | LOG_DEBUG(Service_AM, "called"); |
| 86 | *out_self_controller = | 85 | *out_self_controller = std::make_shared<ISelfController>(system, m_applet, m_process); |
| 87 | std::make_shared<ISelfController>(system, m_applet, m_process, m_nvnflinger); | ||
| 88 | R_SUCCEED(); | 86 | R_SUCCEED(); |
| 89 | } | 87 | } |
| 90 | 88 | ||
diff --git a/src/core/hle/service/am/service/library_applet_proxy.h b/src/core/hle/service/am/service/library_applet_proxy.h index 23e64e295..7d0714b85 100644 --- a/src/core/hle/service/am/service/library_applet_proxy.h +++ b/src/core/hle/service/am/service/library_applet_proxy.h | |||
| @@ -25,7 +25,7 @@ class IWindowController; | |||
| 25 | class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> { | 25 | class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> { |
| 26 | public: | 26 | public: |
| 27 | explicit ILibraryAppletProxy(Core::System& system_, std::shared_ptr<Applet> applet, | 27 | explicit ILibraryAppletProxy(Core::System& system_, std::shared_ptr<Applet> applet, |
| 28 | Kernel::KProcess* process, Nvnflinger::Nvnflinger& nvnflinger); | 28 | Kernel::KProcess* process); |
| 29 | ~ILibraryAppletProxy(); | 29 | ~ILibraryAppletProxy(); |
| 30 | 30 | ||
| 31 | private: | 31 | private: |
| @@ -47,7 +47,6 @@ private: | |||
| 47 | Result GetGlobalStateController( | 47 | Result GetGlobalStateController( |
| 48 | Out<SharedPointer<IGlobalStateController>> out_global_state_controller); | 48 | Out<SharedPointer<IGlobalStateController>> out_global_state_controller); |
| 49 | 49 | ||
| 50 | Nvnflinger::Nvnflinger& m_nvnflinger; | ||
| 51 | Kernel::KProcess* const m_process; | 50 | Kernel::KProcess* const m_process; |
| 52 | const std::shared_ptr<Applet> m_applet; | 51 | const std::shared_ptr<Applet> m_applet; |
| 53 | }; | 52 | }; |
diff --git a/src/core/hle/service/am/service/self_controller.cpp b/src/core/hle/service/am/service/self_controller.cpp index 5c4c13de1..06314407c 100644 --- a/src/core/hle/service/am/service/self_controller.cpp +++ b/src/core/hle/service/am/service/self_controller.cpp | |||
| @@ -15,9 +15,9 @@ | |||
| 15 | namespace Service::AM { | 15 | namespace Service::AM { |
| 16 | 16 | ||
| 17 | ISelfController::ISelfController(Core::System& system_, std::shared_ptr<Applet> applet, | 17 | ISelfController::ISelfController(Core::System& system_, std::shared_ptr<Applet> applet, |
| 18 | Kernel::KProcess* process, Nvnflinger::Nvnflinger& nvnflinger) | 18 | Kernel::KProcess* process) |
| 19 | : ServiceFramework{system_, "ISelfController"}, | 19 | : ServiceFramework{system_, "ISelfController"}, m_process{process}, m_applet{ |
| 20 | m_nvnflinger{nvnflinger}, m_process{process}, m_applet{std::move(applet)} { | 20 | std::move(applet)} { |
| 21 | // clang-format off | 21 | // clang-format off |
| 22 | static const FunctionInfo functions[] = { | 22 | static const FunctionInfo functions[] = { |
| 23 | {0, D<&ISelfController::Exit>, "Exit"}, | 23 | {0, D<&ISelfController::Exit>, "Exit"}, |
| @@ -72,9 +72,16 @@ ISelfController::ISelfController(Core::System& system_, std::shared_ptr<Applet> | |||
| 72 | // clang-format on | 72 | // clang-format on |
| 73 | 73 | ||
| 74 | RegisterHandlers(functions); | 74 | RegisterHandlers(functions); |
| 75 | |||
| 76 | std::scoped_lock lk{m_applet->lock}; | ||
| 77 | m_applet->display_layer_manager.Initialize(system, m_process, m_applet->applet_id, | ||
| 78 | m_applet->library_applet_mode); | ||
| 75 | } | 79 | } |
| 76 | 80 | ||
| 77 | ISelfController::~ISelfController() = default; | 81 | ISelfController::~ISelfController() { |
| 82 | std::scoped_lock lk{m_applet->lock}; | ||
| 83 | m_applet->display_layer_manager.Finalize(); | ||
| 84 | } | ||
| 78 | 85 | ||
| 79 | Result ISelfController::Exit() { | 86 | Result ISelfController::Exit() { |
| 80 | LOG_DEBUG(Service_AM, "called"); | 87 | LOG_DEBUG(Service_AM, "called"); |
| @@ -212,48 +219,42 @@ Result ISelfController::SetAlbumImageOrientation( | |||
| 212 | 219 | ||
| 213 | Result ISelfController::IsSystemBufferSharingEnabled() { | 220 | Result ISelfController::IsSystemBufferSharingEnabled() { |
| 214 | LOG_INFO(Service_AM, "called"); | 221 | LOG_INFO(Service_AM, "called"); |
| 215 | R_SUCCEED_IF(m_applet->system_buffer_manager.Initialize( | 222 | |
| 216 | &m_nvnflinger, m_process, m_applet->applet_id, m_applet->library_applet_mode)); | 223 | std::scoped_lock lk{m_applet->lock}; |
| 217 | R_THROW(VI::ResultOperationFailed); | 224 | R_RETURN(m_applet->display_layer_manager.IsSystemBufferSharingEnabled()); |
| 218 | } | 225 | } |
| 219 | 226 | ||
| 220 | Result ISelfController::GetSystemSharedBufferHandle(Out<u64> out_buffer_id) { | 227 | Result ISelfController::GetSystemSharedBufferHandle(Out<u64> out_buffer_id) { |
| 221 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 228 | LOG_INFO(Service_AM, "called"); |
| 222 | |||
| 223 | R_TRY(this->IsSystemBufferSharingEnabled()); | ||
| 224 | 229 | ||
| 225 | u64 layer_id; | 230 | u64 layer_id; |
| 226 | m_applet->system_buffer_manager.GetSystemSharedLayerHandle(out_buffer_id, &layer_id); | 231 | |
| 227 | R_SUCCEED(); | 232 | std::scoped_lock lk{m_applet->lock}; |
| 233 | R_RETURN(m_applet->display_layer_manager.GetSystemSharedLayerHandle(out_buffer_id, &layer_id)); | ||
| 228 | } | 234 | } |
| 229 | 235 | ||
| 230 | Result ISelfController::GetSystemSharedLayerHandle(Out<u64> out_buffer_id, Out<u64> out_layer_id) { | 236 | Result ISelfController::GetSystemSharedLayerHandle(Out<u64> out_buffer_id, Out<u64> out_layer_id) { |
| 231 | LOG_INFO(Service_AM, "(STUBBED) called"); | 237 | LOG_INFO(Service_AM, "called"); |
| 232 | |||
| 233 | R_TRY(this->IsSystemBufferSharingEnabled()); | ||
| 234 | 238 | ||
| 235 | m_applet->system_buffer_manager.GetSystemSharedLayerHandle(out_buffer_id, out_layer_id); | 239 | std::scoped_lock lk{m_applet->lock}; |
| 236 | R_SUCCEED(); | 240 | R_RETURN( |
| 241 | m_applet->display_layer_manager.GetSystemSharedLayerHandle(out_buffer_id, out_layer_id)); | ||
| 237 | } | 242 | } |
| 238 | 243 | ||
| 239 | Result ISelfController::CreateManagedDisplayLayer(Out<u64> out_layer_id) { | 244 | Result ISelfController::CreateManagedDisplayLayer(Out<u64> out_layer_id) { |
| 240 | LOG_INFO(Service_AM, "called"); | 245 | LOG_INFO(Service_AM, "called"); |
| 241 | 246 | ||
| 242 | m_applet->managed_layer_holder.Initialize(&m_nvnflinger); | 247 | std::scoped_lock lk{m_applet->lock}; |
| 243 | m_applet->managed_layer_holder.CreateManagedDisplayLayer(out_layer_id); | 248 | R_RETURN(m_applet->display_layer_manager.CreateManagedDisplayLayer(out_layer_id)); |
| 244 | |||
| 245 | R_SUCCEED(); | ||
| 246 | } | 249 | } |
| 247 | 250 | ||
| 248 | Result ISelfController::CreateManagedDisplaySeparableLayer(Out<u64> out_layer_id, | 251 | Result ISelfController::CreateManagedDisplaySeparableLayer(Out<u64> out_layer_id, |
| 249 | Out<u64> out_recording_layer_id) { | 252 | Out<u64> out_recording_layer_id) { |
| 250 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 253 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 251 | 254 | ||
| 252 | m_applet->managed_layer_holder.Initialize(&m_nvnflinger); | 255 | std::scoped_lock lk{m_applet->lock}; |
| 253 | m_applet->managed_layer_holder.CreateManagedDisplaySeparableLayer(out_layer_id, | 256 | R_RETURN(m_applet->display_layer_manager.CreateManagedDisplaySeparableLayer( |
| 254 | out_recording_layer_id); | 257 | out_layer_id, out_recording_layer_id)); |
| 255 | |||
| 256 | R_SUCCEED(); | ||
| 257 | } | 258 | } |
| 258 | 259 | ||
| 259 | Result ISelfController::SetHandlesRequestToDisplay(bool enable) { | 260 | Result ISelfController::SetHandlesRequestToDisplay(bool enable) { |
diff --git a/src/core/hle/service/am/service/self_controller.h b/src/core/hle/service/am/service/self_controller.h index 01fa381a3..eca083cfe 100644 --- a/src/core/hle/service/am/service/self_controller.h +++ b/src/core/hle/service/am/service/self_controller.h | |||
| @@ -23,7 +23,7 @@ struct Applet; | |||
| 23 | class ISelfController final : public ServiceFramework<ISelfController> { | 23 | class ISelfController final : public ServiceFramework<ISelfController> { |
| 24 | public: | 24 | public: |
| 25 | explicit ISelfController(Core::System& system_, std::shared_ptr<Applet> applet, | 25 | explicit ISelfController(Core::System& system_, std::shared_ptr<Applet> applet, |
| 26 | Kernel::KProcess* process, Nvnflinger::Nvnflinger& nvnflinger); | 26 | Kernel::KProcess* process); |
| 27 | ~ISelfController() override; | 27 | ~ISelfController() override; |
| 28 | 28 | ||
| 29 | private: | 29 | private: |
| @@ -64,7 +64,6 @@ private: | |||
| 64 | Result SaveCurrentScreenshot(Capture::AlbumReportOption album_report_option); | 64 | Result SaveCurrentScreenshot(Capture::AlbumReportOption album_report_option); |
| 65 | Result SetRecordVolumeMuted(bool muted); | 65 | Result SetRecordVolumeMuted(bool muted); |
| 66 | 66 | ||
| 67 | Nvnflinger::Nvnflinger& m_nvnflinger; | ||
| 68 | Kernel::KProcess* const m_process; | 67 | Kernel::KProcess* const m_process; |
| 69 | const std::shared_ptr<Applet> m_applet; | 68 | const std::shared_ptr<Applet> m_applet; |
| 70 | }; | 69 | }; |
diff --git a/src/core/hle/service/am/service/system_applet_proxy.cpp b/src/core/hle/service/am/service/system_applet_proxy.cpp index 5ec509d2e..d1871ef9b 100644 --- a/src/core/hle/service/am/service/system_applet_proxy.cpp +++ b/src/core/hle/service/am/service/system_applet_proxy.cpp | |||
| @@ -19,10 +19,9 @@ | |||
| 19 | namespace Service::AM { | 19 | namespace Service::AM { |
| 20 | 20 | ||
| 21 | ISystemAppletProxy::ISystemAppletProxy(Core::System& system_, std::shared_ptr<Applet> applet, | 21 | ISystemAppletProxy::ISystemAppletProxy(Core::System& system_, std::shared_ptr<Applet> applet, |
| 22 | Kernel::KProcess* process, | 22 | Kernel::KProcess* process) |
| 23 | Nvnflinger::Nvnflinger& nvnflinger) | 23 | : ServiceFramework{system_, "ISystemAppletProxy"}, m_process{process}, m_applet{ |
| 24 | : ServiceFramework{system_, "ISystemAppletProxy"}, | 24 | std::move(applet)} { |
| 25 | m_nvnflinger{nvnflinger}, m_process{process}, m_applet{std::move(applet)} { | ||
| 26 | // clang-format off | 25 | // clang-format off |
| 27 | static const FunctionInfo functions[] = { | 26 | static const FunctionInfo functions[] = { |
| 28 | {0, D<&ISystemAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, | 27 | {0, D<&ISystemAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"}, |
| @@ -83,8 +82,7 @@ Result ISystemAppletProxy::GetWindowController( | |||
| 83 | Result ISystemAppletProxy::GetSelfController( | 82 | Result ISystemAppletProxy::GetSelfController( |
| 84 | Out<SharedPointer<ISelfController>> out_self_controller) { | 83 | Out<SharedPointer<ISelfController>> out_self_controller) { |
| 85 | LOG_DEBUG(Service_AM, "called"); | 84 | LOG_DEBUG(Service_AM, "called"); |
| 86 | *out_self_controller = | 85 | *out_self_controller = std::make_shared<ISelfController>(system, m_applet, m_process); |
| 87 | std::make_shared<ISelfController>(system, m_applet, m_process, m_nvnflinger); | ||
| 88 | R_SUCCEED(); | 86 | R_SUCCEED(); |
| 89 | } | 87 | } |
| 90 | 88 | ||
diff --git a/src/core/hle/service/am/service/system_applet_proxy.h b/src/core/hle/service/am/service/system_applet_proxy.h index 3d5040315..67cd50e03 100644 --- a/src/core/hle/service/am/service/system_applet_proxy.h +++ b/src/core/hle/service/am/service/system_applet_proxy.h | |||
| @@ -25,7 +25,7 @@ class IWindowController; | |||
| 25 | class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> { | 25 | class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> { |
| 26 | public: | 26 | public: |
| 27 | explicit ISystemAppletProxy(Core::System& system, std::shared_ptr<Applet> applet, | 27 | explicit ISystemAppletProxy(Core::System& system, std::shared_ptr<Applet> applet, |
| 28 | Kernel::KProcess* process, Nvnflinger::Nvnflinger& nvnflinger); | 28 | Kernel::KProcess* process); |
| 29 | ~ISystemAppletProxy(); | 29 | ~ISystemAppletProxy(); |
| 30 | 30 | ||
| 31 | private: | 31 | private: |
| @@ -46,7 +46,6 @@ private: | |||
| 46 | Result GetGlobalStateController( | 46 | Result GetGlobalStateController( |
| 47 | Out<SharedPointer<IGlobalStateController>> out_global_state_controller); | 47 | Out<SharedPointer<IGlobalStateController>> out_global_state_controller); |
| 48 | 48 | ||
| 49 | Nvnflinger::Nvnflinger& m_nvnflinger; | ||
| 50 | Kernel::KProcess* const m_process; | 49 | Kernel::KProcess* const m_process; |
| 51 | const std::shared_ptr<Applet> m_applet; | 50 | const std::shared_ptr<Applet> m_applet; |
| 52 | }; | 51 | }; |
diff --git a/src/core/hle/service/am/service/window_controller.cpp b/src/core/hle/service/am/service/window_controller.cpp index b874ecb91..99a4f50a2 100644 --- a/src/core/hle/service/am/service/window_controller.cpp +++ b/src/core/hle/service/am/service/window_controller.cpp | |||
| @@ -63,7 +63,7 @@ Result IWindowController::RejectToChangeIntoBackground() { | |||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | Result IWindowController::SetAppletWindowVisibility(bool visible) { | 65 | Result IWindowController::SetAppletWindowVisibility(bool visible) { |
| 66 | m_applet->system_buffer_manager.SetWindowVisibility(visible); | 66 | m_applet->display_layer_manager.SetWindowVisibility(visible); |
| 67 | m_applet->hid_registration.EnableAppletToGetInput(visible); | 67 | m_applet->hid_registration.EnableAppletToGetInput(visible); |
| 68 | 68 | ||
| 69 | if (visible) { | 69 | if (visible) { |
diff --git a/src/core/hle/service/am/system_buffer_manager.cpp b/src/core/hle/service/am/system_buffer_manager.cpp deleted file mode 100644 index 48923fe41..000000000 --- a/src/core/hle/service/am/system_buffer_manager.cpp +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/am/system_buffer_manager.h" | ||
| 5 | #include "core/hle/service/nvnflinger/fb_share_buffer_manager.h" | ||
| 6 | #include "core/hle/service/nvnflinger/nvnflinger.h" | ||
| 7 | #include "core/hle/service/vi/vi_results.h" | ||
| 8 | |||
| 9 | namespace Service::AM { | ||
| 10 | |||
| 11 | SystemBufferManager::SystemBufferManager() = default; | ||
| 12 | |||
| 13 | SystemBufferManager::~SystemBufferManager() { | ||
| 14 | if (!m_nvnflinger) { | ||
| 15 | return; | ||
| 16 | } | ||
| 17 | |||
| 18 | // Clean up shared layers. | ||
| 19 | if (m_buffer_sharing_enabled) { | ||
| 20 | m_nvnflinger->GetSystemBufferManager().Finalize(m_process); | ||
| 21 | } | ||
| 22 | } | ||
| 23 | |||
| 24 | bool SystemBufferManager::Initialize(Nvnflinger::Nvnflinger* nvnflinger, Kernel::KProcess* process, | ||
| 25 | AppletId applet_id, LibraryAppletMode mode) { | ||
| 26 | if (m_nvnflinger) { | ||
| 27 | return m_buffer_sharing_enabled; | ||
| 28 | } | ||
| 29 | |||
| 30 | m_process = process; | ||
| 31 | m_nvnflinger = nvnflinger; | ||
| 32 | m_buffer_sharing_enabled = false; | ||
| 33 | m_system_shared_buffer_id = 0; | ||
| 34 | m_system_shared_layer_id = 0; | ||
| 35 | |||
| 36 | if (applet_id <= AppletId::Application) { | ||
| 37 | return false; | ||
| 38 | } | ||
| 39 | |||
| 40 | Nvnflinger::LayerBlending blending = Nvnflinger::LayerBlending::None; | ||
| 41 | if (mode == LibraryAppletMode::PartialForeground || | ||
| 42 | mode == LibraryAppletMode::PartialForegroundIndirectDisplay) { | ||
| 43 | blending = Nvnflinger::LayerBlending::Coverage; | ||
| 44 | } | ||
| 45 | |||
| 46 | const auto display_id = m_nvnflinger->OpenDisplay("Default").value(); | ||
| 47 | const auto res = m_nvnflinger->GetSystemBufferManager().Initialize( | ||
| 48 | m_process, &m_system_shared_buffer_id, &m_system_shared_layer_id, display_id, blending); | ||
| 49 | |||
| 50 | if (res.IsSuccess()) { | ||
| 51 | m_buffer_sharing_enabled = true; | ||
| 52 | m_nvnflinger->SetLayerVisibility(m_system_shared_layer_id, m_visible); | ||
| 53 | } | ||
| 54 | |||
| 55 | return m_buffer_sharing_enabled; | ||
| 56 | } | ||
| 57 | |||
| 58 | void SystemBufferManager::SetWindowVisibility(bool visible) { | ||
| 59 | if (m_visible == visible) { | ||
| 60 | return; | ||
| 61 | } | ||
| 62 | |||
| 63 | m_visible = visible; | ||
| 64 | |||
| 65 | if (m_nvnflinger) { | ||
| 66 | m_nvnflinger->SetLayerVisibility(m_system_shared_layer_id, m_visible); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | Result SystemBufferManager::WriteAppletCaptureBuffer(bool* out_was_written, | ||
| 71 | s32* out_fbshare_layer_index) { | ||
| 72 | if (!m_buffer_sharing_enabled) { | ||
| 73 | return VI::ResultPermissionDenied; | ||
| 74 | } | ||
| 75 | |||
| 76 | return m_nvnflinger->GetSystemBufferManager().WriteAppletCaptureBuffer(out_was_written, | ||
| 77 | out_fbshare_layer_index); | ||
| 78 | } | ||
| 79 | |||
| 80 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/system_buffer_manager.h b/src/core/hle/service/am/system_buffer_manager.h deleted file mode 100644 index 0690f68b6..000000000 --- a/src/core/hle/service/am/system_buffer_manager.h +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <set> | ||
| 7 | |||
| 8 | #include "common/common_funcs.h" | ||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | #include "core/hle/service/am/am_types.h" | ||
| 12 | |||
| 13 | namespace Kernel { | ||
| 14 | class KProcess; | ||
| 15 | } | ||
| 16 | |||
| 17 | namespace Service::Nvnflinger { | ||
| 18 | class Nvnflinger; | ||
| 19 | } | ||
| 20 | |||
| 21 | union Result; | ||
| 22 | |||
| 23 | namespace Service::AM { | ||
| 24 | |||
| 25 | class SystemBufferManager { | ||
| 26 | public: | ||
| 27 | SystemBufferManager(); | ||
| 28 | ~SystemBufferManager(); | ||
| 29 | |||
| 30 | bool Initialize(Nvnflinger::Nvnflinger* flinger, Kernel::KProcess* process, AppletId applet_id, | ||
| 31 | LibraryAppletMode mode); | ||
| 32 | |||
| 33 | void GetSystemSharedLayerHandle(u64* out_system_shared_buffer_id, | ||
| 34 | u64* out_system_shared_layer_id) { | ||
| 35 | *out_system_shared_buffer_id = m_system_shared_buffer_id; | ||
| 36 | *out_system_shared_layer_id = m_system_shared_layer_id; | ||
| 37 | } | ||
| 38 | |||
| 39 | void SetWindowVisibility(bool visible); | ||
| 40 | |||
| 41 | Result WriteAppletCaptureBuffer(bool* out_was_written, s32* out_fbshare_layer_index); | ||
| 42 | |||
| 43 | private: | ||
| 44 | Kernel::KProcess* m_process{}; | ||
| 45 | Nvnflinger::Nvnflinger* m_nvnflinger{}; | ||
| 46 | bool m_buffer_sharing_enabled{}; | ||
| 47 | bool m_visible{true}; | ||
| 48 | u64 m_system_shared_buffer_id{}; | ||
| 49 | u64 m_system_shared_layer_id{}; | ||
| 50 | }; | ||
| 51 | |||
| 52 | } // namespace Service::AM | ||