Merge pull request #133 from Subv/nvflinger2

AppletOE: Stubbed CreateManagedDisplayLayer to create a new layer in the default display.
This commit is contained in:
bunnei 2018-01-22 17:52:47 -05:00 committed by GitHub
commit d8bd70d396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 59 additions and 17 deletions

View file

@ -8,8 +8,9 @@
namespace Service { namespace Service {
namespace AM { namespace AM {
void InstallInterfaces(SM::ServiceManager& service_manager) { void InstallInterfaces(SM::ServiceManager& service_manager,
std::make_shared<AppletOE>()->InstallAsService(service_manager); std::shared_ptr<NVFlinger::NVFlinger> nvflinger) {
std::make_shared<AppletOE>(nvflinger)->InstallAsService(service_manager);
} }
} // namespace AM } // namespace AM

View file

@ -4,13 +4,19 @@
#pragma once #pragma once
#include <memory>
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
namespace Service { namespace Service {
namespace NVFlinger {
class NVFlinger;
}
namespace AM { namespace AM {
/// Registers all AM services with the specified service manager. /// Registers all AM services with the specified service manager.
void InstallInterfaces(SM::ServiceManager& service_manager); void InstallInterfaces(SM::ServiceManager& service_manager,
std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
} // namespace AM } // namespace AM
} // namespace Service } // namespace Service

View file

@ -7,6 +7,7 @@
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
#include "core/hle/service/am/applet_oe.h" #include "core/hle/service/am/applet_oe.h"
#include "core/hle/service/apm/apm.h" #include "core/hle/service/apm/apm.h"
#include "core/hle/service/nvflinger/nvflinger.h"
namespace Service { namespace Service {
namespace AM { namespace AM {
@ -53,7 +54,8 @@ public:
class ISelfController final : public ServiceFramework<ISelfController> { class ISelfController final : public ServiceFramework<ISelfController> {
public: public:
ISelfController() : ServiceFramework("ISelfController") { ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
: ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{1, &ISelfController::LockExit, "LockExit"}, {1, &ISelfController::LockExit, "LockExit"},
{2, &ISelfController::UnlockExit, "UnlockExit"}, {2, &ISelfController::UnlockExit, "UnlockExit"},
@ -65,6 +67,7 @@ public:
{14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"}, {14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"},
{16, &ISelfController::SetOutOfFocusSuspendingEnabled, {16, &ISelfController::SetOutOfFocusSuspendingEnabled,
"SetOutOfFocusSuspendingEnabled"}, "SetOutOfFocusSuspendingEnabled"},
{40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
} }
@ -144,6 +147,21 @@ private:
LOG_WARNING(Service, "(STUBBED) called"); LOG_WARNING(Service, "(STUBBED) called");
} }
void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
// TODO(Subv): Find out how AM determines the display to use, for now just create the layer
// in the Default display.
u64 display_id = nvflinger->OpenDisplay("Default");
u64 layer_id = nvflinger->CreateLayer(display_id);
IPC::RequestBuilder rb{ctx, 4};
rb.Push(RESULT_SUCCESS);
rb.Push(layer_id);
LOG_WARNING(Service, "(STUBBED) called");
}
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
}; };
class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> { class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
@ -367,7 +385,8 @@ public:
class IApplicationProxy final : public ServiceFramework<IApplicationProxy> { class IApplicationProxy final : public ServiceFramework<IApplicationProxy> {
public: public:
IApplicationProxy() : ServiceFramework("IApplicationProxy") { IApplicationProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
: ServiceFramework("IApplicationProxy"), nvflinger(std::move(nvflinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"}, {0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"},
{1, &IApplicationProxy::GetSelfController, "GetSelfController"}, {1, &IApplicationProxy::GetSelfController, "GetSelfController"},
@ -413,7 +432,7 @@ private:
void GetSelfController(Kernel::HLERequestContext& ctx) { void GetSelfController(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; IPC::RequestBuilder rb{ctx, 2, 0, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<ISelfController>(); rb.PushIpcInterface<ISelfController>(nvflinger);
LOG_DEBUG(Service, "called"); LOG_DEBUG(Service, "called");
} }
@ -437,16 +456,19 @@ private:
rb.PushIpcInterface<IApplicationFunctions>(); rb.PushIpcInterface<IApplicationFunctions>();
LOG_DEBUG(Service, "called"); LOG_DEBUG(Service, "called");
} }
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
}; };
void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) { void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; IPC::RequestBuilder rb{ctx, 2, 0, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<IApplicationProxy>(); rb.PushIpcInterface<IApplicationProxy>(nvflinger);
LOG_DEBUG(Service, "called"); LOG_DEBUG(Service, "called");
} }
AppletOE::AppletOE() : ServiceFramework("appletOE") { AppletOE::AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
: ServiceFramework("appletOE"), nvflinger(std::move(nvflinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0x00000000, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"}, {0x00000000, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"},
}; };

View file

@ -4,10 +4,15 @@
#pragma once #pragma once
#include <memory>
#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/hle_ipc.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
namespace Service { namespace Service {
namespace NVFlinger {
class NVFlinger;
}
namespace AM { namespace AM {
// TODO: Add more languages // TODO: Add more languages
@ -18,11 +23,13 @@ enum SystemLanguage {
class AppletOE final : public ServiceFramework<AppletOE> { class AppletOE final : public ServiceFramework<AppletOE> {
public: public:
AppletOE(); AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
~AppletOE() = default; ~AppletOE() = default;
private: private:
void OpenApplicationProxy(Kernel::HLERequestContext& ctx); void OpenApplicationProxy(Kernel::HLERequestContext& ctx);
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
}; };
} // namespace AM } // namespace AM

View file

@ -165,11 +165,15 @@ void AddNamedPort(std::string name, SharedPtr<ClientPort> port) {
/// Initialize ServiceManager /// Initialize ServiceManager
void Init() { void Init() {
// NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
// here and pass it into the respective InstallInterfaces functions.
auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>();
SM::g_service_manager = std::make_shared<SM::ServiceManager>(); SM::g_service_manager = std::make_shared<SM::ServiceManager>();
SM::ServiceManager::InstallInterfaces(SM::g_service_manager); SM::ServiceManager::InstallInterfaces(SM::g_service_manager);
Account::InstallInterfaces(*SM::g_service_manager); Account::InstallInterfaces(*SM::g_service_manager);
AM::InstallInterfaces(*SM::g_service_manager); AM::InstallInterfaces(*SM::g_service_manager, nv_flinger);
AOC::InstallInterfaces(*SM::g_service_manager); AOC::InstallInterfaces(*SM::g_service_manager);
APM::InstallInterfaces(*SM::g_service_manager); APM::InstallInterfaces(*SM::g_service_manager);
Audio::InstallInterfaces(*SM::g_service_manager); Audio::InstallInterfaces(*SM::g_service_manager);
@ -180,7 +184,7 @@ void Init() {
PCTL::InstallInterfaces(*SM::g_service_manager); PCTL::InstallInterfaces(*SM::g_service_manager);
Sockets::InstallInterfaces(*SM::g_service_manager); Sockets::InstallInterfaces(*SM::g_service_manager);
Time::InstallInterfaces(*SM::g_service_manager); Time::InstallInterfaces(*SM::g_service_manager);
VI::InstallInterfaces(*SM::g_service_manager); VI::InstallInterfaces(*SM::g_service_manager, nv_flinger);
Set::InstallInterfaces(*SM::g_service_manager); Set::InstallInterfaces(*SM::g_service_manager);
LOG_DEBUG(Service, "initialized OK"); LOG_DEBUG(Service, "initialized OK");

View file

@ -753,8 +753,9 @@ IApplicationDisplayService::IApplicationDisplayService(
RegisterHandlers(functions); RegisterHandlers(functions);
} }
void InstallInterfaces(SM::ServiceManager& service_manager) { void InstallInterfaces(SM::ServiceManager& service_manager,
std::make_shared<VI_M>()->InstallAsService(service_manager); std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) {
std::make_shared<VI_M>(nv_flinger)->InstallAsService(service_manager);
} }
} // namespace VI } // namespace VI

View file

@ -39,7 +39,8 @@ private:
}; };
/// Registers all VI services with the specified service manager. /// Registers all VI services with the specified service manager.
void InstallInterfaces(SM::ServiceManager& service_manager); void InstallInterfaces(SM::ServiceManager& service_manager,
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
} // namespace VI } // namespace VI
} // namespace Service } // namespace Service

View file

@ -17,13 +17,13 @@ void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) {
rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger); rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger);
} }
VI_M::VI_M() : ServiceFramework("vi:m") { VI_M::VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)
: ServiceFramework("vi:m"), nv_flinger(std::move(nv_flinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{2, &VI_M::GetDisplayService, "GetDisplayService"}, {2, &VI_M::GetDisplayService, "GetDisplayService"},
{3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, {3, nullptr, "GetDisplayServiceWithProxyNameExchange"},
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
nv_flinger = std::make_shared<NVFlinger::NVFlinger>();
} }
} // namespace VI } // namespace VI

View file

@ -16,7 +16,7 @@ namespace VI {
class VI_M final : public ServiceFramework<VI_M> { class VI_M final : public ServiceFramework<VI_M> {
public: public:
VI_M(); VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
~VI_M() = default; ~VI_M() = default;
private: private: