Fix FBO recreated every time the QSG node is updated under some conditions
authorTaylor Braun-Jones <taylor.braun-jones@ge.com>
Fri, 1 Aug 2014 14:48:37 +0000 (10:48 -0400)
committerGunnar Sletta <gunnar.sletta@jollamobile.com>
Tue, 5 Aug 2014 05:46:17 +0000 (07:46 +0200)
When textureFollowsItemsSize is true and the item width/height are (1)
not precise integer values or (2) less than the minimum FBO
width/height, then QQuickFramebufferObject will delete and recreate the
FBO every time the QSG node is updated. This patch fixes the issue.

Task-number: QTBUG-40548
Change-Id: I532aaaa88a5c604ee7cc1fd8f0acb0601c5a94fb
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
src/quick/items/qquickframebufferobject.cpp

index 10d281b..4c43292 100644 (file)
@@ -235,8 +235,12 @@ QSGNode *QQuickFramebufferObject::updatePaintNode(QSGNode *node, UpdatePaintNode
 
     n->renderer->synchronize(this);
 
+    QSize minFboSize = d->sceneGraphContext()->minimumFBOSize();
+    QSize desiredFboSize(qMax<int>(minFboSize.width(), width()),
+                         qMax<int>(minFboSize.height(), height()));
+
     if (n->fbo && (d->followsItemSize || n->invalidatePending)) {
-        if (n->fbo->width() != width() || n->fbo->height() != height()) {
+        if (n->fbo->size() != desiredFboSize) {
             delete n->fbo;
             n->fbo = 0;
             delete n->msDisplayFbo;
@@ -245,10 +249,7 @@ QSGNode *QQuickFramebufferObject::updatePaintNode(QSGNode *node, UpdatePaintNode
     }
 
     if (!n->fbo) {
-        QSize minFboSize = d->sceneGraphContext()->minimumFBOSize();
-        QSize fboSize(qMax<int>(minFboSize.width(), width()),
-                      qMax<int>(minFboSize.height(), height()));
-        n->fbo = n->renderer->createFramebufferObject(fboSize);
+        n->fbo = n->renderer->createFramebufferObject(desiredFboSize);
 
         GLuint displayTexture = n->fbo->texture();