mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
Code cleanup, move a lot of "Host" APIs to GpCommon
This commit is contained in:
@@ -20,7 +20,6 @@ LOCAL_SRC_FILES := \
|
||||
GpGlobalConfig.cpp \
|
||||
GpInputDriverFactory.cpp \
|
||||
GpMain.cpp \
|
||||
GpMemoryBuffer.cpp \
|
||||
GpVOSEventQueue.cpp
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
@@ -136,7 +136,7 @@ void GpAppEnvironment::SetVOSEventQueue(GpVOSEventQueue *eventQueue)
|
||||
m_vosEventQueue = eventQueue;
|
||||
}
|
||||
|
||||
void GpAppEnvironment::SetSystemServices(PortabilityLayer::HostSystemServices *systemServices)
|
||||
void GpAppEnvironment::SetSystemServices(IGpSystemServices *systemServices)
|
||||
{
|
||||
m_systemServices = systemServices;
|
||||
}
|
||||
@@ -156,13 +156,14 @@ void GpAppEnvironment::AppThreadFunc()
|
||||
|
||||
void GpAppEnvironment::InitializeApplicationState()
|
||||
{
|
||||
GpAppInterface_Get()->PL_HostDisplayDriver_SetInstance(m_displayDriver);
|
||||
GpAppInterface_Get()->PL_HostAudioDriver_SetInstance(m_audioDriver);
|
||||
GpAppInterface_Get()->PL_HostInputDriver_SetInstances(m_inputDrivers, m_numInputDrivers);
|
||||
GpAppInterface_Get()->PL_InstallHostSuspendHook(GpAppEnvironment::StaticSuspendHookFunc, this);
|
||||
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
|
||||
drivers->SetDriver<GpDriverIDs::kDisplay>(m_displayDriver);
|
||||
drivers->SetDriver<GpDriverIDs::kAudio>(m_audioDriver);
|
||||
drivers->SetDrivers<GpDriverIDs::kInput>(m_inputDrivers, m_numInputDrivers);
|
||||
drivers->SetDriver<GpDriverIDs::kFont>(m_fontHandler);
|
||||
drivers->SetDriver<GpDriverIDs::kEventQueue>(m_vosEventQueue);
|
||||
|
||||
GpAppInterface_Get()->PL_HostFontHandler_SetInstance(m_fontHandler);
|
||||
GpAppInterface_Get()->PL_HostVOSEventQueue_SetInstance(m_vosEventQueue);
|
||||
GpAppInterface_Get()->PL_InstallHostSuspendHook(GpAppEnvironment::StaticSuspendHookFunc, this);
|
||||
}
|
||||
|
||||
void GpAppEnvironment::SynchronizeState()
|
||||
|
@@ -9,15 +9,15 @@
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
union HostSuspendCallArgument;
|
||||
class HostVOSEventQueue;
|
||||
class HostSystemServices;
|
||||
}
|
||||
|
||||
struct IGpDisplayDriver;
|
||||
struct IGpAudioDriver;
|
||||
struct IGpInputDriver;
|
||||
struct IGpFiber;
|
||||
struct IGpFontHandler;
|
||||
struct IGpInputDriver;
|
||||
struct IGpSystemServices;
|
||||
struct IGpVOSEventQueue;
|
||||
|
||||
class GpAppEnvironment
|
||||
{
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
void SetInputDrivers(IGpInputDriver *const* inputDrivers, size_t numDrivers);
|
||||
void SetFontHandler(IGpFontHandler *fontHandler);
|
||||
void SetVOSEventQueue(GpVOSEventQueue *eventQueue);
|
||||
void SetSystemServices(PortabilityLayer::HostSystemServices *systemServices);
|
||||
void SetSystemServices(IGpSystemServices *systemServices);
|
||||
|
||||
private:
|
||||
enum ApplicationState
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
IGpInputDriver *const* m_inputDrivers;
|
||||
IGpFontHandler *m_fontHandler;
|
||||
GpVOSEventQueue *m_vosEventQueue;
|
||||
PortabilityLayer::HostSystemServices *m_systemServices;
|
||||
IGpSystemServices *m_systemServices;
|
||||
IGpFiber *m_applicationFiber;
|
||||
IGpFiber *m_vosFiber;
|
||||
|
||||
|
@@ -1,16 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
struct IGpFiber;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class HostSystemServices;
|
||||
}
|
||||
struct IGpSystemServices;
|
||||
|
||||
class GpFiberStarter
|
||||
{
|
||||
public:
|
||||
typedef void(*ThreadFunc_t)(void *context);
|
||||
|
||||
static IGpFiber *StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber);
|
||||
static IGpFiber *StartFiber(IGpSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber);
|
||||
};
|
||||
|
@@ -8,11 +8,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
struct IGpLogDriver;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class HostSystemServices;
|
||||
}
|
||||
struct IGpSystemServices;
|
||||
|
||||
struct GpGlobalConfig
|
||||
{
|
||||
@@ -24,7 +20,7 @@ struct GpGlobalConfig
|
||||
size_t m_numInputDrivers;
|
||||
|
||||
IGpLogDriver *m_logger;
|
||||
PortabilityLayer::HostSystemServices *m_systemServices;
|
||||
IGpSystemServices *m_systemServices;
|
||||
void *m_osGlobals;
|
||||
};
|
||||
|
||||
|
@@ -1,49 +0,0 @@
|
||||
#include "GpMemoryBuffer.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
void *GpMemoryBuffer::Contents()
|
||||
{
|
||||
return reinterpret_cast<uint8_t*>(this) + AlignedSize();
|
||||
}
|
||||
|
||||
size_t GpMemoryBuffer::Size()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void GpMemoryBuffer::Destroy()
|
||||
{
|
||||
delete[] reinterpret_cast<uint8_t*>(this);
|
||||
}
|
||||
|
||||
GpMemoryBuffer *GpMemoryBuffer::Create(size_t sz)
|
||||
{
|
||||
const size_t allowedSize = SIZE_MAX - AlignedSize();
|
||||
if (sz > allowedSize)
|
||||
return nullptr;
|
||||
|
||||
const size_t bufferSize = GpMemoryBuffer::AlignedSize() + sz;
|
||||
|
||||
uint8_t *buffer = new uint8_t[bufferSize];
|
||||
new (buffer) GpMemoryBuffer(sz);
|
||||
|
||||
return reinterpret_cast<GpMemoryBuffer*>(buffer);
|
||||
}
|
||||
|
||||
GpMemoryBuffer::GpMemoryBuffer(size_t sz)
|
||||
: m_size(sz)
|
||||
{
|
||||
}
|
||||
|
||||
GpMemoryBuffer::~GpMemoryBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
size_t GpMemoryBuffer::AlignedSize()
|
||||
{
|
||||
const size_t paddedSize = (sizeof(GpMemoryBuffer) + GP_SYSTEM_MEMORY_ALIGNMENT - 1);
|
||||
const size_t sz = paddedSize - paddedSize % GP_SYSTEM_MEMORY_ALIGNMENT;
|
||||
|
||||
return sz;
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostMemoryBuffer.h"
|
||||
|
||||
class GpMemoryBuffer final : public PortabilityLayer::HostMemoryBuffer
|
||||
{
|
||||
public:
|
||||
void *Contents() override;
|
||||
size_t Size() override;
|
||||
void Destroy() override;
|
||||
|
||||
static GpMemoryBuffer *Create(size_t sz);
|
||||
|
||||
private:
|
||||
explicit GpMemoryBuffer(size_t sz);
|
||||
~GpMemoryBuffer();
|
||||
|
||||
static size_t AlignedSize();
|
||||
|
||||
size_t m_size;
|
||||
};
|
@@ -81,7 +81,6 @@
|
||||
<ClCompile Include="GpGlobalConfig.cpp" />
|
||||
<ClCompile Include="GpInputDriverFactory.cpp" />
|
||||
<ClCompile Include="GpMain.cpp" />
|
||||
<ClCompile Include="GpMemoryBuffer.cpp" />
|
||||
<ClCompile Include="GpVOSEventQueue.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@@ -36,9 +36,6 @@
|
||||
<ClCompile Include="GpMain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpMemoryBuffer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpVOSEventQueue.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@@ -2,10 +2,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "HostVOSEventQueue.h"
|
||||
#include "IGpVOSEventQueue.h"
|
||||
#include "GpVOSEvent.h"
|
||||
|
||||
class GpVOSEventQueue final : public PortabilityLayer::HostVOSEventQueue
|
||||
class GpVOSEventQueue final : public IGpVOSEventQueue
|
||||
{
|
||||
public:
|
||||
GpVOSEventQueue();
|
||||
|
Reference in New Issue
Block a user