Code cleanup, move a lot of "Host" APIs to GpCommon

This commit is contained in:
elasota
2020-11-25 12:05:59 -05:00
parent 9d0f2c35b3
commit 5c640b72eb
102 changed files with 759 additions and 1072 deletions

View File

@@ -28,7 +28,7 @@ namespace GpFiberStarter_Win32
}
}
IGpFiber *GpFiberStarter::StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
IGpFiber *GpFiberStarter::StartFiber(IGpSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
{
ULONG_PTR lowLimit;
ULONG_PTR highLimit;

View File

@@ -3,8 +3,7 @@
#include "GpApplicationName.h"
#include "GpFileStream_Win32.h"
#include "GpWindows.h"
#include "GpMemoryBuffer.h"
#include "HostDirectoryCursor.h"
#include "IGpDirectoryCursor.h"
#include <string>
#include <Shlwapi.h>
@@ -15,7 +14,7 @@
extern GpWindowsGlobals g_gpWindowsGlobals;
class GpDirectoryCursor_Win32 final : public PortabilityLayer::HostDirectoryCursor
class GpDirectoryCursor_Win32 final : public IGpDirectoryCursor
{
public:
static GpDirectoryCursor_Win32 *Create(const HANDLE &handle, const WIN32_FIND_DATAW &findData);
@@ -273,7 +272,7 @@ bool GpFileSystem_Win32::DeleteFile(PortabilityLayer::VirtualDirectory_t virtual
return false;
}
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Win32::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
IGpDirectoryCursor *GpFileSystem_Win32::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
{
wchar_t winPath[MAX_PATH + 2];

View File

@@ -1,13 +1,13 @@
#pragma once
#include "HostFileSystem.h"
#include "IGpFileSystem.h"
#include "GpCoreDefs.h"
#include "GpWindows.h"
#include <string>
class GpFileSystem_Win32 final : public PortabilityLayer::HostFileSystem
class GpFileSystem_Win32 final : public IGpFileSystem
{
public:
GpFileSystem_Win32();
@@ -16,7 +16,7 @@ public:
bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists) override;
GpIOStream *OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) override;
bool DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) override;
PortabilityLayer::HostDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override;
IGpDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override;
bool ValidateFilePath(const char *path, size_t sz) const override;
bool ValidateFilePathUnicodeChar(uint32_t ch) const override;

View File

@@ -12,10 +12,9 @@
#include "GpAppInterface.h"
#include "GpSystemServices_Win32.h"
#include "GpVOSEvent.h"
#include "IGpFileSystem.h"
#include "IGpVOSEventQueue.h"
#include "HostFileSystem.h"
#include "GpWindows.h"
#include "resource.h"
@@ -414,9 +413,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
IGpLogDriver *logger = GpLogDriver_Win32::GetInstance();
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Win32::GetInstance());
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Win32::GetInstance());
GpAppInterface_Get()->PL_HostLogDriver_SetInstance(GpLogDriver_Win32::GetInstance());
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Win32::GetInstance());
drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Win32::GetInstance());
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Win32::GetInstance());
g_gpWindowsGlobals.m_hInstance = hInstance;
g_gpWindowsGlobals.m_hPrevInstance = hPrevInstance;

View File

@@ -1,10 +1,10 @@
#pragma once
#include "HostMutex.h"
#include "IGpMutex.h"
#include "GpWindows.h"
class GpMutex_Win32 final : public PortabilityLayer::HostMutex
class GpMutex_Win32 final : public IGpMutex
{
public:
void Destroy() override;

View File

@@ -13,7 +13,7 @@ struct GpSystemServices_Win32_ThreadStartParams
{
GpSystemServices_Win32::ThreadFunc_t m_threadFunc;
void *m_threadContext;
PortabilityLayer::HostThreadEvent *m_threadStartEvent;
IGpThreadEvent *m_threadStartEvent;
};
static DWORD WINAPI StaticStartThread(LPVOID lpThreadParameter)
@@ -22,7 +22,7 @@ static DWORD WINAPI StaticStartThread(LPVOID lpThreadParameter)
GpSystemServices_Win32::ThreadFunc_t threadFunc = threadParams->m_threadFunc;
void *threadContext = threadParams->m_threadContext;
PortabilityLayer::HostThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
IGpThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
threadStartEvent->Signal();
@@ -72,24 +72,24 @@ void GpSystemServices_Win32::GetLocalDateTime(unsigned int &year, unsigned int &
second = localTime.wSecond;
}
PortabilityLayer::HostMutex *GpSystemServices_Win32::CreateMutex()
IGpMutex *GpSystemServices_Win32::CreateMutex()
{
return GpMutex_Win32::Create();
}
PortabilityLayer::HostMutex *GpSystemServices_Win32::CreateRecursiveMutex()
IGpMutex *GpSystemServices_Win32::CreateRecursiveMutex()
{
return GpMutex_Win32::Create();
}
PortabilityLayer::HostThreadEvent *GpSystemServices_Win32::CreateThreadEvent(bool autoReset, bool startSignaled)
IGpThreadEvent *GpSystemServices_Win32::CreateThreadEvent(bool autoReset, bool startSignaled)
{
return GpThreadEvent_Win32::Create(autoReset, startSignaled);
}
void *GpSystemServices_Win32::CreateThread(ThreadFunc_t threadFunc, void *context)
{
PortabilityLayer::HostThreadEvent *evt = CreateThreadEvent(true, false);
IGpThreadEvent *evt = CreateThreadEvent(true, false);
if (!evt)
return nullptr;

View File

@@ -1,6 +1,6 @@
#pragma once
#include "HostSystemServices.h"
#include "IGpSystemServices.h"
#include "GpCoreDefs.h"
#include "GpWindows.h"
@@ -15,17 +15,17 @@
#endif
class GpSystemServices_Win32 final : public PortabilityLayer::HostSystemServices
class GpSystemServices_Win32 final : public IGpSystemServices
{
public:
GpSystemServices_Win32();
int64_t GetTime() const override;
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
PortabilityLayer::HostMutex *CreateMutex() override;
PortabilityLayer::HostMutex *CreateRecursiveMutex() override;
IGpMutex *CreateMutex() override;
IGpMutex *CreateRecursiveMutex() override;
void *CreateThread(ThreadFunc_t threadFunc, void *context) override;
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
uint64_t GetFreeMemoryCosmetic() const override;
void Beep() const override;
bool IsTouchscreen() const override;

View File

@@ -1,10 +1,10 @@
#pragma once
#include "HostThreadEvent.h"
#include "IGpThreadEvent.h"
#include "GpWindows.h"
class GpThreadEvent_Win32 final : public PortabilityLayer::HostThreadEvent
class GpThreadEvent_Win32 final : public IGpThreadEvent
{
public:
void Wait() override;

View File

@@ -1,12 +1,14 @@
#define _LARGEFILE64_SOURCE
#include "GpFileSystem_Android.h"
#include "GpIOStream.h"
#include "HostDirectoryCursor.h"
#include "HostSystemServices.h"
#include "HostMutex.h"
#include "IGpDirectoryCursor.h"
#include "IGpSystemServices.h"
#include "IGpMutex.h"
#include "IGpThreadRelay.h"
#include "VirtualDirectory.h"
#include "PLDrivers.h"
#include "SDL.h"
#include "SDL_rwops.h"
@@ -380,7 +382,7 @@ void GpFileStream_Android_File::Flush()
bool GpFileSystem_Android::OpenSourceExportFD(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths, int &fd, jobject &pfd)
{
if (!m_sourceExportMutex)
m_sourceExportMutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex();
m_sourceExportMutex = PLDrivers::GetSystemServices()->CreateMutex();
m_sourceExportWaiting = true;
m_sourceExportCancelled = false;
@@ -696,7 +698,7 @@ bool GpFileSystem_Android::DeleteFile(PortabilityLayer::VirtualDirectory_t virtu
return true;
}
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths)
IGpDirectoryCursor *GpFileSystem_Android::ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths)
{
ScanDirectoryNestedContext ctx;
ctx.m_this = this;
@@ -715,7 +717,7 @@ void GpFileSystem_Android::ScanDirectoryNestedThunk(void *context)
ctx->m_returnValue = ctx->m_this->ScanDirectoryNestedInternal(ctx->m_virtualDirectory, ctx->m_paths, ctx->m_numPaths);
}
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths)
IGpDirectoryCursor *GpFileSystem_Android::ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *const *paths, size_t numPaths)
{
if (virtualDirectory == PortabilityLayer::VirtualDirectories::kGameData || virtualDirectory == PortabilityLayer::VirtualDirectories::kApplicationData)
return ScanAssetDirectory(virtualDirectory, paths, numPaths);
@@ -809,7 +811,7 @@ GpFileSystem_Android *GpFileSystem_Android::GetInstance()
return &ms_instance;
}
class GpDirectoryCursor_StringList final : public PortabilityLayer::HostDirectoryCursor
class GpDirectoryCursor_StringList final : public IGpDirectoryCursor
{
public:
explicit GpDirectoryCursor_StringList(std::vector<std::string> &paths);
@@ -847,7 +849,7 @@ void GpDirectoryCursor_StringList::Destroy()
delete this;
}
class GpDirectoryCursor_POSIX final : public PortabilityLayer::HostDirectoryCursor
class GpDirectoryCursor_POSIX final : public IGpDirectoryCursor
{
public:
explicit GpDirectoryCursor_POSIX(DIR *dir);
@@ -885,7 +887,7 @@ void GpDirectoryCursor_POSIX::Destroy()
delete this;
}
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanAssetDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
IGpDirectoryCursor *GpFileSystem_Android::ScanAssetDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
{
std::string resolvedPath;
@@ -919,7 +921,7 @@ PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanAssetDirectory(
return new GpDirectoryCursor_StringList(subPaths);
}
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanStorageDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
IGpDirectoryCursor *GpFileSystem_Android::ScanStorageDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths)
{
std::string resolvedPath;
std::vector<std::string> subPaths;

View File

@@ -1,18 +1,15 @@
#pragma once
#include "HostFileSystem.h"
#include "IGpFileSystem.h"
#include "GpCoreDefs.h"
#include <jni.h>
#include <string>
namespace PortabilityLayer
{
class HostMutex;
}
struct IGpMutex;
class GpFileSystem_Android final : public PortabilityLayer::HostFileSystem
class GpFileSystem_Android final : public IGpFileSystem
{
public:
GpFileSystem_Android();
@@ -25,7 +22,7 @@ public:
bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists) override;
GpIOStream *OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* subPaths, size_t numSubPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) override;
bool DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) override;
PortabilityLayer::HostDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override;
IGpDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) override;
bool ValidateFilePath(const char *path, size_t pathLen) const override;
bool ValidateFilePathUnicodeChar(uint32_t ch) const override;
@@ -45,17 +42,17 @@ private:
{
GpFileSystem_Android *m_this;
PortabilityLayer::HostDirectoryCursor *m_returnValue;
IGpDirectoryCursor *m_returnValue;
PortabilityLayer::VirtualDirectory_t m_virtualDirectory;
char const *const *m_paths;
size_t m_numPaths;
};
static void ScanDirectoryNestedThunk(void *context);
PortabilityLayer::HostDirectoryCursor *ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
IGpDirectoryCursor *ScanDirectoryNestedInternal(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
PortabilityLayer::HostDirectoryCursor *ScanAssetDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
PortabilityLayer::HostDirectoryCursor *ScanStorageDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
IGpDirectoryCursor *ScanAssetDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
IGpDirectoryCursor *ScanStorageDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths);
bool OpenSourceExportFD(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, int &fd, jobject &pfd);
bool ResolvePath(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, std::string &resolution, bool &isAsset);
@@ -68,7 +65,7 @@ private:
jmethodID m_selectSourceExportPathMID;
jmethodID m_closeSourceExportPFDMID;
PortabilityLayer::HostMutex *m_sourceExportMutex;
IGpMutex *m_sourceExportMutex;
int m_sourceExportFD;
bool m_sourceExportWaiting;
bool m_sourceExportCancelled;

View File

@@ -14,8 +14,8 @@
#include "IGpVOSEventQueue.h"
#include "IGpLogDriver.h"
#include "HostFileSystem.h"
#include "HostThreadEvent.h"
#include "IGpFileSystem.h"
#include "IGpThreadEvent.h"
#include "GpAndroid.h"
@@ -81,9 +81,10 @@ int main(int argc, char* argv[])
GpFileSystem_Android::GetInstance()->InitJNI();
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Android::GetInstance());
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Android::GetInstance());
GpAppInterface_Get()->PL_HostLogDriver_SetInstance(GpLogDriver_Android::GetInstance());
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Android::GetInstance());
drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Android::GetInstance());
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Android::GetInstance());
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2;

View File

@@ -1,6 +1,6 @@
#include "GpSystemServices_Android.h"
#include "HostMutex.h"
#include "HostThreadEvent.h"
#include "IGpMutex.h"
#include "IGpThreadEvent.h"
#include "SDL.h"
#include <time.h>
@@ -12,7 +12,7 @@ struct GpSystemServices_Android_ThreadStartParams
{
GpSystemServices_Android::ThreadFunc_t m_threadFunc;
void *m_threadContext;
PortabilityLayer::HostThreadEvent *m_threadStartEvent;
IGpThreadEvent *m_threadStartEvent;
};
static int SDLCALL StaticStartThread(void *lpThreadParameter)
@@ -21,7 +21,7 @@ static int SDLCALL StaticStartThread(void *lpThreadParameter)
GpSystemServices_Android::ThreadFunc_t threadFunc = threadParams->m_threadFunc;
void *threadContext = threadParams->m_threadContext;
PortabilityLayer::HostThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
IGpThreadEvent *threadStartEvent = threadParams->m_threadStartEvent;
threadStartEvent->Signal();
@@ -29,7 +29,7 @@ static int SDLCALL StaticStartThread(void *lpThreadParameter)
}
template<class TMutex>
class GpMutex_Cpp11 final : public PortabilityLayer::HostMutex
class GpMutex_Cpp11 final : public IGpMutex
{
public:
GpMutex_Cpp11();
@@ -77,7 +77,7 @@ typedef GpMutex_Cpp11<std::mutex> GpMutex_Cpp11_Vanilla;
typedef GpMutex_Cpp11<std::recursive_mutex> GpMutex_Cpp11_Recursive;
class GpThreadEvent_Cpp11 final : public PortabilityLayer::HostThreadEvent
class GpThreadEvent_Cpp11 final : public IGpThreadEvent
{
public:
GpThreadEvent_Cpp11(bool autoReset, bool startSignaled);
@@ -187,7 +187,7 @@ void GpSystemServices_Android::GetLocalDateTime(unsigned int &year, unsigned int
second = static_cast<unsigned int>(tmObject->tm_sec);
}
PortabilityLayer::HostMutex *GpSystemServices_Android::CreateMutex()
IGpMutex *GpSystemServices_Android::CreateMutex()
{
GpMutex_Cpp11_Vanilla *mutex = static_cast<GpMutex_Cpp11_Vanilla*>(malloc(sizeof(GpMutex_Cpp11_Vanilla)));
if (!mutex)
@@ -199,7 +199,7 @@ PortabilityLayer::HostMutex *GpSystemServices_Android::CreateMutex()
void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *context)
{
PortabilityLayer::HostThreadEvent *evt = CreateThreadEvent(true, false);
IGpThreadEvent *evt = CreateThreadEvent(true, false);
if (!evt)
return nullptr;
@@ -221,7 +221,7 @@ void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *cont
return thread;
}
PortabilityLayer::HostMutex *GpSystemServices_Android::CreateRecursiveMutex()
IGpMutex *GpSystemServices_Android::CreateRecursiveMutex()
{
GpMutex_Cpp11_Recursive *mutex = static_cast<GpMutex_Cpp11_Recursive*>(malloc(sizeof(GpMutex_Cpp11_Recursive)));
if (!mutex)
@@ -230,7 +230,7 @@ PortabilityLayer::HostMutex *GpSystemServices_Android::CreateRecursiveMutex()
return new (mutex) GpMutex_Cpp11_Recursive();
}
PortabilityLayer::HostThreadEvent *GpSystemServices_Android::CreateThreadEvent(bool autoReset, bool startSignaled)
IGpThreadEvent *GpSystemServices_Android::CreateThreadEvent(bool autoReset, bool startSignaled)
{
GpThreadEvent_Cpp11 *evt = static_cast<GpThreadEvent_Cpp11*>(malloc(sizeof(GpThreadEvent_Cpp11)));
if (!evt)

View File

@@ -1,19 +1,19 @@
#pragma once
#include "HostSystemServices.h"
#include "IGpSystemServices.h"
#include "GpCoreDefs.h"
class GpSystemServices_Android final : public PortabilityLayer::HostSystemServices
class GpSystemServices_Android final : public IGpSystemServices
{
public:
GpSystemServices_Android();
int64_t GetTime() const override;
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
PortabilityLayer::HostMutex *CreateMutex() override;
PortabilityLayer::HostMutex *CreateRecursiveMutex() override;
IGpMutex *CreateMutex() override;
IGpMutex *CreateRecursiveMutex() override;
void *CreateThread(ThreadFunc_t threadFunc, void *context) override;
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
uint64_t GetFreeMemoryCosmetic() const override;
void Beep() const override;
bool IsTouchscreen() const override;

View File

@@ -1,12 +1,12 @@
#include "IGpAudioDriver.h"
#include "IGpAudioChannel.h"
#include "IGpAudioChannelCallbacks.h"
#include "IGpMutex.h"
#include "IGpPrefsHandler.h"
#include "IGpSystemServices.h"
#include "GpAudioDriverProperties.h"
#include "CoreDefs.h"
#include "HostMutex.h"
#include "HostSystemServices.h"
#include "SDL_audio.h"
#include "GpRingBuffer.h"
@@ -93,7 +93,7 @@ private:
bool Init(GpAudioDriver_SDL2 *driver);
IGpAudioChannelCallbacks *m_callbacks;
PortabilityLayer::HostMutex *m_mutex;
IGpMutex *m_mutex;
GpAudioDriver_SDL2 *m_owner;
SDL_atomic_t m_refCount;
@@ -131,8 +131,8 @@ private:
void RefillMixChunk(GpAudioChannel_SDL2 *const*channels, size_t numChannels);
GpAudioDriverProperties m_properties;
PortabilityLayer::HostMutex *m_mutex;
PortabilityLayer::HostMutex *m_mixState;
IGpMutex *m_mutex;
IGpMutex *m_mixState;
static const size_t kMaxChannels = 16;
static const size_t kMixChunkSize = 256;

View File

@@ -6,11 +6,11 @@
#include "GpDisplayDriverProperties.h"
#include "GpVOSEvent.h"
#include "GpRingBuffer.h"
#include "HostSystemServices.h"
#include "IGpCursor.h"
#include "IGpDisplayDriverSurface.h"
#include "IGpLogDriver.h"
#include "IGpPrefsHandler.h"
#include "IGpSystemServices.h"
#include "IGpVOSEventQueue.h"
#include "SDL_events.h"
@@ -897,7 +897,7 @@ private:
bool m_mouseIsInClientArea;
IGpFiber *m_vosFiber;
PortabilityLayer::HostThreadEvent *m_vosEvent;
IGpThreadEvent *m_vosEvent;
float m_bgColor[4];
bool m_bgIsDark;

View File

@@ -1,8 +1,8 @@
#include "GpFiberStarter.h"
#include "GpFiber_SDL.h"
#include "HostSystemServices.h"
#include "HostThreadEvent.h"
#include "IGpSystemServices.h"
#include "IGpThreadEvent.h"
#include "SDL_thread.h"
@@ -13,8 +13,8 @@ namespace GpFiberStarter_SDL
struct FiberStartState
{
GpFiberStarter::ThreadFunc_t m_threadFunc;
PortabilityLayer::HostThreadEvent *m_creatingReturnEvent;
PortabilityLayer::HostThreadEvent *m_creatingWakeEvent;
IGpThreadEvent *m_creatingReturnEvent;
IGpThreadEvent *m_creatingWakeEvent;
void *m_context;
};
@@ -23,8 +23,8 @@ namespace GpFiberStarter_SDL
const FiberStartState *tss = static_cast<const FiberStartState*>(lpThreadParameter);
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
PortabilityLayer::HostThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
PortabilityLayer::HostThreadEvent *wakeEvent = tss->m_creatingWakeEvent;
IGpThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
IGpThreadEvent *wakeEvent = tss->m_creatingWakeEvent;
void *context = tss->m_context;
creatingReturnEvent->Signal();
@@ -36,13 +36,13 @@ namespace GpFiberStarter_SDL
}
}
IGpFiber *GpFiberStarter::StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
IGpFiber *GpFiberStarter::StartFiber(IGpSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
{
PortabilityLayer::HostThreadEvent *returnEvent = systemServices->CreateThreadEvent(true, false);
IGpThreadEvent *returnEvent = systemServices->CreateThreadEvent(true, false);
if (!returnEvent)
return nullptr;
PortabilityLayer::HostThreadEvent *wakeEvent = systemServices->CreateThreadEvent(true, false);
IGpThreadEvent *wakeEvent = systemServices->CreateThreadEvent(true, false);
if (!wakeEvent)
{
returnEvent->Destroy();

View File

@@ -1,8 +1,7 @@
#include "GpFiber_SDL.h"
#include "HostSystemServices.h"
#include "HostThreadEvent.h"
#include "IGpThreadEvent.h"
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent)
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, IGpThreadEvent *threadEvent)
: m_event(threadEvent)
, m_thread(thread)
{

View File

@@ -3,16 +3,12 @@
#include "IGpFiber.h"
#include "SDL_thread.h"
namespace PortabilityLayer
{
class HostSystemServices;
class HostThreadEvent;
}
struct IGpThreadEvent;
class GpFiber_SDL final : public IGpFiber
{
public:
explicit GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent);
explicit GpFiber_SDL(SDL_Thread *thread, IGpThreadEvent *threadEvent);
~GpFiber_SDL();
void YieldTo(IGpFiber *fromFiber) override;
@@ -23,6 +19,6 @@ private:
static int SDLCALL InternalThreadFunction(void *data);
bool m_isDestroying;
PortabilityLayer::HostThreadEvent *m_event;
IGpThreadEvent *m_event;
SDL_Thread *m_thread;
};

View File

@@ -13,10 +13,10 @@
#include "GpAppInterface.h"
#include "GpSystemServices_Win32.h"
#include "GpVOSEvent.h"
#include "IGpVOSEventQueue.h"
#include "HostFileSystem.h"
#include "HostThreadEvent.h"
#include "IGpFileSystem.h"
#include "IGpThreadEvent.h"
#include "IGpVOSEventQueue.h"
#include "GpWindows.h"
@@ -56,10 +56,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
}
IGpLogDriver *logger = GpLogDriver_Win32::GetInstance();
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Win32::GetInstance());
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Win32::GetInstance());
GpAppInterface_Get()->PL_HostLogDriver_SetInstance(GpLogDriver_Win32::GetInstance());
drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Win32::GetInstance());
drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Win32::GetInstance());
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Win32::GetInstance());
g_gpWindowsGlobals.m_hInstance = hInstance;
g_gpWindowsGlobals.m_hPrevInstance = hPrevInstance;

View File

@@ -4,7 +4,24 @@
//----------------------------------------------------------------------------
//============================================================================
#include "About.h"
#include "DialogManager.h"
#include "DialogUtils.h"
#include "Environ.h"
#include "Externs.h"
#include "GpApplicationName.h"
#include "GpBuildVersion.h"
#include "IGpSystemServices.h"
#include "RenderedFont.h"
#include "GpRenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "ResourceManager.h"
#include "ScanlineMask.h"
#include "WindowDef.h"
#include "WindowManager.h"
#include "PLArrayView.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h"
#include "PLControlDefinitions.h"
#include "FontFamily.h"
@@ -19,21 +36,6 @@
#include "PLSysCalls.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLWidgets.h"
#include "About.h"
#include "DialogManager.h"
#include "DialogUtils.h"
#include "Environ.h"
#include "Externs.h"
#include "GpApplicationName.h"
#include "GpBuildVersion.h"
#include "HostSystemServices.h"
#include "RenderedFont.h"
#include "GpRenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "ResourceManager.h"
#include "ScanlineMask.h"
#include "WindowDef.h"
#include "WindowManager.h"
static void HiLiteOkayButton (DrawSurface *surface);
@@ -418,7 +420,7 @@ static void UpdateMainPict (Dialog *theDial)
Str255 theStr, theStr2;
uint64_t freeMemory;
freeMemory = PortabilityLayer::HostSystemServices::GetInstance()->GetFreeMemoryCosmetic();
freeMemory = PLDrivers::GetSystemServices()->GetFreeMemoryCosmetic();
PasStringCopy(PSTR("Memory: "), theStr); // display free memory

View File

@@ -5,17 +5,17 @@
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "PLBigEndian.h"
#include "Externs.h"
#include "Environ.h"
#include "HostDisplayDriver.h"
#include "IGpCursor.h"
#include "IGpDisplayDriver.h"
#include "MemoryManager.h"
#include "ResourceManager.h"
#include "PLDrivers.h"
#include "PLResources.h"
#include "PLBigEndian.h"
#include <assert.h>
@@ -219,7 +219,7 @@ IGpCursor *LoadColorCursor(int16_t resID)
mm->Release(colorValues);
IGpCursor *cursor = PortabilityLayer::HostDisplayDriver::GetInstance()->CreateColorCursor(width, height, pixelDataRGBA, cursorHeader->m_hotSpotX, cursorHeader->m_hotSpotY);
IGpCursor *cursor = PLDrivers::GetDisplayDriver()->CreateColorCursor(width, height, pixelDataRGBA, cursorHeader->m_hotSpotX, cursorHeader->m_hotSpotY);
mm->Release(pixelDataRGBA);
@@ -251,7 +251,7 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
else // But, if the cursor loaded ok
{ // add it to our list or cursor handles
(*compiledBallCursH)->frame[i].hwCursor = hwCursor;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(hwCursor);
PLDrivers::GetDisplayDriver()->SetCursor(hwCursor);
}
}
InitCursor(); // Show the cursor again (as arrow)
@@ -343,10 +343,10 @@ void IncrementCursor (void)
acur->index++;
acur->index %= acur->n;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
PLDrivers::GetDisplayDriver()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
}
else
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kWait);
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kWait);
}
//-------------------------------------------------------------- DecrementCursor
@@ -363,10 +363,10 @@ void DecrementCursor (void)
if (((*animCursorH)->index) < 0)
(*animCursorH)->index = ((*animCursorH)->n) - 1;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
PLDrivers::GetDisplayDriver()->SetCursor((*compiledAnimCursorH)->frame[(*animCursorH)->index].hwCursor);
}
else
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kWait);
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kWait);
}
//-------------------------------------------------------------- SpinCursor

View File

@@ -5,18 +5,18 @@
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "PLPasStr.h"
#include "DisplayDeviceManager.h"
#include "Externs.h"
#include "Environ.h"
#include "HostDisplayDriver.h"
#include "HostSystemServices.h"
#include "MenuManager.h"
#include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "WindowManager.h"
#include "PLDrivers.h"
#include "PLResources.h"
#include "PLPasStr.h"
#include <algorithm>
#define kSwitchDepthAlert 130
@@ -301,8 +301,8 @@ void CheckOurEnvirons (void)
thisMac.numScreens = HowManyUsableScreens(false, true, true);
thisMac.isResolutionDirty = true;
thisMac.isTouchscreen = PortabilityLayer::HostSystemServices::GetInstance()->IsTouchscreen();
thisMac.isMouseTouchscreen = PortabilityLayer::HostSystemServices::GetInstance()->IsUsingMouseAsTouch();
thisMac.isTouchscreen = PLDrivers::GetSystemServices()->IsTouchscreen();
thisMac.isMouseTouchscreen = PLDrivers::GetSystemServices()->IsUsingMouseAsTouch();
FlushResolutionChange();
}
@@ -415,14 +415,14 @@ void HandleDepthSwitching (void)
thisMac.isDepth = isDepthPref;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetUseICCProfile(isUseICCProfile != 0);
PLDrivers::GetDisplayDriver()->SetUseICCProfile(isUseICCProfile != 0);
}
void GetDeviceRect(Rect *rect)
{
unsigned int width;
unsigned int height;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&width, &height);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(&width, &height);
SetRect(rect, 0, 0, static_cast<short>(width), static_cast<short>(height));
}

View File

@@ -1,20 +1,15 @@
#include "GpAppInterface.h"
#include "DisplayDeviceManager.h"
#include "HostAudioDriver.h"
#include "HostFileSystem.h"
#include "HostFontHandler.h"
#include "HostDisplayDriver.h"
#include "HostLogDriver.h"
#include "HostSystemServices.h"
#include "HostInputDriver.h"
#include "HostVOSEventQueue.h"
#include "MenuManager.h"
#include "WindowManager.h"
#include "PLDrivers.h"
int gpAppMain();
void gpAppInit();
class GpAppInterfaceImpl final : public GpAppInterface
{
public:
@@ -23,14 +18,7 @@ public:
void PL_IncrementTickCounter(uint32_t count) override;
void PL_Render(IGpDisplayDriver *displayDriver) override;
void PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance) override;
void PL_HostDisplayDriver_SetInstance(IGpDisplayDriver *instance) override;
void PL_HostInputDriver_SetInstances(IGpInputDriver *const* instances, size_t numInstances) override;
void PL_HostSystemServices_SetInstance(PortabilityLayer::HostSystemServices *instance) override;
void PL_HostAudioDriver_SetInstance(IGpAudioDriver *instance) override;
void PL_HostLogDriver_SetInstance(IGpLogDriver *instance) override;
void PL_HostFontHandler_SetInstance(IGpFontHandler *instance) override;
void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) override;
GpDriverCollection *PL_GetDriverCollection() override;
void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) override;
bool PL_AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY) override;
};
@@ -56,44 +44,9 @@ void GpAppInterfaceImpl::PL_Render(IGpDisplayDriver *displayDriver)
PortabilityLayer::MenuManager::GetInstance()->RenderFrame(displayDriver);
}
void GpAppInterfaceImpl::PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance)
GpDriverCollection *GpAppInterfaceImpl::PL_GetDriverCollection()
{
PortabilityLayer::HostFileSystem::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_HostDisplayDriver_SetInstance(IGpDisplayDriver *instance)
{
PortabilityLayer::HostDisplayDriver::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_HostLogDriver_SetInstance(IGpLogDriver *instance)
{
PortabilityLayer::HostLogDriver::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_HostSystemServices_SetInstance(PortabilityLayer::HostSystemServices *instance)
{
PortabilityLayer::HostSystemServices::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_HostAudioDriver_SetInstance(IGpAudioDriver *instance)
{
PortabilityLayer::HostAudioDriver::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_HostInputDriver_SetInstances(IGpInputDriver *const* instances, size_t numInstances)
{
PortabilityLayer::HostInputDriver::SetInstances(instances, numInstances);
}
void GpAppInterfaceImpl::PL_HostFontHandler_SetInstance(IGpFontHandler *instance)
{
PortabilityLayer::HostFontHandler::SetInstance(instance);
}
void GpAppInterfaceImpl::PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance)
{
PortabilityLayer::HostVOSEventQueue::SetInstance(instance);
return PLDrivers::GetDriverCollection();
}
void GpAppInterfaceImpl::PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context)

View File

@@ -17,14 +17,11 @@
#include "FileManager.h"
#include "FontFamily.h"
#include "FontManager.h"
#include "HostDisplayDriver.h"
#include "HostSystemServices.h"
#include "House.h"
#include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "GpIOStream.h"
#include "MainWindow.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
@@ -32,6 +29,10 @@
#include "Vec2i.h"
#include "WindowManager.h"
#include "PLDrivers.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#define kHighScoresPictID 1994
#define kHighScoresMaskID 1998
#define kHighNameDialogID 1020
@@ -383,7 +384,7 @@ Boolean TestHighScore (void)
if (placing != -1)
{
int64_t scoreTimestamp = PortabilityLayer::HostSystemServices::GetInstance()->GetTime();
int64_t scoreTimestamp = PLDrivers::GetSystemServices()->GetTime();
if (scoreTimestamp < 0)
scoreTimestamp = 0;
else if (scoreTimestamp > 0xffffffff)
@@ -508,7 +509,7 @@ void MoveDialogToTopOfScreen(Dialog *dial)
PortabilityLayer::Vec2i pos = window->GetPosition();
unsigned int height = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &height);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(nullptr, &height);
pos.m_y = (height - window->GetDrawSurface()->m_port.GetRect().Height()) / 8;
@@ -542,7 +543,7 @@ void GetHighScoreName (short place)
UpdateNameDialog(theDial);
if (PortabilityLayer::HostSystemServices::GetInstance()->IsTextInputObstructive())
if (PLDrivers::GetSystemServices()->IsTextInputObstructive())
MoveDialogToTopOfScreen(theDial);
Window *exclStack = theDial->GetWindow();
@@ -655,7 +656,7 @@ void GetHighScoreBanner (void)
UpdateBannerDialog(theDial);
if (PortabilityLayer::HostSystemServices::GetInstance()->IsTextInputObstructive())
if (PLDrivers::GetSystemServices()->IsTextInputObstructive())
MoveDialogToTopOfScreen(theDial);
Window *exclStack = theDial->GetWindow();

View File

@@ -15,7 +15,6 @@
#include "FileBrowserUI.h"
#include "FileManager.h"
#include "FontFamily.h"
#include "HostFileSystem.h"
#include "House.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"

View File

@@ -5,23 +5,23 @@
//----------------------------------------------------------------------------
//============================================================================
#include "PLDialogs.h"
#include "PLMovies.h"
#include "PLResources.h"
#include "PLStringCompare.h"
#include "PLPasStr.h"
#include "BitmapImage.h"
#include "DialogManager.h"
#include "Externs.h"
#include "Environ.h"
#include "FileManager.h"
#include "HostFileSystem.h"
#include "HostSystemServices.h"
#include "House.h"
#include "GpIOStream.h"
#include "House.h"
#include "IGpSystemServices.h"
#include "ObjectEdit.h"
#include "ResourceManager.h"
#include "PLDialogs.h"
#include "PLDrivers.h"
#include "PLMovies.h"
#include "PLResources.h"
#include "PLStringCompare.h"
#include "PLPasStr.h"
#define kSaveChangesAlert 1002
#define kSaveChanges 1
@@ -675,7 +675,7 @@ Boolean WriteHouse (Boolean checkIt)
if (fileDirty)
{
int64_t currentTime = PortabilityLayer::HostSystemServices::GetInstance()->GetTime();
int64_t currentTime = PLDrivers::GetSystemServices()->GetTime();
if (currentTime > 0x7fffffff)
currentTime = 0x7fffffff;

View File

@@ -6,16 +6,17 @@
//============================================================================
#include "PLNumberFormatting.h"
#include "PLKeyEncoding.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "DialogManager.h"
#include "DialogUtils.h"
#include "HostDisplayDriver.h"
#include "IGpDisplayDriver.h"
#include "PLArrayView.h"
#include "PLDrivers.h"
#include "PLEditboxWidget.h"
#include "PLNumberFormatting.h"
#include "PLKeyEncoding.h"
#include "PLPasStr.h"
#include "PLTimeTaggedVOSEvent.h"
@@ -179,7 +180,7 @@ int16_t HouseFilter(void *context, Dialog *dial, const TimeTaggedVOSEvent *evt)
{
if (houseCursorIs != kBeamCursor)
{
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kIBeam);
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kIBeam);
houseCursorIs = kBeamCursor;
}
}

View File

@@ -8,17 +8,17 @@
#include "Externs.h"
#include "Environ.h"
#include "HostDisplayDriver.h"
#include "IGpDisplayDriver.h"
#include "GpApplicationName.h"
#include "Map.h"
#include "MenuManager.h"
#include "PLKeyEncoding.h"
#include "PLPasStr.h"
#include "RectUtils.h"
#include "ResourceManager.h"
#include "Tools.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h"
#include "PLPasStr.h"
#define kHandCursorID 128
#define kVertCursorID 129
@@ -101,7 +101,7 @@ IGpCursor *LoadBWCursor(int resID)
const BWCursor *cursorData = static_cast<const BWCursor *>(*resHdl);
IGpCursor *cursor = PortabilityLayer::HostDisplayDriver::GetInstance()->CreateBWCursor(16, 16, cursorData->m_pixels, cursorData->m_mask, cursorData->m_hotSpotX, cursorData->m_hotSpotY);
IGpCursor *cursor = PLDrivers::GetDisplayDriver()->CreateBWCursor(16, 16, cursorData->m_pixels, cursorData->m_mask, cursorData->m_hotSpotX, cursorData->m_hotSpotY);
resHdl.Dispose();
return cursor;

View File

@@ -8,18 +8,13 @@
#include "WindowDef.h"
#include "BitmapImage.h"
#include "PLApplication.h"
#include "PLKeyEncoding.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include "Externs.h"
#include "Environ.h"
#include "FontFamily.h"
#include "GpRenderedFontMetrics.h"
#include "HostDisplayDriver.h"
#include "HostSystemServices.h"
#include "HostThreadEvent.h"
#include "IGpThreadEvent.h"
#include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "GpIOStream.h"
#include "House.h"
#include "MainMenuUI.h"
@@ -34,6 +29,12 @@
#include "WindowManager.h"
#include "WorkerThread.h"
#include "PLApplication.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include <atomic>
@@ -247,7 +248,7 @@ void ReadInPrefs (void)
doPrettyMap = false;
doComplainDialogs = true;
IGpDisplayDriver *displayDriver = PortabilityLayer::HostDisplayDriver::GetInstance();
IGpDisplayDriver *displayDriver = PLDrivers::GetDisplayDriver();
if (!displayDriver->IsFullScreen())
displayDriver->RequestToggleFullScreen(0);
@@ -496,7 +497,7 @@ struct PreloadFontSpec
struct PreloadFontWorkSlot
{
PortabilityLayer::HostThreadEvent *m_completedEvent;
IGpThreadEvent *m_completedEvent;
PortabilityLayer::WorkerThread *m_workerThread;
std::atomic<int> m_singleJobCompleted;
const PreloadFontSpec *m_spec;
@@ -581,7 +582,7 @@ void PreloadFonts()
// but we can do this to unclog the render thread.
PreloadFontWorkSlot slot;
slot.m_workerThread = PortabilityLayer::WorkerThread::Create();
slot.m_completedEvent = PortabilityLayer::HostSystemServices::GetInstance()->CreateThreadEvent(true, false);
slot.m_completedEvent = PLDrivers::GetSystemServices()->CreateThreadEvent(true, false);
while (completedSpecs < numFontSpecs)
{

View File

@@ -2,14 +2,9 @@
#include "FontFamily.h"
#include "GpApplicationName.h"
#include "HostDisplayDriver.h"
#include "GliderProtos.h"
#include "Externs.h"
#include "IGpDisplayDriver.h"
#include "PLCore.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include "RenderedFont.h"
#include "GpRenderedFontMetrics.h"
#include "MainMenuUI.h"
@@ -19,6 +14,12 @@
#include "WindowManager.h"
#include "Vec2i.h"
#include "PLCore.h"
#include "PLDrivers.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
struct MainMenuControlState
{
Window *m_window;
@@ -169,7 +170,7 @@ static void DrawMainMenuControl(DrawSurface *surface, MainMenuUIState::ControlID
void StartScrollForPage()
{
unsigned int displayHeight = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(nullptr, &displayHeight);
DismissMainMenuUI();
@@ -263,7 +264,7 @@ void StartMainMenuUI()
static void DismissMainMenuUIPage()
{
unsigned int displayHeight = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(nullptr, &displayHeight);
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
@@ -293,7 +294,7 @@ void TickMainMenuUI()
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
unsigned int displayHeight = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(nullptr, &displayHeight);
mainMenu.m_scrollInStep -= MainMenuUIState::kControlScrollInDecay;
mainMenu.m_scrollInOffset -= (mainMenu.m_scrollInStep >> MainMenuUIState::kControlScrollInDecayFalloffBits);
@@ -328,7 +329,7 @@ void HandleMainMenuUIResolutionChange()
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
unsigned int displayHeight = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(nullptr, &displayHeight);
for (int i = 0; i < MainMenuUIState::Control_Count; i++)
{

View File

@@ -5,12 +5,9 @@
//============================================================================
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "FontFamily.h"
#include "HostDisplayDriver.h"
#include "House.h"
#include "IGpDisplayDriver.h"
#include "InputManager.h"
@@ -23,6 +20,9 @@
#include "WindowDef.h"
#include "WindowManager.h"
#include "PLDrivers.h"
#include "PLNumberFormatting.h"
#include "PLPasStr.h"
#define kMainWindowID 128
#define kEditWindowID 129

View File

@@ -6,7 +6,6 @@
#include "Externs.h"
#include "HostDisplayDriver.h"
#include "IGpDisplayDriver.h"
#include "InputManager.h"
#include "Marquee.h"
@@ -14,6 +13,8 @@
#include "ObjectEdit.h"
#include "RectUtils.h"
#include "PLDrivers.h"
#include <assert.h>
#include <algorithm>
@@ -222,7 +223,7 @@ void DragMarqueeRect (Window *window, DrawSurface *surface, Point start, Rect *t
Point wasPt, newPt;
short deltaH, deltaV;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(handCursor);
PLDrivers::GetDisplayDriver()->SetCursor(handCursor);
StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
@@ -265,9 +266,9 @@ void DragMarqueeHandle (Window *window, DrawSurface *surface, Point start, short
short deltaH, deltaV;
if ((theMarquee.direction == kAbove) || (theMarquee.direction == kBelow))
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(vertCursor);
PLDrivers::GetDisplayDriver()->SetCursor(vertCursor);
else
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(horiCursor);
PLDrivers::GetDisplayDriver()->SetCursor(horiCursor);
StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index];
@@ -349,7 +350,7 @@ void DragMarqueeCorner (Window *window, DrawSurface *surface, Point start, short
Point wasPt, newPt;
short deltaH, deltaV;
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(diagCursor);
PLDrivers::GetDisplayDriver()->SetCursor(diagCursor);
StopMarquee();
const uint8_t *pattern = theMarquee.pats[theMarquee.index];

View File

@@ -4,18 +4,18 @@
//----------------------------------------------------------------------------
//============================================================================
#include "PLResources.h"
#include "PLSound.h"
#include "DialogManager.h"
#include "Environ.h"
#include "Externs.h"
#include "SoundSync.h"
#include "HostMutex.h"
#include "HostSystemServices.h"
#include "IGpMutex.h"
#include "IGpSystemServices.h"
#include "MemoryManager.h"
#include "ResourceManager.h"
#include "PLDrivers.h"
#include "PLResources.h"
#include "PLSound.h"
#define kBaseBufferMusicID 2000
#define kMaxMusic 7
@@ -47,7 +47,7 @@ struct MusicState
};
MusicState musicState;
PortabilityLayer::HostMutex *musicMutex;
IGpMutex *musicMutex;
extern Boolean isSoundOn;
@@ -337,7 +337,7 @@ void InitMusic (void)
musicState.musicSoundID = musicScore[musicState.musicCursor];
musicState.musicMode = kPlayWholeScoreMode;
musicMutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex();
musicMutex = PLDrivers::GetSystemServices()->CreateMutex();
PL_NotYetImplemented_TODO("MusicSync");

View File

@@ -16,9 +16,8 @@
#include "IGpPrefsHandler.h"
#include "GpIOStream.h"
#include "MemoryManager.h"
#include "HostAudioDriver.h"
#include "HostDisplayDriver.h"
#include "HostInputDriver.h"
#include "PLDrivers.h"
#define kPrefCreatorType 'ozm5'
@@ -333,23 +332,23 @@ Boolean DeletePrefs ()
//-------------------------------------------------------------- RunFunctionOnAllPrefsHandlers
bool RunFunctionOnAllPrefsHandlers (void *context, bool (*func) (void *context, IGpPrefsHandler *handler))
{
IGpPrefsHandler *ddHandler = PortabilityLayer::HostDisplayDriver::GetInstance()->GetPrefsHandler();
IGpPrefsHandler *ddHandler = PLDrivers::GetDisplayDriver()->GetPrefsHandler();
if (ddHandler && !func(context, ddHandler))
return false;
if (IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance())
if (IGpAudioDriver *audioDriver = PLDrivers::GetAudioDriver())
{
IGpPrefsHandler *adHandler = audioDriver->GetPrefsHandler();
if (adHandler && !func(context, adHandler))
return false;
}
size_t numInputDrivers = PortabilityLayer::HostInputDriver::NumInstances();
size_t numInputDrivers = PLDrivers::GetNumInputDrivers();
for (size_t i = 0; i < numInputDrivers; i++)
{
IGpPrefsHandler *idHandler = PortabilityLayer::HostInputDriver::GetInstance(i)->GetPrefsHandler();
IGpPrefsHandler *idHandler = PLDrivers::GetInputDriver(i)->GetPrefsHandler();
if (idHandler && !func(context, idHandler))
return false;
}

View File

@@ -5,16 +5,9 @@
//----------------------------------------------------------------------------
//============================================================================
#include "PLKeyEncoding.h"
#include "PLNumberFormatting.h"
#include "PLResources.h"
#include "PLSound.h"
#include "PLPasStr.h"
#include "PLStandardColors.h"
#include "DialogManager.h"
#include "DialogUtils.h"
#include "Externs.h"
#include "HostDisplayDriver.h"
#include "IGpDisplayDriver.h"
#include "RectUtils.h"
#include "PLPopupMenuWidget.h"
@@ -25,6 +18,13 @@
#include "ResourceManager.h"
#include "Utilities.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h"
#include "PLNumberFormatting.h"
#include "PLResources.h"
#include "PLSound.h"
#include "PLPasStr.h"
#include "PLStandardColors.h"
#define kRoomInfoDialogID 1003
#define kOriginalArtDialogID 1016
@@ -271,7 +271,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
{
if (cursorIs != kHandCursor)
{
PortabilityLayer::HostDisplayDriver::GetInstance()->SetCursor(handCursor);
PLDrivers::GetDisplayDriver()->SetCursor(handCursor);
cursorIs = kHandCursor;
}
@@ -325,7 +325,7 @@ void HiliteTileOver (DrawSurface *surface, Point mouseIs)
{
if (cursorIs != kBeamCursor)
{
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kIBeam);
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kIBeam);
cursorIs = kBeamCursor;
}
}

View File

@@ -5,22 +5,22 @@
//----------------------------------------------------------------------------
//============================================================================
#include "PLArrayView.h"
#include "PLKeyEncoding.h"
#include "PLSound.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLWidgets.h"
#include "ResolveCachingColor.h"
#include "DialogManager.h"
#include "DialogUtils.h"
#include "Externs.h"
#include "Environ.h"
#include "HostDisplayDriver.h"
#include "House.h"
#include "IGpDisplayDriver.h"
#include "WindowManager.h"
#include "PLArrayView.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h"
#include "PLSound.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLWidgets.h"
#define kMainPrefsDialID 1012
#define kDisplayPrefsDialID 1017
@@ -1285,7 +1285,7 @@ void DoSettingsMain (void)
leaving = false;
nextRestartChange = false;
wasFullscreenPref = PortabilityLayer::HostDisplayDriver::GetInstance()->IsFullScreen();
wasFullscreenPref = PLDrivers::GetDisplayDriver()->IsFullScreen();
Window* exclWindow = prefDlg->GetWindow();
@@ -1344,7 +1344,7 @@ void DoSettingsMain (void)
nextRestartChange = false;
}
IGpDisplayDriver *displayDriver = PortabilityLayer::HostDisplayDriver::GetInstance();
IGpDisplayDriver *displayDriver = PLDrivers::GetDisplayDriver();
if (displayDriver->IsFullScreen() != (wasFullscreenPref != 0))
{
@@ -1354,11 +1354,11 @@ void DoSettingsMain (void)
if (needResolutionReset)
{
PortabilityLayer::HostDisplayDriver::GetInstance()->RequestResetVirtualResolution();
displayDriver->RequestResetVirtualResolution();
needResolutionReset = false;
}
PortabilityLayer::HostDisplayDriver::GetInstance()->SetUseICCProfile(isUseICCProfile);
displayDriver->SetUseICCProfile(isUseICCProfile);
WriteOutPrefs();
}

View File

@@ -3,14 +3,11 @@
#include "Environ.h"
#include "GpBuildVersion.h"
#include "GpIOStream.h"
#include "HostDirectoryCursor.h"
#include "HostDisplayDriver.h"
#include "HostFileSystem.h"
#include "GpFileCreationDisposition.h"
#include "IGpDirectoryCursor.h"
#include "IGpDisplayDriver.h"
#include "IGpFileSystem.h"
#include "MemoryManager.h"
#include "PLCore.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include "RenderedFont.h"
#include "GpApplicationName.h"
#include "GpRenderedFontMetrics.h"
@@ -20,6 +17,11 @@
#include "WindowManager.h"
#include "FontFamily.h"
#include "PLCore.h"
#include "PLDrivers.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include <vector>
#include <string>
@@ -140,7 +142,7 @@ static void InitSourceExportWindow(SourceExportState *state)
// the status bar dismissal causes a major change in the virtual resolution.
unsigned int displayWidth = 0;
unsigned int displayHeight = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(&displayWidth, &displayHeight);
int32_t lsX = (static_cast<int32_t>(displayWidth) - kLoadScreenWidth) / 2;
int32_t lsY = (static_cast<int32_t>(displayHeight) - kLoadScreenHeight) / 2;
@@ -183,7 +185,7 @@ static void InitSourceExportWindow(SourceExportState *state)
static bool RetrieveSingleFileSize(PortabilityLayer::VirtualDirectory_t virtualDir, char const* const* paths, size_t numPaths, size_t &outSize)
{
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFileNested(virtualDir, paths, numPaths, false, GpFileCreationDispositions::kOpenExisting);
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFileNested(virtualDir, paths, numPaths, false, GpFileCreationDispositions::kOpenExisting);
if (!stream)
return false;
@@ -199,7 +201,7 @@ static bool RetrieveCompositeDirSize(PortabilityLayer::VirtualDirectory_t virtua
size_t totalSize = 0;
totalSizeOut = 0;
PortabilityLayer::HostDirectoryCursor *dirCursor = PortabilityLayer::HostFileSystem::GetInstance()->ScanDirectory(virtualDir);
IGpDirectoryCursor *dirCursor = PLDrivers::GetFileSystem()->ScanDirectory(virtualDir);
if (!dirCursor)
return false;
@@ -402,7 +404,7 @@ static bool RepackDirectory(SourceExportState &state, GpIOStream *outStream, std
uint16_t dosTime = 0;
ConvertToMSDOSTimestamp(state.m_ts, dosDate, dosTime);
PortabilityLayer::HostDirectoryCursor *dirCursor = PortabilityLayer::HostFileSystem::GetInstance()->ScanDirectory(virtualDir);
IGpDirectoryCursor *dirCursor = PLDrivers::GetFileSystem()->ScanDirectory(virtualDir);
if (!dirCursor)
return false;
@@ -425,7 +427,7 @@ static bool RepackDirectory(SourceExportState &state, GpIOStream *outStream, std
const bool shouldStore = (extension[3] == 'a');
state.m_fStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(virtualDir, fpath, false, GpFileCreationDispositions::kOpenExisting);
state.m_fStream = PLDrivers::GetFileSystem()->OpenFile(virtualDir, fpath, false, GpFileCreationDispositions::kOpenExisting);
if (!state.m_fStream)
return false;
@@ -664,7 +666,7 @@ bool ExportSourceToStream (GpIOStream *stream)
SourceExportState state;
InitSourceExportWindow(&state);
state.m_tsStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kApplicationData, "DefaultTimestamp.timestamp", false, GpFileCreationDispositions::kOpenExisting);
state.m_tsStream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kApplicationData, "DefaultTimestamp.timestamp", false, GpFileCreationDispositions::kOpenExisting);
if (!state.m_tsStream)
return false;
@@ -673,7 +675,7 @@ bool ExportSourceToStream (GpIOStream *stream)
state.m_tsStream->Close();
state.m_tsStream = nullptr;
state.m_sourcePkgStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kApplicationData, "SourceCode.pkg", false, GpFileCreationDispositions::kOpenExisting);
state.m_sourcePkgStream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kApplicationData, "SourceCode.pkg", false, GpFileCreationDispositions::kOpenExisting);
if (!state.m_sourcePkgStream)
return false;
@@ -730,7 +732,7 @@ bool ExportSourceToStream (GpIOStream *stream)
void DoExportSourceCode (void)
{
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kSourceExport, GP_APPLICATION_NAME "-" GP_APPLICATION_VERSION_STRING "-SourceCode.zip", true, GpFileCreationDispositions::kCreateOrOverwrite);
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kSourceExport, GP_APPLICATION_NAME "-" GP_APPLICATION_VERSION_STRING "-SourceCode.zip", true, GpFileCreationDispositions::kCreateOrOverwrite);
if (!stream)
return;

View File

@@ -17,7 +17,6 @@
#include "DialogManager.h"
#include "DisplayDeviceManager.h"
#include "Externs.h"
#include "HostSystemServices.h"
#include "IconLoader.h"
#include "InputManager.h"
#include "ResourceManager.h"

View File

@@ -2,11 +2,7 @@
#include "EGpAudioDriverType.h"
namespace PortabilityLayer
{
class HostSystemServices;
}
struct IGpSystemServices;
struct IGpAudioDriver;
struct IGpLogDriver;
@@ -18,5 +14,5 @@ struct GpAudioDriverProperties
bool m_debug;
IGpLogDriver *m_logger;
PortabilityLayer::HostSystemServices *m_systemServices;
IGpSystemServices *m_systemServices;
};

View File

@@ -9,11 +9,7 @@ struct IGpDisplayDriver;
struct IGpFiber;
struct IGpVOSEventQueue;
struct IGpLogDriver;
namespace PortabilityLayer
{
class HostSystemServices;
}
struct IGpSystemServices;
struct GpDisplayDriverProperties
{
@@ -46,5 +42,5 @@ struct GpDisplayDriverProperties
IGpVOSEventQueue *m_eventQueue;
IGpLogDriver *m_logger;
PortabilityLayer::HostSystemServices *m_systemServices;
IGpSystemServices *m_systemServices;
};

132
GpCommon/GpDriverIndex.h Normal file
View File

@@ -0,0 +1,132 @@
#pragma once
#include "CoreDefs.h"
#include <stdint.h>
namespace GpDriverIDs
{
enum GpDriverID
{
kAudio,
kFileSystem,
kDisplay,
kLog,
kInput,
kSystemServices,
kFont,
kEventQueue,
kCount
};
}
typedef GpDriverIDs::GpDriverID GpDriverID_t;
template<int T>
struct GpDriverIndex
{
};
#define GP_DEFINE_DRIVER(driverID, type) \
struct type;\
template<>\
struct GpDriverIndex<GpDriverIDs::driverID>\
{\
typedef type Type_t;\
static const bool kIsMultiDriver = false;\
}
#define GP_DEFINE_MULTI_DRIVER(driverID, type) \
struct type;\
template<>\
struct GpDriverIndex<GpDriverIDs::driverID>\
{\
typedef type Type_t;\
static const bool kIsMultiDriver = true;\
}
GP_DEFINE_DRIVER(kAudio, IGpAudioDriver);
GP_DEFINE_DRIVER(kFileSystem, IGpFileSystem);
GP_DEFINE_DRIVER(kDisplay, IGpDisplayDriver);
GP_DEFINE_DRIVER(kLog, IGpLogDriver);
GP_DEFINE_MULTI_DRIVER(kInput, IGpInputDriver);
GP_DEFINE_DRIVER(kSystemServices, IGpSystemServices);
GP_DEFINE_DRIVER(kFont, IGpFontHandler);
GP_DEFINE_DRIVER(kEventQueue, IGpVOSEventQueue);
struct GpDriverCollection
{
GpDriverCollection();
template<GpDriverID_t T>
void SetDriver(typename GpDriverIndex<T>::Type_t *driver);
template<GpDriverID_t T>
void SetDrivers(typename GpDriverIndex<T>::Type_t *const* drivers, size_t numDrivers);
template<GpDriverID_t T>
typename GpDriverIndex<T>::Type_t *GetDriver() const;
template<GpDriverID_t T>
typename GpDriverIndex<T>::Type_t *GetDriver(size_t index) const;
template<GpDriverID_t T>
size_t GetDriverCount() const;
private:
struct DriverEntry
{
void *m_value;
size_t m_numDrivers;
};
DriverEntry m_drivers[GpDriverIDs::kCount];
};
inline GpDriverCollection::GpDriverCollection()
{
for (int i = 0; i < GpDriverIDs::kCount; i++)
{
this->m_drivers[i].m_value = nullptr;
this->m_drivers[i].m_numDrivers = 0;
}
}
template<GpDriverID_t T>
void GpDriverCollection::SetDriver(typename GpDriverIndex<T>::Type_t *driver)
{
GP_STATIC_ASSERT(!GpDriverIndex<T>::kIsMultiDriver);
m_drivers[T].m_numDrivers = 1;
m_drivers[T].m_value = driver;
}
template<GpDriverID_t T>
void GpDriverCollection::SetDrivers(typename GpDriverIndex<T>::Type_t *const* drivers, size_t numDrivers)
{
GP_STATIC_ASSERT(GpDriverIndex<T>::kIsMultiDriver);
m_drivers[T].m_numDrivers = numDrivers;
m_drivers[T].m_value = const_cast<typename GpDriverIndex<T>::Type_t **>(drivers);
}
template<GpDriverID_t T>
inline typename GpDriverIndex<T>::Type_t *GpDriverCollection::GetDriver() const
{
GP_STATIC_ASSERT(!GpDriverIndex<T>::kIsMultiDriver);
return static_cast<typename GpDriverIndex<T>::Type_t*>(this->m_drivers[T].m_value);
}
template<GpDriverID_t T>
inline typename GpDriverIndex<T>::Type_t *GpDriverCollection::GetDriver(size_t index) const
{
GP_STATIC_ASSERT(GpDriverIndex<T>::kIsMultiDriver);
return static_cast<typename GpDriverIndex<T>::Type_t*const*>(this->m_drivers[T].m_value)[index];
}
template<GpDriverID_t T>
size_t GpDriverCollection::GetDriverCount() const
{
GP_STATIC_ASSERT(GpDriverIndex<T>::kIsMultiDriver);
return this->m_drivers[T].m_numDrivers;
}

View File

@@ -0,0 +1,8 @@
#pragma once
struct IGpDirectoryCursor
{
public:
virtual bool GetNext(const char *&outFileName) = 0;
virtual void Destroy() = 0;
};

43
GpCommon/IGpFileSystem.h Normal file
View File

@@ -0,0 +1,43 @@
#pragma once
#include "GpFileCreationDisposition.h"
#include "VirtualDirectory.h"
#include <stdint.h>
class GpIOStream;
struct IGpThreadRelay;
struct IGpDirectoryCursor;
struct IGpFileSystem
{
public:
typedef void(*DelayCallback_t)(uint32_t ticks);
virtual bool FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) = 0;
virtual bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists) = 0;
virtual GpIOStream *OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* subPaths, size_t numSubPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) = 0;
virtual bool DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) = 0;
virtual IGpDirectoryCursor *ScanDirectoryNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) = 0;
virtual bool ValidateFilePath(const char *path, size_t pathLen) const = 0;
virtual bool ValidateFilePathUnicodeChar(uint32_t ch) const = 0;
virtual bool IsVirtualDirectoryLooseResources(PortabilityLayer::VirtualDirectory_t virtualDir) const = 0;
virtual void SetMainThreadRelay(IGpThreadRelay *relay) = 0;
virtual void SetDelayCallback(DelayCallback_t delayCallback) = 0;
// Helpers
GpIOStream *OpenFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, GpFileCreationDisposition_t createDisposition);
IGpDirectoryCursor *ScanDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory);
};
inline GpIOStream *IGpFileSystem::OpenFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, GpFileCreationDisposition_t createDisposition)
{
return this->OpenFileNested(virtualDirectory, &path, 1, writeAccess, createDisposition);
}
inline IGpDirectoryCursor *IGpFileSystem::ScanDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory)
{
return this->ScanDirectoryNested(virtualDirectory, nullptr, 0);
}

10
GpCommon/IGpMutex.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
struct IGpMutex
{
public:
virtual void Destroy() = 0;
virtual void Lock() = 0;
virtual void Unlock() = 0;
};

View File

@@ -0,0 +1,35 @@
#pragma once
#include <stdint.h>
#ifdef CreateMutex
#error "CreateMutex was macrod"
#endif
#ifdef CreateThread
#error "CreateThread was macrod"
#endif
struct IGpMutex;
struct IGpThreadEvent;
struct IGpSystemServices
{
public:
typedef int(*ThreadFunc_t)(void *context);
virtual int64_t GetTime() const = 0;
virtual void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const = 0;
virtual IGpMutex *CreateMutex() = 0;
virtual IGpMutex *CreateRecursiveMutex() = 0;
virtual void *CreateThread(ThreadFunc_t threadFunc, void *context) = 0;
virtual IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 0;
virtual uint64_t GetFreeMemoryCosmetic() const = 0; // Returns free memory in bytes, does not have to be accurate
virtual void Beep() const = 0;
virtual bool IsTouchscreen() const = 0;
virtual bool IsUsingMouseAsTouch() const = 0;
virtual bool IsTextInputObstructive() const = 0;
virtual unsigned int GetCPUCount() const = 0;
virtual void SetTextInputEnabled(bool isEnabled) = 0;
virtual bool IsTextInputEnabled() const = 0;
};

12
GpCommon/IGpThreadEvent.h Normal file
View File

@@ -0,0 +1,12 @@
#pragma once
#include <stdint.h>
struct IGpThreadEvent
{
public:
virtual void Wait() = 0;
virtual bool WaitTimed(uint32_t msec) = 0;
virtual void Signal() = 0;
virtual void Destroy() = 0;
};

View File

@@ -20,7 +20,6 @@ LOCAL_SRC_FILES := \
GpGlobalConfig.cpp \
GpInputDriverFactory.cpp \
GpMain.cpp \
GpMemoryBuffer.cpp \
GpVOSEventQueue.cpp
include $(BUILD_STATIC_LIBRARY)

View File

@@ -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()

View File

@@ -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;

View File

@@ -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);
};

View File

@@ -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;
};

View File

@@ -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;
}

View File

@@ -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;
};

View File

@@ -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>

View File

@@ -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>

View File

@@ -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();

View File

@@ -33,15 +33,7 @@ LOCAL_SRC_FILES := \
FontManager.cpp \
FontRenderer.cpp \
GPArchive.cpp \
HostAudioDriver.cpp \
HostDisplayDriver.cpp \
HostFileSystem.cpp \
HostFontHandler.cpp \
HostInputDriver.cpp \
HostLogDriver.cpp \
HostSuspendHook.cpp \
HostSystemServices.cpp \
HostVOSEventQueue.cpp \
IconLoader.cpp \
InputManager.cpp \
LinePlotter.cpp \
@@ -59,6 +51,7 @@ LOCAL_SRC_FILES := \
PLCore.cpp \
PLCTabReducer.cpp \
PLDialogs.cpp \
PLDrivers.cpp \
PLEditboxWidget.cpp \
PLEventQueue.cpp \
PLHacks.cpp \

View File

@@ -1,8 +1,10 @@
#include "AntiAliasTable.h"
#include "RGBAColor.h"
#include "HostFileSystem.h"
#include "GpIOStream.h"
#include "IGpFileSystem.h"
#include "PLBigEndian.h"
#include "PLDrivers.h"
#include <algorithm>
#include <math.h>
@@ -63,7 +65,7 @@ namespace PortabilityLayer
#else
bool AntiAliasTable::LoadFromCache(const char *cacheFileName)
{
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, cacheFileName, false, GpFileCreationDispositions::kOpenExisting);
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, cacheFileName, false, GpFileCreationDispositions::kOpenExisting);
if (!stream)
return false;
@@ -83,7 +85,7 @@ namespace PortabilityLayer
void AntiAliasTable::SaveToCache(const char *cacheFileName)
{
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, cacheFileName, true, GpFileCreationDispositions::kCreateOrOverwrite);
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, cacheFileName, true, GpFileCreationDispositions::kCreateOrOverwrite);
if (!stream)
return;

View File

@@ -1,13 +1,21 @@
#include "DialogManager.h"
#include "HostDisplayDriver.h"
#include "HostSystemServices.h"
#include "IconLoader.h"
#include "IGpDisplayDriver.h"
#include "IGpSystemServices.h"
#include "ResourceManager.h"
#include "QDPixMap.h"
#include "Rect2i.h"
#include "ResTypeID.h"
#include "SharedTypes.h"
#include "UTF8.h"
#include "WindowDef.h"
#include "WindowManager.h"
#include "PLArrayView.h"
#include "PLBigEndian.h"
#include "PLButtonWidget.h"
#include "PLDialogs.h"
#include "PLDrivers.h"
#include "PLEditboxWidget.h"
#include "PLIconWidget.h"
#include "PLImageWidget.h"
@@ -18,13 +26,6 @@
#include "PLSysCalls.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLWidgets.h"
#include "QDPixMap.h"
#include "Rect2i.h"
#include "ResTypeID.h"
#include "SharedTypes.h"
#include "UTF8.h"
#include "WindowDef.h"
#include "WindowManager.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
@@ -388,7 +389,7 @@ namespace PortabilityLayer
Rect2i windowFullRect = WindowManager::GetInstance()->GetWindowFullRect(window);
if (!windowFullRect.Contains(Vec2i(mouseEvent.m_x, mouseEvent.m_y)))
{
PortabilityLayer::HostSystemServices::GetInstance()->Beep();
PLDrivers::GetSystemServices()->Beep();
continue;
}
}
@@ -759,7 +760,7 @@ namespace PortabilityLayer
// If sound index is 0, play no sound
if (soundIndexes[0] != 0)
PortabilityLayer::HostSystemServices::GetInstance()->Beep();
PLDrivers::GetSystemServices()->Beep();
const Rect dialogRect = alertResData.m_rect.ToRect();
@@ -830,7 +831,7 @@ namespace PortabilityLayer
void DialogManagerImpl::PositionWindow(Window *window, const Rect &rect) const
{
unsigned int displayWidth, displayHeight;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(&displayWidth, &displayHeight);
const unsigned int halfDisplayHeight = displayHeight / 2;
const unsigned int quarterDisplayWidth = displayHeight / 4;

View File

@@ -1,6 +1,6 @@
#include "DisplayDeviceManager.h"
#include "HostDisplayDriver.h"
#include "PLDrivers.h"
#include "IGpDisplayDriver.h"
#include "PLQDraw.h"
#include "MemoryManager.h"

View File

@@ -8,10 +8,10 @@
#include "GpBuildVersion.h"
#include "GpIOStream.h"
#include "GpRenderedFontMetrics.h"
#include "HostFileSystem.h"
#include "HostDirectoryCursor.h"
#include "HostSystemServices.h"
#include "IGpDirectoryCursor.h"
#include "IGpFileSystem.h"
#include "IGpFont.h"
#include "IGpSystemServices.h"
#include "WindowManager.h"
#include "MacFileInfo.h"
#include "MemoryManager.h"
@@ -25,6 +25,7 @@
#include "PLControlDefinitions.h"
#include "PLCore.h"
#include "PLDialogs.h"
#include "PLDrivers.h"
#include "PLEditboxWidget.h"
#include "PLKeyEncoding.h"
#include "PLQDraw.h"
@@ -161,7 +162,7 @@ namespace PortabilityLayer
{
uint16_t unicodeChar = MacRoman::ToUnicode(ch);
return HostFileSystem::GetInstance()->ValidateFilePathUnicodeChar(unicodeChar);
return PLDrivers::GetFileSystem()->ValidateFilePathUnicodeChar(unicodeChar);
}
bool FileBrowserUIImpl::AppendName(const char *name, size_t nameLen, void *details)
@@ -537,7 +538,7 @@ namespace PortabilityLayer
int16_t FileBrowserUIImpl::PopUpAlert(const Rect &rect, int dialogResID, const DialogTextSubstitutions *substitutions)
{
PortabilityLayer::HostSystemServices *sysServices = PortabilityLayer::HostSystemServices::GetInstance();
IGpSystemServices *sysServices = PLDrivers::GetSystemServices();
// Disable text input temporarily and restore it after
const bool wasTextInput = sysServices->IsTextInputEnabled();
@@ -573,7 +574,7 @@ namespace PortabilityLayer
dialogID = kFileBrowserUIOpenDialogTemplateID;
else if (mode == Mode_Save)
{
if (PortabilityLayer::HostSystemServices::GetInstance()->IsTextInputObstructive())
if (PLDrivers::GetSystemServices()->IsTextInputObstructive())
{
dialogID = kFileBrowserUISaveDialogUnobstructiveTemplateID;
windowHeight = 208;
@@ -591,8 +592,8 @@ namespace PortabilityLayer
FileBrowserUIImpl uiImpl(callbackAPI);
// Enumerate files
PortabilityLayer::HostFileSystem *fs = PortabilityLayer::HostFileSystem::GetInstance();
PortabilityLayer::HostDirectoryCursor *dirCursor = fs->ScanDirectory(dirID);
IGpFileSystem *fs = PLDrivers::GetFileSystem();
IGpDirectoryCursor *dirCursor = fs->ScanDirectory(dirID);
if (!dirCursor)
return false;
@@ -730,14 +731,14 @@ namespace PortabilityLayer
if (hit == kOkayButton && mode == Mode_Save)
{
HostFileSystem *fs = HostFileSystem::GetInstance();
IGpFileSystem *fs = PLDrivers::GetFileSystem();
EditboxWidget *editBox = static_cast<EditboxWidget*>(dialog->GetItems()[kFileNameEditBox - 1].GetWidget());
PLPasStr nameStr = editBox->GetString();
if (nameStr.Length() == 0 || !fs->ValidateFilePath(nameStr.Chars(), nameStr.Length()))
{
PortabilityLayer::HostSystemServices::GetInstance()->Beep();
PLDrivers::GetSystemServices()->Beep();
FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIBadNameDialogTemplateID, nullptr);
hit = -1;
}
@@ -745,7 +746,7 @@ namespace PortabilityLayer
{
DialogTextSubstitutions substitutions(nameStr);
PortabilityLayer::HostSystemServices::GetInstance()->Beep();
PLDrivers::GetSystemServices()->Beep();
int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIOverwriteDialogTemplateID, &substitutions);
if (subHit == kOverwriteNoButton)
@@ -755,7 +756,7 @@ namespace PortabilityLayer
if (mode == Mode_Open && hit == kDeleteButton)
{
PortabilityLayer::HostSystemServices::GetInstance()->Beep();
PLDrivers::GetSystemServices()->Beep();
int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIDeleteDialogTemplateID, &substitutions);
if (subHit == kOverwriteYesButton)

View File

@@ -1,16 +1,17 @@
#include "FileManager.h"
#include "FileBrowserUI.h"
#include "HostFileSystem.h"
#include "HostMemoryBuffer.h"
#include "IGpFileSystem.h"
#include "IGpSystemServices.h"
#include "MemReaderStream.h"
#include "MacBinary2.h"
#include "MacFileMem.h"
#include "ResTypeID.h"
#include "PLDrivers.h"
#include "PLPasStr.h"
#include "PLErrorCodes.h"
#include "PLSysCalls.h"
#include "ResTypeID.h"
#include "HostSystemServices.h"
#include <vector>
@@ -57,7 +58,7 @@ namespace PortabilityLayer
if (!ConstructFilename(extFN, filename, ".gpf"))
return false;
return HostFileSystem::GetInstance()->FileExists(dirID, extFN);
return PLDrivers::GetFileSystem()->FileExists(dirID, extFN);
}
bool FileManagerImpl::FileLocked(VirtualDirectory_t dirID, const PLPasStr &filename)
@@ -71,7 +72,7 @@ namespace PortabilityLayer
return true;
bool exists = false;
if (HostFileSystem::GetInstance()->FileLocked(dirID, extFN, &exists) && exists)
if (PLDrivers::GetFileSystem()->FileLocked(dirID, extFN, &exists) && exists)
return true;
}
@@ -92,7 +93,7 @@ namespace PortabilityLayer
return true;
bool existed = false;
if (!PortabilityLayer::HostFileSystem::GetInstance()->DeleteFile(dirID, extFN, existed))
if (!PLDrivers::GetFileSystem()->DeleteFile(dirID, extFN, existed))
{
if (extMayNotExist[extIndex] && !existed)
continue;
@@ -134,7 +135,7 @@ namespace PortabilityLayer
MacFileProperties mfp;
fileCreator.ExportAsChars(mfp.m_fileCreator);
fileType.ExportAsChars(mfp.m_fileType);
mfp.m_creationDate = mfp.m_modifiedDate = PortabilityLayer::HostSystemServices::GetInstance()->GetTime();
mfp.m_creationDate = mfp.m_modifiedDate = PLDrivers::GetSystemServices()->GetTime();
return CreateFile(dirID, filename, mfp);
}
@@ -222,7 +223,7 @@ namespace PortabilityLayer
if (!ConstructFilename(gpfExtFN, filename, ".gpf"))
return PLErrors::kBadFileName;
if (!HostFileSystem::GetInstance()->FileExists(dirID, gpfExtFN))
if (!PLDrivers::GetFileSystem()->FileExists(dirID, gpfExtFN))
return PLErrors::kFileNotFound;
}
@@ -233,21 +234,21 @@ namespace PortabilityLayer
switch (permission)
{
case EFilePermission_Any:
fstream = HostFileSystem::GetInstance()->OpenFile(dirID, extFN, true, createDisposition);
fstream = PLDrivers::GetFileSystem()->OpenFile(dirID, extFN, true, createDisposition);
if (fstream)
permission = EFilePermission_ReadWrite;
else
{
permission = EFilePermission_Read;
fstream = HostFileSystem::GetInstance()->OpenFile(dirID, extFN, false, createDisposition);
fstream = PLDrivers::GetFileSystem()->OpenFile(dirID, extFN, false, createDisposition);
}
break;
case EFilePermission_Read:
fstream = HostFileSystem::GetInstance()->OpenFile(dirID, extFN, false, createDisposition);
fstream = PLDrivers::GetFileSystem()->OpenFile(dirID, extFN, false, createDisposition);
break;
case EFilePermission_ReadWrite:
case EFilePermission_Write:
fstream = HostFileSystem::GetInstance()->OpenFile(dirID, extFN, true, createDisposition);
fstream = PLDrivers::GetFileSystem()->OpenFile(dirID, extFN, true, createDisposition);
break;
}
@@ -268,7 +269,7 @@ namespace PortabilityLayer
memcpy(extFN, fn.Chars(), fnameSize);
memcpy(extFN + fnameSize, extension, strlen(extension) + 1);
if (!PortabilityLayer::HostFileSystem::GetInstance()->ValidateFilePath(extFN, fnameSize))
if (!PLDrivers::GetFileSystem()->ValidateFilePath(extFN, fnameSize))
return false;
return true;

View File

@@ -1,10 +1,11 @@
#include "FontFamily.h"
#include "GpIOStream.h"
#include "HostFileSystem.h"
#include "IGpFileSystem.h"
#include "IGpFontHandler.h"
#include "HostFontHandler.h"
#include "IGpFont.h"
#include "PLDrivers.h"
#include <stdlib.h>
#include <new>
@@ -12,11 +13,11 @@ namespace PortabilityLayer
{
void FontFamily::AddFont(int flags, const char *path, FontHacks fontHacks)
{
GpIOStream *sysFontStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kFonts, path, false, GpFileCreationDispositions::kOpenExisting);
GpIOStream *sysFontStream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kFonts, path, false, GpFileCreationDispositions::kOpenExisting);
if (!sysFontStream)
return;
IGpFontHandler *fontHandler = PortabilityLayer::HostFontHandler::GetInstance();
IGpFontHandler *fontHandler = PLDrivers::GetFontHandler();
IGpFont *font = fontHandler->LoadFont(sysFontStream);

View File

@@ -2,12 +2,13 @@
#include "FontFamily.h"
#include "FontRenderer.h"
#include "HostFileSystem.h"
#include "IGpFont.h"
#include "HostFontHandler.h"
#include "GpIOStream.h"
#include "IGpFileSystem.h"
#include "IGpFont.h"
#include "RenderedFont.h"
#include "PLBigEndian.h"
#include "PLDrivers.h"
#include <stdio.h>
#include <string.h>
@@ -111,7 +112,7 @@ namespace PortabilityLayer
if (m_monospaceFont)
m_monospaceFont->Destroy();
IGpFontHandler *hfh = HostFontHandler::GetInstance();
IGpFontHandler *hfh = PLDrivers::GetFontHandler();
for (int i = 0; i < sizeof(m_cachedRenderedFonts) / sizeof(m_cachedRenderedFonts[0]); i++)
{
@@ -220,7 +221,7 @@ namespace PortabilityLayer
char filename[kFontCacheNameSize];
GenerateCacheFileName(filename, cacheID, size, aa, flags);
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, filename, false, GpFileCreationDispositions::kOpenExisting);
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, filename, false, GpFileCreationDispositions::kOpenExisting);
if (!stream)
return nullptr;
@@ -242,7 +243,7 @@ namespace PortabilityLayer
char filename[kFontCacheNameSize];
GenerateCacheFileName(filename, cacheID, size, aa, flags);
GpIOStream *stream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, filename, true, GpFileCreationDispositions::kCreateOrOverwrite);
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, filename, true, GpFileCreationDispositions::kCreateOrOverwrite);
if (!stream)
return;

View File

@@ -3,15 +3,16 @@
#include "CoreDefs.h"
#include "IGpFont.h"
#include "GpIOStream.h"
#include "HostFontHandler.h"
#include "IGpFontRenderedGlyph.h"
#include "MacRomanConversion.h"
#include "PLBigEndian.h"
#include "PLPasStr.h"
#include "RenderedFont.h"
#include "GpRenderedFontMetrics.h"
#include "GpRenderedGlyphMetrics.h"
#include "PLBigEndian.h"
#include "PLDrivers.h"
#include "PLPasStr.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>

View File

@@ -5,6 +5,8 @@
#include "HostSuspendHook.h"
#include <stdint.h>
#include "GpDriverIndex.h"
#ifdef GP_APP_DLL
#ifdef GP_APP_DLL_EXPORT
@@ -23,14 +25,7 @@ struct IGpAudioDriver;
struct IGpLogDriver;
struct IGpInputDriver;
struct IGpFontHandler;
namespace PortabilityLayer
{
class HostFileSystem;
class HostDisplayDriver;
class HostSystemServices;
class HostVOSEventQueue;
}
struct GpDriverCollection;
struct IGpDisplayDriver;
@@ -41,14 +36,7 @@ public:
virtual int ApplicationMain() = 0;
virtual void PL_IncrementTickCounter(uint32_t count) = 0;
virtual void PL_Render(IGpDisplayDriver *displayDriver) = 0;
virtual void PL_HostAudioDriver_SetInstance(IGpAudioDriver *instance) = 0;
virtual void PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance) = 0;
virtual void PL_HostDisplayDriver_SetInstance(IGpDisplayDriver *instance) = 0;
virtual void PL_HostLogDriver_SetInstance(IGpLogDriver *instance) = 0;
virtual void PL_HostInputDriver_SetInstances(IGpInputDriver *const* instances, size_t numInstances) = 0;
virtual void PL_HostSystemServices_SetInstance(PortabilityLayer::HostSystemServices *instance) = 0;
virtual void PL_HostFontHandler_SetInstance(IGpFontHandler *instance) = 0;
virtual void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) = 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;

View File

@@ -1,16 +0,0 @@
#include "HostAudioDriver.h"
namespace PortabilityLayer
{
IGpAudioDriver *HostAudioDriver::GetInstance()
{
return ms_instance;
}
void HostAudioDriver::SetInstance(IGpAudioDriver *instance)
{
ms_instance = instance;
}
IGpAudioDriver *HostAudioDriver::ms_instance;
}

View File

@@ -1,16 +0,0 @@
#pragma once
struct IGpAudioDriver;
namespace PortabilityLayer
{
class HostAudioDriver
{
public:
static IGpAudioDriver *GetInstance();
static void SetInstance(IGpAudioDriver *instance);
private:
static IGpAudioDriver *ms_instance;
};
}

View File

@@ -1,11 +0,0 @@
#pragma once
namespace PortabilityLayer
{
class HostDirectoryCursor
{
public:
virtual bool GetNext(const char *&outFileName) = 0;
virtual void Destroy() = 0;
};
}

View File

@@ -1,16 +0,0 @@
#include "HostDisplayDriver.h"
namespace PortabilityLayer
{
IGpDisplayDriver *HostDisplayDriver::GetInstance()
{
return ms_instance;
}
void HostDisplayDriver::SetInstance(IGpDisplayDriver *instance)
{
ms_instance = instance;
}
IGpDisplayDriver *HostDisplayDriver::ms_instance;
}

View File

@@ -1,24 +0,0 @@
#pragma once
#ifndef __PL_HOST_DISPLAY_DRIVER_H__
#define __PL_HOST_DISPLAY_DRIVER_H__
#include "GpPixelFormat.h"
#include "EGpStandardCursor.h"
struct IGpCursor;
struct IGpDisplayDriver;
namespace PortabilityLayer
{
class HostDisplayDriver
{
public:
static void SetInstance(IGpDisplayDriver *instance);
static IGpDisplayDriver *GetInstance();
private:
static IGpDisplayDriver *ms_instance;
};
}
#endif

View File

@@ -1,16 +0,0 @@
#include "HostFileSystem.h"
namespace PortabilityLayer
{
HostFileSystem *HostFileSystem::GetInstance()
{
return ms_instance;
}
void HostFileSystem::SetInstance(HostFileSystem *instance)
{
ms_instance = instance;
}
HostFileSystem *HostFileSystem::ms_instance;
}

View File

@@ -1,53 +0,0 @@
#pragma once
#include "GpFileCreationDisposition.h"
#include "VirtualDirectory.h"
#include <stdint.h>
class GpIOStream;
struct IGpThreadRelay;
namespace PortabilityLayer
{
class HostDirectoryCursor;
class HostFileSystem
{
public:
typedef void (*DelayCallback_t)(uint32_t ticks);
virtual bool FileExists(VirtualDirectory_t virtualDirectory, const char *path) = 0;
virtual bool FileLocked(VirtualDirectory_t virtualDirectory, const char *path, bool *exists) = 0;
virtual GpIOStream *OpenFileNested(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* subPaths, size_t numSubPaths, bool writeAccess, GpFileCreationDisposition_t createDisposition) = 0;
virtual bool DeleteFile(VirtualDirectory_t virtualDirectory, const char *path, bool &existed) = 0;
virtual HostDirectoryCursor *ScanDirectoryNested(VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths) = 0;
HostDirectoryCursor *ScanDirectory(VirtualDirectory_t virtualDirectory);
virtual bool ValidateFilePath(const char *path, size_t pathLen) const = 0;
virtual bool ValidateFilePathUnicodeChar(uint32_t ch) const = 0;
virtual bool IsVirtualDirectoryLooseResources(VirtualDirectory_t virtualDir) const = 0;
static HostFileSystem *GetInstance();
static void SetInstance(HostFileSystem *instance);
GpIOStream *OpenFile(VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, GpFileCreationDisposition_t createDisposition);
virtual void SetMainThreadRelay(IGpThreadRelay *relay) = 0;
virtual void SetDelayCallback(DelayCallback_t delayCallback) = 0;
private:
static HostFileSystem *ms_instance;
};
}
inline GpIOStream *PortabilityLayer::HostFileSystem::OpenFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, GpFileCreationDisposition_t createDisposition)
{
return this->OpenFileNested(virtualDirectory, &path, 1, writeAccess, createDisposition);
}
inline PortabilityLayer::HostDirectoryCursor *PortabilityLayer::HostFileSystem::ScanDirectory(VirtualDirectory_t virtualDirectory)
{
return this->ScanDirectoryNested(virtualDirectory, nullptr, 0);
}

View File

@@ -1,16 +0,0 @@
#include "HostFontHandler.h"
namespace PortabilityLayer
{
void HostFontHandler::SetInstance(IGpFontHandler *instance)
{
ms_instance = instance;
}
IGpFontHandler *HostFontHandler::GetInstance()
{
return ms_instance;
}
IGpFontHandler *HostFontHandler::ms_instance = nullptr;
}

View File

@@ -1,17 +0,0 @@
#pragma once
class GpIOStream;
struct IGpFontHandler;
namespace PortabilityLayer
{
class HostFontHandler
{
public:
static void SetInstance(IGpFontHandler *instance);
static IGpFontHandler *GetInstance();
private:
static IGpFontHandler *ms_instance;
};
}

View File

@@ -1,23 +0,0 @@
#include "HostInputDriver.h"
namespace PortabilityLayer
{
size_t HostInputDriver::NumInstances()
{
return ms_numInstances;
}
IGpInputDriver *HostInputDriver::GetInstance(size_t index)
{
return ms_instances[index];
}
void HostInputDriver::SetInstances(IGpInputDriver *const* instances, size_t numInstances)
{
ms_instances = instances;
ms_numInstances = numInstances;
}
IGpInputDriver *const* HostInputDriver::ms_instances;
size_t HostInputDriver::ms_numInstances;
}

View File

@@ -1,20 +0,0 @@
#pragma once
#include <stdint.h>
struct IGpInputDriver;
namespace PortabilityLayer
{
class HostInputDriver
{
public:
static size_t NumInstances();
static IGpInputDriver *GetInstance(size_t index);
static void SetInstances(IGpInputDriver *const* instances, size_t numInstances);
private:
static IGpInputDriver *const* ms_instances;
static size_t ms_numInstances;
};
}

View File

@@ -1,16 +0,0 @@
#include "HostLogDriver.h"
namespace PortabilityLayer
{
void HostLogDriver::SetInstance(IGpLogDriver *instance)
{
ms_instance = instance;
}
IGpLogDriver *HostLogDriver::GetInstance()
{
return ms_instance;
}
IGpLogDriver *HostLogDriver::ms_instance;
}

View File

@@ -1,16 +0,0 @@
#pragma once
struct IGpLogDriver;
namespace PortabilityLayer
{
class HostLogDriver
{
public:
static void SetInstance(IGpLogDriver *instance);
static IGpLogDriver *GetInstance();
private:
static IGpLogDriver *ms_instance;
};
}

View File

@@ -1,20 +0,0 @@
#pragma once
#ifndef __PL_HOST_MEMORYBUFFER_H__
#define __PL_HOST_MEMORYBUFFER_H__
#include <stdint.h>
#include "CoreDefs.h"
namespace PortabilityLayer
{
class HostMemoryBuffer
{
public:
virtual void *Contents() = 0;
virtual size_t Size() = 0;
virtual void Destroy() = 0;
};
}
#endif

View File

@@ -1,13 +0,0 @@
#pragma once
namespace PortabilityLayer
{
class HostMutex
{
public:
virtual void Destroy() = 0;
virtual void Lock() = 0;
virtual void Unlock() = 0;
};
}

View File

@@ -1,16 +0,0 @@
#include "HostSystemServices.h"
namespace PortabilityLayer
{
void HostSystemServices::SetInstance(HostSystemServices *instance)
{
ms_instance = instance;
}
HostSystemServices *HostSystemServices::GetInstance()
{
return ms_instance;
}
HostSystemServices *HostSystemServices::ms_instance;
}

View File

@@ -1,44 +0,0 @@
#pragma once
#include <stdint.h>
#ifdef CreateMutex
#error "CreateMutex was macrod"
#endif
#ifdef CreateThread
#error "CreateThread was macrod"
#endif
namespace PortabilityLayer
{
class HostMutex;
class HostThreadEvent;
class HostSystemServices
{
public:
typedef int (*ThreadFunc_t)(void *context);
virtual int64_t GetTime() const = 0;
virtual void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const = 0;
virtual HostMutex *CreateMutex() = 0;
virtual HostMutex *CreateRecursiveMutex() = 0;
virtual void *CreateThread(ThreadFunc_t threadFunc, void *context) = 0;
virtual HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 0;
virtual uint64_t GetFreeMemoryCosmetic() const = 0; // Returns free memory in bytes, does not have to be accurate
virtual void Beep() const = 0;
virtual bool IsTouchscreen() const = 0;
virtual bool IsUsingMouseAsTouch() const = 0;
virtual bool IsTextInputObstructive() const = 0;
virtual unsigned int GetCPUCount() const = 0;
virtual void SetTextInputEnabled(bool isEnabled) = 0;
virtual bool IsTextInputEnabled() const = 0;
static void SetInstance(HostSystemServices *instance);
static HostSystemServices *GetInstance();
private:
static HostSystemServices *ms_instance;
};
}

View File

@@ -1,15 +0,0 @@
#pragma once
#include <stdint.h>
namespace PortabilityLayer
{
class HostThreadEvent
{
public:
virtual void Wait() = 0;
virtual bool WaitTimed(uint32_t msec) = 0;
virtual void Signal() = 0;
virtual void Destroy() = 0;
};
}

View File

@@ -1,16 +0,0 @@
#include "HostVOSEventQueue.h"
namespace PortabilityLayer
{
void HostVOSEventQueue::SetInstance(HostVOSEventQueue *instance)
{
ms_instance = instance;
}
HostVOSEventQueue *HostVOSEventQueue::GetInstance()
{
return ms_instance;
}
HostVOSEventQueue *HostVOSEventQueue::ms_instance = nullptr;
}

View File

@@ -1,16 +0,0 @@
#pragma once
#include "IGpVOSEventQueue.h"
namespace PortabilityLayer
{
class HostVOSEventQueue : public IGpVOSEventQueue
{
public:
static void SetInstance(HostVOSEventQueue *instance);
static HostVOSEventQueue *GetInstance();
private:
static HostVOSEventQueue *ms_instance;
};
}

View File

@@ -2,19 +2,11 @@
#include "DisplayDeviceManager.h"
#include "FontFamily.h"
#include "FontManager.h"
#include "HostDisplayDriver.h"
#include "IGpFont.h"
#include "IGpDisplayDriver.h"
#include "MemoryManager.h"
#include "ResourceManager.h"
#include "SimpleGraphic.h"
#include "PLBigEndian.h"
#include "PLCore.h"
#include "PLPasStr.h"
#include "PLResources.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLQDOffscreen.h"
#include "RenderedFont.h"
#include "QDGraf.h"
#include "QDManager.h"
@@ -23,6 +15,15 @@
#include "ResolveCachingColor.h"
#include "Vec2i.h"
#include "PLBigEndian.h"
#include "PLCore.h"
#include "PLDrivers.h"
#include "PLPasStr.h"
#include "PLResources.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLQDOffscreen.h"
#include <stdint.h>
#include <assert.h>
#include <algorithm>
@@ -840,7 +841,7 @@ namespace PortabilityLayer
}
unsigned int width;
HostDisplayDriver::GetInstance()->GetDisplayResolution(&width, nullptr);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(&width, nullptr);
GpPixelFormat_t pixelFormat = DisplayDeviceManager::GetInstance()->GetPixelFormat();
@@ -1307,7 +1308,7 @@ namespace PortabilityLayer
if (m_isTouchScreen)
{
unsigned int displayHeight = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(nullptr, &displayHeight);
return y >= (static_cast<int32_t>(displayHeight - kTouchscreenMenuBarHeight)) && y < static_cast<int32_t>(displayHeight);
}
else
@@ -1388,7 +1389,7 @@ namespace PortabilityLayer
int32_t popupBottom = static_cast<int32_t>(m_popupPosition.m_y + menu->layoutFinalHeight);
unsigned int displayHeight = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
PLDrivers::GetDisplayDriver()->GetDisplayResolution(nullptr, &displayHeight);
if (popupBottom > static_cast<int32_t>(displayHeight))
m_popupPosition.m_y -= popupBottom - static_cast<int32_t>(displayHeight);
}

View File

@@ -1,6 +1,8 @@
#include "IGpSystemServices.h"
#include "PLApplication.h"
#include "PLCore.h"
#include "HostSystemServices.h"
#include "PLDrivers.h"
#include <string.h>
#include <assert.h>
@@ -20,5 +22,5 @@ namespace PortabilityLayer
void SysBeep(int duration)
{
PortabilityLayer::HostSystemServices::GetInstance()->Beep();
PLDrivers::GetSystemServices()->Beep();
}

View File

@@ -12,15 +12,13 @@
#include "FontFamily.h"
#include "FontManager.h"
#include "GpVOSEvent.h"
#include "HostDirectoryCursor.h"
#include "HostFileSystem.h"
#include "IGpDirectoryCursor.h"
#include "HostSuspendCallArgument.h"
#include "HostSuspendHook.h"
#include "HostDisplayDriver.h"
#include "HostSystemServices.h"
#include "HostVOSEventQueue.h"
#include "IGpCursor.h"
#include "IGpDisplayDriver.h"
#include "IGpFileSystem.h"
#include "IGpSystemServices.h"
#include "IGpThreadRelay.h"
#include "InputManager.h"
#include "ResourceManager.h"
@@ -33,17 +31,19 @@
#include "RenderedFont.h"
#include "ResTypeID.h"
#include "RandomNumberGenerator.h"
#include "QDManager.h"
#include "Vec2i.h"
#include "WindowDef.h"
#include "WindowManager.h"
#include "PLArrayViewIterator.h"
#include "PLBigEndian.h"
#include "PLDrivers.h"
#include "PLEventQueue.h"
#include "PLKeyEncoding.h"
#include "PLSysCalls.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLWidgets.h"
#include "QDManager.h"
#include "Vec2i.h"
#include "WindowDef.h"
#include "WindowManager.h"
#include <assert.h>
#include <algorithm>
@@ -96,7 +96,7 @@ static bool ConvertFilenameToSafePStr(const char *str, uint8_t *pstr)
void InitCursor()
{
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kArrow);
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kArrow);
}
Rect BERect::ToRect() const
@@ -121,7 +121,7 @@ Point BEPoint::ToPoint() const
void HideCursor()
{
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kHidden);
PLDrivers::GetDisplayDriver()->SetStandardCursor(EGpStandardCursors::kHidden);
}
void Delay(int ticks, UInt32 *endTickCount)
@@ -437,8 +437,8 @@ PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfo)
DirectoryFileListEntry *GetDirectoryFiles(PortabilityLayer::VirtualDirectory_t dirID)
{
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
PortabilityLayer::HostFileSystem *fs = PortabilityLayer::HostFileSystem::GetInstance();
PortabilityLayer::HostDirectoryCursor *dirCursor = fs->ScanDirectory(dirID);
IGpFileSystem *fs = PLDrivers::GetFileSystem();
IGpDirectoryCursor *dirCursor = fs->ScanDirectory(dirID);
DirectoryFileListEntry *firstDFL = nullptr;
DirectoryFileListEntry *lastDFL = nullptr;
@@ -568,7 +568,7 @@ void GetTime(DateTimeRec *dateTime)
unsigned int hour;
unsigned int minute;
unsigned int second;
PortabilityLayer::HostSystemServices::GetInstance()->GetLocalDateTime(year, month, day, hour, minute, second);
PLDrivers::GetSystemServices()->GetLocalDateTime(year, month, day, hour, minute, second);
dateTime->month = month;
dateTime->hour = hour;
@@ -678,8 +678,8 @@ void PL_Init()
PortabilityLayer::QDManager::GetInstance()->Init();
PortabilityLayer::MenuManager::GetInstance()->Init();
PortabilityLayer::HostFileSystem::GetInstance()->SetMainThreadRelay(PLMainThreadRelay::GetInstance());
PortabilityLayer::HostFileSystem::GetInstance()->SetDelayCallback(PLSysCalls::Sleep);
PLDrivers::GetFileSystem()->SetMainThreadRelay(PLMainThreadRelay::GetInstance());
PLDrivers::GetFileSystem()->SetDelayCallback(PLSysCalls::Sleep);
}
WindowPtr PL_GetPutInFrontWindowPtr()

View File

@@ -0,0 +1,53 @@
#include "PLDrivers.h"
GpDriverCollection *PLDrivers::GetDriverCollection()
{
return &ms_drivers;
}
IGpAudioDriver *PLDrivers::GetAudioDriver()
{
return ms_drivers.GetDriver<GpDriverIDs::kAudio>();
}
IGpFileSystem *PLDrivers::GetFileSystem()
{
return ms_drivers.GetDriver<GpDriverIDs::kFileSystem>();
}
IGpDisplayDriver *PLDrivers::GetDisplayDriver()
{
return ms_drivers.GetDriver<GpDriverIDs::kDisplay>();
}
IGpLogDriver *PLDrivers::GetLogDriver()
{
return ms_drivers.GetDriver<GpDriverIDs::kLog>();
}
size_t PLDrivers::GetNumInputDrivers()
{
return ms_drivers.GetDriverCount<GpDriverIDs::kInput>();
}
IGpInputDriver *PLDrivers::GetInputDriver(size_t index)
{
return ms_drivers.GetDriver<GpDriverIDs::kInput>(index);
}
IGpSystemServices *PLDrivers::GetSystemServices()
{
return ms_drivers.GetDriver<GpDriverIDs::kSystemServices>();
}
IGpFontHandler *PLDrivers::GetFontHandler()
{
return ms_drivers.GetDriver<GpDriverIDs::kFont>();
}
IGpVOSEventQueue *PLDrivers::GetVOSEventQueue()
{
return ms_drivers.GetDriver<GpDriverIDs::kEventQueue>();
}
GpDriverCollection PLDrivers::ms_drivers;

View File

@@ -0,0 +1,22 @@
#pragma once
#include "GpDriverIndex.h"
class PLDrivers
{
public:
static GpDriverCollection *GetDriverCollection();
static IGpAudioDriver *GetAudioDriver();
static IGpFileSystem *GetFileSystem();
static IGpDisplayDriver *GetDisplayDriver();
static IGpLogDriver *GetLogDriver();
static size_t GetNumInputDrivers();
static IGpInputDriver *GetInputDriver(size_t index);
static IGpSystemServices *GetSystemServices();
static IGpFontHandler *GetFontHandler();
static IGpVOSEventQueue *GetVOSEventQueue();
private:
static GpDriverCollection ms_drivers;
};

View File

@@ -2,19 +2,21 @@
#include "FontFamily.h"
#include "FontManager.h"
#include "HostSystemServices.h"
#include "IGpSystemServices.h"
#include "InputManager.h"
#include "MacRomanConversion.h"
#include "MemoryManager.h"
#include "RenderedFont.h"
#include "GpRenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "TextPlacer.h"
#include "Rect2i.h"
#include "PLDrivers.h"
#include "PLKeyEncoding.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "ResolveCachingColor.h"
#include "TextPlacer.h"
#include "Rect2i.h"
#include <algorithm>
@@ -44,7 +46,7 @@ namespace PortabilityLayer
EditboxWidget::~EditboxWidget()
{
if (m_hasFocus)
PortabilityLayer::HostSystemServices::GetInstance()->SetTextInputEnabled(false);
PLDrivers::GetSystemServices()->SetTextInputEnabled(false);
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
@@ -160,13 +162,13 @@ namespace PortabilityLayer
DrawControl(surface);
}
PortabilityLayer::HostSystemServices::GetInstance()->SetTextInputEnabled(true);
PLDrivers::GetSystemServices()->SetTextInputEnabled(true);
}
void EditboxWidget::LoseFocus()
{
if (m_hasFocus)
PortabilityLayer::HostSystemServices::GetInstance()->SetTextInputEnabled(false);
PLDrivers::GetSystemServices()->SetTextInputEnabled(false);
m_hasFocus = false;
m_selStartChar = 0;
@@ -782,7 +784,7 @@ namespace PortabilityLayer
if (mouseEvent.m_eventType == GpMouseEventTypes::kUp)
{
// Re-enable text input if it was dismissed
PortabilityLayer::HostSystemServices::GetInstance()->SetTextInputEnabled(true);
PLDrivers::GetSystemServices()->SetTextInputEnabled(true);
m_caratScrollLocked = false;
m_isDraggingSelection = false;

View File

@@ -9,9 +9,6 @@
#include "MMHandleBlock.h"
#include "MemoryManager.h"
#include "MemReaderStream.h"
#include "HostFontHandler.h"
#include "PLPasStr.h"
#include "PLStandardColors.h"
#include "RenderedFont.h"
#include "GpRenderedFontMetrics.h"
#include "GpRenderedGlyphMetrics.h"
@@ -31,6 +28,9 @@
#include "QDPixMap.h"
#include "Vec2i.h"
#include "PLPasStr.h"
#include "PLStandardColors.h"
#include <algorithm>
#include <assert.h>

View File

@@ -4,9 +4,8 @@
#include "BMPFormat.h"
#include "FileManager.h"
#include "GPArchive.h"
#include "HostDirectoryCursor.h"
#include "HostFileSystem.h"
#include "HostMemoryBuffer.h"
#include "IGpDirectoryCursor.h"
#include "IGpFileSystem.h"
#include "GpIOStream.h"
#include "MacBinary2.h"
#include "MacFileMem.h"
@@ -15,13 +14,15 @@
#include "MMHandleBlock.h"
#include "ResourceCompiledTypeList.h"
#include "ResourceFile.h"
#include "PLPasStr.h"
#include "PLErrorCodes.h"
#include "VirtualDirectory.h"
#include "WaveFormat.h"
#include "ZipFileProxy.h"
#include "ZipFile.h"
#include "PLDrivers.h"
#include "PLPasStr.h"
#include "PLErrorCodes.h"
#include <stdio.h>
#include <algorithm>
@@ -189,7 +190,7 @@ namespace PortabilityLayer
IResourceArchive *ResourceManagerImpl::LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const
{
if (PortabilityLayer::HostFileSystem::GetInstance()->IsVirtualDirectoryLooseResources(virtualDir))
if (PLDrivers::GetFileSystem()->IsVirtualDirectoryLooseResources(virtualDir))
return LoadResDirectory(virtualDir, filename);
GpIOStream *fStream = nullptr;
@@ -581,11 +582,11 @@ namespace PortabilityLayer
bool ResourceArchiveDirectory::Init()
{
PortabilityLayer::HostFileSystem *fs = PortabilityLayer::HostFileSystem::GetInstance();
IGpFileSystem *fs = PLDrivers::GetFileSystem();
const char *typePaths[1] = { this->m_subdirectory };
PortabilityLayer::HostDirectoryCursor *typeDirCursor = fs->ScanDirectoryNested(m_directory, typePaths, 1);
IGpDirectoryCursor *typeDirCursor = fs->ScanDirectoryNested(m_directory, typePaths, 1);
if (!typeDirCursor)
return false;
@@ -621,7 +622,7 @@ namespace PortabilityLayer
rte.m_lastRes = m_numResources;
const char *idScanFilenames[2] = { this->m_subdirectory, typeScanFilename };
PortabilityLayer::HostDirectoryCursor *typeIDCursor = fs->ScanDirectoryNested(m_directory, idScanFilenames, 2);
IGpDirectoryCursor *typeIDCursor = fs->ScanDirectoryNested(m_directory, idScanFilenames, 2);
if (!typeIDCursor)
continue;
@@ -779,7 +780,7 @@ namespace PortabilityLayer
const char *paths[3] = { m_subdirectory, resTypeTag.m_id, fileName };
GpIOStream *ioStream = PortabilityLayer::HostFileSystem::GetInstance()->OpenFileNested(m_directory, paths, 3, false, GpFileCreationDispositions::kOpenExisting);
GpIOStream *ioStream = PLDrivers::GetFileSystem()->OpenFileNested(m_directory, paths, 3, false, GpFileCreationDispositions::kOpenExisting);
if (!ioStream)
return THandle<void>();

View File

@@ -1,6 +1,5 @@
#include "PLResources.h"
#include "HostFileSystem.h"
#include "MemoryManager.h"
#include "MMHandleBlock.h"
#include "PLPasStr.h"

View File

@@ -1,15 +1,16 @@
#include "PLSound.h"
#include "HostAudioDriver.h"
#include "MemoryManager.h"
#include "HostMutex.h"
#include "HostSystemServices.h"
#include "HostThreadEvent.h"
#include "IGpMutex.h"
#include "IGpThreadEvent.h"
#include "IGpAudioChannel.h"
#include "IGpAudioChannelCallbacks.h"
#include "IGpAudioDriver.h"
#include "IGpSystemServices.h"
#include "WaveFormat.h"
#include "PLDrivers.h"
#include <assert.h>
namespace PortabilityLayer
@@ -40,7 +41,7 @@ namespace PortabilityLayer
class AudioChannelImpl final : public AudioChannel, public IGpAudioChannelCallbacks
{
public:
explicit AudioChannelImpl(IGpAudioChannel *channel, HostThreadEvent *threadEvent, HostMutex *mutex);
explicit AudioChannelImpl(IGpAudioChannel *channel, IGpThreadEvent *threadEvent, IGpMutex *mutex);
~AudioChannelImpl();
void Destroy(bool wait) override;
@@ -73,8 +74,8 @@ namespace PortabilityLayer
IGpAudioChannel *m_audioChannel;
HostMutex *m_mutex;
HostThreadEvent *m_threadEvent;
IGpMutex *m_mutex;
IGpThreadEvent *m_threadEvent;
AudioCommand m_commandQueue[kMaxQueuedCommands];
size_t m_numQueuedCommands;
@@ -84,7 +85,7 @@ namespace PortabilityLayer
bool m_isIdle;
};
AudioChannelImpl::AudioChannelImpl(IGpAudioChannel *channel, HostThreadEvent *threadEvent, HostMutex *mutex)
AudioChannelImpl::AudioChannelImpl(IGpAudioChannel *channel, IGpThreadEvent *threadEvent, IGpMutex *mutex)
: m_audioChannel(channel)
, m_threadEvent(threadEvent)
, m_mutex(mutex)
@@ -353,7 +354,7 @@ namespace PortabilityLayer
AudioChannel *SoundSystemImpl::CreateChannel()
{
IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance();
IGpAudioDriver *audioDriver = PLDrivers::GetAudioDriver();
if (!audioDriver)
return nullptr;
@@ -369,7 +370,7 @@ namespace PortabilityLayer
return nullptr;
}
PortabilityLayer::HostMutex *mutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateRecursiveMutex();
IGpMutex *mutex = PLDrivers::GetSystemServices()->CreateRecursiveMutex();
if (!mutex)
{
audioChannel->Destroy();
@@ -377,7 +378,7 @@ namespace PortabilityLayer
return nullptr;
}
PortabilityLayer::HostThreadEvent *threadEvent = PortabilityLayer::HostSystemServices::GetInstance()->CreateThreadEvent(true, false);
IGpThreadEvent *threadEvent = PLDrivers::GetSystemServices()->CreateThreadEvent(true, false);
if (!threadEvent)
{
mutex->Destroy();
@@ -391,7 +392,7 @@ namespace PortabilityLayer
void SoundSystemImpl::SetVolume(uint8_t vol)
{
IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance();
IGpAudioDriver *audioDriver = PLDrivers::GetAudioDriver();
if (!audioDriver)
return;

View File

@@ -8,14 +8,14 @@
#include "DisplayDeviceManager.h"
#include "GpVOSEvent.h"
#include "IGpDisplayDriver.h"
#include "IGpVOSEventQueue.h"
#include "InputManager.h"
#include "HostDisplayDriver.h"
#include "HostFileSystem.h"
#include "HostSuspendCallArgument.h"
#include "HostSuspendHook.h"
#include "HostVOSEventQueue.h"
#include "MacRomanConversion.h"
#include "PLDrivers.h"
static void TranslateMouseInputEvent(const GpVOSEvent &vosEventBase, uint32_t timestamp, PortabilityLayer::EventQueue *queue)
{
const GpMouseInputEvent &vosEvent = vosEventBase.m_event.m_mouseInputEvent;
@@ -84,7 +84,7 @@ static void TranslateKeyboardInputEvent(const GpVOSEvent &vosEventBase, uint32_t
const KeyDownStates *keyStates = inputManager->GetKeys();
if (keyStates->m_special.Get(GpKeySpecials::kLeftAlt) || keyStates->m_special.Get(GpKeySpecials::kRightAlt))
{
IGpDisplayDriver *dd = PortabilityLayer::HostDisplayDriver::GetInstance();
IGpDisplayDriver *dd = PLDrivers::GetDisplayDriver();
if (dd)
dd->RequestToggleFullScreen(timestamp);
}
@@ -160,7 +160,7 @@ static void ImportVOSEvents(uint32_t timestamp)
{
PortabilityLayer::EventQueue *plQueue = PortabilityLayer::EventQueue::GetInstance();
PortabilityLayer::HostVOSEventQueue *evtQueue = PortabilityLayer::HostVOSEventQueue::GetInstance();
IGpVOSEventQueue *evtQueue = PLDrivers::GetVOSEventQueue();
while (const GpVOSEvent *evt = evtQueue->GetNext())
{
TranslateVOSEvent(evt, timestamp, plQueue);

View File

@@ -101,30 +101,16 @@
<ClInclude Include="FileBrowserUI.h" />
<ClInclude Include="FileManager.h" />
<ClInclude Include="FilePermission.h" />
<ClInclude Include="FilePos.h" />
<ClInclude Include="FontFamily.h" />
<ClInclude Include="FontManager.h" />
<ClInclude Include="FontRenderer.h" />
<ClInclude Include="GpAppInterface.h" />
<ClInclude Include="GPArchive.h" />
<ClInclude Include="HostAudioDriver.h" />
<ClInclude Include="HostDirectoryCursor.h" />
<ClInclude Include="HostFont.h" />
<ClInclude Include="HostFontHandler.h" />
<ClInclude Include="HostFontRenderedGlyph.h" />
<ClInclude Include="HostInputDriver.h" />
<ClInclude Include="HostLogDriver.h" />
<ClInclude Include="HostMutex.h" />
<ClInclude Include="HostSuspendCallArgument.h" />
<ClInclude Include="HostSuspendCallID.h" />
<ClInclude Include="HostSuspendHook.h" />
<ClInclude Include="HostDisplayDriver.h" />
<ClInclude Include="HostSystemServices.h" />
<ClInclude Include="HostThreadEvent.h" />
<ClInclude Include="HostVOSEventQueue.h" />
<ClInclude Include="IconLoader.h" />
<ClInclude Include="InputManager.h" />
<ClInclude Include="IOStream.h" />
<ClInclude Include="IPlotter.h" />
<ClInclude Include="LinePlotter.h" />
<ClInclude Include="MacBinary2.h" />
@@ -138,8 +124,6 @@
<ClInclude Include="MMHandleBlock.h" />
<ClInclude Include="PascalStr.h" />
<ClInclude Include="PascalStrLiteral.h" />
<ClInclude Include="HostMemoryBuffer.h" />
<ClInclude Include="HostFileSystem.h" />
<ClInclude Include="PLApplication.h" />
<ClInclude Include="PLArrayView.h" />
<ClInclude Include="PLArrayViewIterator.h" />
@@ -149,6 +133,7 @@
<ClInclude Include="PLCore.h" />
<ClInclude Include="PLCTabReducer.h" />
<ClInclude Include="PLDialogs.h" />
<ClInclude Include="PLDrivers.h" />
<ClInclude Include="PLEditboxWidget.h" />
<ClInclude Include="PLErrorCodes.h" />
<ClInclude Include="PLEventQueue.h" />
@@ -249,15 +234,7 @@
<ClCompile Include="FontManager.cpp" />
<ClCompile Include="FontRenderer.cpp" />
<ClCompile Include="GPArchive.cpp" />
<ClCompile Include="HostAudioDriver.cpp" />
<ClCompile Include="HostDisplayDriver.cpp" />
<ClCompile Include="HostFileSystem.cpp" />
<ClCompile Include="HostFontHandler.cpp" />
<ClCompile Include="HostInputDriver.cpp" />
<ClCompile Include="HostLogDriver.cpp" />
<ClCompile Include="HostSuspendHook.cpp" />
<ClCompile Include="HostSystemServices.cpp" />
<ClCompile Include="HostVOSEventQueue.cpp" />
<ClCompile Include="IconLoader.cpp" />
<ClCompile Include="InputManager.cpp" />
<ClCompile Include="LinePlotter.cpp" />
@@ -275,6 +252,7 @@
<ClCompile Include="PLCore.cpp" />
<ClCompile Include="PLCTabReducer.cpp" />
<ClCompile Include="PLDialogs.cpp" />
<ClCompile Include="PLDrivers.cpp" />
<ClCompile Include="PLEditboxWidget.cpp" />
<ClCompile Include="PLEventQueue.cpp" />
<ClCompile Include="PLHacks.cpp" />

View File

@@ -21,9 +21,6 @@
<ClInclude Include="CFileStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="IOStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RCPtr.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -117,12 +114,6 @@
<ClInclude Include="MemReaderStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostFileSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostMemoryBuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ResourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -147,9 +138,6 @@
<ClInclude Include="DisplayDeviceManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostDisplayDriver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ByteSwap.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -174,9 +162,6 @@
<ClInclude Include="PLErrorCodes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostSystemServices.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RandomNumberGenerator.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -249,42 +234,15 @@
<ClInclude Include="QDPort.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostAudioDriver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostMutex.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostThreadEvent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostDirectoryCursor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FilePos.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MenuManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostFontHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FontManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostFont.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostInputDriver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="InputManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostVOSEventQueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PLEventQueue.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -297,9 +255,6 @@
<ClInclude Include="RenderedFont.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostFontRenderedGlyph.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SimpleGraphic.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -456,15 +411,15 @@
<ClInclude Include="ResolveCachingColor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HostLogDriver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FileBrowserUI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WorkerThread.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PLDrivers.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CFileStream.cpp">
@@ -521,9 +476,6 @@
<ClCompile Include="MemReaderStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostFileSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ResourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -539,9 +491,6 @@
<ClCompile Include="DisplayDeviceManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostDisplayDriver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ByteSwap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -554,9 +503,6 @@
<ClCompile Include="RandomNumberGenerator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostSystemServices.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostSuspendHook.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -593,24 +539,15 @@
<ClCompile Include="QDPort.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostAudioDriver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MenuManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostFontHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FontManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="InputManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostVOSEventQueue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PLEventQueue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -731,17 +668,14 @@
<ClCompile Include="ResolveCachingColor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostLogDriver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HostInputDriver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileBrowserUI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WorkerThread.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PLDrivers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -1,15 +1,9 @@
#include "WindowManager.h"
#include "DisplayDeviceManager.h"
#include "HostDisplayDriver.h"
#include "HostLogDriver.h"
#include "IGpDisplayDriver.h"
#include "IGpDisplayDriverSurface.h"
#include "IGpLogDriver.h"
#include "PLCore.h"
#include "PLEventQueue.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include "FontFamily.h"
#include "MemoryManager.h"
#include "MenuManager.h"
@@ -24,6 +18,12 @@
#include "Vec2i.h"
#include "WindowDef.h"
#include "PLCore.h"
#include "PLDrivers.h"
#include "PLEventQueue.h"
#include "PLStandardColors.h"
#include "PLSysCalls.h"
#include <algorithm>
struct GDevice;
@@ -1301,7 +1301,7 @@ namespace PortabilityLayer
const bool haveExclusiveWindow = (m_exclusiveWindow != nullptr);
if (hadExclusiveWindow != haveExclusiveWindow)
HostDisplayDriver::GetInstance()->SetBackgroundDarkenEffect(haveExclusiveWindow);
PLDrivers::GetDisplayDriver()->SetBackgroundDarkenEffect(haveExclusiveWindow);
}
void WindowManagerImpl::FlickerWindowIn(Window *window, int32_t velocity)
@@ -1436,7 +1436,7 @@ namespace PortabilityLayer
void WindowManagerImpl::HandleScreenResolutionChange(uint32_t prevWidth, uint32_t prevHeight, uint32_t newWidth, uint32_t newHeight)
{
IGpLogDriver *logger = PortabilityLayer::HostLogDriver::GetInstance();
IGpLogDriver *logger = PLDrivers::GetLogDriver();
if (logger)
logger->Printf(IGpLogDriver::Category_Information, "WindowManagerImpl: Resizing from %ix%i to %ix%i", static_cast<int>(prevWidth), static_cast<int>(prevHeight), static_cast<int>(newWidth), static_cast<int>(newHeight));
@@ -1530,7 +1530,7 @@ namespace PortabilityLayer
void WindowManagerImpl::SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b)
{
HostDisplayDriver::GetInstance()->SetBackgroundColor(r, g, b, 255);
PLDrivers::GetDisplayDriver()->SetBackgroundColor(r, g, b, 255);
}
void WindowManagerImpl::ResizeWindow(Window *window, int width, int height)

Some files were not shown because too many files have changed in this diff Show More