mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-13 19:49:36 +00:00
Font system refactor, use pre-rendered fonts
This commit is contained in:
@@ -63,6 +63,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AerofoilSDL", "AerofoilSDL\
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MergeGPF", "MergeGPF\MergeGPF.vcxproj", "{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GenerateFonts", "GenerateFonts\GenerateFonts.vcxproj", "{3B7FD18D-7A50-4DF5-AC25-543E539BFACE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -175,6 +177,10 @@ Global
|
||||
{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}.Debug|x64.Build.0 = Debug|x64
|
||||
{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}.Release|x64.ActiveCfg = Release|x64
|
||||
{36DAF5FA-6ADB-4F20-9810-1610DE0AE653}.Release|x64.Build.0 = Release|x64
|
||||
{3B7FD18D-7A50-4DF5-AC25-543E539BFACE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3B7FD18D-7A50-4DF5-AC25-543E539BFACE}.Debug|x64.Build.0 = Debug|x64
|
||||
{3B7FD18D-7A50-4DF5-AC25-543E539BFACE}.Release|x64.ActiveCfg = Release|x64
|
||||
{3B7FD18D-7A50-4DF5-AC25-543E539BFACE}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -84,7 +84,6 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="GpBWCursor_Win32.cpp" />
|
||||
<ClCompile Include="GpColorCursor_Win32.cpp" />
|
||||
<ClCompile Include="GpFiber_Win32.cpp" />
|
||||
<ClCompile Include="GpFileStream_Win32.cpp" />
|
||||
<ClCompile Include="GpFileSystem_Win32.cpp" />
|
||||
<ClCompile Include="GpLogDriver_Win32.cpp" />
|
||||
@@ -107,7 +106,6 @@
|
||||
<ClInclude Include="..\GpCommon\IGpLogDriver.h" />
|
||||
<ClInclude Include="..\GpCommon\IGpPrefsHandler.h" />
|
||||
<ClInclude Include="GpBWCursor_Win32.h" />
|
||||
<ClInclude Include="GpFiber_Win32.h" />
|
||||
<ClInclude Include="GpFileStream_Win32.h" />
|
||||
<ClInclude Include="GpFileSystem_Win32.h" />
|
||||
<ClInclude Include="GpLogDriver_Win32.h" />
|
||||
@@ -126,9 +124,6 @@
|
||||
<ProjectReference Include="..\GpDisplayDriver_D3D11\GpDisplayDriver_D3D11.vcxproj">
|
||||
<Project>{ffc961ac-55b4-4a38-a83e-06ae98f59acc}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GpFontHandler_FreeType2\GpFontHandler_FreeType2.vcxproj">
|
||||
<Project>{4b564030-8985-4975-91e1-e1b2c16ae2a1}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GpInputDriver_XInput\GpInputDriver_XInput.vcxproj">
|
||||
<Project>{17b96f07-ef92-47cd-95a5-8e6ee38ab564}</Project>
|
||||
</ProjectReference>
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
<ClCompile Include="GpColorCursor_Win32.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpFiber_Win32.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpFileStream_Win32.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -45,9 +42,6 @@
|
||||
<ClInclude Include="..\GpCommon\GpDisplayDriverTickStatus.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GpFiber_Win32.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\GpCommon\GpFileCreationDisposition.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#include "GpFiber_Win32.h"
|
||||
#include <new>
|
||||
|
||||
GpFiber_Win32::GpFiber_Win32(LPVOID fiber)
|
||||
: m_fiber(fiber)
|
||||
{
|
||||
}
|
||||
|
||||
void GpFiber_Win32::YieldTo(IGpFiber *toFiber)
|
||||
{
|
||||
SwitchToFiber(static_cast<GpFiber_Win32*>(toFiber)->m_fiber);
|
||||
}
|
||||
|
||||
void GpFiber_Win32::YieldToTerminal(IGpFiber *toFiber)
|
||||
{
|
||||
YieldTo(toFiber);
|
||||
}
|
||||
|
||||
void GpFiber_Win32::Destroy()
|
||||
{
|
||||
this->~GpFiber_Win32();
|
||||
free(this);
|
||||
}
|
||||
|
||||
GpFiber_Win32::~GpFiber_Win32()
|
||||
{
|
||||
DeleteFiber(m_fiber);
|
||||
}
|
||||
|
||||
IGpFiber *GpFiber_Win32::Create(LPVOID fiber)
|
||||
{
|
||||
void *storage = malloc(sizeof(GpFiber_Win32));
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
return new (storage) GpFiber_Win32(fiber);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
#include "GpWindows.h"
|
||||
#include "IGpFiber.h"
|
||||
|
||||
class GpFiber_Win32 final : public IGpFiber
|
||||
{
|
||||
public:
|
||||
void YieldTo(IGpFiber *toFiber) override;
|
||||
void YieldToTerminal(IGpFiber *toFiber) override;
|
||||
void Destroy() override;
|
||||
|
||||
static IGpFiber *Create(LPVOID fiber);
|
||||
|
||||
LPVOID GetFiber() const;
|
||||
|
||||
private:
|
||||
explicit GpFiber_Win32(LPVOID fiber);
|
||||
~GpFiber_Win32();
|
||||
|
||||
LPVOID m_fiber;
|
||||
};
|
||||
|
||||
inline LPVOID GpFiber_Win32::GetFiber() const
|
||||
{
|
||||
return m_fiber;
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "GpColorCursor_Win32.h"
|
||||
#include "GpDisplayDriverFactory.h"
|
||||
#include "GpGlobalConfig.h"
|
||||
#include "GpFiber_Win32.h"
|
||||
#include "GpFileSystem_Win32.h"
|
||||
#include "GpLogDriver_Win32.h"
|
||||
#include "GpFontHandlerFactory.h"
|
||||
@@ -28,7 +27,6 @@ GpWindowsGlobals g_gpWindowsGlobals;
|
||||
extern "C" __declspec(dllimport) IGpAudioDriver *GpDriver_CreateAudioDriver_XAudio2(const GpAudioDriverProperties &properties);
|
||||
extern "C" __declspec(dllimport) IGpDisplayDriver *GpDriver_CreateDisplayDriver_D3D11(const GpDisplayDriverProperties &properties);
|
||||
extern "C" __declspec(dllimport) IGpInputDriver *GpDriver_CreateInputDriver_XInput(const GpInputDriverProperties &properties);
|
||||
extern "C" __declspec(dllimport) IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
|
||||
|
||||
static void PostMouseEvent(IGpVOSEventQueue *eventQueue, GpMouseEventType_t eventType, GpMouseButton_t button, int32_t x, int32_t y, float pixelScaleX, float pixelScaleY)
|
||||
{
|
||||
@@ -430,7 +428,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
g_gpWindowsGlobals.m_hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_ICON1));
|
||||
g_gpWindowsGlobals.m_hIconSm = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_ICON2));
|
||||
|
||||
g_gpWindowsGlobals.m_createFiberFunc = GpFiber_Win32::Create;
|
||||
g_gpWindowsGlobals.m_createBWCursorFunc = GpBWCursor_Win32::Create;
|
||||
g_gpWindowsGlobals.m_createColorCursorFunc = GpColorCursor_Win32::Create;
|
||||
g_gpWindowsGlobals.m_translateWindowsMessageFunc = TranslateWindowsMessage;
|
||||
@@ -439,7 +436,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
|
||||
g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_XAudio2;
|
||||
|
||||
g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_FreeType2;
|
||||
g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_None;
|
||||
|
||||
EGpInputDriverType inputDrivers[] =
|
||||
{
|
||||
@@ -456,7 +453,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_D3D11, GpDriver_CreateDisplayDriver_D3D11);
|
||||
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_XAudio2, GpDriver_CreateAudioDriver_XAudio2);
|
||||
GpInputDriverFactory::RegisterInputDriverFactory(EGpInputDriverType_XInput, GpDriver_CreateInputDriver_XInput);
|
||||
GpFontHandlerFactory::RegisterFontHandlerFactory(EGpFontHandlerType_FreeType2, GpDriver_CreateFontHandler_FreeType2);
|
||||
|
||||
if (logger)
|
||||
logger->Printf(IGpLogDriver::Category_Information, "Windows environment configured, starting up");
|
||||
|
||||
8
AerofoilPortable.props
Normal file
8
AerofoilPortable.props
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup />
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "GpAudioDriverFactory.h"
|
||||
#include "GpDisplayDriverFactory.h"
|
||||
#include "GpGlobalConfig.h"
|
||||
#include "GpFiber_Win32.h"
|
||||
#include "GpFileSystem_Win32.h"
|
||||
#include "GpLogDriver_Win32.h"
|
||||
#include "GpFontHandlerFactory.h"
|
||||
|
||||
12
AerofoilWin.props
Normal file
12
AerofoilWin.props
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Aerofoil;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
@@ -14,8 +14,6 @@
|
||||
"DITL/2008.json" : "ApplicationResourcePatches/DITL/2008.json",
|
||||
"PICT/1300.bmp" : "ApplicationResourcePatches/PICT/1300.bmp",
|
||||
"PICT/1301.bmp" : "ApplicationResourcePatches/PICT/1301.bmp",
|
||||
"PICT/1302.bmp" : "ApplicationResourcePatches/PICT/1302.bmp",
|
||||
"PICT/1303.bmp" : "ApplicationResourcePatches/PICT/1303.bmp",
|
||||
"PICT/1971.bmp" : "ApplicationResourcePatches/PICT/1971.bmp",
|
||||
"PICT/1972.bmp" : "ApplicationResourcePatches/PICT/1972.bmp",
|
||||
"PICT/1973.bmp" : "ApplicationResourcePatches/PICT/1973.bmp",
|
||||
|
||||
@@ -4,12 +4,23 @@ mkdir Packaged
|
||||
mkdir Packaged\Houses
|
||||
|
||||
x64\Release\MiniRez.exe "GliderProData\Glider PRO.r" Packaged\ApplicationResources.gpr
|
||||
|
||||
x64\Release\gpr2gpa.exe "Packaged\ApplicationResources.gpr" "DefaultTimestamp.timestamp" "Packaged\ApplicationResources.gpa" "ApplicationResourcePatches\manifest.json"
|
||||
x64\Release\FTagData.exe "DefaultTimestamp.timestamp" "Packaged\ApplicationResources.gpf" data ozm5 0 0 locked
|
||||
|
||||
x64\Release\MergeGPF.exe "Packaged\ApplicationResources.gpf"
|
||||
|
||||
x64\Release\GenerateFonts.exe
|
||||
|
||||
x64\Release\MiniRez.exe "Empty.r" Packaged\Fonts.gpr
|
||||
x64\Release\gpr2gpa.exe "Packaged\Fonts.gpr" "DefaultTimestamp.timestamp" "Packaged\Fonts.gpa" "Packaged\FontCacheManifest.json"
|
||||
x64\Release\FTagData.exe "DefaultTimestamp.timestamp" "Packaged\Fonts.gpf" data ozm5 0 0 locked
|
||||
x64\Release\MergeGPF.exe "Packaged\Fonts.gpf"
|
||||
|
||||
del /Q Packaged\CachedFont*.bin
|
||||
del Packaged\FontCacheCatalog.bin
|
||||
del Packaged\FontCacheManifest.json
|
||||
del Packaged\Fonts.gpr
|
||||
del Packaged\Fonts.gpa
|
||||
|
||||
x64\Release\ConvertColorCursors.exe
|
||||
|
||||
attrib -R Packaged\ApplicationResources.gpf
|
||||
|
||||
313
GenerateFonts/GenerateFonts.cpp
Normal file
313
GenerateFonts/GenerateFonts.cpp
Normal file
@@ -0,0 +1,313 @@
|
||||
#include "FontFamily.h"
|
||||
#include "FontManager.h"
|
||||
#include "FontRenderer.h"
|
||||
#include "IGpFont.h"
|
||||
#include "IGpFontHandler.h"
|
||||
#include "GpAppInterface.h"
|
||||
#include "GpDriverIndex.h"
|
||||
#include "GpFontHandlerProperties.h"
|
||||
#include "GpFileSystem_Win32.h"
|
||||
#include "GpSystemServices_Win32.h"
|
||||
#include "CFileStream.h"
|
||||
|
||||
#include "PLDrivers.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "RenderedFontCatalog.h"
|
||||
|
||||
#include "WindowsUnicodeToolShim.h"
|
||||
|
||||
extern "C" __declspec(dllimport) IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
|
||||
|
||||
class MemBufferStream final : public GpIOStream
|
||||
{
|
||||
public:
|
||||
size_t Read(void *bytesOut, size_t size) override;
|
||||
size_t Write(const void *bytes, size_t size) override;
|
||||
bool IsSeekable() const override;
|
||||
bool IsReadOnly() const override;
|
||||
bool IsWriteOnly() const override;
|
||||
bool SeekStart(GpUFilePos_t loc) override;
|
||||
bool SeekCurrent(GpFilePos_t loc) override;
|
||||
bool SeekEnd(GpUFilePos_t loc) override;
|
||||
GpUFilePos_t Size() const override;
|
||||
GpUFilePos_t Tell() const override;
|
||||
void Close() override;
|
||||
void Flush() override;
|
||||
|
||||
const uint8_t *GetBytes() const;
|
||||
|
||||
private:
|
||||
size_t m_writeOffset;
|
||||
std::vector<uint8_t> m_buffer;
|
||||
};
|
||||
|
||||
size_t MemBufferStream::Read(void *bytesOut, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t MemBufferStream::Write(const void *bytes, size_t size)
|
||||
{
|
||||
const uint8_t *bytesUInt8 = static_cast<const uint8_t*>(bytes);
|
||||
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
if (m_writeOffset == m_buffer.size())
|
||||
m_buffer.push_back(bytesUInt8[i]);
|
||||
else
|
||||
m_buffer[m_writeOffset] = bytesUInt8[i];
|
||||
|
||||
m_writeOffset++;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
bool MemBufferStream::IsSeekable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MemBufferStream::IsReadOnly() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MemBufferStream::IsWriteOnly() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MemBufferStream::SeekStart(GpUFilePos_t loc)
|
||||
{
|
||||
m_writeOffset = static_cast<size_t>(loc);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MemBufferStream::SeekCurrent(GpFilePos_t loc)
|
||||
{
|
||||
m_writeOffset = static_cast<size_t>(static_cast<GpFilePos_t>(m_writeOffset) + loc);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MemBufferStream::SeekEnd(GpUFilePos_t loc)
|
||||
{
|
||||
m_writeOffset = this->Size() - loc;
|
||||
return true;
|
||||
}
|
||||
|
||||
GpUFilePos_t MemBufferStream::Size() const
|
||||
{
|
||||
return m_buffer.size();
|
||||
}
|
||||
|
||||
GpUFilePos_t MemBufferStream::Tell() const
|
||||
{
|
||||
return m_writeOffset;
|
||||
}
|
||||
|
||||
void MemBufferStream::Close()
|
||||
{
|
||||
}
|
||||
|
||||
void MemBufferStream::Flush()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const uint8_t *MemBufferStream::GetBytes() const
|
||||
{
|
||||
return &m_buffer[0];
|
||||
}
|
||||
|
||||
struct KnownFontSpec
|
||||
{
|
||||
public:
|
||||
KnownFontSpec();
|
||||
KnownFontSpec(const char *path, int size, bool aa, PortabilityLayer::FontHacks hacks);
|
||||
|
||||
bool operator==(const KnownFontSpec &other) const;
|
||||
bool operator!=(const KnownFontSpec &other) const;
|
||||
|
||||
private:
|
||||
std::string m_path;
|
||||
int m_size;
|
||||
bool m_aa;
|
||||
PortabilityLayer::FontHacks m_hacks;
|
||||
};
|
||||
|
||||
|
||||
KnownFontSpec::KnownFontSpec()
|
||||
: m_size(0)
|
||||
, m_aa(false)
|
||||
, m_hacks(PortabilityLayer::FontHacks_None)
|
||||
{
|
||||
}
|
||||
|
||||
KnownFontSpec::KnownFontSpec(const char *path, int size, bool aa, PortabilityLayer::FontHacks hacks)
|
||||
: m_path(path)
|
||||
, m_size(size)
|
||||
, m_aa(aa)
|
||||
, m_hacks(hacks)
|
||||
{
|
||||
}
|
||||
|
||||
bool KnownFontSpec::operator==(const KnownFontSpec &other) const
|
||||
{
|
||||
return !((*this) != other);
|
||||
}
|
||||
|
||||
bool KnownFontSpec::operator!=(const KnownFontSpec &other) const
|
||||
{
|
||||
return m_path != other.m_path ||
|
||||
m_size != other.m_size ||
|
||||
m_aa != other.m_aa ||
|
||||
m_hacks != other.m_hacks;
|
||||
}
|
||||
|
||||
int toolMain(int argc, const char **argv)
|
||||
{
|
||||
GpFontHandlerProperties fhProperties;
|
||||
fhProperties.m_type = EGpFontHandlerType_FreeType2;
|
||||
|
||||
IGpFontHandler *ft2Handler = GpDriver_CreateFontHandler_FreeType2(fhProperties);
|
||||
|
||||
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
|
||||
PortabilityLayer::FontRenderer *fontRenderer = PortabilityLayer::FontRenderer::GetInstance();
|
||||
fontManager->Init();
|
||||
|
||||
std::vector<std::string> paths;
|
||||
std::vector<PortabilityLayer::RenderedFontCatalogRFontEntry> catalog;
|
||||
std::vector<KnownFontSpec> fontSpecs;
|
||||
|
||||
FILE *manifestF = fopen_utf8("Packaged/FontCacheManifest.json", "wb");
|
||||
|
||||
fprintf(manifestF, "{\n");
|
||||
fprintf(manifestF, "\t\"add\" :\n");
|
||||
fprintf(manifestF, "\t{\n");
|
||||
fprintf(manifestF, "\t\t\"RFCT/1000.bin\" : \"Packaged/FontCacheCatalog.bin\"");
|
||||
|
||||
int numFontsEmitted = 0;
|
||||
for (int presetIndex = 0; presetIndex < PortabilityLayer::FontPresets::kCount; presetIndex++)
|
||||
{
|
||||
int size = 0;
|
||||
int flags = 0;
|
||||
bool aa = false;
|
||||
PortabilityLayer::FontFamilyID_t fontFamilyID;
|
||||
|
||||
fontManager->GetFontPreset(static_cast<PortabilityLayer::FontPreset_t>(presetIndex), &fontFamilyID, &size, &flags, &aa);
|
||||
PortabilityLayer::FontFamily *fontFamily = fontManager->GetFont(fontFamilyID);
|
||||
|
||||
int variation = fontFamily->GetVariationForFlags(flags);
|
||||
|
||||
PortabilityLayer::FontHacks hacks;
|
||||
const char *path = nullptr;
|
||||
fontFamily->GetFontSpec(variation, hacks, path);
|
||||
|
||||
KnownFontSpec spec(path, size, aa, hacks);
|
||||
|
||||
if (std::find(fontSpecs.begin(), fontSpecs.end(), spec) != fontSpecs.end())
|
||||
continue;
|
||||
|
||||
fontSpecs.push_back(spec);
|
||||
|
||||
std::string resPath = std::string("Resources/") + path;
|
||||
FILE *fontFile = fopen_utf8(resPath.c_str(), "rb");
|
||||
|
||||
if (fontFile)
|
||||
{
|
||||
PortabilityLayer::CFileStream stream(fontFile);
|
||||
|
||||
IGpFont *font = ft2Handler->LoadFont(&stream);
|
||||
if (!ft2Handler->KeepStreamOpen())
|
||||
stream.Close();
|
||||
|
||||
PortabilityLayer::RenderedFont *rfont = fontRenderer->RenderFont(font, size, aa, hacks);
|
||||
|
||||
|
||||
{
|
||||
char fontPath[1024];
|
||||
sprintf(fontPath, "Packaged/CachedFont%i.bin", numFontsEmitted);
|
||||
|
||||
FILE *cachedFontF = fopen_utf8(fontPath, "wb");
|
||||
PortabilityLayer::CFileStream cacheStream(cachedFontF);
|
||||
|
||||
fontRenderer->SaveCache(rfont, &cacheStream);
|
||||
cacheStream.Close();
|
||||
|
||||
fprintf(manifestF, ",\n\t\t\"RFNT/%i.bin\" : \"%s\"", 1000 + numFontsEmitted, fontPath);
|
||||
}
|
||||
|
||||
rfont->Destroy();
|
||||
|
||||
font->Destroy();
|
||||
|
||||
PortabilityLayer::RenderedFontCatalogRFontEntry catEntry;
|
||||
catEntry.m_fontSize = static_cast<uint8_t>(size);
|
||||
catEntry.m_hacks = static_cast<uint8_t>(hacks);
|
||||
catEntry.m_isAA = aa ? 1 : 0;
|
||||
catEntry.m_pathIndex = 0;
|
||||
|
||||
bool foundPath = false;
|
||||
for (size_t i = 0; i < paths.size(); i++)
|
||||
{
|
||||
if (paths[i] == path)
|
||||
{
|
||||
catEntry.m_pathIndex = static_cast<uint8_t>(i);
|
||||
foundPath = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPath)
|
||||
{
|
||||
catEntry.m_pathIndex = static_cast<uint8_t>(paths.size());
|
||||
paths.push_back(std::string(path));
|
||||
}
|
||||
|
||||
catalog.push_back(catEntry);
|
||||
|
||||
numFontsEmitted++;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(manifestF, "\n\t},\n");
|
||||
fprintf(manifestF, "\t\"delete\" :\n");
|
||||
fprintf(manifestF, "\t[\n");
|
||||
fprintf(manifestF, "\t]\n");
|
||||
fprintf(manifestF, "}\n");
|
||||
|
||||
PortabilityLayer::RenderedFontCatalogHeader catHeader;
|
||||
|
||||
FILE *catF = fopen_utf8("Packaged/FontCacheCatalog.bin", "wb");
|
||||
|
||||
catHeader.m_version = PortabilityLayer::RenderedFontCatalogHeader::kVersion;
|
||||
catHeader.m_pathsOffset = static_cast<uint32_t>(sizeof(PortabilityLayer::RenderedFontCatalogHeader) + paths.size() * sizeof(PortabilityLayer::RenderedFontCatalogPathEntry) + numFontsEmitted * sizeof(PortabilityLayer::RenderedFontCatalogRFontEntry));
|
||||
catHeader.m_numPaths = static_cast<uint16_t>(paths.size());
|
||||
catHeader.m_numRFonts = static_cast<uint16_t>(numFontsEmitted);
|
||||
|
||||
fwrite(&catHeader, sizeof(catHeader), 1, catF);
|
||||
|
||||
PortabilityLayer::RenderedFontCatalogPathEntry pathEntry;
|
||||
pathEntry.m_pathOffset = 0;
|
||||
pathEntry.m_pathSize = 0;
|
||||
for (size_t i = 0; i < paths.size(); i++)
|
||||
{
|
||||
pathEntry.m_pathOffset = static_cast<uint16_t>(pathEntry.m_pathOffset) + pathEntry.m_pathSize;
|
||||
pathEntry.m_pathSize = static_cast<uint16_t>(paths[i].size());
|
||||
|
||||
fwrite(&pathEntry, sizeof(pathEntry), 1, catF);
|
||||
}
|
||||
|
||||
fwrite(&catalog[0], sizeof(PortabilityLayer::RenderedFontCatalogRFontEntry), catalog.size(), catF);
|
||||
|
||||
for (size_t i = 0; i < paths.size(); i++)
|
||||
{
|
||||
const std::string &str = paths[i];
|
||||
fwrite(&str[0], str.size(), 1, catF);
|
||||
}
|
||||
|
||||
fclose(catF);
|
||||
|
||||
return 0;
|
||||
}
|
||||
101
GenerateFonts/GenerateFonts.vcxproj
Normal file
101
GenerateFonts/GenerateFonts.vcxproj
Normal file
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{3B7FD18D-7A50-4DF5-AC25-543E539BFACE}</ProjectGuid>
|
||||
<RootNamespace>GenerateFonts</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\PortabilityLayer.props" />
|
||||
<Import Project="..\AerofoilWin.props" />
|
||||
<Import Project="..\Debug.props" />
|
||||
<Import Project="..\WindowsUnicodeToolShim.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\PortabilityLayer.props" />
|
||||
<Import Project="..\AerofoilWin.props" />
|
||||
<Import Project="..\Release.props" />
|
||||
<Import Project="..\WindowsUnicodeToolShim.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GpFontHandler_FreeType2\GpFontHandler_FreeType2.vcxproj">
|
||||
<Project>{4b564030-8985-4975-91e1-e1b2c16ae2a1}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\PortabilityLayer\PortabilityLayer.vcxproj">
|
||||
<Project>{6ec62b0f-9353-40a4-a510-3788f1368b33}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WindowsUnicodeToolShim\WindowsUnicodeToolShim.vcxproj">
|
||||
<Project>{15009625-1120-405e-8bba-69a16cd6713d}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="GenerateFonts.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
22
GenerateFonts/GenerateFonts.vcxproj.filters
Normal file
22
GenerateFonts/GenerateFonts.vcxproj.filters
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="GenerateFonts.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -314,8 +314,8 @@ void DoAboutFramework (void)
|
||||
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR(""));
|
||||
|
||||
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *fontLight = GetApplicationFont(8, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *font = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
PortabilityLayer::RenderedFont *fontLight = GetFont(PortabilityLayer::FontPresets::kApplication8);
|
||||
|
||||
int16_t verticalPoint = 16 + font->GetMetrics().m_ascent;
|
||||
int16_t horizontalOffset = 16;
|
||||
@@ -578,7 +578,7 @@ static int16_t AboutFrameworkFilter(void *context, Dialog *dialog, const TimeTag
|
||||
|
||||
void DrawLicenseReader(Window *window)
|
||||
{
|
||||
PortabilityLayer::RenderedFont *rfont = GetMonospaceFont(10, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kMono10);
|
||||
if (!rfont)
|
||||
return;
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ void DrawBannerMessage (Point topLeft)
|
||||
|
||||
PasStringCopy((*thisHouse)->banner, bannerStr);
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
|
||||
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
|
||||
|
||||
@@ -221,7 +221,7 @@ void DisplayStarsRemaining(void)
|
||||
|
||||
DrawSurface *surface = starsWindow->GetDrawSurface();
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
|
||||
NumToString((long)numStarsRemaining, theStr);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ void UpdateCoordWindow (void)
|
||||
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
|
||||
PortabilityLayer::ResolveCachingColor blueColor = StdColors::Blue();
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, 0, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication9);
|
||||
|
||||
DrawSurface *surface = coordWindow->GetDrawSurface();
|
||||
|
||||
|
||||
@@ -568,7 +568,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
|
||||
|
||||
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication9);
|
||||
|
||||
PasStringCopy(text, stringCopy);
|
||||
|
||||
@@ -619,7 +619,7 @@ void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
|
||||
Str255 stringCopy;
|
||||
|
||||
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication9);
|
||||
|
||||
PasStringCopy(text, stringCopy);
|
||||
const Rect iRect = dial->GetItems()[item - 1].GetWidget()->GetRect();
|
||||
|
||||
@@ -107,7 +107,7 @@ void SetUpFinalScreen (void)
|
||||
{
|
||||
GetLineOfText(tempStr, count, subStr);
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
offset = ((thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) -
|
||||
appFont->MeasurePStr(subStr)) / 2;
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ void DrawHighScores (DrawSurface *surface)
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont14 = GetApplicationFont(14, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont14 = GetFont(PortabilityLayer::FontPresets::kApplication14Bold);
|
||||
|
||||
PasStringCopy(PSTR("\xa5 "), tempStr);
|
||||
PasStringConcat(tempStr, thisHouseName);
|
||||
@@ -157,7 +157,7 @@ void DrawHighScores (DrawSurface *surface)
|
||||
const Point scoreTextPoint = Point::Create(scoreLeft + ((kScoreWide - appFont14->MeasurePStr(tempStr)) / 2), dropIt - 65);
|
||||
surface->DrawString(scoreTextPoint, tempStr, cyanColor, appFont14);
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont12 = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont12 = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
|
||||
thisHousePtr = *thisHouse;
|
||||
// message for score #1
|
||||
@@ -264,7 +264,7 @@ void DrawHighScores (DrawSurface *surface)
|
||||
}
|
||||
}
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont9 = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont9 = GetFont(PortabilityLayer::FontPresets::kApplication9Bold);
|
||||
|
||||
const Point textPos = Point::Create(scoreLeft + 80, dropIt - 1 + (10 * kScoreSpacing));
|
||||
GetLocalizedString(8, tempStr);
|
||||
|
||||
@@ -158,7 +158,7 @@ void DrawTouchScreenMenu (DrawSurface *surface, const THandle<BitmapImage> &back
|
||||
|
||||
const int numItems = sizeof(itemTexts) / sizeof(itemTexts[0]);
|
||||
|
||||
PortabilityLayer::RenderedFont *rfont = GetHandwritingFont(48, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kHandwriting48);
|
||||
if (!rfont)
|
||||
return;
|
||||
|
||||
|
||||
580
GpApp/Main.cpp
580
GpApp/Main.cpp
@@ -43,14 +43,6 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
int loadScreenWindowPhase;
|
||||
int loadScreenRingStep;
|
||||
WindowPtr loadScreenWindow;
|
||||
Rect loadScreenProgressBarRect;
|
||||
int loadScreenProgress;
|
||||
DrawSurface *loadScreenRingSurface;
|
||||
|
||||
|
||||
#define kPrefsVersion 0x0039
|
||||
|
||||
|
||||
@@ -364,548 +356,6 @@ void WriteOutPrefs (void)
|
||||
modulePrefs.Dispose();
|
||||
}
|
||||
|
||||
void StepLoadScreenRing()
|
||||
{
|
||||
if (loadScreenWindow)
|
||||
{
|
||||
const int loadScreenStepGranularity = 2;
|
||||
loadScreenRingStep++;
|
||||
if (loadScreenRingStep == 24 * loadScreenStepGranularity)
|
||||
loadScreenRingStep = 0;
|
||||
|
||||
Rect ringDestRect = Rect::Create(8, 8, 24, 24);
|
||||
Rect ringSrcRect = Rect::Create(0, 0, 16, 16) + Point::Create((loadScreenRingStep / loadScreenStepGranularity) * 16, 0);
|
||||
|
||||
if (loadScreenWindowPhase == 0)
|
||||
{
|
||||
ringDestRect = Rect::Create(0, 0, 64, 64);
|
||||
|
||||
const int progression = (loadScreenRingStep / loadScreenStepGranularity);
|
||||
ringSrcRect = Rect::Create(0, 0, 64, 64) + Point::Create((progression % 6) * 64, (progression / 6) * 64);
|
||||
}
|
||||
|
||||
CopyBits(*loadScreenRingSurface->m_port.GetPixMap(), *loadScreenWindow->GetDrawSurface()->m_port.GetPixMap(), &ringSrcRect, &ringDestRect, srcCopy);
|
||||
loadScreenWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateLoadScreenWindow(int phase)
|
||||
{
|
||||
FlushResolutionChange();
|
||||
|
||||
if (loadScreenRingSurface)
|
||||
{
|
||||
DisposeGWorld(loadScreenRingSurface);
|
||||
loadScreenRingSurface = nullptr;
|
||||
}
|
||||
|
||||
if (loadScreenWindow)
|
||||
{
|
||||
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(loadScreenWindow);
|
||||
loadScreenWindow = nullptr;
|
||||
}
|
||||
|
||||
if (phase == 0)
|
||||
{
|
||||
static const int kLoadScreenHeight = 64;
|
||||
static const int kLoadScreenWidth = 64;
|
||||
static const int kLoadRingResource = 1303;
|
||||
|
||||
ForceSyncFrame();
|
||||
PLSysCalls::Sleep(1);
|
||||
|
||||
THandle<BitmapImage> loadRingImageH = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kLoadRingResource).StaticCast<BitmapImage>();
|
||||
BitmapImage *loadRingImage = *loadRingImageH;
|
||||
|
||||
DrawSurface *loadRingSurface = nullptr;
|
||||
Rect loadRingRect = loadRingImage->GetRect();
|
||||
loadRingRect.right *= 2;
|
||||
loadRingRect.bottom *= 2;
|
||||
CreateOffScreenGWorld(&loadRingSurface, &loadRingRect);
|
||||
loadRingSurface->DrawPicture(loadRingImageH, loadRingRect, false);
|
||||
|
||||
int32_t lsX = (thisMac.fullScreen.Width() - kLoadScreenWidth) / 2;
|
||||
int32_t lsY = (thisMac.fullScreen.Height() - kLoadScreenHeight) / 2;
|
||||
|
||||
|
||||
const Rect loadScreenRect = Rect::Create(lsY, lsX, lsY + kLoadScreenHeight, lsX + kLoadScreenWidth);
|
||||
const Rect loadScreenLocalRect = Rect::Create(0, 0, loadScreenRect.Height(), loadScreenRect.Width());
|
||||
|
||||
PortabilityLayer::WindowDef def = PortabilityLayer::WindowDef::Create(loadScreenRect, PortabilityLayer::WindowStyleFlags::kBorderless, true, 0, 0, PSTR(""));
|
||||
|
||||
loadScreenWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(def);
|
||||
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(loadScreenWindow, PL_GetPutInFrontWindowPtr());
|
||||
|
||||
DrawSurface *surface = loadScreenWindow->GetDrawSurface();
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
|
||||
surface->FillRect(loadScreenLocalRect, blackColor);
|
||||
|
||||
loadScreenProgressBarRect = Rect::Create(0, 0, 0, 0);
|
||||
loadScreenProgress = 0;
|
||||
|
||||
Rect ringDestRect = Rect::Create(0, 0, 64, 64);
|
||||
Rect ringSrcRect = Rect::Create(0, 0, 64, 64);
|
||||
CopyBits(*loadRingSurface->m_port.GetPixMap(), *surface->m_port.GetPixMap(), &ringSrcRect, &ringDestRect, srcCopy);
|
||||
|
||||
loadRingImageH.Dispose();
|
||||
|
||||
loadScreenRingSurface = loadRingSurface;
|
||||
}
|
||||
else if (phase == 1)
|
||||
{
|
||||
static const int kLoadScreenHeight = 32;
|
||||
static const int kLoadRingResource = 1302;
|
||||
|
||||
int kLoadScreenWidth = 296;
|
||||
PLPasStr loadingText = PSTR("Loading...");
|
||||
|
||||
if (!isPrefsLoaded)
|
||||
{
|
||||
loadingText = PSTR("Getting some things ready...");
|
||||
kLoadScreenWidth = 440;
|
||||
}
|
||||
|
||||
ForceSyncFrame();
|
||||
PLSysCalls::Sleep(1);
|
||||
|
||||
THandle<BitmapImage> loadRingImageH = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', kLoadRingResource).StaticCast<BitmapImage>();
|
||||
BitmapImage *loadRingImage = *loadRingImageH;
|
||||
|
||||
DrawSurface *loadRingSurface = nullptr;
|
||||
Rect loadRingRect = loadRingImage->GetRect();
|
||||
CreateOffScreenGWorld(&loadRingSurface, &loadRingRect);
|
||||
loadRingSurface->DrawPicture(loadRingImageH, loadRingRect, false);
|
||||
|
||||
int32_t lsX = (thisMac.fullScreen.Width() - kLoadScreenWidth) / 2;
|
||||
int32_t lsY = (thisMac.fullScreen.Height() - kLoadScreenHeight) / 2;
|
||||
|
||||
|
||||
const Rect loadScreenRect = Rect::Create(lsY, lsX, lsY + kLoadScreenHeight, lsX + kLoadScreenWidth);
|
||||
const Rect loadScreenLocalRect = Rect::Create(0, 0, loadScreenRect.Height(), loadScreenRect.Width());
|
||||
|
||||
PortabilityLayer::WindowDef def = PortabilityLayer::WindowDef::Create(loadScreenRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR(""));
|
||||
|
||||
loadScreenWindow = PortabilityLayer::WindowManager::GetInstance()->CreateWindow(def);
|
||||
PortabilityLayer::WindowManager::GetInstance()->PutWindowBehind(loadScreenWindow, PL_GetPutInFrontWindowPtr());
|
||||
|
||||
DrawSurface *surface = loadScreenWindow->GetDrawSurface();
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::ResolveCachingColor whiteColor(StdColors::White());
|
||||
|
||||
surface->FillRect(loadScreenLocalRect, whiteColor);
|
||||
|
||||
PortabilityLayer::WindowManager::GetInstance()->FlickerWindowIn(loadScreenWindow, 32);
|
||||
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(18, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
int32_t textY = (kLoadScreenHeight + font->GetMetrics().m_ascent) / 2;
|
||||
surface->DrawString(Point::Create(4 + 16 + 8, textY), loadingText, blackColor, font);
|
||||
|
||||
static const int32_t loadBarPadding = 16;
|
||||
static const int32_t loadBarHeight = 10;
|
||||
int32_t loadBarStartX = static_cast<int32_t>(font->MeasureString(loadingText.UChars(), loadingText.Length())) + 4 + 16 + 8 + loadBarPadding;
|
||||
int32_t loadBarEndX = loadScreenLocalRect.right - loadBarPadding;
|
||||
|
||||
loadScreenProgressBarRect = Rect::Create((loadScreenLocalRect.Height() - loadBarHeight) / 2, loadBarStartX, (loadScreenLocalRect.Height() + loadBarHeight) / 2, loadBarEndX);
|
||||
|
||||
PortabilityLayer::ResolveCachingColor partialFillColor(PortabilityLayer::RGBAColor::Create(255, 255, 204, 255));
|
||||
surface->FrameRect(loadScreenProgressBarRect, blackColor);
|
||||
surface->FillRect(loadScreenProgressBarRect.Inset(1, 1), partialFillColor);
|
||||
|
||||
Rect ringDestRect = Rect::Create(8, 8, 24, 24);
|
||||
Rect ringSrcRect = Rect::Create(0, 0, 16, 16);
|
||||
CopyBits(*loadRingSurface->m_port.GetPixMap(), *surface->m_port.GetPixMap(), &ringSrcRect, &ringDestRect, srcCopy);
|
||||
|
||||
loadRingImageH.Dispose();
|
||||
|
||||
loadScreenRingSurface = loadRingSurface;
|
||||
}
|
||||
}
|
||||
|
||||
void StepLoadScreen(int steps, bool insertDelay)
|
||||
{
|
||||
if (loadScreenWindow)
|
||||
{
|
||||
static const int kLoadScreenPhaseSwitchBreakpoint = 20;
|
||||
|
||||
int oldProgress = loadScreenProgress;
|
||||
|
||||
if (loadScreenProgress + steps >= kLoadScreenPhaseSwitchBreakpoint && loadScreenWindowPhase == 0)
|
||||
{
|
||||
loadScreenWindowPhase = 1;
|
||||
CreateLoadScreenWindow(loadScreenWindowPhase);
|
||||
|
||||
// Reset old progress since the progress bar was redrawn
|
||||
oldProgress = 0;
|
||||
}
|
||||
|
||||
const Rect loadScreenProgressBarFillRect = loadScreenProgressBarRect.Inset(1, 1);
|
||||
|
||||
int loadScreenMax = 43;
|
||||
loadScreenProgress = loadScreenProgress + steps;
|
||||
if (loadScreenProgress > loadScreenMax)
|
||||
loadScreenProgress = loadScreenMax;
|
||||
|
||||
PortabilityLayer::ResolveCachingColor fillColor(PortabilityLayer::RGBAColor::Create(51, 51, 51, 255));
|
||||
|
||||
int prevStep = oldProgress * loadScreenProgressBarFillRect.Width() / loadScreenMax;
|
||||
int thisStep = loadScreenProgress * loadScreenProgressBarFillRect.Width() / loadScreenMax;
|
||||
|
||||
loadScreenWindow->GetDrawSurface()->FillRect(Rect::Create(loadScreenProgressBarFillRect.top, loadScreenProgressBarFillRect.left + prevStep, loadScreenProgressBarFillRect.bottom, loadScreenProgressBarFillRect.left + thisStep), fillColor);
|
||||
ForceSyncFrame();
|
||||
|
||||
if (insertDelay)
|
||||
{
|
||||
StepLoadScreenRing();
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
SpinCursor(steps);
|
||||
}
|
||||
|
||||
void InitLoadingWindow()
|
||||
{
|
||||
if (!thisMac.isTouchscreen && isPrefsLoaded)
|
||||
return;
|
||||
|
||||
if (isPrefsLoaded)
|
||||
loadScreenWindowPhase = 1;
|
||||
else
|
||||
loadScreenWindowPhase = 0;
|
||||
|
||||
CreateLoadScreenWindow(loadScreenWindowPhase);
|
||||
}
|
||||
|
||||
enum PreloadFontCategory
|
||||
{
|
||||
FontCategory_System,
|
||||
FontCategory_Application,
|
||||
FontCategory_Handwriting,
|
||||
FontCategory_Monospace,
|
||||
};
|
||||
|
||||
struct PreloadFontSpec
|
||||
{
|
||||
PreloadFontCategory m_category;
|
||||
int m_size;
|
||||
int m_flags;
|
||||
bool m_aa;
|
||||
};
|
||||
|
||||
struct PreloadFontWorkSlot
|
||||
{
|
||||
IGpThreadEvent *m_completedEvent;
|
||||
PortabilityLayer::WorkerThread *m_workerThread;
|
||||
std::atomic<int> m_singleJobCompleted;
|
||||
const PreloadFontSpec *m_spec;
|
||||
bool m_queued;
|
||||
|
||||
PreloadFontWorkSlot();
|
||||
~PreloadFontWorkSlot();
|
||||
};
|
||||
|
||||
PreloadFontWorkSlot::PreloadFontWorkSlot()
|
||||
: m_completedEvent(nullptr)
|
||||
, m_workerThread(nullptr)
|
||||
, m_spec(nullptr)
|
||||
, m_queued(false)
|
||||
{
|
||||
}
|
||||
|
||||
PreloadFontWorkSlot::~PreloadFontWorkSlot()
|
||||
{
|
||||
if (m_workerThread)
|
||||
m_workerThread->Destroy();
|
||||
}
|
||||
|
||||
void PreloadSingleFont (const PreloadFontSpec &spec)
|
||||
{
|
||||
switch (spec.m_category)
|
||||
{
|
||||
case FontCategory_Application:
|
||||
GetApplicationFont(spec.m_size, spec.m_flags, spec.m_aa);
|
||||
break;
|
||||
case FontCategory_System:
|
||||
GetSystemFont(spec.m_size, spec.m_flags, spec.m_aa);
|
||||
break;
|
||||
case FontCategory_Handwriting:
|
||||
GetHandwritingFont(spec.m_size, spec.m_flags, spec.m_aa);
|
||||
break;
|
||||
case FontCategory_Monospace:
|
||||
GetMonospaceFont(spec.m_size, spec.m_flags, spec.m_aa);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PreloadFontThreadFunc(void *context)
|
||||
{
|
||||
PreloadFontWorkSlot *wSlot = static_cast<PreloadFontWorkSlot*>(context);
|
||||
|
||||
PreloadSingleFont(*wSlot->m_spec);
|
||||
wSlot->m_singleJobCompleted.fetch_add(1, std::memory_order_release);
|
||||
wSlot->m_completedEvent->Signal();
|
||||
}
|
||||
|
||||
void PreloadFonts()
|
||||
{
|
||||
static PreloadFontSpec specs[] =
|
||||
{
|
||||
// First entry should be the one needed to show the load screen
|
||||
{ FontCategory_Application, 18, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
|
||||
{ FontCategory_System, 9, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_System, 10, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_System, 12, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_System, 12, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_Application, 8, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Application, 9, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Application, 12, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_Application, 14, PortabilityLayer::FontFamilyFlag_Bold, true },
|
||||
{ FontCategory_Application, 14, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Application, 40, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Handwriting, 24, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Handwriting, 48, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
{ FontCategory_Monospace, 10, PortabilityLayer::FontFamilyFlag_None, true },
|
||||
};
|
||||
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
|
||||
const int numFontSpecs = sizeof(specs) / sizeof(specs[0]);
|
||||
|
||||
int queuedSpecs = 0;
|
||||
int completedSpecs = 0;
|
||||
|
||||
// We can't actually slot these because FT isn't thread-safe when accessing the same font,
|
||||
// but we can do this to unclog the render thread.
|
||||
PreloadFontWorkSlot slot;
|
||||
slot.m_workerThread = PortabilityLayer::WorkerThread::Create();
|
||||
slot.m_completedEvent = PLDrivers::GetSystemServices()->CreateThreadEvent(true, false);
|
||||
|
||||
while (completedSpecs < numFontSpecs)
|
||||
{
|
||||
if (slot.m_queued)
|
||||
{
|
||||
if (slot.m_singleJobCompleted.load(std::memory_order_acquire) != 0)
|
||||
{
|
||||
slot.m_completedEvent->Wait();
|
||||
slot.m_queued = false;
|
||||
completedSpecs++;
|
||||
|
||||
StepLoadScreen(1, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!slot.m_queued)
|
||||
{
|
||||
if (queuedSpecs < numFontSpecs)
|
||||
{
|
||||
slot.m_queued = true;
|
||||
slot.m_spec = specs + queuedSpecs;
|
||||
slot.m_singleJobCompleted.store(0, std::memory_order_release);
|
||||
slot.m_workerThread->AsyncExecuteTask(PreloadFontThreadFunc, &slot);
|
||||
|
||||
queuedSpecs++;
|
||||
}
|
||||
}
|
||||
|
||||
StepLoadScreenRing();
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
|
||||
PortabilityLayer::FontManager::GetInstance()->PurgeCache();
|
||||
}
|
||||
|
||||
struct PreloadAATableSpec
|
||||
{
|
||||
PortabilityLayer::RGBAColor m_color;
|
||||
bool m_isTone;
|
||||
};
|
||||
|
||||
struct PreloadAATableWorkSlot
|
||||
{
|
||||
IGpThreadEvent *m_completedEvent;
|
||||
IGpMutex *m_mutex;
|
||||
PortabilityLayer::WorkerThread *m_workerThread;
|
||||
std::atomic<int> m_singleJobCompleted;
|
||||
const PreloadAATableSpec *m_spec;
|
||||
bool m_queued;
|
||||
|
||||
PreloadAATableWorkSlot();
|
||||
~PreloadAATableWorkSlot();
|
||||
};
|
||||
|
||||
PreloadAATableWorkSlot::PreloadAATableWorkSlot()
|
||||
: m_completedEvent(nullptr)
|
||||
, m_workerThread(nullptr)
|
||||
, m_spec(nullptr)
|
||||
, m_queued(false)
|
||||
{
|
||||
}
|
||||
|
||||
PreloadAATableWorkSlot::~PreloadAATableWorkSlot()
|
||||
{
|
||||
if (m_workerThread)
|
||||
m_workerThread->Destroy();
|
||||
}
|
||||
|
||||
|
||||
void PreloadAATableThreadFunc(void *context)
|
||||
{
|
||||
PreloadAATableWorkSlot *wSlot = static_cast<PreloadAATableWorkSlot*>(context);
|
||||
|
||||
PortabilityLayer::StandardPalette *sp = PortabilityLayer::StandardPalette::GetInstance();
|
||||
|
||||
if (wSlot->m_spec->m_isTone)
|
||||
sp->GetCachedToneAATable(wSlot->m_spec->m_color.r, wSlot->m_mutex);
|
||||
else
|
||||
sp->GetCachedPaletteAATable(wSlot->m_spec->m_color, wSlot->m_mutex);
|
||||
|
||||
wSlot->m_singleJobCompleted.fetch_add(1, std::memory_order_release);
|
||||
wSlot->m_completedEvent->Signal();
|
||||
}
|
||||
|
||||
void PreloadAATables()
|
||||
{
|
||||
PortabilityLayer::StandardPalette *sp = PortabilityLayer::StandardPalette::GetInstance();
|
||||
PortabilityLayer::RGBAColor preloadColors[] =
|
||||
{
|
||||
PortabilityLayer::RGBAColor::Create(255, 255, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 51, 51, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 0, 0, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 255, 0, 255),
|
||||
PortabilityLayer::RGBAColor::Create(0, 255, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(0, 0, 255, 255),
|
||||
PortabilityLayer::RGBAColor::Create(204, 102, 51, 255),
|
||||
PortabilityLayer::RGBAColor::Create(102, 102, 102, 255),
|
||||
PortabilityLayer::RGBAColor::Create(51, 51, 102, 255),
|
||||
PortabilityLayer::RGBAColor::Create(255, 255, 51, 255),
|
||||
PortabilityLayer::RGBAColor::Create(0, 0, 0, 255),
|
||||
};
|
||||
|
||||
const size_t numPalettePreloads = sizeof(preloadColors) / sizeof(preloadColors[0]);
|
||||
const size_t maxTonePreloads = numPalettePreloads * 3;
|
||||
|
||||
PreloadAATableSpec specs[numPalettePreloads + maxTonePreloads];
|
||||
for (size_t i = 0; i < numPalettePreloads; i++)
|
||||
{
|
||||
specs[i].m_color = preloadColors[i];
|
||||
specs[i].m_isTone = false;
|
||||
}
|
||||
|
||||
size_t numTonePreloads = 0;
|
||||
for (size_t i = 0; i < numPalettePreloads; i++)
|
||||
{
|
||||
const uint8_t rgb[3] = { preloadColors[i].r, preloadColors[i].g, preloadColors[i].b };
|
||||
|
||||
for (int ch = 0; ch < 3; ch++)
|
||||
{
|
||||
uint8_t tone = rgb[ch];
|
||||
|
||||
bool toneAlreadyQueued = false;
|
||||
for (size_t j = 0; j < numTonePreloads; j++)
|
||||
{
|
||||
if (specs[numPalettePreloads + j].m_color.r == tone)
|
||||
{
|
||||
toneAlreadyQueued = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!toneAlreadyQueued)
|
||||
{
|
||||
PreloadAATableSpec &spec = specs[numPalettePreloads + numTonePreloads];
|
||||
numTonePreloads++;
|
||||
|
||||
spec.m_color = PortabilityLayer::RGBAColor::Create(tone, tone, tone, 255);
|
||||
spec.m_isTone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
|
||||
const int numAASpecs = numPalettePreloads + numTonePreloads;
|
||||
|
||||
unsigned int cpus = PLDrivers::GetSystemServices()->GetCPUCount();
|
||||
if (cpus < 2)
|
||||
{
|
||||
for (size_t i = 0; i < numAASpecs; i++)
|
||||
{
|
||||
PreloadAATableThreadFunc(specs + i);
|
||||
StepLoadScreen(1, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cpus -= 1;
|
||||
|
||||
int queuedSpecs = 0;
|
||||
int completedSpecs = 0;
|
||||
|
||||
PreloadAATableWorkSlot *slots = static_cast<PreloadAATableWorkSlot*>(mm->Alloc(sizeof(PreloadAATableWorkSlot) * cpus));
|
||||
|
||||
IGpMutex *mutex = PLDrivers::GetSystemServices()->CreateMutex();
|
||||
|
||||
for (unsigned int i = 0; i < cpus; i++)
|
||||
{
|
||||
PreloadAATableWorkSlot *slot = new (slots + i) PreloadAATableWorkSlot();
|
||||
slot->m_workerThread = PortabilityLayer::WorkerThread::Create();
|
||||
slot->m_completedEvent = PLDrivers::GetSystemServices()->CreateThreadEvent(true, false);
|
||||
slot->m_mutex = mutex;
|
||||
}
|
||||
|
||||
while (completedSpecs < numAASpecs)
|
||||
{
|
||||
int completedThisStep = 0;
|
||||
for (unsigned int i = 0; i < cpus; i++)
|
||||
{
|
||||
PreloadAATableWorkSlot &slot = slots[i];
|
||||
|
||||
if (slot.m_queued)
|
||||
{
|
||||
if (slot.m_singleJobCompleted.load(std::memory_order_acquire) != 0)
|
||||
{
|
||||
slot.m_completedEvent->Wait();
|
||||
slot.m_queued = false;
|
||||
completedSpecs++;
|
||||
|
||||
completedThisStep++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!slot.m_queued)
|
||||
{
|
||||
if (queuedSpecs < numAASpecs)
|
||||
{
|
||||
slot.m_queued = true;
|
||||
slot.m_spec = specs + queuedSpecs;
|
||||
slot.m_singleJobCompleted.store(0, std::memory_order_release);
|
||||
slot.m_workerThread->AsyncExecuteTask(PreloadAATableThreadFunc, &slot);
|
||||
|
||||
queuedSpecs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (completedThisStep > 0)
|
||||
StepLoadScreen(completedThisStep, false);
|
||||
|
||||
StepLoadScreenRing();
|
||||
Delay(1, nullptr);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < cpus; i++)
|
||||
slots[i].~PreloadAATableWorkSlot();
|
||||
|
||||
mm->Release(slots);
|
||||
mutex->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void ShowInitialLaunchDisclaimer()
|
||||
{
|
||||
const char *disclaimerLines[] =
|
||||
@@ -933,8 +383,8 @@ void ShowInitialLaunchDisclaimer()
|
||||
|
||||
const size_t numLines = sizeof(disclaimerLines) / sizeof(disclaimerLines[0]);
|
||||
|
||||
PortabilityLayer::RenderedFont *rfont = GetApplicationFont(14, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *buttonFont = GetApplicationFont(18, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kApplication14);
|
||||
PortabilityLayer::RenderedFont *buttonFont = GetFont(PortabilityLayer::FontPresets::kApplication18);
|
||||
|
||||
const int kButtonSpacing = 16;
|
||||
const int kButtonHeight = 32;
|
||||
@@ -1098,11 +548,6 @@ int gpAppMain()
|
||||
SpinCursor(2); // Tick once to let the display driver flush any resolution changes from prefs
|
||||
FlushResolutionChange();
|
||||
|
||||
InitLoadingWindow(); StepLoadScreen(2, true);
|
||||
PreloadAATables();
|
||||
assert(isPrefsLoaded || loadScreenWindowPhase == 0);
|
||||
PreloadFonts(); StepLoadScreen(2, true);
|
||||
|
||||
#if defined COMPILEDEMO
|
||||
copyGood = true;
|
||||
#elif defined COMPILENOCP
|
||||
@@ -1120,25 +565,12 @@ int gpAppMain()
|
||||
// if ((thisMac.numScreens > 1) && (isUseSecondScreen))
|
||||
// ReflectSecondMonitorEnvirons(false, true, true);
|
||||
HandleDepthSwitching();
|
||||
VariableInit(); StepLoadScreen(2, true);
|
||||
GetExtraCursors(); StepLoadScreen(2, true);
|
||||
VariableInit();
|
||||
GetExtraCursors();
|
||||
InitMarquee();
|
||||
CreatePointers(); StepLoadScreen(2, true);
|
||||
CreatePointers();
|
||||
InitSrcRects();
|
||||
CreateOffscreens(); StepLoadScreen(2, true);
|
||||
|
||||
if (loadScreenWindow)
|
||||
{
|
||||
PortabilityLayer::WindowManager::GetInstance()->FlickerWindowOut(loadScreenWindow, 32);
|
||||
PortabilityLayer::WindowManager::GetInstance()->DestroyWindow(loadScreenWindow);
|
||||
PLSysCalls::Sleep(15);
|
||||
}
|
||||
|
||||
if (loadScreenRingSurface)
|
||||
{
|
||||
DisposeGWorld(loadScreenRingSurface);
|
||||
loadScreenRingSurface = nullptr;
|
||||
}
|
||||
CreateOffscreens();
|
||||
|
||||
bool resolutionChanged = false;
|
||||
|
||||
|
||||
@@ -64,13 +64,13 @@ struct MainMenuUIState
|
||||
ControlID m_activeControl;
|
||||
|
||||
static const unsigned int kControlHeight = 40;
|
||||
static const unsigned int kControlFontSize = 24;
|
||||
static const unsigned int kControlLeftSpacing = 20;
|
||||
static const unsigned int kControlBottomSpacing = 20;
|
||||
static const unsigned int kControlIntermediateSpacing = 16;
|
||||
static const unsigned int kControlInteriorSpacing = 6;
|
||||
static const unsigned int kControlScrollInDecay = 32;
|
||||
static const unsigned int kControlScrollInDecayFalloffBits = 0;
|
||||
static const PortabilityLayer::FontPreset_t kControlFontPreset = PortabilityLayer::FontPresets::kHandwriting24;
|
||||
};
|
||||
|
||||
static MainMenuUIState mainMenu;
|
||||
@@ -135,7 +135,7 @@ static void DrawMainMenuControl(DrawSurface *surface, MainMenuUIState::ControlID
|
||||
{
|
||||
case MainMenuUIState::ControlStyle_Text:
|
||||
{
|
||||
PortabilityLayer::RenderedFont *rfont = GetHandwritingFont(MainMenuUIState::kControlFontSize, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *rfont = GetFont(MainMenuUIState::kControlFontPreset);
|
||||
if (!rfont)
|
||||
return;
|
||||
|
||||
@@ -219,7 +219,7 @@ void StartMainMenuUI()
|
||||
{
|
||||
DismissMainMenuUI();
|
||||
|
||||
PortabilityLayer::RenderedFont *rfont = GetHandwritingFont(MainMenuUIState::kControlFontSize, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *rfont = GetFont(MainMenuUIState::kControlFontPreset);
|
||||
if (!rfont)
|
||||
return;
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ void DrawOnSplash(DrawSurface *surface)
|
||||
if ((thisMac.hasQT) && (hasMovie))
|
||||
PasStringConcat(houseLoadedStr, PSTR(" (TV)"));
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication9Bold);
|
||||
|
||||
const Point textPoint = Point::Create(splashOriginH + 436, splashOriginV + 314);
|
||||
if (thisMac.isDepth == 4)
|
||||
|
||||
@@ -1057,7 +1057,7 @@ void DrawCalendar (Rect *theRect)
|
||||
backSrcMap->DrawPicture(thePicture, bounds);
|
||||
thePicture.Dispose();
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication9Bold);
|
||||
|
||||
GetTime(&timeRec);
|
||||
GetIndString(monthStr, kMonthStringID, timeRec.month);
|
||||
|
||||
@@ -251,7 +251,7 @@ void ReadyBackground (short theID, short *theTiles)
|
||||
|
||||
workSrcMap->FillRect(workSrcRect, ltGrayColor);
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication9);
|
||||
|
||||
const Point textPoint = Point::Create(10, 20);
|
||||
if (houseUnlocked)
|
||||
|
||||
@@ -44,7 +44,7 @@ static const int kScoreOffset = 320;
|
||||
static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint)
|
||||
{
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::RenderedFont *rfont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kSystem12Bold);
|
||||
|
||||
surface->DrawString(basePoint + Point::Create(kStarsOffset, 0), PSTR("Stars Left"), blackColor, rfont);
|
||||
surface->DrawString(basePoint + Point::Create(kGlidersOffset, 0), PSTR("Gliders"), blackColor, rfont);
|
||||
@@ -54,7 +54,7 @@ static void FBUI_DrawLabels(DrawSurface *surface, const Point &basePoint)
|
||||
static void FBUI_DrawFileDetails(DrawSurface *surface, const Point &basePoint, const Rect &constraintRect, void *fileDetails)
|
||||
{
|
||||
PortabilityLayer::ResolveCachingColor blackColor(StdColors::Black());
|
||||
PortabilityLayer::RenderedFont *rfont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *rfont = GetFont(PortabilityLayer::FontPresets::kSystem12Bold);
|
||||
|
||||
const game2Type *gameData = static_cast<const game2Type*>(fileDetails);
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ void RefreshRoomTitle (short mode)
|
||||
const Point strShadowPoint = Point::Create(1, 10);
|
||||
const Point strPoint = Point::Create(0, 9);
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
@@ -221,7 +221,7 @@ void RefreshNumGliders (void)
|
||||
long displayMortals;
|
||||
DrawSurface *surface = boardGSrcMap;
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
|
||||
PortabilityLayer::ResolveCachingColor theRGBColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(kGrayBackgroundColor);
|
||||
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
|
||||
@@ -256,7 +256,7 @@ void RefreshPoints (void)
|
||||
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
|
||||
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
|
||||
surface->FillRect(boardPSrcRect, theRGBColor);
|
||||
|
||||
@@ -286,7 +286,7 @@ void QuickGlidersRefresh (void)
|
||||
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
|
||||
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
|
||||
surface->FillRect(boardGSrcRect, theRGBColor);
|
||||
|
||||
@@ -316,7 +316,7 @@ void QuickScoreRefresh (void)
|
||||
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
|
||||
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication12Bold);
|
||||
|
||||
surface->FillRect(boardPSrcRect, theRGBColor);
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ static void InitSourceExportWindow(SourceExportState *state)
|
||||
PortabilityLayer::WindowManager::GetInstance()->FlickerWindowIn(state->m_window, 32);
|
||||
|
||||
const PLPasStr loadingText = PSTR("Exporting...");
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(18, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *font = GetFont(PortabilityLayer::FontPresets::kApplication18);
|
||||
int32_t textY = (kLoadScreenHeight + font->GetMetrics().m_ascent) / 2;
|
||||
surface->DrawString(Point::Create(4 + 16, textY), loadingText, blackColor, font);
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ void DrawToolName (DrawSurface *surface)
|
||||
|
||||
const Point textPoint = Point::Create(toolTextRect.left + 3, toolTextRect.bottom - 6);
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication9Bold);
|
||||
ColorText(surface, textPoint, theString, 171L, appFont);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -146,7 +146,7 @@ void SetMessageWindowMessage (StringPtr message, const PortabilityLayer::RGBACol
|
||||
{
|
||||
DrawSurface *surface = mssgWindow->GetDrawSurface();
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(PortabilityLayer::FontPresets::kSystem12);
|
||||
|
||||
SetRect(&mssgWindowRect, 0, 0, 256, kMessageWindowTall);
|
||||
InsetRect(&mssgWindowRect, 16, 16);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
enum EGpFontHandlerType
|
||||
{
|
||||
EGpFontHandlerType_None,
|
||||
EGpFontHandlerType_FreeType2,
|
||||
|
||||
EGpFontHandlerType_Count,
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#undef LoadCursor
|
||||
#undef CreateFile
|
||||
|
||||
struct IGpFiber;
|
||||
struct IGpBWCursor_Win32;
|
||||
struct IGpCursor_Win32;
|
||||
struct IGpVOSEventQueue;
|
||||
@@ -29,7 +28,6 @@ struct GpWindowsGlobals
|
||||
HICON m_hIconSm;
|
||||
int m_nCmdShow;
|
||||
|
||||
IGpFiber *(*m_createFiberFunc)(LPVOID fiber);
|
||||
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);
|
||||
void (*m_translateWindowsMessageFunc)(const MSG *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY);
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreDefs.h"
|
||||
|
||||
struct IGpFiber
|
||||
{
|
||||
virtual void YieldTo(IGpFiber *toFiber) = 0;
|
||||
virtual void YieldToTerminal(IGpFiber *toFiber) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
};
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "GpVOSEvent.h"
|
||||
#include "GpWindows.h"
|
||||
#include "IGpCursor_Win32.h"
|
||||
#include "IGpFiber.h"
|
||||
#include "IGpVOSEventQueue.h"
|
||||
|
||||
#include "IGpLogDriver.h"
|
||||
@@ -624,8 +623,6 @@ bool GpDisplayDriverD3D11::InitResources(uint32_t virtualWidth, uint32_t virtual
|
||||
|
||||
bool GpDisplayDriverD3D11::SyncRender()
|
||||
{
|
||||
fprintf(stderr, "Test\n");
|
||||
|
||||
if (m_frameTimeAccumulated >= m_frameTimeSliceSize)
|
||||
{
|
||||
m_frameTimeAccumulated -= m_frameTimeSliceSize;
|
||||
@@ -777,165 +774,6 @@ bool GpDisplayDriverD3D11::SyncRender()
|
||||
return false;
|
||||
}
|
||||
|
||||
GpDisplayDriverTickStatus_t GpDisplayDriverD3D11::PresentFrameAndSync()
|
||||
{
|
||||
SynchronizeCursors();
|
||||
|
||||
FLOAT bgColor[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
bgColor[i] = m_bgColor[i];
|
||||
|
||||
if (m_bgIsDark)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
bgColor[i] *= 0.25f;
|
||||
}
|
||||
|
||||
m_deviceContext->ClearRenderTargetView(m_virtualScreenTextureRTV, bgColor);
|
||||
|
||||
//ID3D11RenderTargetView *const rtv = m_backBufferRTV;
|
||||
ID3D11RenderTargetView *const vsRTV = m_virtualScreenTextureRTV;
|
||||
m_deviceContext->OMSetRenderTargets(1, &vsRTV, nullptr);
|
||||
|
||||
{
|
||||
D3D11_VIEWPORT viewport;
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
viewport.Width = static_cast<FLOAT>(m_windowWidthVirtual);
|
||||
viewport.Height = static_cast<FLOAT>(m_windowHeightVirtual);
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
|
||||
m_deviceContext->RSSetViewports(1, &viewport);
|
||||
}
|
||||
|
||||
m_properties.m_renderFunc(m_properties.m_renderFuncContext);
|
||||
|
||||
ScaleVirtualScreen();
|
||||
|
||||
DXGI_PRESENT_PARAMETERS presentParams;
|
||||
|
||||
ZeroMemory(&presentParams, sizeof(presentParams));
|
||||
|
||||
UINT lastPresentCount = 0;
|
||||
|
||||
if (FAILED(m_swapChain->GetLastPresentCount(&lastPresentCount)))
|
||||
return GpDisplayDriverTickStatuses::kNonFatalFault;
|
||||
|
||||
if (FAILED(m_swapChain->Present1(1, 0, &presentParams)))
|
||||
return GpDisplayDriverTickStatuses::kNonFatalFault;
|
||||
|
||||
//DebugPrintf("r: %i\n", static_cast<int>(r));
|
||||
|
||||
DXGI_FRAME_STATISTICS stats;
|
||||
if (FAILED(m_swapChain->GetFrameStatistics(&stats)))
|
||||
return GpDisplayDriverTickStatuses::kNonFatalFault;
|
||||
|
||||
if (stats.SyncQPCTime.QuadPart != 0)
|
||||
{
|
||||
if (m_syncTimeBase.QuadPart == 0)
|
||||
m_syncTimeBase = stats.SyncQPCTime;
|
||||
|
||||
LARGE_INTEGER timestamp;
|
||||
timestamp.QuadPart = stats.SyncQPCTime.QuadPart - m_syncTimeBase.QuadPart;
|
||||
|
||||
bool compacted = false;
|
||||
if (m_presentHistory.Size() > 0)
|
||||
{
|
||||
CompactedPresentHistoryItem &lastItem = m_presentHistory[m_presentHistory.Size() - 1];
|
||||
LONGLONG timeDelta = timestamp.QuadPart - lastItem.m_timestamp.QuadPart;
|
||||
|
||||
if (timeDelta < 0)
|
||||
timeDelta = 0; // This should never happen
|
||||
|
||||
if (timeDelta * static_cast<LONGLONG>(m_properties.m_frameTimeLockDenominator) < m_QPFrequency.QuadPart * static_cast<LONGLONG>(m_properties.m_frameTimeLockNumerator))
|
||||
{
|
||||
lastItem.m_numFrames++;
|
||||
compacted = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!compacted)
|
||||
{
|
||||
if (m_presentHistory.Size() == m_presentHistory.CAPACITY)
|
||||
m_presentHistory.RemoveFromStart();
|
||||
|
||||
CompactedPresentHistoryItem *newItem = m_presentHistory.Append();
|
||||
newItem->m_timestamp = timestamp;
|
||||
newItem->m_numFrames = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_presentHistory.Size() >= 2)
|
||||
{
|
||||
const size_t presentHistorySizeMinusOne = m_presentHistory.Size() - 1;
|
||||
unsigned int numFrames = 0;
|
||||
for (size_t i = 0; i < presentHistorySizeMinusOne; i++)
|
||||
numFrames += m_presentHistory[i].m_numFrames;
|
||||
|
||||
LONGLONG timeFrame = m_presentHistory[presentHistorySizeMinusOne].m_timestamp.QuadPart - m_presentHistory[0].m_timestamp.QuadPart;
|
||||
|
||||
unsigned int cancelledFrames = 0;
|
||||
LONGLONG cancelledTime = 0;
|
||||
|
||||
const int overshootTolerance = 2;
|
||||
|
||||
for (size_t i = 0; i < presentHistorySizeMinusOne; i++)
|
||||
{
|
||||
LONGLONG blockTimeframe = m_presentHistory[i + 1].m_timestamp.QuadPart - m_presentHistory[i].m_timestamp.QuadPart;
|
||||
unsigned int blockNumFrames = m_presentHistory[i].m_numFrames;
|
||||
|
||||
if (blockTimeframe * static_cast<LONGLONG>(numFrames) >= timeFrame * static_cast<LONGLONG>(blockNumFrames) * overshootTolerance)
|
||||
{
|
||||
cancelledTime += blockTimeframe;
|
||||
cancelledFrames += blockNumFrames;
|
||||
}
|
||||
}
|
||||
|
||||
numFrames -= cancelledFrames;
|
||||
timeFrame -= cancelledTime;
|
||||
|
||||
// timeFrame / numFrames = Frame timestep
|
||||
// Unless Frame timestep is within the frame lock range, a.k.a.
|
||||
// timeFrame / numFrames / qpFreq >= minFrameTimeNum / minFrameTimeDenom
|
||||
|
||||
bool isInFrameTimeLock = false;
|
||||
if (timeFrame * static_cast<LONGLONG>(m_properties.m_frameTimeLockMinDenominator) >= static_cast<LONGLONG>(numFrames) * static_cast<LONGLONG>(m_properties.m_frameTimeLockMinNumerator) * m_QPFrequency.QuadPart
|
||||
&& timeFrame * static_cast<LONGLONG>(m_properties.m_frameTimeLockMaxDenominator) <= static_cast<LONGLONG>(numFrames) * static_cast<LONGLONG>(m_properties.m_frameTimeLockMaxNumerator) * m_QPFrequency.QuadPart)
|
||||
{
|
||||
isInFrameTimeLock = true;
|
||||
}
|
||||
|
||||
LONGLONG frameTimeStep = m_frameTimeSliceSize;
|
||||
if (!isInFrameTimeLock)
|
||||
{
|
||||
const int MAX_FRAMES_PER_STEP = 4;
|
||||
|
||||
frameTimeStep = timeFrame / numFrames;
|
||||
if (frameTimeStep > m_frameTimeSliceSize * MAX_FRAMES_PER_STEP)
|
||||
frameTimeStep = m_frameTimeSliceSize * MAX_FRAMES_PER_STEP;
|
||||
}
|
||||
|
||||
m_frameTimeAccumulated += frameTimeStep;
|
||||
while (m_frameTimeAccumulated >= m_frameTimeSliceSize)
|
||||
{
|
||||
GpDisplayDriverTickStatus_t tickStatus = m_properties.m_tickFunc(m_properties.m_tickFuncContext, m_vosFiber);
|
||||
m_frameTimeAccumulated -= m_frameTimeSliceSize;
|
||||
|
||||
if (tickStatus == GpDisplayDriverTickStatuses::kSynchronizing)
|
||||
{
|
||||
m_frameTimeAccumulated = 0;
|
||||
break;
|
||||
}
|
||||
else if (tickStatus != GpDisplayDriverTickStatuses::kOK)
|
||||
return tickStatus;
|
||||
}
|
||||
}
|
||||
|
||||
return GpDisplayDriverTickStatuses::kOK;
|
||||
}
|
||||
|
||||
void GpDisplayDriverD3D11::ScaleVirtualScreen()
|
||||
{
|
||||
{
|
||||
@@ -1294,6 +1132,11 @@ bool GpDisplayDriverD3D11::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
void GpDisplayDriverD3D11::ForceSync()
|
||||
{
|
||||
m_frameTimeAccumulated = 0;
|
||||
}
|
||||
|
||||
void GpDisplayDriverD3D11::ServeTicks(int tickCount)
|
||||
{
|
||||
HMENU menus = NULL;
|
||||
@@ -1398,157 +1241,6 @@ void GpDisplayDriverD3D11::ServeTicks(int tickCount)
|
||||
}
|
||||
}
|
||||
|
||||
void GpDisplayDriverD3D11::Run()
|
||||
{
|
||||
IGpLogDriver *logger = m_properties.m_logger;
|
||||
|
||||
WNDCLASSEX wc;
|
||||
|
||||
LPVOID fiber = ConvertThreadToFiberEx(this, 0);
|
||||
if (!fiber)
|
||||
{
|
||||
if (logger)
|
||||
logger->Printf(IGpLogDriver::Category_Error, "ConvertThreadToFiberEx failed");
|
||||
|
||||
return; // ???
|
||||
}
|
||||
|
||||
m_vosFiber = m_osGlobals->m_createFiberFunc(fiber);
|
||||
|
||||
ZeroMemory(&wc, sizeof(wc));
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = WinProc;
|
||||
wc.hInstance = m_osGlobals->m_hInstance;
|
||||
wc.hCursor = m_arrowCursor;
|
||||
wc.hIcon = m_osGlobals->m_hIcon;
|
||||
wc.hIconSm = m_osGlobals->m_hIconSm;
|
||||
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
|
||||
wc.lpszClassName = "GPD3D11WindowClass";
|
||||
|
||||
RegisterClassEx(&wc);
|
||||
|
||||
LONG windowStyle = WS_OVERLAPPEDWINDOW;
|
||||
HMENU menus = NULL;
|
||||
|
||||
// TODO: Fix the resolution here
|
||||
RECT wr = { 0, 0, static_cast<DWORD>(m_windowWidthPhysical), static_cast<DWORD>(m_windowHeightPhysical) };
|
||||
AdjustWindowRect(&wr, windowStyle, menus != NULL);
|
||||
|
||||
m_osGlobals->m_hwnd = CreateWindowExW(NULL, L"GPD3D11WindowClass", GP_APPLICATION_NAME_W, WS_OVERLAPPEDWINDOW, 300, 300, wr.right - wr.left, wr.bottom - wr.top, NULL, menus, m_osGlobals->m_hInstance, NULL);
|
||||
|
||||
ShowWindow(m_osGlobals->m_hwnd, m_osGlobals->m_nCmdShow);
|
||||
|
||||
StartD3DForWindow(m_osGlobals->m_hwnd, m_swapChain, m_device, m_deviceContext, logger);
|
||||
|
||||
InitResources(m_windowWidthVirtual, m_windowHeightVirtual);
|
||||
|
||||
LARGE_INTEGER lastTimestamp;
|
||||
memset(&lastTimestamp, 0, sizeof(lastTimestamp));
|
||||
|
||||
m_initialWidth = m_windowWidthVirtual;
|
||||
m_initialHeight = m_windowHeightVirtual;
|
||||
|
||||
MSG msg;
|
||||
for (;;)
|
||||
{
|
||||
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
DispatchMessage(&msg);
|
||||
|
||||
{
|
||||
if (msg.message == WM_MOUSEMOVE)
|
||||
{
|
||||
if (!m_mouseIsInClientArea)
|
||||
{
|
||||
m_mouseIsInClientArea = true;
|
||||
|
||||
TRACKMOUSEEVENT tme;
|
||||
ZeroMemory(&tme, sizeof(tme));
|
||||
|
||||
tme.cbSize = sizeof(tme);
|
||||
tme.dwFlags = TME_LEAVE;
|
||||
tme.hwndTrack = m_osGlobals->m_hwnd;
|
||||
tme.dwHoverTime = HOVER_DEFAULT;
|
||||
TrackMouseEvent(&tme);
|
||||
}
|
||||
}
|
||||
else if (msg.message == WM_MOUSELEAVE)
|
||||
m_mouseIsInClientArea = false;
|
||||
|
||||
m_osGlobals->m_translateWindowsMessageFunc(&msg, m_properties.m_eventQueue, m_pixelScaleX, m_pixelScaleY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_isFullScreen != m_isFullScreenDesired)
|
||||
{
|
||||
if (m_isFullScreenDesired)
|
||||
BecomeFullScreen(windowStyle);
|
||||
else
|
||||
BecomeWindowed(windowStyle);
|
||||
}
|
||||
|
||||
RECT clientRect;
|
||||
GetClientRect(m_osGlobals->m_hwnd, &clientRect);
|
||||
|
||||
unsigned int desiredWidth = clientRect.right - clientRect.left;
|
||||
unsigned int desiredHeight = clientRect.bottom - clientRect.top;
|
||||
if (clientRect.right - clientRect.left != m_windowWidthPhysical || clientRect.bottom - clientRect.top != m_windowHeightPhysical || m_isResolutionResetDesired)
|
||||
{
|
||||
uint32_t prevWidthPhysical = m_windowWidthPhysical;
|
||||
uint32_t prevHeightPhysical = m_windowHeightPhysical;
|
||||
uint32_t prevWidthVirtual = m_windowWidthVirtual;
|
||||
uint32_t prevHeightVirtual = m_windowHeightVirtual;
|
||||
uint32_t virtualWidth = m_windowWidthVirtual;
|
||||
uint32_t virtualHeight = m_windowHeightVirtual;
|
||||
float pixelScaleX = 1.0f;
|
||||
float pixelScaleY = 1.0f;
|
||||
|
||||
if (desiredWidth < 640)
|
||||
desiredWidth = 640;
|
||||
|
||||
if (desiredHeight < 480)
|
||||
desiredHeight = 480;
|
||||
|
||||
if (m_properties.m_adjustRequestedResolutionFunc(m_properties.m_adjustRequestedResolutionFuncContext, desiredWidth, desiredHeight, virtualWidth, virtualHeight, pixelScaleX, pixelScaleY))
|
||||
{
|
||||
bool resizedOK = ResizeD3DWindow(m_osGlobals->m_hwnd, m_windowWidthPhysical, m_windowHeightPhysical, desiredWidth, desiredHeight, windowStyle, menus, logger);
|
||||
resizedOK = resizedOK && DetachSwapChain();
|
||||
resizedOK = resizedOK && ResizeSwapChain(m_swapChain, m_windowWidthPhysical, m_windowHeightPhysical);
|
||||
resizedOK = resizedOK && InitBackBuffer(virtualWidth, virtualHeight);
|
||||
|
||||
if (!resizedOK)
|
||||
break; // Critical video driver error, exit
|
||||
|
||||
m_windowWidthVirtual = virtualWidth;
|
||||
m_windowHeightVirtual = virtualHeight;
|
||||
m_pixelScaleX = pixelScaleX;
|
||||
m_pixelScaleY = pixelScaleY;
|
||||
m_isResolutionResetDesired = false;
|
||||
|
||||
if (GpVOSEvent *resizeEvent = m_properties.m_eventQueue->QueueEvent())
|
||||
{
|
||||
resizeEvent->m_eventType = GpVOSEventTypes::kVideoResolutionChanged;
|
||||
resizeEvent->m_event.m_resolutionChangedEvent.m_prevWidth = prevWidthVirtual;
|
||||
resizeEvent->m_event.m_resolutionChangedEvent.m_prevHeight = prevHeightVirtual;
|
||||
resizeEvent->m_event.m_resolutionChangedEvent.m_newWidth = m_windowWidthVirtual;
|
||||
resizeEvent->m_event.m_resolutionChangedEvent.m_newHeight = m_windowHeightVirtual;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GpDisplayDriverTickStatus_t tickStatus = PresentFrameAndSync();
|
||||
if (tickStatus == GpDisplayDriverTickStatuses::kFatalFault || tickStatus == GpDisplayDriverTickStatuses::kApplicationTerminated)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Exit
|
||||
ConvertFiberToThread();
|
||||
}
|
||||
|
||||
void GpDisplayDriverD3D11::Shutdown()
|
||||
{
|
||||
this->~GpDisplayDriverD3D11();
|
||||
@@ -1833,7 +1525,6 @@ GpDisplayDriverD3D11::GpDisplayDriverD3D11(const GpDisplayDriverProperties &prop
|
||||
, m_initialHeight(480)
|
||||
, m_pixelScaleX(1.0f)
|
||||
, m_pixelScaleY(1.0f)
|
||||
, m_vosFiber(nullptr)
|
||||
, m_osGlobals(static_cast<GpWindowsGlobals*>(properties.m_osGlobals))
|
||||
, m_pendingCursor(nullptr)
|
||||
, m_activeCursor(nullptr)
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
struct GpWindowsGlobals;
|
||||
struct IGpCursor_Win32;
|
||||
struct IGpCursor;
|
||||
struct IGpFiber;
|
||||
|
||||
struct IDXGISwapChain1;
|
||||
struct ID3D11Buffer;
|
||||
@@ -37,8 +36,8 @@ class GpDisplayDriverD3D11 : public IGpDisplayDriver, public IGpPrefsHandler
|
||||
{
|
||||
public:
|
||||
bool Init() override;
|
||||
void ForceSync() override;
|
||||
void ServeTicks(int tickCount) override;
|
||||
void Run() override;
|
||||
void Shutdown() override;
|
||||
|
||||
void GetInitialDisplayResolution(unsigned int *width, unsigned int *height) override;
|
||||
@@ -117,7 +116,6 @@ private:
|
||||
bool DetachSwapChain();
|
||||
bool InitBackBuffer(uint32_t virtualWidth, uint32_t virtualHeight);
|
||||
bool InitResources(uint32_t virtualWidth, uint32_t virtualHeight);
|
||||
GpDisplayDriverTickStatus_t PresentFrameAndSync();
|
||||
bool SyncRender();
|
||||
void ScaleVirtualScreen();
|
||||
|
||||
@@ -192,7 +190,6 @@ private:
|
||||
EGpStandardCursor_t m_pendingStandardCursor;
|
||||
bool m_mouseIsInClientArea;
|
||||
|
||||
IGpFiber *m_vosFiber;
|
||||
GpWindowsGlobals *m_osGlobals;
|
||||
|
||||
HCURSOR m_arrowCursor;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#include "GpAppEnvironment.h"
|
||||
#include "GpFiberStarter.h"
|
||||
#include "GpAppInterface.h"
|
||||
#include "GpDisplayDriverTickStatus.h"
|
||||
#include "GpFontHandlerFactory.h"
|
||||
#include "HostSuspendCallArgument.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "IGpFiber.h"
|
||||
#include "IGpInputDriver.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
struct IGpFiber;
|
||||
struct IGpSystemServices;
|
||||
|
||||
class GpFiberStarter
|
||||
{
|
||||
public:
|
||||
typedef void(*ThreadFunc_t)(void *context);
|
||||
|
||||
static IGpFiber *StartFiber(IGpSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber);
|
||||
};
|
||||
@@ -12,7 +12,6 @@ copy /Y x64\Release\GpAudioDriver_XAudio2.dll ReleasePkg\Aerofoil
|
||||
copy /Y x64\Release\xaudio2_9redist.dll ReleasePkg\Aerofoil
|
||||
copy /Y x64\Release\GpDisplayDriver_D3D11.dll ReleasePkg\Aerofoil
|
||||
copy /Y x64\Release\GpInputDriver_XInput.dll ReleasePkg\Aerofoil
|
||||
copy /Y x64\Release\GpFontHandler_FreeType2.dll ReleasePkg\Aerofoil
|
||||
copy /Y x64\Release\FreeType.dll ReleasePkg\Aerofoil
|
||||
copy /Y x64\Release\GpApp.dll ReleasePkg\Aerofoil
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\PortabilityLayer;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)PortabilityLayer;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __PL_CFILESTREAM_H__
|
||||
#define __PL_CFILESTREAM_H__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CoreDefs.h"
|
||||
@@ -38,5 +35,3 @@ namespace PortabilityLayer
|
||||
bool m_seekable;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace PortabilityLayer
|
||||
|
||||
void FileBrowserUIImpl::DrawHeaders()
|
||||
{
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *font = GetFont(FontPresets::kApplication12Bold);
|
||||
|
||||
ResolveCachingColor blackColor = StdColors::Black();
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace PortabilityLayer
|
||||
if (!m_entries.MMBlock())
|
||||
return;
|
||||
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *font = GetFont(FontPresets::kApplication12Bold);
|
||||
|
||||
GpRenderedFontMetrics metrics = font->GetMetrics();
|
||||
int32_t spacing = metrics.m_linegap;
|
||||
@@ -634,8 +634,8 @@ namespace PortabilityLayer
|
||||
PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(windowRect, PortabilityLayer::WindowStyleFlags::kAlert, true, 0, 0, PSTR(""));
|
||||
|
||||
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
|
||||
PortabilityLayer::RenderedFont *font = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *fontLight = GetApplicationFont(8, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *font = GetFont(FontPresets::kApplication12Bold);
|
||||
PortabilityLayer::RenderedFont *fontLight = GetFont(FontPresets::kApplication8);
|
||||
|
||||
int16_t verticalPoint = 16 + font->GetMetrics().m_ascent;
|
||||
int16_t horizontalOffset = 16;
|
||||
|
||||
@@ -38,10 +38,10 @@ namespace PortabilityLayer
|
||||
m_defaultVariation = defaultVariation;
|
||||
}
|
||||
|
||||
int FontFamily::GetVariationForFlags(int variation) const
|
||||
int FontFamily::GetVariationForFlags(int flags) const
|
||||
{
|
||||
if (m_fontSpecs[variation].m_isRegistered)
|
||||
return variation;
|
||||
if (m_fontSpecs[flags].m_isRegistered)
|
||||
return flags;
|
||||
|
||||
if (m_fontSpecs[0].m_isRegistered)
|
||||
return 0;
|
||||
@@ -111,9 +111,20 @@ namespace PortabilityLayer
|
||||
return m_fontSpecs[variation].m_hacks;
|
||||
}
|
||||
|
||||
int FontFamily::GetCacheID() const
|
||||
bool FontFamily::GetFontSpec(int variation, FontHacks &outHacks, const char *&outPath)
|
||||
{
|
||||
return m_cacheID;
|
||||
if (!m_fontSpecs[variation].m_isRegistered)
|
||||
return false;
|
||||
|
||||
outHacks = m_fontSpecs[variation].m_hacks;
|
||||
outPath = m_fontSpecs[variation].m_fontPath;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FontFamilyID_t FontFamily::GetFamilyID() const
|
||||
{
|
||||
return m_familyID;
|
||||
}
|
||||
|
||||
void FontFamily::PurgeCache()
|
||||
@@ -128,13 +139,13 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
FontFamily *FontFamily::Create(int cacheID)
|
||||
FontFamily *FontFamily::Create(FontFamilyID_t familyID)
|
||||
{
|
||||
void *storage = malloc(sizeof(FontFamily));
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
return new (storage) FontFamily(cacheID);
|
||||
return new (storage) FontFamily(familyID);
|
||||
}
|
||||
|
||||
void FontFamily::Destroy()
|
||||
@@ -143,9 +154,9 @@ namespace PortabilityLayer
|
||||
free(this);
|
||||
}
|
||||
|
||||
FontFamily::FontFamily(int cacheID)
|
||||
FontFamily::FontFamily(FontFamilyID_t familyID)
|
||||
: m_defaultVariation(0)
|
||||
, m_cacheID(cacheID)
|
||||
, m_familyID(familyID)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "FontFamilyID.h"
|
||||
#include "FontHacks.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class PLPasStr;
|
||||
@@ -24,16 +26,17 @@ namespace PortabilityLayer
|
||||
|
||||
void AddFont(int flags, const char *path, FontHacks fontHacks);
|
||||
void SetDefaultVariation(int defaultVariation);
|
||||
bool GetFontSpec(int variation, FontHacks &outHacks, const char *&outPath);
|
||||
|
||||
int GetVariationForFlags(int variation) const;
|
||||
int GetVariationForFlags(int flags) const;
|
||||
IGpFont *GetFontForVariation(int variation);
|
||||
FontHacks GetHacksForVariation(int variation) const;
|
||||
|
||||
int GetCacheID() const;
|
||||
FontFamilyID_t GetFamilyID() const;
|
||||
|
||||
void PurgeCache();
|
||||
|
||||
static FontFamily *Create(int cacheID);
|
||||
static FontFamily *Create(FontFamilyID_t familyID);
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
@@ -49,9 +52,9 @@ namespace PortabilityLayer
|
||||
|
||||
FontSpec m_fontSpecs[kNumVariations];
|
||||
uint8_t m_defaultVariation;
|
||||
int m_cacheID;
|
||||
FontFamilyID_t m_familyID;
|
||||
|
||||
explicit FontFamily(int cacheID);
|
||||
explicit FontFamily(FontFamilyID_t familyID);
|
||||
~FontFamily();
|
||||
};
|
||||
}
|
||||
|
||||
19
PortabilityLayer/FontFamilyID.h
Normal file
19
PortabilityLayer/FontFamilyID.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
namespace FontFamilyIDs
|
||||
{
|
||||
enum FontFamilyID
|
||||
{
|
||||
kSystem,
|
||||
kApplication,
|
||||
kMonospace,
|
||||
kHandwriting,
|
||||
|
||||
kCount
|
||||
};
|
||||
}
|
||||
|
||||
typedef FontFamilyIDs::FontFamilyID FontFamilyID_t;
|
||||
}
|
||||
@@ -2,13 +2,18 @@
|
||||
#include "FontFamily.h"
|
||||
#include "FontRenderer.h"
|
||||
|
||||
#include "FileManager.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "IGpFileSystem.h"
|
||||
#include "IGpFont.h"
|
||||
#include "RenderedFont.h"
|
||||
|
||||
#include "MemReaderStream.h"
|
||||
#include "PLBigEndian.h"
|
||||
#include "PLDrivers.h"
|
||||
#include "RenderedFontCatalog.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "ResTypeID.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -24,15 +29,12 @@ namespace PortabilityLayer
|
||||
void Init() override;
|
||||
void Shutdown() override;
|
||||
|
||||
FontFamily *GetSystemFont(int textSize, int variationFlags) const override;
|
||||
FontFamily *GetApplicationFont(int textSize, int variationFlags) const override;
|
||||
FontFamily *GetHandwritingFont(int textSize, int variationFlags) const override;
|
||||
FontFamily *GetMonospaceFont(int textSize, int variationFlags) const override;
|
||||
FontFamily *GetFont(FontFamilyID_t fontFamilyID) const override;
|
||||
void GetFontPreset(FontPreset_t fontPreset, FontFamilyID_t *outFamilyID, int *outSize, int *outVariationFlags, bool *outAA) const override;
|
||||
|
||||
RenderedFont *GetRenderedFontFromFamily(FontFamily *font, int size, bool aa, int flags) override;
|
||||
|
||||
RenderedFont *LoadCachedRenderedFont(int cacheID, int size, bool aa, int flags) const override;
|
||||
void SaveCachedRenderedFont(const RenderedFont *rfont, int cacheID, int size, bool aa, int flags) const override;
|
||||
RenderedFont *LoadCachedRenderedFont(FontFamilyID_t familyID, int size, bool aa, int flags) override;
|
||||
|
||||
void PurgeCache() override;
|
||||
|
||||
@@ -40,12 +42,6 @@ namespace PortabilityLayer
|
||||
|
||||
private:
|
||||
static const unsigned int kNumCachedRenderedFonts = 32;
|
||||
static const int kSystemFontCacheID = 1;
|
||||
static const int kApplicationFontCacheID = 2;
|
||||
static const int kHandwritingFontCacheID = 3;
|
||||
static const int kMonospaceFontCacheID = 4;
|
||||
static const int kFontCacheVersion = 2;
|
||||
static const int kFontCacheNameSize = 64;
|
||||
|
||||
struct CachedRenderedFont
|
||||
{
|
||||
@@ -56,6 +52,14 @@ namespace PortabilityLayer
|
||||
bool m_aa;
|
||||
};
|
||||
|
||||
struct FontPreset
|
||||
{
|
||||
FontFamilyID_t m_familyID;
|
||||
int m_textSize;
|
||||
int m_variationFlags;
|
||||
bool m_aa;
|
||||
};
|
||||
|
||||
FontManagerImpl();
|
||||
|
||||
bool FindOrReserveCacheSlot(int cacheID, int size, bool aa, CachedRenderedFont *&outCacheSlot, RenderedFont *&outRF);
|
||||
@@ -64,57 +68,49 @@ namespace PortabilityLayer
|
||||
void ResetUsageCounter();
|
||||
static int CRFSortPredicate(const void *a, const void *b);
|
||||
|
||||
static void GenerateCacheFileName(char(&str)[kFontCacheNameSize], int cacheID, int size, bool aa, int flags);
|
||||
|
||||
FontFamily *m_systemFont;
|
||||
FontFamily *m_applicationFont;
|
||||
FontFamily *m_handwritingFont;
|
||||
FontFamily *m_monospaceFont;
|
||||
FontFamily *m_fontFamilies[FontFamilyIDs::kCount];
|
||||
uint32_t m_usageCounter;
|
||||
|
||||
CachedRenderedFont m_cachedRenderedFonts[kNumCachedRenderedFonts];
|
||||
|
||||
IResourceArchive *m_fontArchive;
|
||||
PortabilityLayer::CompositeFile *m_fontArchiveFile;
|
||||
THandle<void> m_fontArchiveCatalogData;
|
||||
|
||||
static FontManagerImpl ms_instance;
|
||||
static FontPreset ms_fontPresets[FontPresets::kCount];
|
||||
};
|
||||
|
||||
void FontManagerImpl::Init()
|
||||
{
|
||||
m_systemFont = FontFamily::Create(kSystemFontCacheID);
|
||||
m_applicationFont = FontFamily::Create(kApplicationFontCacheID);
|
||||
m_handwritingFont = FontFamily::Create(kHandwritingFontCacheID);
|
||||
m_monospaceFont = FontFamily::Create(kMonospaceFontCacheID);
|
||||
for (int i = 0; i < FontFamilyIDs::kCount; i++)
|
||||
m_fontFamilies[static_cast<FontFamilyID_t>(i)] = FontFamily::Create(static_cast<FontFamilyID_t>(i));
|
||||
|
||||
if (m_systemFont)
|
||||
m_systemFont->AddFont(FontFamilyFlag_None, "Fonts/OpenSans/OpenSans-ExtraBold.ttf", FontHacks_None);
|
||||
if (m_fontFamilies[FontFamilyIDs::kSystem])
|
||||
m_fontFamilies[FontFamilyIDs::kSystem]->AddFont(FontFamilyFlag_None, "Fonts/OpenSans/OpenSans-ExtraBold.ttf", FontHacks_None);
|
||||
|
||||
if (m_applicationFont)
|
||||
if (m_fontFamilies[FontFamilyIDs::kApplication])
|
||||
{
|
||||
m_applicationFont->AddFont(FontFamilyFlag_None, "Fonts/OpenSans/OpenSans-SemiBold.ttf", FontHacks_None);
|
||||
m_applicationFont->AddFont(FontFamilyFlag_Bold, "Fonts/OpenSans/OpenSans-Bold.ttf", FontHacks_None);
|
||||
m_fontFamilies[FontFamilyIDs::kApplication]->AddFont(FontFamilyFlag_None, "Fonts/OpenSans/OpenSans-SemiBold.ttf", FontHacks_None);
|
||||
m_fontFamilies[FontFamilyIDs::kApplication]->AddFont(FontFamilyFlag_Bold, "Fonts/OpenSans/OpenSans-Bold.ttf", FontHacks_None);
|
||||
}
|
||||
|
||||
if (m_handwritingFont)
|
||||
m_handwritingFont->AddFont(FontFamilyFlag_None, "Fonts/GochiHand/GochiHand-Regular.ttf", FontHacks_None);
|
||||
if (m_fontFamilies[FontFamilyIDs::kHandwriting])
|
||||
m_fontFamilies[FontFamilyIDs::kHandwriting]->AddFont(FontFamilyFlag_None, "Fonts/GochiHand/GochiHand-Regular.ttf", FontHacks_None);
|
||||
|
||||
if (m_monospaceFont)
|
||||
m_monospaceFont->AddFont(FontFamilyFlag_None, "Fonts/Roboto/RobotoMono-Regular.ttf", FontHacks_None);
|
||||
if (m_fontFamilies[FontFamilyIDs::kMonospace])
|
||||
m_fontFamilies[FontFamilyIDs::kMonospace]->AddFont(FontFamilyFlag_None, "Fonts/Roboto/RobotoMono-Regular.ttf", FontHacks_None);
|
||||
|
||||
memset(m_cachedRenderedFonts, 0, sizeof(m_cachedRenderedFonts));
|
||||
}
|
||||
|
||||
void FontManagerImpl::Shutdown()
|
||||
{
|
||||
if (m_systemFont)
|
||||
m_systemFont->Destroy();
|
||||
|
||||
if (m_applicationFont)
|
||||
m_applicationFont->Destroy();
|
||||
|
||||
if (m_handwritingFont)
|
||||
m_handwritingFont->Destroy();
|
||||
|
||||
if (m_monospaceFont)
|
||||
m_monospaceFont->Destroy();
|
||||
for (int fid = 0; fid < FontFamilyIDs::kCount; fid++)
|
||||
{
|
||||
if (m_fontFamilies[fid])
|
||||
m_fontFamilies[fid]->Destroy();
|
||||
}
|
||||
|
||||
IGpFontHandler *hfh = PLDrivers::GetFontHandler();
|
||||
|
||||
@@ -126,27 +122,37 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
FontFamily *FontManagerImpl::GetSystemFont(int textSize, int variationFlags) const
|
||||
FontFamily *FontManagerImpl::GetFont(FontFamilyID_t fontFamilyID) const
|
||||
{
|
||||
return m_systemFont;
|
||||
return m_fontFamilies[fontFamilyID];
|
||||
}
|
||||
|
||||
FontFamily *FontManagerImpl::GetApplicationFont(int textSize, int variationFlags) const
|
||||
void FontManagerImpl::GetFontPreset(FontPreset_t preset, FontFamilyID_t *outFamilyID, int *outSize, int *outVariationFlags, bool *outAA) const
|
||||
{
|
||||
if (textSize < 11 && (variationFlags & FontFamilyFlag_Bold) != 0)
|
||||
return m_systemFont; // Use heavier font below 11pt
|
||||
if (outSize)
|
||||
*outSize = ms_fontPresets[preset].m_textSize;
|
||||
|
||||
return m_applicationFont;
|
||||
}
|
||||
if (outVariationFlags)
|
||||
*outVariationFlags = ms_fontPresets[preset].m_variationFlags;
|
||||
|
||||
FontFamily *FontManagerImpl::GetHandwritingFont(int textSize, int variationFlags) const
|
||||
{
|
||||
return m_handwritingFont;
|
||||
}
|
||||
if (outAA)
|
||||
*outAA = ms_fontPresets[preset].m_aa;
|
||||
|
||||
FontFamily *FontManagerImpl::GetMonospaceFont(int textSize, int variationFlags) const
|
||||
{
|
||||
return m_monospaceFont;
|
||||
if (outFamilyID)
|
||||
{
|
||||
switch (ms_fontPresets[preset].m_familyID)
|
||||
{
|
||||
case FontFamilyIDs::kApplication:
|
||||
if (ms_fontPresets[preset].m_textSize < 11 && (ms_fontPresets[preset].m_variationFlags & FontFamilyFlag_Bold) != 0)
|
||||
*outFamilyID = FontFamilyIDs::kSystem; // Use heavier font below 11pt
|
||||
else
|
||||
*outFamilyID = FontFamilyIDs::kApplication;
|
||||
break;
|
||||
default:
|
||||
*outFamilyID = ms_fontPresets[preset].m_familyID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FontManagerImpl::FindOrReserveCacheSlot(int cacheID, int size, bool aa, CachedRenderedFont *&outCacheSlot, RenderedFont *&outRF)
|
||||
@@ -206,15 +212,15 @@ namespace PortabilityLayer
|
||||
|
||||
RenderedFont *rfont = nullptr;
|
||||
CachedRenderedFont *cacheSlot = nullptr;
|
||||
int cacheID = fontFamily->GetCacheID();
|
||||
FontFamilyID_t familyID = fontFamily->GetFamilyID();
|
||||
|
||||
if (this->FindOrReserveCacheSlot(cacheID, size, aa, cacheSlot, rfont))
|
||||
if (this->FindOrReserveCacheSlot(familyID, size, aa, cacheSlot, rfont))
|
||||
return rfont;
|
||||
|
||||
rfont = fm->LoadCachedRenderedFont(cacheID, size, aa, flags);
|
||||
rfont = fm->LoadCachedRenderedFont(familyID, size, aa, flags);
|
||||
if (rfont)
|
||||
{
|
||||
ReplaceCachedRenderedFont(*cacheSlot, rfont, cacheID, size, aa, flags);
|
||||
ReplaceCachedRenderedFont(*cacheSlot, rfont, familyID, size, aa, flags);
|
||||
return rfont;
|
||||
}
|
||||
|
||||
@@ -228,9 +234,7 @@ namespace PortabilityLayer
|
||||
rfont = FontRenderer::GetInstance()->RenderFont(hostFont, size, aa, fontFamily->GetHacksForVariation(variation));
|
||||
if (rfont)
|
||||
{
|
||||
fm->SaveCachedRenderedFont(rfont, fontFamily->GetCacheID(), size, aa, flags);
|
||||
|
||||
ReplaceCachedRenderedFont(*cacheSlot, rfont, cacheID, size, aa, flags);
|
||||
ReplaceCachedRenderedFont(*cacheSlot, rfont, familyID, size, aa, flags);
|
||||
|
||||
return rfont;
|
||||
}
|
||||
@@ -238,60 +242,110 @@ namespace PortabilityLayer
|
||||
return rfont;
|
||||
}
|
||||
|
||||
RenderedFont *FontManagerImpl::LoadCachedRenderedFont(int cacheID, int size, bool aa, int flags) const
|
||||
RenderedFont *FontManagerImpl::LoadCachedRenderedFont(FontFamilyID_t familyID, int size, bool aa, int flags)
|
||||
{
|
||||
char filename[kFontCacheNameSize];
|
||||
GenerateCacheFileName(filename, cacheID, size, aa, flags);
|
||||
|
||||
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, filename, false, GpFileCreationDispositions::kOpenExisting);
|
||||
if (!stream)
|
||||
return nullptr;
|
||||
|
||||
BEUInt32_t version;
|
||||
if (stream->Read(&version, sizeof(version)) != sizeof(version) || version != kFontCacheVersion)
|
||||
if (!m_fontArchive)
|
||||
{
|
||||
stream->Close();
|
||||
return nullptr;
|
||||
m_fontArchiveFile = PortabilityLayer::FileManager::GetInstance()->OpenCompositeFile(VirtualDirectories::kApplicationData, PSTR("Fonts"));
|
||||
if (!m_fontArchiveFile)
|
||||
return nullptr;
|
||||
|
||||
m_fontArchive = PortabilityLayer::ResourceManager::GetInstance()->LoadResFile(m_fontArchiveFile);
|
||||
if (!m_fontArchive)
|
||||
{
|
||||
m_fontArchiveFile->Close();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_fontArchiveCatalogData = m_fontArchive->LoadResource('RFCT', 1000);
|
||||
if (!m_fontArchiveCatalogData)
|
||||
{
|
||||
m_fontArchive->Destroy();
|
||||
m_fontArchiveFile->Close();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
RenderedFont *rfont = PortabilityLayer::FontRenderer::GetInstance()->LoadCache(stream);
|
||||
stream->Close();
|
||||
FontFamily *fontFamily = this->GetFont(familyID);
|
||||
int variation = fontFamily->GetVariationForFlags(flags);
|
||||
|
||||
FontHacks hacks = FontHacks_None;
|
||||
const char *path = nullptr;
|
||||
if (!fontFamily->GetFontSpec(variation, hacks, path))
|
||||
return nullptr;
|
||||
|
||||
size_t pathLen = strlen(path);
|
||||
|
||||
// Parse font cache header
|
||||
const uint8_t *catalogBytes = static_cast<const uint8_t*>(*m_fontArchiveCatalogData);
|
||||
|
||||
RenderedFontCatalogHeader catHeader;
|
||||
memcpy(&catHeader, catalogBytes, sizeof(catHeader));
|
||||
|
||||
if (catHeader.m_version != RenderedFontCatalogHeader::kVersion)
|
||||
return nullptr;
|
||||
|
||||
size_t numPaths = catHeader.m_numPaths;
|
||||
size_t numFonts = catHeader.m_numRFonts;
|
||||
|
||||
const uint8_t *pathsBytes = catalogBytes + catHeader.m_pathsOffset;
|
||||
const uint8_t *pathEntryBytes = catalogBytes + sizeof(RenderedFontCatalogHeader);
|
||||
const uint8_t *fontEntryBytes = pathEntryBytes + sizeof(RenderedFontCatalogPathEntry) * numPaths;
|
||||
|
||||
size_t pathIndex = numPaths;
|
||||
for (size_t i = 0; i < numPaths; i++)
|
||||
{
|
||||
RenderedFontCatalogPathEntry pathEntry;
|
||||
memcpy(&pathEntry, pathEntryBytes + i * sizeof(RenderedFontCatalogPathEntry), sizeof(RenderedFontCatalogPathEntry));
|
||||
|
||||
if (pathEntry.m_pathSize != pathLen)
|
||||
continue;
|
||||
|
||||
if (!memcmp(pathsBytes + pathEntry.m_pathOffset, path, pathLen))
|
||||
{
|
||||
pathIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pathIndex == numPaths)
|
||||
return nullptr;
|
||||
|
||||
size_t fontIndex = numFonts;
|
||||
for (size_t i = 0; i < numFonts; i++)
|
||||
{
|
||||
RenderedFontCatalogRFontEntry fontEntry;
|
||||
memcpy(&fontEntry, fontEntryBytes + i * sizeof(RenderedFontCatalogRFontEntry), sizeof(RenderedFontCatalogRFontEntry));
|
||||
|
||||
if (fontEntry.m_pathIndex == pathIndex && static_cast<FontHacks>(fontEntry.m_hacks) == hacks && fontEntry.m_fontSize == size && (fontEntry.m_isAA != 0) == aa)
|
||||
{
|
||||
fontIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fontIndex == numFonts)
|
||||
return nullptr;
|
||||
|
||||
THandle<void> res = m_fontArchive->LoadResource('RFNT', 1000 + static_cast<int>(fontIndex));
|
||||
if (!res)
|
||||
return nullptr;
|
||||
|
||||
PortabilityLayer::MemReaderStream stream(*res, res.MMBlock()->m_size);
|
||||
|
||||
RenderedFont *rfont = PortabilityLayer::FontRenderer::GetInstance()->LoadCache(&stream);
|
||||
res.Dispose();
|
||||
|
||||
return rfont;
|
||||
}
|
||||
|
||||
void FontManagerImpl::SaveCachedRenderedFont(const RenderedFont *rfont, int cacheID, int size, bool aa, int flags) const
|
||||
{
|
||||
char filename[kFontCacheNameSize];
|
||||
GenerateCacheFileName(filename, cacheID, size, aa, flags);
|
||||
|
||||
GpIOStream *stream = PLDrivers::GetFileSystem()->OpenFile(PortabilityLayer::VirtualDirectories::kFontCache, filename, true, GpFileCreationDispositions::kCreateOrOverwrite);
|
||||
if (!stream)
|
||||
return;
|
||||
|
||||
BEUInt32_t zero32(0);
|
||||
if (stream->Write(&zero32, sizeof(zero32)) != sizeof(zero32))
|
||||
{
|
||||
stream->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (PortabilityLayer::FontRenderer::GetInstance()->SaveCache(rfont, stream))
|
||||
{
|
||||
BEUInt32_t version(kFontCacheVersion);
|
||||
stream->SeekStart(0);
|
||||
stream->Write(&version, sizeof(version));
|
||||
}
|
||||
|
||||
stream->Close();
|
||||
}
|
||||
|
||||
void FontManagerImpl::PurgeCache()
|
||||
{
|
||||
m_systemFont->PurgeCache();
|
||||
m_applicationFont->PurgeCache();
|
||||
m_handwritingFont->PurgeCache();
|
||||
m_monospaceFont->PurgeCache();
|
||||
for (int fid = 0; fid < FontFamilyIDs::kCount; fid++)
|
||||
{
|
||||
if (m_fontFamilies[fid])
|
||||
m_fontFamilies[fid]->PurgeCache();
|
||||
}
|
||||
}
|
||||
|
||||
FontManagerImpl *FontManagerImpl::GetInstance()
|
||||
@@ -300,8 +354,11 @@ namespace PortabilityLayer
|
||||
}
|
||||
|
||||
FontManagerImpl::FontManagerImpl()
|
||||
: m_systemFont(nullptr)
|
||||
: m_fontArchive(nullptr)
|
||||
, m_fontArchiveFile(nullptr)
|
||||
{
|
||||
for (int fid = 0; fid < FontFamilyIDs::kCount; fid++)
|
||||
m_fontFamilies[fid] = nullptr;
|
||||
}
|
||||
|
||||
void FontManagerImpl::ResetUsageCounter()
|
||||
@@ -345,10 +402,26 @@ namespace PortabilityLayer
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FontManagerImpl::GenerateCacheFileName(char(&str)[kFontCacheNameSize], int cacheID, int size, bool aa, int flags)
|
||||
FontManagerImpl::FontPreset FontManagerImpl::ms_fontPresets[FontPresets::kCount] =
|
||||
{
|
||||
sprintf(str, "rf_%i_%i_%s_%i.cache", cacheID, size, aa ? "aa" : "mc", flags);
|
||||
}
|
||||
{ FontFamilyIDs::kSystem, 12, FontFamilyFlag_None, true },
|
||||
{ FontFamilyIDs::kSystem, 12, FontFamilyFlag_Bold, true },
|
||||
|
||||
{ FontFamilyIDs::kApplication, 8, FontFamilyFlag_None, true },
|
||||
{ FontFamilyIDs::kApplication, 9, FontFamilyFlag_None, true },
|
||||
{ FontFamilyIDs::kApplication, 9, FontFamilyFlag_Bold, true },
|
||||
{ FontFamilyIDs::kApplication, 10, FontFamilyFlag_Bold, true },
|
||||
{ FontFamilyIDs::kApplication, 12, FontFamilyFlag_Bold, true },
|
||||
{ FontFamilyIDs::kApplication, 14, FontFamilyFlag_None, true },
|
||||
{ FontFamilyIDs::kApplication, 14, FontFamilyFlag_Bold, true },
|
||||
{ FontFamilyIDs::kApplication, 18, FontFamilyFlag_None, true },
|
||||
{ FontFamilyIDs::kApplication, 40, FontFamilyFlag_None, true },
|
||||
|
||||
{ FontFamilyIDs::kMonospace, 10, FontFamilyFlag_None, true },
|
||||
|
||||
{ FontFamilyIDs::kHandwriting, 24, FontFamilyFlag_None, true },
|
||||
{ FontFamilyIDs::kHandwriting, 48, FontFamilyFlag_None, true },
|
||||
};
|
||||
|
||||
FontManagerImpl FontManagerImpl::ms_instance;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "FontHacks.h"
|
||||
#include "FontFamilyID.h"
|
||||
|
||||
struct IGpFont;
|
||||
|
||||
@@ -9,21 +10,46 @@ namespace PortabilityLayer
|
||||
class FontFamily;
|
||||
class RenderedFont;
|
||||
|
||||
namespace FontPresets
|
||||
{
|
||||
enum FontPreset
|
||||
{
|
||||
kSystem12,
|
||||
kSystem12Bold,
|
||||
|
||||
kApplication8,
|
||||
kApplication9,
|
||||
kApplication9Bold,
|
||||
kApplication10Bold,
|
||||
kApplication12Bold,
|
||||
kApplication14,
|
||||
kApplication14Bold,
|
||||
kApplication18,
|
||||
kApplication40,
|
||||
|
||||
kMono10,
|
||||
|
||||
kHandwriting24,
|
||||
kHandwriting48,
|
||||
|
||||
kCount,
|
||||
};
|
||||
}
|
||||
|
||||
typedef FontPresets::FontPreset FontPreset_t;
|
||||
|
||||
class FontManager
|
||||
{
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual FontFamily *GetSystemFont(int fontSize, int variationFlags) const = 0;
|
||||
virtual FontFamily *GetApplicationFont(int fontSize, int variationFlags) const = 0;
|
||||
virtual FontFamily *GetHandwritingFont(int fontSize, int variationFlags) const = 0;
|
||||
virtual FontFamily *GetMonospaceFont(int fontSize, int variationFlags) const = 0;
|
||||
virtual FontFamily *GetFont(FontFamilyID_t fontFamilyID) const = 0;
|
||||
virtual void GetFontPreset(FontPreset_t fontPreset, FontFamilyID_t *outFamilyID, int *outSize, int *outVariationFlags, bool *outAA) const = 0;
|
||||
|
||||
virtual RenderedFont *GetRenderedFontFromFamily(FontFamily *fontFamily, int fontSize, bool aa, int flags) = 0;
|
||||
|
||||
virtual RenderedFont *LoadCachedRenderedFont(int cacheID, int size, bool aa, int flags) const = 0;
|
||||
virtual void SaveCachedRenderedFont(const RenderedFont *rfont, int cacheID, int size, bool aa, int flags) const = 0;
|
||||
virtual RenderedFont *LoadCachedRenderedFont(FontFamilyID_t familyID, int size, bool aa, int flags) = 0;
|
||||
|
||||
virtual void PurgeCache() = 0;
|
||||
|
||||
|
||||
@@ -44,19 +44,42 @@ namespace PortabilityLayer
|
||||
struct CacheHeader
|
||||
{
|
||||
BEUInt32_t m_cacheVersion;
|
||||
BEUInt32_t m_glyphDataUncompressedSize;
|
||||
BEUInt32_t m_glyphDataCompressedSize;
|
||||
BEUInt32_t m_sizeSize;
|
||||
BEUInt32_t m_glyphDataSize;
|
||||
|
||||
BEUInt32_t m_isAA;
|
||||
};
|
||||
|
||||
static const uint32_t kRFontCacheVersion = 2;
|
||||
struct SerializedGlyphMetrics
|
||||
{
|
||||
BEUInt32_t m_glyphDataPitch;
|
||||
|
||||
BEUInt32_t m_glyphWidth;
|
||||
BEUInt32_t m_glyphHeight;
|
||||
|
||||
BEInt16_t m_bearingX;
|
||||
BEInt16_t m_bearingY;
|
||||
BEInt16_t m_advanceX;
|
||||
};
|
||||
|
||||
struct SerializedFontMetrics
|
||||
{
|
||||
BEInt32_t m_ascent;
|
||||
BEInt32_t m_descent;
|
||||
BEInt32_t m_linegap;
|
||||
};
|
||||
|
||||
static const uint32_t kRFontCacheVersion = 3;
|
||||
|
||||
RenderedFontImpl(void *data, size_t dataSize, bool aa);
|
||||
~RenderedFontImpl();
|
||||
|
||||
bool LoadInternal(GpIOStream *stream, size_t compressedDataSize);
|
||||
bool LoadInternal(GpIOStream *stream, size_t dataSize);
|
||||
|
||||
static SerializedGlyphMetrics SerializeGlyphMetrics(const GpRenderedGlyphMetrics &metrics);
|
||||
static GpRenderedGlyphMetrics DeserializeGlyphMetrics(const SerializedGlyphMetrics &metrics);
|
||||
|
||||
static SerializedFontMetrics SerializeFontMetrics(const GpRenderedFontMetrics &metrics);
|
||||
static GpRenderedFontMetrics DeserializeFontMetrics(const SerializedFontMetrics &metrics);
|
||||
|
||||
size_t m_dataOffsets[256];
|
||||
GpRenderedGlyphMetrics m_glyphMetrics[256];
|
||||
@@ -143,14 +166,11 @@ namespace PortabilityLayer
|
||||
if (header.m_cacheVersion != kRFontCacheVersion)
|
||||
return nullptr;
|
||||
|
||||
if (header.m_sizeSize != sizeof(size_t))
|
||||
return nullptr;
|
||||
|
||||
RenderedFontImpl *rfont = RenderedFontImpl::Create(header.m_glyphDataUncompressedSize, header.m_isAA != 0);
|
||||
RenderedFontImpl *rfont = RenderedFontImpl::Create(header.m_glyphDataSize, header.m_isAA != 0);
|
||||
if (!rfont)
|
||||
return nullptr;
|
||||
|
||||
if (!rfont->LoadInternal(stream, header.m_glyphDataCompressedSize))
|
||||
if (!rfont->LoadInternal(stream, header.m_glyphDataSize))
|
||||
{
|
||||
rfont->Destroy();
|
||||
return nullptr;
|
||||
@@ -163,51 +183,35 @@ namespace PortabilityLayer
|
||||
{
|
||||
CacheHeader header;
|
||||
header.m_cacheVersion = kRFontCacheVersion;
|
||||
header.m_glyphDataUncompressedSize = static_cast<uint32_t>(this->m_dataSize);
|
||||
header.m_glyphDataCompressedSize = 0;
|
||||
header.m_isAA = m_isAntiAliased;
|
||||
header.m_sizeSize = sizeof(size_t);
|
||||
header.m_glyphDataSize = static_cast<uint32_t>(this->m_dataSize);
|
||||
header.m_isAA = m_isAntiAliased ? 1 : 0;
|
||||
|
||||
GpUFilePos_t headerPos = stream->Tell();
|
||||
|
||||
if (stream->Write(&header, sizeof(header)) != sizeof(header))
|
||||
return false;
|
||||
|
||||
DeflateContext *deflateContext = DeflateContext::Create(stream, 9);
|
||||
if (!deflateContext)
|
||||
if (!stream->WriteExact(m_data, m_dataSize))
|
||||
return false;
|
||||
|
||||
GpUFilePos_t dataStartPos = stream->Tell();
|
||||
|
||||
if (!deflateContext->Append(m_data, m_dataSize) || !deflateContext->Flush())
|
||||
for (size_t i = 0; i < sizeof(m_dataOffsets) / sizeof(m_dataOffsets[0]); i++)
|
||||
{
|
||||
deflateContext->Destroy();
|
||||
return false;
|
||||
BEUInt32_t dataOffset = BEUInt32_t(static_cast<uint32_t>(m_dataOffsets[i]));
|
||||
if (!stream->WriteExact(&dataOffset, sizeof(dataOffset)))
|
||||
return false;
|
||||
}
|
||||
|
||||
deflateContext->Destroy();
|
||||
for (size_t i = 0; i < sizeof(m_glyphMetrics) / sizeof(m_glyphMetrics[0]); i++)
|
||||
{
|
||||
SerializedGlyphMetrics serialized = SerializeGlyphMetrics(m_glyphMetrics[i]);
|
||||
|
||||
GpUFilePos_t dataEndPos = stream->Tell();
|
||||
if (!stream->WriteExact(&serialized, sizeof(serialized)))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stream->Write(m_dataOffsets, sizeof(m_dataOffsets)) != sizeof(m_dataOffsets))
|
||||
return false;
|
||||
SerializedFontMetrics fontMetrics = SerializeFontMetrics(m_fontMetrics);
|
||||
|
||||
if (stream->Write(m_glyphMetrics, sizeof(m_glyphMetrics)) != sizeof(m_glyphMetrics))
|
||||
return false;
|
||||
|
||||
if (stream->Write(&m_fontMetrics, sizeof(m_fontMetrics)) != sizeof(m_fontMetrics))
|
||||
return false;
|
||||
|
||||
GpUFilePos_t endPos = stream->Tell();
|
||||
|
||||
if (!stream->SeekStart(headerPos))
|
||||
return false;
|
||||
|
||||
header.m_glyphDataCompressedSize = dataEndPos - dataStartPos;
|
||||
if (stream->Write(&header, sizeof(header)) != sizeof(header))
|
||||
return false;
|
||||
|
||||
if (!stream->SeekStart(headerPos))
|
||||
if (!stream->WriteExact(&fontMetrics, sizeof(fontMetrics)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -246,25 +250,86 @@ namespace PortabilityLayer
|
||||
{
|
||||
}
|
||||
|
||||
bool RenderedFontImpl::LoadInternal(GpIOStream *stream, size_t compressedDataSize)
|
||||
bool RenderedFontImpl::LoadInternal(GpIOStream *stream, size_t dataSize)
|
||||
{
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
|
||||
if (!DeflateCodec::DecompressStream(stream, compressedDataSize, m_data, m_dataSize))
|
||||
if (!stream->ReadExact(m_data, m_dataSize))
|
||||
return false;
|
||||
|
||||
if (stream->Read(m_dataOffsets, sizeof(m_dataOffsets)) != sizeof(m_dataOffsets))
|
||||
for (size_t i = 0; i < sizeof(m_dataOffsets) / sizeof(m_dataOffsets[0]); i++)
|
||||
{
|
||||
BEUInt32_t dataOffset;
|
||||
if (!stream->ReadExact(&dataOffset, sizeof(dataOffset)))
|
||||
return false;
|
||||
|
||||
m_dataOffsets[i] = dataOffset;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sizeof(m_glyphMetrics) / sizeof(m_glyphMetrics[0]); i++)
|
||||
{
|
||||
SerializedGlyphMetrics glyphMetrics;
|
||||
if (!stream->ReadExact(&glyphMetrics, sizeof(glyphMetrics)))
|
||||
return false;
|
||||
|
||||
m_glyphMetrics[i] = DeserializeGlyphMetrics(glyphMetrics);
|
||||
}
|
||||
|
||||
SerializedFontMetrics fontMetrics;
|
||||
if (!stream->ReadExact(&fontMetrics, sizeof(fontMetrics)))
|
||||
return false;
|
||||
|
||||
if (stream->Read(m_glyphMetrics, sizeof(m_glyphMetrics)) != sizeof(m_glyphMetrics))
|
||||
return false;
|
||||
|
||||
if (stream->Read(&m_fontMetrics, sizeof(m_fontMetrics)) != sizeof(m_fontMetrics))
|
||||
return false;
|
||||
m_fontMetrics = DeserializeFontMetrics(fontMetrics);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
RenderedFontImpl::SerializedGlyphMetrics RenderedFontImpl::SerializeGlyphMetrics(const GpRenderedGlyphMetrics &metrics)
|
||||
{
|
||||
SerializedGlyphMetrics result;
|
||||
result.m_advanceX = metrics.m_advanceX;
|
||||
result.m_bearingX = metrics.m_bearingX;
|
||||
result.m_bearingY = metrics.m_bearingY;
|
||||
result.m_glyphDataPitch = static_cast<uint32_t>(metrics.m_glyphDataPitch);
|
||||
result.m_glyphHeight = metrics.m_glyphHeight;
|
||||
result.m_glyphWidth = metrics.m_glyphWidth;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GpRenderedGlyphMetrics RenderedFontImpl::DeserializeGlyphMetrics(const SerializedGlyphMetrics &metrics)
|
||||
{
|
||||
GpRenderedGlyphMetrics result;
|
||||
result.m_advanceX = metrics.m_advanceX;
|
||||
result.m_bearingX = metrics.m_bearingX;
|
||||
result.m_bearingY = metrics.m_bearingY;
|
||||
result.m_glyphDataPitch = static_cast<uint32_t>(metrics.m_glyphDataPitch);
|
||||
result.m_glyphHeight = metrics.m_glyphHeight;
|
||||
result.m_glyphWidth = metrics.m_glyphWidth;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
RenderedFontImpl::SerializedFontMetrics RenderedFontImpl::SerializeFontMetrics(const GpRenderedFontMetrics &metrics)
|
||||
{
|
||||
SerializedFontMetrics result;
|
||||
result.m_ascent = metrics.m_ascent;
|
||||
result.m_descent = metrics.m_descent;
|
||||
result.m_linegap = metrics.m_linegap;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GpRenderedFontMetrics RenderedFontImpl::DeserializeFontMetrics(const SerializedFontMetrics &metrics)
|
||||
{
|
||||
GpRenderedFontMetrics result;
|
||||
result.m_ascent = metrics.m_ascent;
|
||||
result.m_descent = metrics.m_descent;
|
||||
result.m_linegap = metrics.m_linegap;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
RenderedFont *FontRendererImpl::RenderFont(IGpFont *font, int size, bool aa, FontHacks fontHacks)
|
||||
{
|
||||
|
||||
@@ -209,8 +209,6 @@ namespace PortabilityLayer
|
||||
static bool ItemIsSeparator(const Menu &menu, const MenuItem &item);
|
||||
|
||||
static const unsigned int kIconResID = 128;
|
||||
static const unsigned int kMenuFontSize = 12;
|
||||
static const unsigned int kTouchScreenMenuFontSize = 40;
|
||||
static const unsigned int kMenuBarIconYOffset = 2;
|
||||
static const unsigned int kMenuBarTextYOffset = 14;
|
||||
static const unsigned int kTouchScreenMenuBarTextYOffset = 40;
|
||||
@@ -235,6 +233,9 @@ namespace PortabilityLayer
|
||||
static const int kMenuFontFlags = PortabilityLayer::FontFamilyFlag_Bold;
|
||||
static const int kTouchScreenMenuFontFlags = PortabilityLayer::FontFamilyFlag_None;
|
||||
|
||||
static const FontPreset_t kMenuFontPreset = FontPresets::kSystem12Bold;
|
||||
static const FontPreset_t kTouchScreenMenuFontPreset = FontPresets::kApplication40;
|
||||
|
||||
DrawSurface *m_menuBarGraf;
|
||||
|
||||
THandle<Menu> m_firstMenu;
|
||||
@@ -954,12 +955,12 @@ namespace PortabilityLayer
|
||||
unsigned int textYOffset = 0;
|
||||
if (m_isTouchScreen)
|
||||
{
|
||||
sysFont = GetApplicationFont(kTouchScreenMenuFontSize, kTouchScreenMenuFontFlags, true);
|
||||
sysFont = GetFont(kTouchScreenMenuFontPreset);
|
||||
textYOffset = kTouchScreenMenuBarTextYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
sysFont = GetSystemFont(kMenuFontSize, kMenuFontFlags, true);
|
||||
sysFont = GetFont(kMenuFontPreset);
|
||||
textYOffset = kMenuBarTextYOffset;
|
||||
}
|
||||
|
||||
@@ -1086,29 +1087,17 @@ namespace PortabilityLayer
|
||||
|
||||
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
|
||||
|
||||
PortabilityLayer::RenderedFont *rfont = nullptr;
|
||||
PortabilityLayer::FontFamily *fontFamily = nullptr;
|
||||
|
||||
unsigned int fontSize = 0;
|
||||
unsigned int fontFlags = 0;
|
||||
|
||||
if (m_isTouchScreen)
|
||||
{
|
||||
fontSize = kTouchScreenMenuFontSize;
|
||||
fontFlags = PortabilityLayer::FontFamilyFlag_None;
|
||||
fontFamily = PortabilityLayer::FontManager::GetInstance()->GetApplicationFont(kTouchScreenMenuFontSize, PortabilityLayer::FontFamilyFlag_None);
|
||||
}
|
||||
rfont = GetFont(kTouchScreenMenuFontPreset);
|
||||
else
|
||||
{
|
||||
fontSize = kMenuFontSize;
|
||||
fontFlags = kMenuFontFlags;
|
||||
fontFamily = PortabilityLayer::FontManager::GetInstance()->GetSystemFont(kMenuFontSize, kMenuFontFlags);
|
||||
}
|
||||
rfont = GetFont(kMenuFontPreset);
|
||||
|
||||
|
||||
if (!fontFamily)
|
||||
return;
|
||||
|
||||
PortabilityLayer::RenderedFont *rfont = PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, fontSize, true, fontFlags);
|
||||
if (!rfont)
|
||||
return;
|
||||
|
||||
@@ -1148,11 +1137,7 @@ namespace PortabilityLayer
|
||||
|
||||
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
|
||||
|
||||
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetSystemFont(kMenuFontSize, kMenuFontFlags);
|
||||
if (!fontFamily)
|
||||
return;
|
||||
|
||||
PortabilityLayer::RenderedFont *rfont = PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, kMenuFontSize, true, kMenuFontFlags);
|
||||
PortabilityLayer::RenderedFont *rfont = GetFont(kMenuFontPreset);
|
||||
if (!rfont)
|
||||
return;
|
||||
|
||||
@@ -1498,7 +1483,7 @@ namespace PortabilityLayer
|
||||
surface->FillRect(Rect::Create(static_cast<int16_t>(menu->layoutFinalHeight - 1), 1, static_cast<int16_t>(menu->layoutFinalHeight), static_cast<int16_t>(menu->layoutWidth - 1)), darkGrayColor);
|
||||
}
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(kMenuFontPreset);
|
||||
|
||||
const uint8_t *strBlob = static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents);
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace PortabilityLayer
|
||||
|
||||
ResolveCachingColor textCacheColor = textColor;
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(FontPresets::kSystem12Bold);
|
||||
|
||||
int32_t x = (m_rect.left + m_rect.right - static_cast<int32_t>(sysFont->MeasureString(reinterpret_cast<const uint8_t*>(m_text.UnsafeCharPtr()), m_text.Length()))) / 2;
|
||||
int32_t y = (m_rect.top + m_rect.bottom + static_cast<int32_t>(sysFont->GetMetrics().m_ascent)) / 2;
|
||||
@@ -535,7 +535,7 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(FontPresets::kSystem12Bold);
|
||||
int32_t textV = (m_rect.top + m_rect.bottom + sysFont->GetMetrics().m_ascent) / 2;
|
||||
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), *textColor, sysFont);
|
||||
}
|
||||
@@ -596,7 +596,7 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(FontPresets::kSystem12Bold);
|
||||
int32_t textV = (m_rect.top + m_rect.bottom + sysFont->GetMetrics().m_ascent) / 2;
|
||||
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), *textColor, sysFont);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace PortabilityLayer
|
||||
surface->FillRect(outerRect, blackColor);
|
||||
surface->FillRect(innerRect, whiteColor);
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_None, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(FontPresets::kSystem12);
|
||||
int32_t ascender = sysFont->GetMetrics().m_ascent;
|
||||
int32_t lineGap = sysFont->GetMetrics().m_linegap;
|
||||
|
||||
@@ -1327,7 +1327,9 @@ namespace PortabilityLayer
|
||||
|
||||
FontFamily *EditboxWidget::GetFontFamily() const
|
||||
{
|
||||
return PortabilityLayer::FontManager::GetInstance()->GetSystemFont(12, FontFamilyFlag_None);
|
||||
FontFamilyID_t preset = FontFamilyIDs::kCount;
|
||||
PortabilityLayer::FontManager::GetInstance()->GetFontPreset(FontPresets::kSystem12, &preset, nullptr, nullptr, nullptr);
|
||||
return PortabilityLayer::FontManager::GetInstance()->GetFont(preset);
|
||||
}
|
||||
|
||||
RenderedFont *EditboxWidget::GetRenderedFont() const
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace PortabilityLayer
|
||||
|
||||
surface->FillRect(m_rect, whiteColor);
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(FontPresets::kSystem12Bold);
|
||||
|
||||
const Point topLeftCorner = Point::Create(m_rect.left, m_rect.top);
|
||||
const Point textStartPoint = topLeftCorner + Point::Create(0, sysFont->GetMetrics().m_ascent);
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace PortabilityLayer
|
||||
Rect textRect = innerRect;
|
||||
textRect.right -= 11;
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(FontPresets::kSystem12Bold);
|
||||
Point basePoint = Point::Create(textRect.left + 2, (textRect.top + textRect.bottom + sysFont->GetMetrics().m_ascent + 1) / 2 - 1);
|
||||
|
||||
surface->DrawStringConstrained(basePoint, GetString(), textRect, blackColor, sysFont);
|
||||
|
||||
@@ -2003,41 +2003,20 @@ void BitMap::Init(const Rect &rect, GpPixelFormat_t pixelFormat, size_t pitch, v
|
||||
m_data = dataPtr;
|
||||
}
|
||||
|
||||
|
||||
PortabilityLayer::RenderedFont *GetApplicationFont(int size, int variationFlags, bool aa)
|
||||
PortabilityLayer::RenderedFont *GetFont(PortabilityLayer::FontPreset_t fontPreset)
|
||||
{
|
||||
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetApplicationFont(size, variationFlags);
|
||||
if (!fontFamily)
|
||||
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
|
||||
|
||||
int size = 0;
|
||||
int variationFlags = 0;
|
||||
bool aa = false;
|
||||
PortabilityLayer::FontFamilyID_t familyID = PortabilityLayer::FontFamilyIDs::kCount;
|
||||
|
||||
fontManager->GetFontPreset(fontPreset, &familyID, &size, &variationFlags, &aa);
|
||||
if (familyID == PortabilityLayer::FontFamilyIDs::kCount)
|
||||
return nullptr;
|
||||
|
||||
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, size, aa, variationFlags);
|
||||
}
|
||||
|
||||
PortabilityLayer::RenderedFont *GetSystemFont(int size, int variationFlags, bool aa)
|
||||
{
|
||||
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetSystemFont(size, variationFlags);
|
||||
if (!fontFamily)
|
||||
return nullptr;
|
||||
|
||||
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, size, aa, variationFlags);
|
||||
}
|
||||
|
||||
PortabilityLayer::RenderedFont *GetHandwritingFont(int size, int variationFlags, bool aa)
|
||||
{
|
||||
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetHandwritingFont(size, variationFlags);
|
||||
if (!fontFamily)
|
||||
return nullptr;
|
||||
|
||||
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, size, aa, variationFlags);
|
||||
}
|
||||
|
||||
PortabilityLayer::RenderedFont *GetMonospaceFont(int size, int variationFlags, bool aa)
|
||||
{
|
||||
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetMonospaceFont(size, variationFlags);
|
||||
if (!fontFamily)
|
||||
return nullptr;
|
||||
|
||||
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, size, aa, variationFlags);
|
||||
return fontManager->GetRenderedFontFromFamily(fontManager->GetFont(familyID), size, aa, variationFlags);
|
||||
}
|
||||
|
||||
#include "stb_image_write.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "PLCore.h"
|
||||
#include "QDGraf.h"
|
||||
#include "SharedTypes.h"
|
||||
#include "FontManager.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
@@ -91,10 +92,7 @@ PixMap *GetPortBitMapForCopyBits(DrawSurface *grafPtr);
|
||||
|
||||
Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection);
|
||||
|
||||
PortabilityLayer::RenderedFont *GetApplicationFont(int size, int variationFlags, bool aa);
|
||||
PortabilityLayer::RenderedFont *GetSystemFont(int size, int variationFlags, bool aa);
|
||||
PortabilityLayer::RenderedFont *GetHandwritingFont(int size, int variationFlags, bool aa);
|
||||
PortabilityLayer::RenderedFont *GetMonospaceFont(int size, int variationFlags, bool aa);
|
||||
PortabilityLayer::RenderedFont *GetFont(PortabilityLayer::FontPreset_t fontPreset);
|
||||
|
||||
|
||||
inline RGBColor::RGBColor(uint8_t r, uint8_t g, uint8_t b)
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
<ClInclude Include="FilePermission.h" />
|
||||
<ClInclude Include="FileSectionStream.h" />
|
||||
<ClInclude Include="FontFamily.h" />
|
||||
<ClInclude Include="FontFamilyID.h" />
|
||||
<ClInclude Include="FontManager.h" />
|
||||
<ClInclude Include="FontRenderer.h" />
|
||||
<ClInclude Include="GpAppInterface.h" />
|
||||
@@ -151,6 +152,7 @@
|
||||
<ClInclude Include="PLScrollBarWidget.h" />
|
||||
<ClInclude Include="PLUnalignedPtr.h" />
|
||||
<ClInclude Include="PLWidgets.h" />
|
||||
<ClInclude Include="RenderedFontCatalog.h" />
|
||||
<ClInclude Include="ResolveCachingColor.h" />
|
||||
<ClInclude Include="WorkerThread.h" />
|
||||
<ClInclude Include="TextPlacer.h" />
|
||||
|
||||
@@ -426,6 +426,12 @@
|
||||
<ClInclude Include="InflateStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RenderedFontCatalog.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FontFamilyID.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CFileStream.cpp">
|
||||
|
||||
30
PortabilityLayer/RenderedFontCatalog.h
Normal file
30
PortabilityLayer/RenderedFontCatalog.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "PLBigEndian.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
struct RenderedFontCatalogHeader
|
||||
{
|
||||
static const int kVersion = 1;
|
||||
|
||||
BEUInt32_t m_version;
|
||||
BEUInt32_t m_pathsOffset;
|
||||
BEUInt16_t m_numPaths;
|
||||
BEUInt16_t m_numRFonts;
|
||||
};
|
||||
|
||||
struct RenderedFontCatalogPathEntry
|
||||
{
|
||||
BEUInt16_t m_pathOffset;
|
||||
BEUInt16_t m_pathSize;
|
||||
};
|
||||
|
||||
struct RenderedFontCatalogRFontEntry
|
||||
{
|
||||
uint8_t m_pathIndex;
|
||||
uint8_t m_hacks;
|
||||
uint8_t m_fontSize;
|
||||
uint8_t m_isAA;
|
||||
};
|
||||
}
|
||||
@@ -474,7 +474,7 @@ namespace PortabilityLayer
|
||||
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
|
||||
RenderChromeCloseBox(surface, rect, false);
|
||||
|
||||
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *sysFont = GetFont(FontPresets::kSystem12Bold);
|
||||
int32_t ascender = sysFont->GetMetrics().m_ascent;
|
||||
|
||||
const PLPasStr titlePStr = window->GetTitle().ToShortStr();
|
||||
@@ -593,7 +593,7 @@ namespace PortabilityLayer
|
||||
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
|
||||
RenderChromeCloseBox(surface, rect, false);
|
||||
|
||||
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(10, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
|
||||
PortabilityLayer::RenderedFont *appFont = GetFont(PortabilityLayer::FontPresets::kApplication10Bold);
|
||||
int32_t ascender = appFont->GetMetrics().m_ascent;
|
||||
|
||||
const PLPasStr titlePStr = window->GetTitle().ToShortStr();
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<!-- Installation directory -->
|
||||
<Directory Id="ProgramFiles64Folder">
|
||||
<Directory Id="AEROFOILPRODUCTDIR" Name="Aerofoil">
|
||||
<Directory Id="AEROFOILRESOURCESDIR" Name="Resources" />
|
||||
<Directory Id="AEROFOILPACKAGEDDIR" Name="Packaged">
|
||||
<Directory Id="AEROFOILHOUSESDIR" Name="Houses" />
|
||||
</Directory>
|
||||
@@ -84,6 +83,9 @@
|
||||
<Component Id="ApplicationResources" Guid="*">
|
||||
<File Id="ApplicationResources.gpf" Source="$(var.PackagedDataDir)\ApplicationResources.gpf" KeyPath="yes" Checksum="yes"/>
|
||||
</Component>
|
||||
<Component Id="Fonts" Guid="*">
|
||||
<File Id="Fonts.gpf" Source="$(var.PackagedDataDir)\Fonts.gpf" KeyPath="yes" Checksum="yes"/>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<DirectoryRef Id="AEROFOILTOOLSDIR">
|
||||
|
||||
Reference in New Issue
Block a user