File system refactoring

This commit is contained in:
elasota
2019-12-29 06:38:18 -05:00
parent b24505164d
commit 430842d17b
74 changed files with 874 additions and 1240 deletions

View File

@@ -18,12 +18,10 @@ namespace PortabilityLayer
void Init() override;
QDPort *GetPort() const override;
void SetPort(QDPort *gw) override;
int NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, int flags) override;
PLError_t NewGWorld(CGraf **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) override;
void DisposeGWorld(CGraf *gw) override;
QDState *GetState() override;
int DepthForPixelFormat(GpPixelFormat_t pixelFormat) const override;
static QDManagerImpl *GetInstance();
private:
@@ -51,37 +49,17 @@ namespace PortabilityLayer
m_port = gw;
}
int QDManagerImpl::NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, int flags)
PLError_t QDManagerImpl::NewGWorld(CGraf **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable)
{
GpPixelFormat_t pixelFormat;
switch (depth)
{
case 1:
pixelFormat = GpPixelFormats::kBW1;
break;
case 8:
pixelFormat = (colorTable == nullptr) ? GpPixelFormats::k8BitStandard : GpPixelFormats::k8BitCustom;
break;
case 16:
pixelFormat = GpPixelFormats::kRGB555;
break;
case 32:
pixelFormat = GpPixelFormats::kRGB32;
break;
default:
return genericErr;
}
void *grafStorage = MemoryManager::GetInstance()->Alloc(sizeof(CGraf));
if (!grafStorage)
return mFulErr;
return PLErrors::kOutOfMemory;
if (!bounds.IsValid())
return genericErr;
return PLErrors::kInvalidParameter;
CGraf *graf = new (grafStorage) CGraf();
int initError = graf->Init(bounds, pixelFormat);
PLError_t initError = graf->Init(bounds, pixelFormat);
if (initError)
{
DisposeGWorld(graf);
@@ -89,7 +67,7 @@ namespace PortabilityLayer
}
*gw = graf;
return noErr;
return PLErrors::kNone;
}
void QDManagerImpl::DisposeGWorld(CGraf *gw)
@@ -103,25 +81,6 @@ namespace PortabilityLayer
return m_port->GetState();
}
int QDManagerImpl::DepthForPixelFormat(GpPixelFormat_t pixelFormat) const
{
switch (pixelFormat)
{
case GpPixelFormats::k8BitStandard:
case GpPixelFormats::k8BitCustom:
return 8;
case GpPixelFormats::kRGB555:
return 16;
case GpPixelFormats::kRGB24:
return 24;
case GpPixelFormats::kRGB32:
return 32;
default:
assert(false);
return 0;
}
}
QDManagerImpl *QDManagerImpl::GetInstance()
{
return &ms_instance;