diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-12-01 12:31:14 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-12-09 09:36:20 +0000 |
commit | 1b61390856ce336c82f7b99def574775893bf4f2 (patch) | |
tree | 86dc2d87ea934cb2ed9a5451c7bdad245e56d9ed /src/widgets | |
parent | 8f74fe1b66aed3ca26a9721359472c86d0beeb5b (diff) |
Reduce flushes with repaint() when GL-based compositing is active
Task-number: QTBUG-49655
Change-Id: I7a5d08f681a7d87709aac745154730764040e922
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qwidgetbackingstore.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index b86c376385..17187002ca 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -448,6 +448,26 @@ void QWidgetBackingStore::sendUpdateRequest(QWidget *widget, UpdateTime updateTi if (!widget) return; +#ifndef QT_NO_OPENGL + // Having every repaint() leading to a sync/flush is bad as it causes + // compositing and waiting for vsync each and every time. Change to + // UpdateLater, except for approx. once per frame to prevent starvation in + // case the control does not get back to the event loop. + QWidget *w = widget->window(); + if (updateTime == UpdateNow && w && w->windowHandle() && QWindowPrivate::get(w->windowHandle())->compositing) { + int refresh = 60; + QScreen *ws = w->windowHandle()->screen(); + if (ws) + refresh = ws->refreshRate(); + QWindowPrivate *wd = QWindowPrivate::get(w->windowHandle()); + if (wd->lastComposeTime.isValid()) { + const qint64 elapsed = wd->lastComposeTime.elapsed(); + if (elapsed <= qint64(1000.0f / refresh)) + updateTime = UpdateLater; + } + } +#endif + switch (updateTime) { case UpdateLater: updateRequestSent = true; |