mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Implemented lazy totalRedraw to prevent multiple redraws on single frame
This commit is contained in:
@@ -99,6 +99,12 @@ bool WindowHandler::isTopWindow(IShowActivatable * window) const
|
|||||||
|
|
||||||
void WindowHandler::totalRedraw()
|
void WindowHandler::totalRedraw()
|
||||||
{
|
{
|
||||||
|
totalRedrawRequested = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowHandler::totalRedrawImpl()
|
||||||
|
{
|
||||||
|
logGlobal->debug("totalRedraw requested!");
|
||||||
CSDL_Ext::fillSurface(screen2, Colors::BLACK);
|
CSDL_Ext::fillSurface(screen2, Colors::BLACK);
|
||||||
|
|
||||||
Canvas target = Canvas::createFromSurface(screen2);
|
Canvas target = Canvas::createFromSurface(screen2);
|
||||||
@@ -109,6 +115,16 @@ void WindowHandler::totalRedraw()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WindowHandler::simpleRedraw()
|
void WindowHandler::simpleRedraw()
|
||||||
|
{
|
||||||
|
if (totalRedrawRequested)
|
||||||
|
totalRedrawImpl();
|
||||||
|
else
|
||||||
|
simpleRedrawImpl();
|
||||||
|
|
||||||
|
totalRedrawRequested = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowHandler::simpleRedrawImpl()
|
||||||
{
|
{
|
||||||
//update only top interface and draw background
|
//update only top interface and draw background
|
||||||
if(windowsStack.size() > 1)
|
if(windowsStack.size() > 1)
|
||||||
|
|||||||
@@ -20,9 +20,17 @@ class WindowHandler
|
|||||||
/// Temporary list of recently popped windows
|
/// Temporary list of recently popped windows
|
||||||
std::vector<std::shared_ptr<IShowActivatable>> disposed;
|
std::vector<std::shared_ptr<IShowActivatable>> disposed;
|
||||||
|
|
||||||
|
bool totalRedrawRequested = false;
|
||||||
|
|
||||||
/// returns top windows
|
/// returns top windows
|
||||||
std::shared_ptr<IShowActivatable> topWindowImpl() const;
|
std::shared_ptr<IShowActivatable> topWindowImpl() const;
|
||||||
|
|
||||||
|
/// forces total redraw (using showAll), sets a flag, method gets called at the end of the rendering
|
||||||
|
void totalRedrawImpl();
|
||||||
|
|
||||||
|
/// update only top windows and draw background from buffer, sets a flag, method gets called at the end of the rendering
|
||||||
|
void simpleRedrawImpl();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// forces total redraw (using showAll), sets a flag, method gets called at the end of the rendering
|
/// forces total redraw (using showAll), sets a flag, method gets called at the end of the rendering
|
||||||
void totalRedraw();
|
void totalRedraw();
|
||||||
|
|||||||
@@ -337,13 +337,7 @@ void CMainMenu::update()
|
|||||||
|
|
||||||
// Handles mouse and key input
|
// Handles mouse and key input
|
||||||
GH.handleEvents();
|
GH.handleEvents();
|
||||||
|
GH.windows().simpleRedraw();
|
||||||
Canvas canvas = Canvas::createFromSurface(screen);
|
|
||||||
|
|
||||||
// check for null othervice crash on finishing a campaign
|
|
||||||
// /FIXME: find out why GH.windows().listInt is empty to begin with
|
|
||||||
if(GH.windows().topWindow<CIntObject>())
|
|
||||||
GH.windows().topWindow<CIntObject>()->show(canvas);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainMenu::openLobby(ESelectionScreen screenType, bool host, const std::vector<std::string> * names, ELoadMode loadMode)
|
void CMainMenu::openLobby(ESelectionScreen screenType, bool host, const std::vector<std::string> * names, ELoadMode loadMode)
|
||||||
|
|||||||
Reference in New Issue
Block a user