Avoid superfluous calls to SetDirtyAsBlocks when dragging window

See: #170
This commit is contained in:
Jonathan G Rennison
2020-07-09 20:27:51 +01:00
parent e8843cb979
commit 48b15bb7b8
3 changed files with 7 additions and 2 deletions

View File

@@ -1542,7 +1542,7 @@ void DrawDirtyBlocks()
RedrawScreenRect(0, 0, _screen.width, _screen.height); RedrawScreenRect(0, 0, _screen.width, _screen.height);
Window *w; Window *w;
FOR_ALL_WINDOWS_FROM_BACK(w) { FOR_ALL_WINDOWS_FROM_BACK(w) {
w->flags &= ~(WF_DIRTY | WF_WIDGETS_DIRTY); w->flags &= ~(WF_DIRTY | WF_WIDGETS_DIRTY | WF_DRAG_DIRTIED);
} }
_whole_screen_dirty = false; _whole_screen_dirty = false;
} else { } else {
@@ -1562,6 +1562,7 @@ void DrawDirtyBlocks()
Window *w; Window *w;
FOR_ALL_WINDOWS_FROM_BACK(w) { FOR_ALL_WINDOWS_FROM_BACK(w) {
w->flags &= ~WF_DRAG_DIRTIED;
if (!MayBeShown(w)) continue; if (!MayBeShown(w)) continue;
if (w->viewport != nullptr) w->viewport->is_drawn = false; if (w->viewport != nullptr) w->viewport->is_drawn = false;

View File

@@ -2244,7 +2244,10 @@ static EventState HandleWindowDragging()
break; break;
} }
w->SetDirtyAsBlocks(); if (!(w->flags & WF_DRAG_DIRTIED)) {
w->flags |= WF_DRAG_DIRTIED;
w->SetDirtyAsBlocks();
}
int x = _cursor.pos.x + _drag_delta.x; int x = _cursor.pos.x + _drag_delta.x;
int y = _cursor.pos.y + _drag_delta.y; int y = _cursor.pos.y + _drag_delta.y;

View File

@@ -254,6 +254,7 @@ enum WindowFlags : uint16 {
WF_CENTERED = 1 << 10, ///< Window is centered and shall stay centered after ReInit. WF_CENTERED = 1 << 10, ///< Window is centered and shall stay centered after ReInit.
WF_DIRTY = 1 << 11, ///< Whole window is dirty, and requires repainting. WF_DIRTY = 1 << 11, ///< Whole window is dirty, and requires repainting.
WF_WIDGETS_DIRTY = 1 << 12, ///< One or more widgets are dirty, and require repainting. WF_WIDGETS_DIRTY = 1 << 12, ///< One or more widgets are dirty, and require repainting.
WF_DRAG_DIRTIED = 1 << 13, ///< The window has already been marked dirty as blocks as part of the current drag operation
}; };
DECLARE_ENUM_AS_BIT_SET(WindowFlags) DECLARE_ENUM_AS_BIT_SET(WindowFlags)