mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Add Roboto font, misc icons and text things
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
#include "GpColorCursor_Win32.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
|
||||
void GpColorCursor_Win32::Destroy()
|
||||
{
|
||||
this->DecRef();
|
||||
}
|
||||
|
||||
GpColorCursor_Win32 *GpColorCursor_Win32::Load(const wchar_t *path)
|
||||
{
|
||||
HANDLE imageH = LoadImageW(nullptr, path, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
|
||||
|
||||
if (imageH == nullptr)
|
||||
return nullptr;
|
||||
|
||||
HCURSOR cursor = reinterpret_cast<HCURSOR>(imageH);
|
||||
void *storage = malloc(sizeof(GpColorCursor_Win32));
|
||||
if (!storage)
|
||||
{
|
||||
DestroyCursor(cursor);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new (storage) GpColorCursor_Win32(reinterpret_cast<HCURSOR>(cursor));
|
||||
}
|
||||
|
||||
GpColorCursor_Win32::GpColorCursor_Win32(HCURSOR cursor)
|
||||
: m_cursor(cursor)
|
||||
, m_refCount(1)
|
||||
{
|
||||
}
|
||||
|
||||
GpColorCursor_Win32::~GpColorCursor_Win32()
|
||||
{
|
||||
DestroyCursor(m_cursor);
|
||||
}
|
||||
|
||||
const HCURSOR &GpColorCursor_Win32::GetHCursor() const
|
||||
{
|
||||
return m_cursor;
|
||||
}
|
||||
|
||||
void GpColorCursor_Win32::IncRef()
|
||||
{
|
||||
m_refCount++;
|
||||
}
|
||||
|
||||
void GpColorCursor_Win32::DecRef()
|
||||
{
|
||||
m_refCount--;
|
||||
if (m_refCount == 0)
|
||||
{
|
||||
this->~GpColorCursor_Win32();
|
||||
free(this);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGpColorCursor.h"
|
||||
#include "IGpColorCursor_Win32.h"
|
||||
#include "GpWindows.h"
|
||||
|
||||
class GpColorCursor_Win32 final : public IGpColorCursor
|
||||
|
||||
class GpColorCursor_Win32 final : public IGpColorCursor_Win32
|
||||
{
|
||||
public:
|
||||
void Destroy() override;
|
||||
|
||||
const HCURSOR &GetHCursor() const;
|
||||
const HCURSOR &GetHCursor() const override;
|
||||
|
||||
void IncRef();
|
||||
void DecRef();
|
||||
void IncRef() override;
|
||||
void DecRef() override;
|
||||
|
||||
static GpColorCursor_Win32 *Load(const wchar_t *path);
|
||||
|
||||
|
||||
120
GpCommon/GpComPtr.h
Normal file
120
GpCommon/GpComPtr.h
Normal file
@@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
template<class T>
|
||||
class GpComPtr final
|
||||
{
|
||||
public:
|
||||
GpComPtr();
|
||||
const GpComPtr(const GpComPtr<T> &other);
|
||||
explicit GpComPtr(T *ptr);
|
||||
~GpComPtr();
|
||||
|
||||
GpComPtr<T> &operator=(const GpComPtr<T> &other);
|
||||
GpComPtr<T> &operator=(T *other);
|
||||
|
||||
bool operator==(const GpComPtr<T> &other) const;
|
||||
bool operator!=(const GpComPtr<T> &other) const;
|
||||
|
||||
bool operator==(const T *other) const;
|
||||
bool operator!=(const T *other) const;
|
||||
|
||||
operator T*() const;
|
||||
T *operator->() const;
|
||||
|
||||
T **GetMutablePtr();
|
||||
|
||||
private:
|
||||
T *m_ptr;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::GpComPtr()
|
||||
: m_ptr(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::GpComPtr(const GpComPtr<T> &other)
|
||||
: m_ptr(other.m_ptr)
|
||||
{
|
||||
if (m_ptr)
|
||||
m_ptr->AddRef();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::GpComPtr(T *ptr)
|
||||
: m_ptr(ptr)
|
||||
{
|
||||
if (ptr)
|
||||
ptr->AddRef();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::~GpComPtr()
|
||||
{
|
||||
if (m_ptr)
|
||||
m_ptr->Release();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T> &GpComPtr<T>::operator=(const GpComPtr<T> &other)
|
||||
{
|
||||
(*this) = other.m_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T> &GpComPtr<T>::operator=(T *other)
|
||||
{
|
||||
if (other)
|
||||
other->AddRef();
|
||||
|
||||
if (m_ptr)
|
||||
m_ptr->Release();
|
||||
|
||||
m_ptr = other;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool GpComPtr<T>::operator==(const GpComPtr<T> &other) const
|
||||
{
|
||||
return m_ptr == other.m_ptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool GpComPtr<T>::operator!=(const GpComPtr<T> &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool GpComPtr<T>::operator==(const T *other) const
|
||||
{
|
||||
return m_ptr == other;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool GpComPtr<T>::operator!=(const T *other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T **GpComPtr<T>::GetMutablePtr()
|
||||
{
|
||||
return &m_ptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::operator T*() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T *GpComPtr<T>::operator->() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
@@ -3,11 +3,11 @@
|
||||
#include "EGpDisplayDriverType.h"
|
||||
|
||||
struct IGpDisplayDriver;
|
||||
class GpFiber;
|
||||
struct IGpFiber;
|
||||
|
||||
struct GpDisplayDriverProperties
|
||||
{
|
||||
typedef void(*TickFunc_t)(void *context, GpFiber *vosFiber);
|
||||
typedef void(*TickFunc_t)(void *context, IGpFiber *vosFiber);
|
||||
typedef void(*RenderFunc_t)(void *context);
|
||||
|
||||
EGpDisplayDriverType m_type;
|
||||
|
||||
17
GpCommon/GpPixelFormat.h
Normal file
17
GpCommon/GpPixelFormat.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
namespace GpPixelFormats
|
||||
{
|
||||
enum GpPixelFormat
|
||||
{
|
||||
kInvalid,
|
||||
|
||||
k8BitStandard,
|
||||
k8BitCustom,
|
||||
kRGB555,
|
||||
kRGB24,
|
||||
kRGB32,
|
||||
};
|
||||
}
|
||||
|
||||
typedef GpPixelFormats::GpPixelFormat GpPixelFormat_t;
|
||||
63
GpCommon/GpRingBuffer.h
Normal file
63
GpCommon/GpRingBuffer.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "GpCoreDefs.h"
|
||||
|
||||
template<class TItem, size_t TCapacity>
|
||||
class GpRingBuffer
|
||||
{
|
||||
public:
|
||||
GpRingBuffer()
|
||||
: m_Size(0)
|
||||
, m_Start(0)
|
||||
{
|
||||
}
|
||||
|
||||
TItem &operator[](size_t index)
|
||||
{
|
||||
assert(index < m_Size);
|
||||
return m_Items[(m_Start + index) % TCapacity];
|
||||
}
|
||||
|
||||
void RemoveFromStart()
|
||||
{
|
||||
assert(m_Size >= 1);
|
||||
m_Start = (m_Start + 1) % TCapacity;
|
||||
m_Size--;
|
||||
}
|
||||
|
||||
void RemoveFromEnd()
|
||||
{
|
||||
assert(m_Size >= 1);
|
||||
m_Size--;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_Size = 0;
|
||||
m_Start = 0;
|
||||
}
|
||||
|
||||
size_t Size() const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
|
||||
TItem *Append()
|
||||
{
|
||||
if (m_Size == TCapacity)
|
||||
return nullptr;
|
||||
|
||||
m_Size++;
|
||||
return &m_Items[(m_Start + (m_Size - 1)) % TCapacity];
|
||||
}
|
||||
|
||||
static const size_t CAPACITY = TCapacity;
|
||||
|
||||
private:
|
||||
TItem m_Items[TCapacity];
|
||||
size_t m_Size;
|
||||
size_t m_Start;
|
||||
};
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#undef CreateMutex
|
||||
|
||||
struct IGpFiber;
|
||||
struct IGpColorCursor_Win32;
|
||||
|
||||
struct GpWindowsGlobals
|
||||
{
|
||||
HINSTANCE m_hInstance;
|
||||
@@ -13,8 +18,8 @@ struct GpWindowsGlobals
|
||||
LPCSTR m_cmdLine;
|
||||
LPCWSTR m_baseDir;
|
||||
int m_nCmdShow;
|
||||
|
||||
IGpFiber *(*m_createFiberFunc)(LPVOID fiber);
|
||||
IGpColorCursor_Win32 *(*m_loadColorCursorFunc)(const wchar_t *path);
|
||||
};
|
||||
|
||||
extern GpWindowsGlobals g_gpWindowsGlobals;
|
||||
|
||||
#undef CreateMutex
|
||||
|
||||
13
GpCommon/IGpColorCursor_Win32.h
Normal file
13
GpCommon/IGpColorCursor_Win32.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGpColorCursor.h"
|
||||
#include "GpWindows.h"
|
||||
|
||||
struct IGpColorCursor_Win32 : public IGpColorCursor
|
||||
{
|
||||
public:
|
||||
virtual const HCURSOR &GetHCursor() const = 0;
|
||||
|
||||
virtual void IncRef() = 0;
|
||||
virtual void DecRef() = 0;
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "PixelFormat.h"
|
||||
#include "GpPixelFormat.h"
|
||||
#include "EGpStandardCursor.h"
|
||||
|
||||
struct IGpDisplayDriverSurface;
|
||||
@@ -13,9 +13,9 @@ public:
|
||||
virtual void Run() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual void GetDisplayResolution(unsigned int *width, unsigned int *height, PortabilityLayer::PixelFormat *bpp) = 0;
|
||||
virtual void GetDisplayResolution(unsigned int *width, unsigned int *height, GpPixelFormat_t *bpp) = 0;
|
||||
|
||||
virtual IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, PortabilityLayer::PixelFormat pixelFormat) = 0;
|
||||
virtual IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) = 0;
|
||||
virtual void DrawSurface(IGpDisplayDriverSurface *surface, size_t x, size_t y, size_t width, size_t height) = 0;
|
||||
|
||||
virtual IGpColorCursor *LoadColorCursor(int cursorID) = 0;
|
||||
|
||||
9
GpCommon/IGpFiber.h
Normal file
9
GpCommon/IGpFiber.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreDefs.h"
|
||||
|
||||
struct IGpFiber
|
||||
{
|
||||
virtual void YieldTo() = 0;
|
||||
virtual void Destroy() = 0;
|
||||
};
|
||||
Reference in New Issue
Block a user