mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
Display driver loop refactor
This commit is contained in:
@@ -38,7 +38,6 @@ public:
|
||||
virtual void PL_Render(IGpDisplayDriver *displayDriver) = 0;
|
||||
virtual GpDriverCollection *PL_GetDriverCollection() = 0;
|
||||
|
||||
virtual void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) = 0;
|
||||
virtual bool PL_AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY) = 0;
|
||||
};
|
||||
|
||||
|
@@ -1,22 +1,17 @@
|
||||
#include "HostSuspendHook.h"
|
||||
#include "HostSuspendCallArgument.h"
|
||||
#include "HostSuspendCallArgument.h"
|
||||
|
||||
#include "DisplayDeviceManager.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static PortabilityLayer::HostSuspendHook_t gs_suspendHook;
|
||||
static void *gs_suspendContext;
|
||||
}
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
void InstallHostSuspendHook(HostSuspendHook_t hook, void *context)
|
||||
void RenderFrames(unsigned int ticks)
|
||||
{
|
||||
gs_suspendHook = hook;
|
||||
gs_suspendContext = context;
|
||||
}
|
||||
|
||||
void SuspendApplication(HostSuspendCallID callID, const HostSuspendCallArgument *args, HostSuspendCallArgument *returnValue)
|
||||
{
|
||||
gs_suspendHook(gs_suspendContext, callID, args, returnValue);
|
||||
PLDrivers::GetDisplayDriver()->ServeTicks(ticks);
|
||||
DisplayDeviceManager::GetInstance()->IncrementTickCount(ticks);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef __PL_HOST_API_HOOK_H__
|
||||
#define __PL_HOST_API_HOOK_H__
|
||||
|
||||
#include "HostSuspendCallID.h"
|
||||
|
||||
@@ -10,8 +8,5 @@ namespace PortabilityLayer
|
||||
|
||||
typedef void(*HostSuspendHook_t)(void *context, HostSuspendCallID callID, const HostSuspendCallArgument *args, HostSuspendCallArgument *returnValue);
|
||||
|
||||
void InstallHostSuspendHook(HostSuspendHook_t hook, void *context);
|
||||
void SuspendApplication(HostSuspendCallID callID, const HostSuspendCallArgument *args, HostSuspendCallArgument *returnValue);
|
||||
}
|
||||
|
||||
#endif
|
||||
void RenderFrames(unsigned int ticks);
|
||||
}
|
||||
|
@@ -52,28 +52,6 @@
|
||||
#include <algorithm>
|
||||
#include <limits.h>
|
||||
|
||||
class PLMainThreadRelay final : public IGpThreadRelay
|
||||
{
|
||||
public:
|
||||
void Invoke(Callback_t callback, void *context) const override;
|
||||
|
||||
static PLMainThreadRelay *GetInstance();
|
||||
|
||||
private:
|
||||
static PLMainThreadRelay ms_instance;
|
||||
};
|
||||
|
||||
void PLMainThreadRelay::Invoke(Callback_t callback, void *context) const
|
||||
{
|
||||
PLSysCalls::RunOnVOSThread(callback, context);
|
||||
}
|
||||
|
||||
PLMainThreadRelay *PLMainThreadRelay::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
PLMainThreadRelay PLMainThreadRelay::ms_instance;
|
||||
|
||||
static bool ConvertFilenameToSafePStr(const char *str, uint8_t *pstr)
|
||||
{
|
||||
@@ -138,7 +116,7 @@ void Delay(int ticks, UInt32 *endTickCount)
|
||||
|
||||
void ForceSyncFrame()
|
||||
{
|
||||
PLSysCalls::ForceSyncFrame();
|
||||
PLDrivers::GetDisplayDriver()->ForceSync();
|
||||
}
|
||||
|
||||
short FindWindow(Point point, WindowPtr *window)
|
||||
@@ -671,7 +649,6 @@ void PL_Init()
|
||||
PortabilityLayer::MenuManager::GetInstance()->Init();
|
||||
PortabilityLayer::WindowManager::GetInstance()->Init();
|
||||
|
||||
PLDrivers::GetFileSystem()->SetMainThreadRelay(PLMainThreadRelay::GetInstance());
|
||||
PLDrivers::GetFileSystem()->SetDelayCallback(PLSysCalls::Sleep);
|
||||
}
|
||||
|
||||
|
@@ -176,11 +176,8 @@ namespace PLSysCalls
|
||||
void Sleep(uint32_t ticks)
|
||||
{
|
||||
if (ticks > 0)
|
||||
{
|
||||
PortabilityLayer::HostSuspendCallArgument args[1];
|
||||
args[0].m_uint = static_cast<uint32_t>(ticks);
|
||||
|
||||
PortabilityLayer::SuspendApplication(PortabilityLayer::HostSuspendCallID_Delay, args, nullptr);
|
||||
{
|
||||
PortabilityLayer::RenderFrames(ticks);
|
||||
|
||||
ImportVOSEvents(PortabilityLayer::DisplayDeviceManager::GetInstance()->GetTickCount());
|
||||
|
||||
@@ -188,20 +185,6 @@ namespace PLSysCalls
|
||||
}
|
||||
}
|
||||
|
||||
void ForceSyncFrame()
|
||||
{
|
||||
PortabilityLayer::SuspendApplication(PortabilityLayer::HostSuspendCallID_ForceSyncFrame, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void RunOnVOSThread(void(*callback)(void *context), void *context)
|
||||
{
|
||||
PortabilityLayer::HostSuspendCallArgument args[2];
|
||||
args[0].m_functionPtr = callback;
|
||||
args[1].m_pointer = context;
|
||||
|
||||
PortabilityLayer::SuspendApplication(PortabilityLayer::HostSuspendCallID_CallOnVOSThread, args, nullptr);
|
||||
}
|
||||
|
||||
static jmp_buf gs_mainExitWrapper;
|
||||
static int gs_exitCode = 0;
|
||||
|
||||
|
@@ -7,8 +7,6 @@
|
||||
namespace PLSysCalls
|
||||
{
|
||||
void Sleep(uint32_t ticks);
|
||||
void ForceSyncFrame();
|
||||
void RunOnVOSThread(void(*callback)(void *context), void *context);
|
||||
void Exit(int exitCode);
|
||||
|
||||
int MainExitWrapper(int (*mainFunc)());
|
||||
|
Reference in New Issue
Block a user