summaryrefslogtreecommitdiffstats
path: root/src/opengl/qwindowsurface_gl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qwindowsurface_gl.cpp')
-rw-r--r--src/opengl/qwindowsurface_gl.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 6185ff8..81575e3 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -302,6 +302,7 @@ struct QGLWindowSurfacePrivate
};
QGLFormat QGLWindowSurface::surfaceFormat;
+QGLWindowSurface::SwapMode QGLWindowSurface::swapBehavior = QGLWindowSurface::AutomaticSwap;
void QGLWindowSurfaceGLPaintDevice::endPaint()
{
@@ -549,9 +550,10 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
// did_paint is set to true in ::beginPaint. ::beginPaint means that we
// at least cleared the background (= painted something). In EGL API it's a
- // mistakte to call swapBuffers if nothing was painted. This check protects
- // the flush func from being executed if it's for nothing.
- if (!d_ptr->did_paint)
+ // mistake to call swapBuffers if nothing was painted unless
+ // EGL_BUFFER_PRESERVED is set. This check protects the flush func from
+ // being executed if it's for nothing.
+ if (!hasPartialUpdateSupport() && !d_ptr->did_paint)
return;
QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
@@ -576,6 +578,9 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
const GLenum target = GL_TEXTURE_2D;
Q_UNUSED(target);
+ if (QGLWindowSurface::swapBehavior == QGLWindowSurface::KillSwap)
+ return;
+
if (context()) {
context()->makeCurrent();
@@ -623,7 +628,14 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
}
}
#endif
- bool doingPartialUpdate = hasPartialUpdateSupport() && br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2;
+ bool doingPartialUpdate = false;
+ if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AutomaticSwap)
+ doingPartialUpdate = hasPartialUpdateSupport() && br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2;
+ else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysFullSwap)
+ doingPartialUpdate = false;
+ else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysPartialSwap)
+ doingPartialUpdate = hasPartialUpdateSupport();
+
QGLContext *ctx = reinterpret_cast<QGLContext *>(parent->d_func()->extraData()->glContext);
if (widget != window()) {
if (initializeOffscreenTexture(window()->size()))