summaryrefslogtreecommitdiffstats
path: root/src/opengl/qwindowsurface_gl.cpp
diff options
context:
space:
mode:
authorMichael Dominic K <mdk@codethink.co.uk>2010-12-14 09:26:39 (GMT)
committerHarald Fernengel <harald.fernengel@nokia.com>2010-12-14 09:26:48 (GMT)
commit284211ccbd2cbdfea46cdf4b8628a1a967271985 (patch)
treec8f004496edf6e2cc97675295f8e7236d2f508f9 /src/opengl/qwindowsurface_gl.cpp
parent00cd44c1976fb25f419e487bd6e626c5d2520727 (diff)
downloadQt-284211ccbd2cbdfea46cdf4b8628a1a967271985.zip
Qt-284211ccbd2cbdfea46cdf4b8628a1a967271985.tar.gz
Qt-284211ccbd2cbdfea46cdf4b8628a1a967271985.tar.bz2
Prevent ::flush from being called on QGLWindowSurface if no painting happened.
Merge-request: 2527 Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com> Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/opengl/qwindowsurface_gl.cpp')
-rw-r--r--src/opengl/qwindowsurface_gl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index f64b93c..6749826 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -267,6 +267,7 @@ struct QGLWindowSurfacePrivate
int tried_pb : 1;
int destructive_swap_buffers : 1;
int geometry_updated : 1;
+ int did_paint : 1;
QGLContext *ctx;
@@ -330,6 +331,7 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window)
d_ptr->glDevice.d = d_ptr;
d_ptr->q_ptr = this;
d_ptr->geometry_updated = false;
+ d_ptr->did_paint = false;
}
QGLWindowSurface::~QGLWindowSurface()
@@ -461,6 +463,8 @@ void QGLWindowSurface::beginPaint(const QRegion &)
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(clearFlags);
}
+
+ d_ptr->did_paint = true;
}
void QGLWindowSurface::endPaint(const QRegion &rgn)
@@ -513,6 +517,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
if (d_ptr->geometry_updated)
return;
+ // 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)
+ return;
+
QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
Q_ASSERT(parent);
@@ -736,6 +747,8 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
ctx->swapBuffers();
else
glFlush();
+
+ d_ptr->did_paint = false;
}