Renderer/WindowSwapchain: Don't create swapchain on minimized window
This is mainly to prepare for Android "windows" where the window is considered minimized when app is in the background (and thus has no ANativeWindow to render to)
This commit is contained in:
parent
3e41400a63
commit
6df919eb70
|
|
@ -56,8 +56,8 @@ namespace Nz
|
||||||
inline CursorController& GetCursorController();
|
inline CursorController& GetCursorController();
|
||||||
inline WindowEventHandler& GetEventHandler();
|
inline WindowEventHandler& GetEventHandler();
|
||||||
WindowHandle GetHandle() const;
|
WindowHandle GetHandle() const;
|
||||||
Vector2i GetPosition() const;
|
const Vector2i& GetPosition() const;
|
||||||
Vector2ui GetSize() const;
|
const Vector2ui& GetSize() const;
|
||||||
WindowStyleFlags GetStyle() const;
|
WindowStyleFlags GetStyle() const;
|
||||||
std::string GetTitle() const;
|
std::string GetTitle() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,18 @@ namespace Nz
|
||||||
return m_eventHandler;
|
return m_eventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const Vector2i& Window::GetPosition() const
|
||||||
|
{
|
||||||
|
NazaraAssert(m_impl, "Window not created");
|
||||||
|
return m_position;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Vector2ui& Window::GetSize() const
|
||||||
|
{
|
||||||
|
NazaraAssert(m_impl, "Window not created");
|
||||||
|
return m_size;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool Window::IsOpen(bool checkClosed)
|
inline bool Window::IsOpen(bool checkClosed)
|
||||||
{
|
{
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,10 @@ namespace Nz
|
||||||
|
|
||||||
if (m_window->IsValid())
|
if (m_window->IsValid())
|
||||||
{
|
{
|
||||||
m_swapchain = m_renderDevice->InstantiateSwapchain(window.GetHandle(), window.GetSize(), m_parameters);
|
|
||||||
m_isMinimized = window.IsMinimized();
|
m_isMinimized = window.IsMinimized();
|
||||||
|
|
||||||
|
if (!m_isMinimized)
|
||||||
|
m_swapchain = m_renderDevice->InstantiateSwapchain(window.GetHandle(), window.GetSize(), m_parameters);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_isMinimized = true; //< consider it minimized so AcquireFrame returns no frame
|
m_isMinimized = true; //< consider it minimized so AcquireFrame returns no frame
|
||||||
|
|
@ -45,7 +47,7 @@ namespace Nz
|
||||||
|
|
||||||
const Vector2ui& WindowSwapchain::GetSize() const
|
const Vector2ui& WindowSwapchain::GetSize() const
|
||||||
{
|
{
|
||||||
return m_swapchain->GetSize();
|
return (m_swapchain) ? m_swapchain->GetSize() : m_window->GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSwapchain::ConnectSignals()
|
void WindowSwapchain::ConnectSignals()
|
||||||
|
|
@ -53,9 +55,9 @@ namespace Nz
|
||||||
WindowEventHandler& windowEvents = m_window->GetEventHandler();
|
WindowEventHandler& windowEvents = m_window->GetEventHandler();
|
||||||
m_onCreated.Connect(windowEvents.OnCreated, [this](const WindowEventHandler* /*eventHandler*/)
|
m_onCreated.Connect(windowEvents.OnCreated, [this](const WindowEventHandler* /*eventHandler*/)
|
||||||
{
|
{
|
||||||
// Recreate swapchain
|
|
||||||
m_swapchain = m_renderDevice->InstantiateSwapchain(m_window->GetHandle(), m_window->GetSize(), m_parameters);
|
|
||||||
m_isMinimized = m_window->IsMinimized();
|
m_isMinimized = m_window->IsMinimized();
|
||||||
|
if (!m_isMinimized)
|
||||||
|
m_swapchain = m_renderDevice->InstantiateSwapchain(m_window->GetHandle(), m_window->GetSize(), m_parameters);
|
||||||
});
|
});
|
||||||
|
|
||||||
m_onDestruction.Connect(windowEvents.OnDestruction, [this](const WindowEventHandler* /*eventHandler*/)
|
m_onDestruction.Connect(windowEvents.OnDestruction, [this](const WindowEventHandler* /*eventHandler*/)
|
||||||
|
|
@ -87,6 +89,9 @@ namespace Nz
|
||||||
|
|
||||||
m_onRestored.Connect(windowEvents.OnRestored, [this](const WindowEventHandler* /*eventHandler*/)
|
m_onRestored.Connect(windowEvents.OnRestored, [this](const WindowEventHandler* /*eventHandler*/)
|
||||||
{
|
{
|
||||||
|
if (!m_swapchain)
|
||||||
|
m_swapchain = m_renderDevice->InstantiateSwapchain(m_window->GetHandle(), m_window->GetSize(), m_parameters);
|
||||||
|
|
||||||
m_isMinimized = false;
|
m_isMinimized = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue