Fix flicker when showing QQuickWidget

This also reintroduces the change from commit 14b4747b17.
Due to some bizarre merge issue that change has disappeared from qquickwidget.cpp
and its history. It is there in the main log, though.

The new fix depends on this older one, so the combined one fixes the following
three issues:

1. Polish and sync cannot be skipped when we are rendering for the first time.

2. Recreating the fbo twice when the widget is shown. Calling
createFramebufferObject() is not necessary in this case since createContext()
will trigger this anyhow due to scenegraphInitialized().

3. Avoid recreating the fbo when the size is the same as before. Some platforms
are keen on sending resize events with the same size. These should be ignored.
What's worse, some platforms (cocoa) generate a resize on exitting (Cmd-Q)
and not ignoring the resize at that stage is dangerous since the scenegraph
is already invalidated.

Task-number: QTBUG-40710
Task-number: QTBUG-40505
Change-Id: I2e897acc68fa68233563a1db63ffb6c5d0baad73
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
This commit is contained in:
Laszlo Agocs 2014-08-14 12:58:55 +02:00
parent ccb1eb743d
commit ddb134af99
1 changed files with 22 additions and 4 deletions

View File

@ -891,8 +891,23 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
d->renderControl->sync();
}
d->createContext();
createFramebufferObject();
bool newFbo = false;
if (d->context) {
// Bail out in the special case of receiving a resize after
// scenegraph invalidation during application exit.
if (!d->fbo && !d->offscreenWindow->openglContext())
return;
if (!d->fbo || d->fbo->size() != size() * devicePixelRatio()) {
newFbo = true;
createFramebufferObject();
}
} else {
// This will result in a scenegraphInitialized() signal which
// is connected to createFramebufferObject().
newFbo = true;
d->createContext();
}
QCoreApplication::sendEvent(d->offscreenWindow, e);
d->offscreenWindow->setGeometry(0, 0, e->size().width(), e->size().height());
@ -904,10 +919,13 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
context->makeCurrent(d->offscreenSurface);
if (d->fakeHidden) {
d->fakeHidden = false;
if (newFbo) {
d->renderControl->polishItems();
d->renderControl->sync();
} else if (d->fakeHidden) {
d->renderControl->sync();
}
d->fakeHidden = false;
d->renderControl->render();
context->functions()->glFlush();