diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-04-13 15:52:51 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-04-14 15:50:43 +0000 |
commit | 472216da2d3e88472df3594cbc9eccc6d6b1b44b (patch) | |
tree | eea5fce8aa644313ee1b3fa507a72ebfac155449 /src | |
parent | 666486b3efec871301b82244ec661e1eaa6cca9c (diff) |
Defer Q(OpenGL|Raster)Window updates when non-exposed
This is similar to how widgets work. On platforms like OS X this
becomes essential since in non-exposed state SwapBuffers does not block
so continuing to update continuously leads to undesirable effects.
Task-number: QTBUG-45524
Change-Id: I80f4c00b218561b9e62c3cad1e66f61f4debd4af
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qpaintdevicewindow.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gui/kernel/qpaintdevicewindow.cpp b/src/gui/kernel/qpaintdevicewindow.cpp index b32ab3b34d..ff661d017d 100644 --- a/src/gui/kernel/qpaintdevicewindow.cpp +++ b/src/gui/kernel/qpaintdevicewindow.cpp @@ -60,6 +60,9 @@ QT_BEGIN_NAMESPACE \note Subsequent calls to this function before the next paint event will get ignored. + + \note For non-exposed windows the update is deferred until the + window becomes exposed again. */ void QPaintDeviceWindow::update() { @@ -70,26 +73,34 @@ void QPaintDeviceWindow::update() Marks the \a rect of the window as dirty and schedules a repaint. \note Subsequent calls to this function before the next paint - event will get ignored. + event will get ignored, but \a rect is added to the region to update. + + \note For non-exposed windows the update is deferred until the + window becomes exposed again. */ void QPaintDeviceWindow::update(const QRect &rect) { Q_D(QPaintDeviceWindow); d->dirtyRegion += rect; - requestUpdate(); + if (isExposed()) + requestUpdate(); } /*! Marks the \a region of the window as dirty and schedules a repaint. \note Subsequent calls to this function before the next paint - event will get ignored. + event will get ignored, but \a region is added to the region to update. + + \note For non-exposed windows the update is deferred until the + window becomes exposed again. */ void QPaintDeviceWindow::update(const QRegion ®ion) { Q_D(QPaintDeviceWindow); d->dirtyRegion += region; - requestUpdate(); + if (isExposed()) + requestUpdate(); } /*! @@ -168,6 +179,9 @@ void QPaintDeviceWindow::exposeEvent(QExposeEvent *exposeEvent) // sometimes relative to the parent, depending on the platform plugin. // We require local coords here. d->doFlush(QRect(QPoint(0, 0), size())); + } else if (!d->dirtyRegion.isEmpty()) { + // Updates while non-exposed were ignored. Schedule an update now. + requestUpdate(); } } |