From d76c52133160f4394df2d6dc4d239c54833c1ab3 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 2 Sep 2009 11:27:10 +1000 Subject: Fix animation-after-zooming problem. Ensures final viewport XY is set and that setting it always clears animations (even if the position is coincidentally unchanged). Case is changing width/height twice - once too small, then large enough again, first change starts correction animation, which must be stopped by second change. --- demos/declarative/webbrowser/webbrowser.qml | 29 +++++++++++++++++++++++------ src/declarative/fx/qfxflickable.cpp | 4 ++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 4c4ad7c..6217019 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -215,14 +215,14 @@ Item { property: "scale" from: 1 to: 0 // set before calling - easing: "easeInOutQuad" + easing: "easeLinear" duration: 200 } NumberAnimation { id: FlickVX target: Flick property: "viewportX" - easing: "easeInOutQuad" + easing: "easeLinear" duration: 200 from: 0 // set before calling to: 0 // set before calling @@ -231,21 +231,36 @@ Item { id: FlickVY target: Flick property: "viewportY" - easing: "easeInOutQuad" + easing: "easeLinear" duration: 200 from: 0 // set before calling to: 0 // set before calling } } PropertyAction { + id: FinalZoom + target: MyWebView + property: "zoomFactor" + } + PropertyAction { target: MyWebView property: "scale" value: 1.0 } + // Have to set the viewportXY, since the above 2 + // size changes may have started a correction if + // zoomFactor < 1.0. PropertyAction { - id: FinalZoom - target: MyWebView - property: "zoomFactor" + id: FinalX + target: Flick + property: "viewportX" + value: 0 // set before calling + } + PropertyAction { + id: FinalY + target: Flick + property: "viewportY" + value: 0 // set before calling } PropertyAction { target: MyWebView @@ -259,8 +274,10 @@ Item { ScaleAnim.to = sc; FlickVX.from = Flick.viewportX FlickVX.to = Math.min(Math.max(0,centerX-Flick.width/2),MyWebView.width*sc-Flick.width) + FinalX.value = Math.min(Math.max(0,centerX-Flick.width/2),MyWebView.width*sc-Flick.width) FlickVY.from = Flick.viewportY FlickVY.to = Math.min(Math.max(0,centerY-Flick.height/2),MyWebView.height*sc-Flick.height) + FinalY.value = Math.min(Math.max(0,centerY-Flick.height/2),MyWebView.height*sc-Flick.height) FinalZoom.value = zoom QuickZoom.start() } diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 27bfa27..118658f 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -386,8 +386,8 @@ void QFxFlickable::setViewportX(qreal pos) { Q_D(QFxFlickable); pos = qRound(pos); + d->_tl.reset(d->_moveX); if (-pos != d->_moveX.value()) { - d->_tl.reset(d->_moveX); d->_moveX.setValue(-pos); viewportMoved(); } @@ -403,8 +403,8 @@ void QFxFlickable::setViewportY(qreal pos) { Q_D(QFxFlickable); pos = qRound(pos); + d->_tl.reset(d->_moveY); if (-pos != d->_moveY.value()) { - d->_tl.reset(d->_moveY); d->_moveY.setValue(-pos); viewportMoved(); } -- cgit v0.12 From 3d209a098d9abf5f8ffe9b64b27adbe622e84497 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 4 Sep 2009 10:58:36 +1000 Subject: Smooth the rendering in the tiles, not of the tiles. Turn smoothing on in webbrowsser demo. --- demos/declarative/webbrowser/webbrowser.qml | 2 +- src/declarative/fx/qfxpainteditem.cpp | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 6217019..9a8af29 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -190,7 +190,7 @@ Item { } url: fixUrl(WebBrowser.urlString) - smooth: false + smooth: true fillColor: "white" focus: true diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 695236d..cbd00cf 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -208,12 +208,6 @@ void QFxPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidge ++inpaint; - bool oldAntiAliasing = p->testRenderHint(QPainter::Antialiasing); - bool oldSmoothPixmap = p->testRenderHint(QPainter::SmoothPixmapTransform); - if (oldAntiAliasing) - p->setRenderHints(QPainter::Antialiasing, false); // cannot stitch properly otherwise - if (d->smooth) - p->setRenderHints(QPainter::SmoothPixmapTransform, true); QRectF clipf = p->clipRegion().boundingRect(); if (clipf.isEmpty()) clipf = mapToScene(content).boundingRect(); // ### Inefficient: Maps toScene and then fromScene @@ -234,6 +228,7 @@ void QFxPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidge if (!d->cachefrozen) { if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) { QPainter qp(&d->imagecache[i]->image); + qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smooth); qp.translate(-area.x(), -area.y()); if (d->fillColor.isValid()) qp.fillRect(d->imagecache[i]->dirty,d->fillColor); @@ -280,6 +275,8 @@ void QFxPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidge img.fill(d->fillColor); { QPainter qp(&img); + qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smooth); + qp.translate(-r.x(),-r.y()); drawContents(&qp, r); } @@ -296,11 +293,6 @@ void QFxPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidge } } - if (oldAntiAliasing) - p->setRenderHints(QPainter::Antialiasing, oldAntiAliasing); - if (d->smooth) - p->setRenderHints(QPainter::SmoothPixmapTransform, oldSmoothPixmap); - if (inpaint_clearcache) { clearCache(); inpaint_clearcache = 0; -- cgit v0.12 From f2d3043e72dbfd9281925ccda76840dfd35ff38f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 4 Sep 2009 13:35:25 +1000 Subject: Don't call pure virtuals on deleting QGraphicsItem This also needs to be reviewed by andreas. Reviewed-by: Michael Brasser --- src/gui/graphicsview/qgraphicsitem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index e931e4c..75bdf1f 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4789,10 +4789,12 @@ void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &n if (transformData) thisToParentTransform = transformData->computedFullTransform(&thisToParentTransform); QGraphicsItem *clipParent = parent; - while (clipParent && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) { + while (clipParent && !clipParent->d_ptr->inDestructor && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) { thisToParentTransform *= clipParent->d_ptr->transformToParent(); clipParent = clipParent->d_ptr->parent; } + if (clipParent && clipParent->d_ptr->inDestructor) + return; // thisToParentTransform is now the same as q->itemTransform(clipParent), except // that the new position (which is not yet set on the item) is taken into account. -- cgit v0.12