Remove port state, fix background not darkening in room editor

This commit is contained in:
elasota
2020-06-20 02:08:22 -04:00
parent 3bf689664f
commit 9d5adb9bb6
34 changed files with 45 additions and 138 deletions

View File

@@ -845,10 +845,6 @@ namespace PortabilityLayer
RefreshMenuBarLayout();
DrawSurface *oldGraf = GetGraphicsPort();
SetGraphicsPort(m_menuBarGraf);
ResolveCachingColor barMidColor = gs_barMidColor;
graf->FillRect(menuRect, barMidColor);
@@ -976,8 +972,6 @@ namespace PortabilityLayer
}
}
SetGraphicsPort(oldGraf);
m_menuBarGraf->m_port.SetDirty(QDPortDirtyFlag_Contents);
}
@@ -1406,10 +1400,6 @@ namespace PortabilityLayer
DrawSurface *surface = m_menuGraf;
DrawSurface *oldGraf = GetGraphicsPort();
SetGraphicsPort(m_menuGraf);
ResolveCachingColor barMidColor = gs_barMidColor;
{
@@ -1514,8 +1504,6 @@ namespace PortabilityLayer
}
m_menuGraf->m_port.SetDirty(QDPortDirtyFlag_Contents);
SetGraphicsPort(oldGraf);
}
MenuManager *MenuManager::GetInstance()

View File

@@ -43,13 +43,3 @@ void OffsetRect(Rect *rect, int right, int down)
rect->top += down;
rect->bottom += down;
}
DrawSurface *GetGraphicsPort()
{
return PortabilityLayer::QDManager::GetInstance()->GetPort();
}
void SetGraphicsPort(DrawSurface *gw)
{
PortabilityLayer::QDManager::GetInstance()->SetPort(gw);
}

View File

@@ -24,8 +24,5 @@ PixMapHandle GetGWorldPixMap(DrawSurface *gworld);
void OffsetRect(Rect *rect, int right, int down);
DrawSurface *GetGraphicsPort();
void SetGraphicsPort(DrawSurface *gw);
#endif

View File

@@ -48,11 +48,6 @@ static inline void InvertPixel32(uint8_t *pixel)
pixel[3] = 255;
}
void SetPort(DrawSurface *graf)
{
PortabilityLayer::QDManager::GetInstance()->SetPort(graf);
}
void EndUpdate(WindowPtr graf)
{
graf->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
@@ -66,12 +61,6 @@ void SetRect(Rect *rect, short left, short top, short right, short bottom)
rect->right = right;
}
void SetPortWindowPort(WindowPtr window)
{
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
PortabilityLayer::QDManager::GetInstance()->SetPort(window->GetDrawSurface());
}
static void PlotLine(DrawSurface *surface, const PortabilityLayer::Vec2i &pointA, const PortabilityLayer::Vec2i &pointB, PortabilityLayer::ResolveCachingColor &foreColor)
{
const Rect lineRect = Rect::Create(

View File

@@ -61,10 +61,6 @@ typedef CIconPtr *CIconHandle;
typedef Byte Pattern[8];
void SetPortWindowPort(WindowPtr window);
void SetPort(DrawSurface *graf);
void EndUpdate(WindowPtr graf);
void SetRect(Rect *rect, short left, short top, short right, short bottom);

View File

@@ -15,21 +15,16 @@ namespace PortabilityLayer
QDManagerImpl();
void Init() override;
DrawSurface *GetPort() const override;
void SetPort(DrawSurface *gw) override;
PLError_t NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) override;
void DisposeGWorld(DrawSurface *gw) override;
static QDManagerImpl *GetInstance();
private:
DrawSurface *m_port;
static QDManagerImpl ms_instance;
};
QDManagerImpl::QDManagerImpl()
: m_port(nullptr)
{
}
@@ -37,21 +32,6 @@ namespace PortabilityLayer
{
}
DrawSurface *QDManagerImpl::GetPort() const
{
return m_port;
}
void QDManagerImpl::SetPort(DrawSurface *gw)
{
#if GP_DEBUG_CONFIG
if (gw)
gw->m_port.CheckPortSentinel();
#endif
m_port = gw;
}
PLError_t QDManagerImpl::NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable)
{
void *grafStorage = MemoryManager::GetInstance()->Alloc(sizeof(DrawSurface));

View File

@@ -15,8 +15,6 @@ namespace PortabilityLayer
{
public:
virtual void Init() = 0;
virtual DrawSurface *GetPort() const = 0;
virtual void SetPort(DrawSurface *gw) = 0;
virtual PLError_t NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) = 0;
virtual void DisposeGWorld(DrawSurface *gw) = 0;

View File

@@ -196,6 +196,8 @@ namespace PortabilityLayer
void HandleScreenResolutionChange(uint32_t prevWidth, uint32_t prevHeight, uint32_t newWidth, uint32_t newHeight) override;
void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b) override;
Window *GetPutInFrontSentinel() const override;
static WindowManagerImpl *GetInstance();
@@ -1163,9 +1165,6 @@ namespace PortabilityLayer
DetachWindow(window);
if (PortabilityLayer::QDManager::GetInstance()->GetPort() == windowImpl->GetDrawSurface())
PortabilityLayer::QDManager::GetInstance()->SetPort(nullptr);
windowImpl->~WindowImpl();
PortabilityLayer::MemoryManager::GetInstance()->Release(windowImpl);
}
@@ -1290,9 +1289,16 @@ namespace PortabilityLayer
void WindowManagerImpl::SwapExclusiveWindow(Window *& windowRef)
{
const bool hadExclusiveWindow = (m_exclusiveWindow != nullptr);
Window *temp = m_exclusiveWindow;
m_exclusiveWindow = static_cast<WindowImpl*>(windowRef);
windowRef = temp;
const bool haveExclusiveWindow = (m_exclusiveWindow != nullptr);
if (hadExclusiveWindow != haveExclusiveWindow)
HostDisplayDriver::GetInstance()->SetBackgroundDarkenEffect(haveExclusiveWindow);
}
void WindowManagerImpl::FlickerWindowIn(Window *window, int32_t velocity)
@@ -1472,6 +1478,11 @@ namespace PortabilityLayer
}
}
void WindowManagerImpl::SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b)
{
HostDisplayDriver::GetInstance()->SetBackgroundColor(r, g, b, 255);
}
void WindowManagerImpl::ResizeWindow(Window *window, int width, int height)
{
static_cast<WindowImpl*>(window)->Resize(width, height);

View File

@@ -50,6 +50,8 @@ namespace PortabilityLayer
virtual void HandleScreenResolutionChange(uint32_t prevWidth, uint32_t prevHeight, uint32_t newWidth, uint32_t newHeight) = 0;
virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b) = 0;
static WindowManager *GetInstance();
};
}