From: Gunnar Sletta Date: Wed, 12 Jun 2013 14:30:05 +0000 (+0200) Subject: Fix resizing canvas with renderStrategy == Cooperative X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=e500396d12c9f0155797ff53e347bf8ba9f69c7a;p=konrad%2Fqtdeclarative.git Fix resizing canvas with renderStrategy == Cooperative updatePolish() called prepare() which would use a queued metaInvoke() to change the size of the texture. However, there is no guaranteed event processing on the render thread between polish on the GUI thread and sync on the render thread, we would very often get to updatePaintNode() before the queued invoke landed, resulting the drawing being done to a texture of the wrong size. Fix this by calling prepare from updatePaintNode when in CooperativeMode so that the autoconnection becomes a direct one and we get prepare and flush processed in the right order. Change-Id: I0fa4687a94ada4bdaddca19133e686bca0bc745c Reviewed-by: Alan Alpert --- diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 4144256..3b1b6d5 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -645,7 +645,7 @@ void QQuickCanvasItem::updatePolish() Q_D(QQuickCanvasItem); - if (d->context) + if (d->context && d->renderStrategy != QQuickCanvasItem::Cooperative) d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, d->antialiasing); if (d->animationCallbacks.size() > 0 && isVisible()) { @@ -697,8 +697,10 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData else node->setFiltering(QSGTexture::Nearest); - if (d->renderStrategy == QQuickCanvasItem::Cooperative) + if (d->renderStrategy == QQuickCanvasItem::Cooperative) { + d->context->prepare(d->canvasSize.toSize(), d->tileSize, d->canvasWindow.toRect(), d->dirtyRect.toRect(), d->smooth, d->antialiasing); d->context->flush(); + } node->setTexture(d->context->texture()); node->markDirty(QSGNode::DirtyMaterial);