2019-12-11 00:51:42 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-12-21 18:40:17 -05:00
|
|
|
#include "GpVOSEventQueue.h"
|
2019-12-11 00:51:42 -05:00
|
|
|
#include "HostSuspendCallID.h"
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
namespace PortabilityLayer
|
|
|
|
|
{
|
|
|
|
|
union HostSuspendCallArgument;
|
2019-12-21 18:40:17 -05:00
|
|
|
class HostFontHandler;
|
|
|
|
|
class HostVOSEventQueue;
|
2019-12-11 00:51:42 -05:00
|
|
|
}
|
|
|
|
|
|
2019-12-21 18:40:17 -05:00
|
|
|
struct IGpDisplayDriver;
|
|
|
|
|
struct IGpAudioDriver;
|
2019-12-29 17:39:19 -05:00
|
|
|
struct IGpInputDriver;
|
2019-12-23 17:43:10 -05:00
|
|
|
struct IGpFiber;
|
2019-12-11 00:51:42 -05:00
|
|
|
|
|
|
|
|
class GpAppEnvironment
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
GpAppEnvironment();
|
|
|
|
|
~GpAppEnvironment();
|
|
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
|
|
2019-12-23 17:43:10 -05:00
|
|
|
void Tick(IGpFiber *vosFiber);
|
2019-12-21 18:40:17 -05:00
|
|
|
void Render();
|
|
|
|
|
|
2019-12-11 00:51:42 -05:00
|
|
|
void SetDisplayDriver(IGpDisplayDriver *displayDriver);
|
|
|
|
|
void SetAudioDriver(IGpAudioDriver *audioDriver);
|
2019-12-29 17:39:19 -05:00
|
|
|
void SetInputDrivers(IGpInputDriver *const* inputDrivers, size_t numDrivers);
|
2019-12-21 18:40:17 -05:00
|
|
|
void SetFontHandler(PortabilityLayer::HostFontHandler *fontHandler);
|
2019-12-24 02:35:24 -05:00
|
|
|
void SetVOSEventQueue(GpVOSEventQueue *eventQueue);
|
2019-12-11 00:51:42 -05:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
enum ApplicationState
|
|
|
|
|
{
|
|
|
|
|
ApplicationState_NotStarted,
|
|
|
|
|
ApplicationState_WaitingForEvents,
|
|
|
|
|
ApplicationState_Running,
|
|
|
|
|
ApplicationState_Terminated,
|
|
|
|
|
ApplicationState_SystemCall,
|
|
|
|
|
ApplicationState_TimedSuspend,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void StaticAppThreadFunc(void *context);
|
|
|
|
|
void AppThreadFunc();
|
|
|
|
|
void InitializeApplicationState();
|
|
|
|
|
void SynchronizeState();
|
|
|
|
|
|
|
|
|
|
static void StaticSuspendHookFunc(void *context, PortabilityLayer::HostSuspendCallID callID, const PortabilityLayer::HostSuspendCallArgument *args, PortabilityLayer::HostSuspendCallArgument *returnValue);
|
|
|
|
|
void DispatchSystemCall(PortabilityLayer::HostSuspendCallID callID, const PortabilityLayer::HostSuspendCallArgument *args, PortabilityLayer::HostSuspendCallArgument *returnValue);
|
|
|
|
|
|
|
|
|
|
ApplicationState m_applicationState;
|
|
|
|
|
IGpDisplayDriver *m_displayDriver;
|
|
|
|
|
IGpAudioDriver *m_audioDriver;
|
2019-12-29 17:39:19 -05:00
|
|
|
IGpInputDriver *const* m_inputDrivers;
|
2019-12-21 18:40:17 -05:00
|
|
|
PortabilityLayer::HostFontHandler *m_fontHandler;
|
2019-12-24 02:35:24 -05:00
|
|
|
GpVOSEventQueue *m_vosEventQueue;
|
2019-12-23 17:43:10 -05:00
|
|
|
IGpFiber *m_applicationFiber;
|
|
|
|
|
IGpFiber *m_vosFiber;
|
2019-12-11 00:51:42 -05:00
|
|
|
|
|
|
|
|
uint32_t m_delaySuspendTicks;
|
2019-12-29 17:39:19 -05:00
|
|
|
size_t m_numInputDrivers;
|
2019-12-11 00:51:42 -05:00
|
|
|
|
|
|
|
|
PortabilityLayer::HostSuspendCallID m_suspendCallID;
|
|
|
|
|
const PortabilityLayer::HostSuspendCallArgument *m_suspendArgs;
|
|
|
|
|
PortabilityLayer::HostSuspendCallArgument *m_suspendReturnValue;
|
|
|
|
|
};
|