Allocator refactor

This commit is contained in:
elasota
2021-04-28 01:46:07 -04:00
parent 472462c535
commit a2d374f650
75 changed files with 473 additions and 253 deletions

View File

@@ -5,6 +5,7 @@
struct IGpSystemServices;
struct IGpAudioDriver;
struct IGpLogDriver;
struct IGpAllocator;
struct GpAudioDriverProperties
{
@@ -15,4 +16,5 @@ struct GpAudioDriverProperties
IGpLogDriver *m_logger;
IGpSystemServices *m_systemServices;
IGpAllocator *m_alloc;
};

View File

@@ -10,6 +10,7 @@ struct IGpFiber;
struct IGpVOSEventQueue;
struct IGpLogDriver;
struct IGpSystemServices;
struct IGpAllocator;
struct GpDisplayDriverProperties
{
@@ -43,4 +44,5 @@ struct GpDisplayDriverProperties
IGpVOSEventQueue *m_eventQueue;
IGpLogDriver *m_logger;
IGpSystemServices *m_systemServices;
IGpAllocator *m_alloc;
};

View File

@@ -16,6 +16,7 @@ namespace GpDriverIDs
kSystemServices,
kFont,
kEventQueue,
kAlloc,
kCount
};
@@ -54,6 +55,7 @@ GP_DEFINE_MULTI_DRIVER(kInput, IGpInputDriver);
GP_DEFINE_DRIVER(kSystemServices, IGpSystemServices);
GP_DEFINE_DRIVER(kFont, IGpFontHandler);
GP_DEFINE_DRIVER(kEventQueue, IGpVOSEventQueue);
GP_DEFINE_DRIVER(kAlloc, IGpAllocator);
struct GpDriverCollection
{

View File

@@ -2,7 +2,11 @@
#include "EGpFontHandlerType.h"
struct IGpAllocator;
struct GpFontHandlerProperties
{
EGpFontHandlerType m_type;
IGpAllocator *m_alloc;
};

View File

@@ -4,10 +4,12 @@
struct IGpAudioDriver;
struct IGpVOSEventQueue;
struct IGpAllocator;
struct GpInputDriverProperties
{
EGpInputDriverType m_type;
IGpVOSEventQueue *m_eventQueue;
IGpAllocator *m_alloc;
};

View File

@@ -13,6 +13,7 @@
struct IGpBWCursor_Win32;
struct IGpCursor_Win32;
struct IGpAllocator;
struct IGpVOSEventQueue;
struct GpWindowsGlobals
@@ -28,7 +29,7 @@ struct GpWindowsGlobals
HICON m_hIconSm;
int m_nCmdShow;
IGpCursor_Win32 *(*m_createColorCursorFunc)(size_t width, size_t height, const void *pixelDataRGBA, size_t hotSpotX, size_t hotSpotY);
IGpCursor_Win32 *(*m_createBWCursorFunc)(size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY);
IGpCursor_Win32 *(*m_createColorCursorFunc)(IGpAllocator *alloc, size_t width, size_t height, const void *pixelDataRGBA, size_t hotSpotX, size_t hotSpotY);
IGpCursor_Win32 *(*m_createBWCursorFunc)(IGpAllocator *alloc, size_t width, size_t height, const void *pixelData, const void *maskData, size_t hotSpotX, size_t hotSpotY);
void (*m_translateWindowsMessageFunc)(const MSG *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY);
};

12
GpCommon/IGpAllocator.h Normal file
View File

@@ -0,0 +1,12 @@
#pragma once
#include <stdint.h>
#include <stddef.h>
struct IGpAllocator
{
virtual void *Realloc(void *buf, size_t newSize) = 0;
inline void *Alloc(size_t size) { return this->Realloc(nullptr, size); }
inline void Release(void *ptr) { this->Realloc(ptr, 0); }
};