From 2d19fe6798a900aec59657bfc5eded66f8f798d5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 3 Aug 2019 22:39:24 +0200 Subject: Windows: Improve puglPostRedisplay() performance --- pugl/detail/win.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'pugl/detail/win.c') diff --git a/pugl/detail/win.c b/pugl/detail/win.c index edc8447..1203bca 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -511,7 +511,8 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_SHOWWINDOW: rect = handleConfigure(view, &event); - puglPostRedisplay(view); + RedrawWindow(view->impl->hwnd, NULL, NULL, + RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_INTERNALPAINT); break; case WM_SIZE: rect = handleConfigure(view, &event); @@ -688,8 +689,15 @@ puglWaitForEvent(PuglView* PUGL_UNUSED(view)) } PUGL_API PuglStatus -puglDispatchEvents(PuglWorld* PUGL_UNUSED(world)) +puglDispatchEvents(PuglWorld* world) { + for (size_t i = 0; i < world->numViews; ++i) { + if (world->views[i]->redisplay) { + UpdateWindow(world->views[i]->impl->hwnd); + world->views[i]->redisplay = false; + } + } + /* Windows has no facility to process only currently queued messages, which causes the event loop to run forever in cases like mouse movement where the queue is constantly being filled with new messages. To work around @@ -756,9 +764,8 @@ puglGetTime(const PuglWorld* world) void puglPostRedisplay(PuglView* view) { - RedrawWindow(view->impl->hwnd, NULL, NULL, - RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_INTERNALPAINT); - UpdateWindow(view->impl->hwnd); + InvalidateRect(view->impl->hwnd, NULL, false); + view->redisplay = true; } PuglNativeWindow -- cgit v1.2.1