Reduce redundant resize repaint passes
This commit is contained in:
@@ -957,6 +957,7 @@ LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LP
|
||||
Application* application = Host::WindowMessageDispatcher::GetApplicationFromWindow(hwnd);
|
||||
if (application != nullptr &&
|
||||
Host::WindowMessageDispatcher::TryDispatch(
|
||||
hwnd,
|
||||
*application,
|
||||
message,
|
||||
wParam,
|
||||
|
||||
@@ -45,11 +45,23 @@ bool WindowMessageDispatcher::TryHandleNonClientCreate(
|
||||
}
|
||||
|
||||
bool WindowMessageDispatcher::TryDispatch(
|
||||
HWND hwnd,
|
||||
Application& application,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam,
|
||||
LRESULT& outResult) {
|
||||
const auto renderAndValidateWindow = [&application, hwnd]() {
|
||||
if (!application.m_renderReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
application.RenderFrame();
|
||||
if (hwnd != nullptr && IsWindow(hwnd)) {
|
||||
ValidateRect(hwnd, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
switch (message) {
|
||||
case WM_SETCURSOR:
|
||||
if (LOWORD(lParam) == HTCLIENT && application.ApplyCurrentCursor()) {
|
||||
@@ -64,9 +76,7 @@ bool WindowMessageDispatcher::TryDispatch(
|
||||
application.OnDpiChanged(
|
||||
static_cast<UINT>(LOWORD(wParam)),
|
||||
*reinterpret_cast<const RECT*>(lParam));
|
||||
if (application.m_renderReady) {
|
||||
application.RenderFrame();
|
||||
}
|
||||
renderAndValidateWindow();
|
||||
outResult = 0;
|
||||
return true;
|
||||
case WM_ENTERSIZEMOVE:
|
||||
@@ -75,9 +85,7 @@ bool WindowMessageDispatcher::TryDispatch(
|
||||
return true;
|
||||
case WM_EXITSIZEMOVE:
|
||||
application.OnExitSizeMove();
|
||||
if (application.m_renderReady) {
|
||||
application.RenderFrame();
|
||||
}
|
||||
renderAndValidateWindow();
|
||||
outResult = 0;
|
||||
return true;
|
||||
case WM_SIZE:
|
||||
@@ -85,9 +93,7 @@ bool WindowMessageDispatcher::TryDispatch(
|
||||
application.OnResize(
|
||||
static_cast<UINT>(LOWORD(lParam)),
|
||||
static_cast<UINT>(HIWORD(lParam)));
|
||||
if (application.m_renderReady) {
|
||||
application.RenderFrame();
|
||||
}
|
||||
renderAndValidateWindow();
|
||||
}
|
||||
outResult = 0;
|
||||
return true;
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
LPARAM lParam,
|
||||
LRESULT& outResult);
|
||||
static bool TryDispatch(
|
||||
HWND hwnd,
|
||||
Application& application,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
|
||||
Reference in New Issue
Block a user