Set default fbo redirect correctly for QOpenGLWidget viewports

Task-number: QTBUG-59318
Change-Id: Icf2ea4e5ebdeec31750edc8b34a9b9f6bfb64744
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2017-03-17 15:55:00 +01:00
parent 9ef14bcc3a
commit c1a2f97a3b
2 changed files with 21 additions and 0 deletions

View File

@ -537,6 +537,7 @@ public:
w(widget) { }
void beginPaint() Q_DECL_OVERRIDE;
void endPaint() Q_DECL_OVERRIDE;
QOpenGLWidget *w;
};
@ -631,6 +632,16 @@ void QOpenGLWidgetPaintDevicePrivate::beginPaint()
}
}
void QOpenGLWidgetPaintDevicePrivate::endPaint()
{
QOpenGLWidgetPrivate *wd = static_cast<QOpenGLWidgetPrivate *>(QWidgetPrivate::get(w));
if (!wd->initialized)
return;
if (!wd->inPaintGL)
QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = 0;
}
void QOpenGLWidgetPaintDevice::ensureActiveTarget()
{
QOpenGLWidgetPaintDevicePrivate *d = static_cast<QOpenGLWidgetPaintDevicePrivate *>(d_ptr.data());
@ -643,6 +654,9 @@ void QOpenGLWidgetPaintDevice::ensureActiveTarget()
else
wd->fbo->bind();
if (!wd->inPaintGL)
QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = wd->fbo->handle();
// When used as a viewport, drawing is done via opening a QPainter on the widget
// without going through paintEvent(). We will have to make sure a glFlush() is done
// before the texture is accessed also in this case.

View File

@ -282,6 +282,13 @@ protected:
void CountingGraphicsView::drawForeground(QPainter *, const QRectF &)
{
++m_count;
// QTBUG-59318: verify that the context's internal default fbo redirection
// is active also when using the QOpenGLWidget as a viewport.
GLint currentFbo = -1;
QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &currentFbo);
GLuint defFbo = QOpenGLContext::currentContext()->defaultFramebufferObject();
QCOMPARE(GLuint(currentFbo), defFbo);
}
void tst_QOpenGLWidget::asViewport()