aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-08-03 22:39:24 +0200
committerDavid Robillard <d@drobilla.net>2019-09-03 08:34:39 +0200
commit2d19fe6798a900aec59657bfc5eded66f8f798d5 (patch)
treef8d8d3e04becb108d570601fe989171b649463e9 /pugl
parent69f38f68879412a9ef157d335d7798917888a261 (diff)
downloadpugl-2d19fe6798a900aec59657bfc5eded66f8f798d5.tar.gz
pugl-2d19fe6798a900aec59657bfc5eded66f8f798d5.tar.bz2
pugl-2d19fe6798a900aec59657bfc5eded66f8f798d5.zip
Windows: Improve puglPostRedisplay() performance
Diffstat (limited to 'pugl')
-rw-r--r--pugl/detail/types.h1
-rw-r--r--pugl/detail/win.c17
2 files changed, 13 insertions, 5 deletions
diff --git a/pugl/detail/types.h b/pugl/detail/types.h
index 5254f01..fa120f0 100644
--- a/pugl/detail/types.h
+++ b/pugl/detail/types.h
@@ -64,6 +64,7 @@ struct PuglViewImpl {
int max_aspect_x;
int max_aspect_y;
bool visible;
+ bool redisplay;
};
/** Cross-platform world definition. */
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