diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-10 14:49:25 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-10-10 14:49:25 +0000 |
commit | 8fe6b4d3ef03955c23a1d8816d4c947efbde381b (patch) | |
tree | bb077d2bfa9c2d922eb83cb386859162aa3a63c1 /src/quick/items | |
parent | bae22adafc3a6f5ff7f920e71c1542dc25cf1bab (diff) | |
parent | 102fa9b6db82ecd2b95d168912fde0c8bc3798b3 (diff) |
Merge "Merge remote-tracking branch 'origin/5.7' into 5.8" into refs/staging/5.8
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/context2d/qquickcontext2dtexture.cpp | 12 | ||||
-rw-r--r-- | src/quick/items/qquickanimatedsprite.cpp | 32 | ||||
-rw-r--r-- | src/quick/items/qquickanimatedsprite_p.h | 1 | ||||
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 9 | ||||
-rw-r--r-- | src/quick/items/qquickitem.cpp | 40 | ||||
-rw-r--r-- | src/quick/items/qquickitem.h | 2 | ||||
-rw-r--r-- | src/quick/items/qquickitem_p.h | 4 | ||||
-rw-r--r-- | src/quick/items/qquickmousearea.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquickpositioners.cpp | 8 | ||||
-rw-r--r-- | src/quick/items/qquickrectangle.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquicktext.cpp | 6 | ||||
-rw-r--r-- | src/quick/items/qquickview.cpp | 26 | ||||
-rw-r--r-- | src/quick/items/qquickview_p.h | 30 | ||||
-rw-r--r-- | src/quick/items/qquickwindowmodule.cpp | 8 |
14 files changed, 88 insertions, 94 deletions
diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp index ddecf7c3d4..4435c0c37b 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture.cpp +++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp @@ -548,6 +548,9 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() { QQuickContext2DTexture::beginPainting(); + const qreal devicePixelRatio = (m_item && m_item->window()) ? + m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio(); + if (m_canvasWindow.size().isEmpty()) { delete m_fbo; delete m_multisampledFbo; @@ -562,7 +565,7 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() delete m_paint_device; m_paint_device = 0; - m_fboSize = npotAdjustedSize(m_canvasWindow.size()); + m_fboSize = npotAdjustedSize(m_canvasWindow.size() * devicePixelRatio); m_canvasWindowChanged = false; if (doMultisampling()) { @@ -600,6 +603,7 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() QOpenGLPaintDevice *gl_device = new QOpenGLPaintDevice(m_fbo->size()); gl_device->setPaintFlipped(true); gl_device->setSize(m_fbo->size()); + gl_device->setDevicePixelRatio(devicePixelRatio); m_paint_device = gl_device; } @@ -705,8 +709,12 @@ QPaintDevice* QQuickContext2DImageTexture::beginPainting() if (m_canvasWindow.size().isEmpty()) return 0; + const qreal devicePixelRatio = (m_item && m_item->window()) ? + m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio(); + if (m_canvasWindowChanged) { - m_image = QImage(m_canvasWindow.size(), QImage::Format_ARGB32_Premultiplied); + m_image = QImage(m_canvasWindow.size() * devicePixelRatio, QImage::Format_ARGB32_Premultiplied); + m_image.setDevicePixelRatio(devicePixelRatio); m_image.fill(0x00000000); m_canvasWindowChanged = false; } diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index 991ca8519f..8aeef4ef4a 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -42,6 +42,7 @@ #include "qquicksprite_p.h" #include "qquickspriteengine_p.h" #include <QtQuick/private/qsgcontext_p.h> +#include <QtQuick/private/qquickitem_p.h> #include <private/qsgadaptationlayer_p.h> #include <private/qqmlglobal_p.h> #include <QtQuick/qsgnode.h> @@ -349,7 +350,7 @@ void QQuickAnimatedSprite::start() } emit currentFrameChanged(0); emit runningChanged(true); - update(); + maybeUpdate(); } void QQuickAnimatedSprite::stop() @@ -360,7 +361,7 @@ void QQuickAnimatedSprite::stop() return; d->m_pauseOffset = 0; emit runningChanged(false); - update(); + maybeUpdate(); } /*! @@ -379,7 +380,15 @@ void QQuickAnimatedSprite::advance(int frames) d->m_curFrame += d->m_spriteEngine->maxFrames(); d->m_curFrame = d->m_curFrame % d->m_spriteEngine->maxFrames(); emit currentFrameChanged(d->m_curFrame); - update(); + maybeUpdate(); +} + +void QQuickAnimatedSprite::maybeUpdate() +{ + QQuickItemPrivate *priv = QQuickItemPrivate::get(this); + const QLazilyAllocated<QQuickItemPrivate::ExtraData> &extraData = priv->extra; + if ((extraData.isAllocated() && extraData->effectRefCount > 0) || priv->effectiveVisible) + update(); } /*! @@ -399,7 +408,7 @@ void QQuickAnimatedSprite::pause() d->m_pauseOffset = d->m_timestamp.elapsed(); d->m_paused = true; emit pausedChanged(true); - update(); + maybeUpdate(); } /*! @@ -419,7 +428,7 @@ void QQuickAnimatedSprite::resume() d->m_pauseOffset = d->m_pauseOffset - d->m_timestamp.elapsed(); d->m_paused = false; emit pausedChanged(false); - update(); + maybeUpdate(); } void QQuickAnimatedSprite::setRunning(bool arg) @@ -610,7 +619,6 @@ void QQuickAnimatedSprite::createEngine() d->m_spriteEngine = new QQuickSpriteEngine(QList<QQuickSprite*>(spriteList), this); d->m_spriteEngine->startAssemblingImage(); reset(); - update(); } QSGSpriteNode* QQuickAnimatedSprite::initNode() @@ -622,10 +630,10 @@ QSGSpriteNode* QQuickAnimatedSprite::initNode() return nullptr; } else if (d->m_spriteEngine->status() == QQuickPixmap::Null) { d->m_spriteEngine->startAssemblingImage(); - update();//Schedule another update, where we will check again + maybeUpdate();//Schedule another update, where we will check again return nullptr; } else if (d->m_spriteEngine->status() == QQuickPixmap::Loading) { - update();//Schedule another update, where we will check again + maybeUpdate();//Schedule another update, where we will check again return nullptr; } @@ -651,7 +659,7 @@ void QQuickAnimatedSprite::reset() { Q_D(QQuickAnimatedSprite); d->m_pleaseReset = true; - update(); + maybeUpdate(); } QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) @@ -673,7 +681,7 @@ QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNode prepareNextFrame(node); if (d->m_running && !d->m_paused) - update(); + maybeUpdate(); return node; } @@ -726,7 +734,7 @@ void QQuickAnimatedSprite::prepareNextFrame(QSGSpriteNode *node) frameAt = 0; d->m_running = false; emit runningChanged(false); - update(); + maybeUpdate(); } } else { frameAt = d->m_curFrame; @@ -734,7 +742,7 @@ void QQuickAnimatedSprite::prepareNextFrame(QSGSpriteNode *node) if (d->m_curFrame != lastFrame) { if (isCurrentFrameChangedConnected()) emit currentFrameChanged(d->m_curFrame); - update(); + maybeUpdate(); } qreal frameCount = d->m_spriteEngine->spriteFrames(); diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h index 11cdfe11cc..850461a011 100644 --- a/src/quick/items/qquickanimatedsprite_p.h +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -172,6 +172,7 @@ protected: void componentComplete() Q_DECL_OVERRIDE; QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; private: + void maybeUpdate(); bool isCurrentFrameChangedConnected(); void prepareNextFrame(QSGSpriteNode *node); void reloadImage(); diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index e69c6a8d59..12b01b8aaf 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1556,11 +1556,11 @@ void QQuickFlickablePrivate::replayDelayedPress() // If we have the grab, release before delivering the event if (QQuickWindow *w = q->window()) { + replayingPressEvent = true; if (w->mouseGrabberItem() == q) q->ungrabMouse(); // Use the event handler that will take care of finding the proper item to propagate the event - replayingPressEvent = true; QCoreApplication::sendEvent(w, mouseEvent.data()); replayingPressEvent = false; } @@ -1590,7 +1590,7 @@ void QQuickFlickable::timerEvent(QTimerEvent *event) d->movementEndingTimer.stop(); d->pressed = false; d->stealMouse = false; - if (!d->velocityTimeline.isActive()) + if (!d->velocityTimeline.isActive() && !d->timeline.isActive()) movementEnding(true, true); } } @@ -1643,7 +1643,7 @@ void QQuickFlickable::viewportMoved(Qt::Orientations orient) void QQuickFlickablePrivate::viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, QQuickTimeLineCallback::Callback fixupCallback) { - if (pressed || calcVelocity) { + if (!scrollingPhase && (pressed || calcVelocity)) { int elapsed = data.velocityTime.restart(); if (elapsed > 0) { qreal velocity = (data.lastPos - data.move.value()) * 1000 / elapsed; @@ -2216,7 +2216,8 @@ void QQuickFlickable::mouseUngrabEvent() Q_D(QQuickFlickable); // if our mouse grab has been removed (probably by another Flickable), // fix our state - d->cancelInteraction(); + if (!d->replayingPressEvent) + d->cancelInteraction(); } void QQuickFlickablePrivate::cancelInteraction() diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 63d95f6032..e219e9b34e 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -7033,15 +7033,6 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover) } } -void QQuickItemPrivate::markObjects(QV4::ExecutionEngine *e) -{ - Q_Q(QQuickItem); - QV4::QObjectWrapper::markWrapper(q, e); - - for (QQuickItem *child : qAsConst(childItems)) - QQuickItemPrivate::get(child)->markObjects(e); -} - #ifndef QT_NO_CURSOR /*! @@ -8222,6 +8213,37 @@ QAccessible::Role QQuickItemPrivate::accessibleRole() const } #endif +// helper code to let a visual parent mark its visual children for the garbage collector + +namespace QV4 { +namespace Heap { +struct QQuickItemWrapper : public QObjectWrapper { +}; +} +} + +struct QQuickItemWrapper : public QV4::QObjectWrapper { + V4_OBJECT2(QQuickItemWrapper, QV4::QObjectWrapper) + static void markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e); +}; + +DEFINE_OBJECT_VTABLE(QQuickItemWrapper); + +void QQuickItemWrapper::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e) +{ + QObjectWrapper::Data *This = static_cast<QObjectWrapper::Data *>(that); + if (QQuickItem *item = static_cast<QQuickItem*>(This->object())) { + foreach (QQuickItem *child, QQuickItemPrivate::get(item)->childItems) + QV4::QObjectWrapper::markWrapper(child, e); + } + QV4::QObjectWrapper::markObjects(that, e); +} + +quint64 QQuickItemPrivate::_q_createJSWrapper(QV4::ExecutionEngine *engine) +{ + return (engine->memoryManager->allocObject<QQuickItemWrapper>(q_func()))->asReturnedValue(); +} + QT_END_NAMESPACE #include <moc_qquickitem.cpp> diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h index 87ae83246c..510d46739a 100644 --- a/src/quick/items/qquickitem.h +++ b/src/quick/items/qquickitem.h @@ -148,6 +148,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQuickItemLayer *layer READ layer DESIGNABLE false CONSTANT FINAL) Q_CLASSINFO("DefaultProperty", "data") + Q_CLASSINFO("qt_QmlJSWrapperFactoryMethod", "_q_createJSWrapper(QV4::ExecutionEngine*)") public: enum Flag { @@ -442,6 +443,7 @@ protected: private: Q_PRIVATE_SLOT(d_func(), void _q_resourceObjectDeleted(QObject *)) + Q_PRIVATE_SLOT(d_func(), quint64 _q_createJSWrapper(QV4::ExecutionEngine *)) friend class QQuickWindow; friend class QQuickWindowPrivate; diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 3bb4b2835c..4bff293657 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -305,6 +305,7 @@ public: void _q_resourceObjectDeleted(QObject *); void _q_windowChanged(QQuickWindow *w); + quint64 _q_createJSWrapper(QV4::ExecutionEngine *engine); enum ChangeType { Geometry = 0x01, @@ -600,9 +601,6 @@ public: void setHasCursorInChild(bool hasCursor); void setHasHoverInChild(bool hasHover); - // recursive helper to let a visual parent mark its visual children - void markObjects(QV4::ExecutionEngine *e); - virtual void updatePolish() { } }; diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index b377390535..6bd83dd808 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -673,6 +673,7 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event) Q_D(QQuickMouseArea); d->moved = false; d->stealMouse = d->preventStealing; + d->overThreshold = false; if (!d->enabled || !(event->button() & acceptedMouseButtons())) { QQuickItem::mousePressEvent(event); } else { @@ -958,6 +959,7 @@ bool QQuickMouseArea::sendMouseEvent(QMouseEvent *event) if (!d->pressed) { // no other buttons are pressed d->stealMouse = false; + d->overThreshold = false; if (c && c->mouseGrabberItem() == this) ungrabMouse(); emit canceled(); diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp index 38e89e78eb..e22427ca49 100644 --- a/src/quick/items/qquickpositioners.cpp +++ b/src/quick/items/qquickpositioners.cpp @@ -872,7 +872,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem) the item that is being added. See the \l ViewTransition documentation for more details and examples on using these transitions. - \note This transition is not applied to the items that already part of the positioner + \note This transition is not applied to the items that are already part of the positioner at the time of its creation. In this case, the \l populate transition is applied instead. \sa populate, ViewTransition, {Qt Quick Examples - Positioners} @@ -1039,7 +1039,7 @@ void QQuickColumn::reportConflictingAnchors() the item that is being added. See the \l ViewTransition documentation for more details and examples on using these transitions. - \note This transition is not applied to the items that already part of the positioner + \note This transition is not applied to the items that are already part of the positioner at the time of its creation. In this case, the \l populate transition is applied instead. \sa populate, ViewTransition, {Qt Quick Examples - Positioners} @@ -1307,7 +1307,7 @@ void QQuickRow::reportConflictingAnchors() the item that is being added. See the \l ViewTransition documentation for more details and examples on using these transitions. - \note This transition is not applied to the items that already part of the positioner + \note This transition is not applied to the items that are already part of the positioner at the time of its creation. In this case, the \l populate transition is applied instead. \sa populate, ViewTransition, {Qt Quick Examples - Positioners} @@ -1882,7 +1882,7 @@ void QQuickGrid::reportConflictingAnchors() the item that is being added. See the \l ViewTransition documentation for more details and examples on using these transitions. - \note This transition is not applied to the items that already part of the positioner + \note This transition is not applied to the items that are already part of the positioner at the time of its creation. In this case, the \l populate transition is applied instead. \sa populate, ViewTransition, {Qt Quick Examples - Positioners} diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp index 9e747f2c47..7ba2421d62 100644 --- a/src/quick/items/qquickrectangle.cpp +++ b/src/quick/items/qquickrectangle.cpp @@ -365,7 +365,7 @@ QQuickPen *QQuickRectangle::border() The gradient to use to fill the rectangle. This property allows for the construction of simple vertical gradients. - Other gradients may by formed by adding rotation to the rectangle. + Other gradients may be formed by adding rotation to the rectangle. \div {class="float-left"} \inlineimage declarative-rect_gradient.png diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 14268b472e..2bfb4501fc 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -898,11 +898,11 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) // If the width of the item has changed and it's possible the result of wrapping, // eliding, scaling has changed, or the text is not left aligned do another layout. - if ((lineWidth < qMin(oldWidth, naturalWidth) || (widthExceeded && lineWidth > oldWidth)) + if ((!qFuzzyCompare(lineWidth, oldWidth) || (widthExceeded && lineWidth > oldWidth)) && (singlelineElide || multilineElide || canWrap || horizontalFit || q->effectiveHAlign() != QQuickText::AlignLeft)) { widthChanged = true; - widthExceeded = false; + widthExceeded = lineWidth >= qMin(oldWidth, naturalWidth); heightExceeded = false; continue; } @@ -937,7 +937,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) bool wasInLayout = internalWidthUpdate; internalWidthUpdate = true; - q->setImplicitHeight(naturalHeight); + q->setImplicitHeight(naturalHeight + q->topPadding() + q->bottomPadding()); internalWidthUpdate = wasInLayout; multilineElide = elideMode == QQuickText::ElideRight diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp index d79d8ba3cd..a167f01484 100644 --- a/src/quick/items/qquickview.cpp +++ b/src/quick/items/qquickview.cpp @@ -48,29 +48,11 @@ #include <QtQml/qqmlengine.h> #include <private/qqmlengine_p.h> +#include <private/qv4qobjectwrapper_p.h> #include <QtCore/qbasictimer.h> QT_BEGIN_NAMESPACE -DEFINE_OBJECT_VTABLE(QV4::QQuickRootItemMarker); - -QV4::Heap::QQuickRootItemMarker *QV4::QQuickRootItemMarker::create(QQmlEngine *engine, QQuickWindow *window) -{ - QV4::ExecutionEngine *e = QQmlEnginePrivate::getV4Engine(engine); - return e->memoryManager->allocObject<QQuickRootItemMarker>(window); -} - -void QV4::QQuickRootItemMarker::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e) -{ - QQuickItem *root = static_cast<QQuickRootItemMarker::Data *>(that)->window->contentItem(); - if (root) { - QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(root); - rootPrivate->markObjects(e); - } - - QV4::Object::markObjects(that, e); -} - void QQuickViewPrivate::init(QQmlEngine* e) { Q_Q(QQuickView); @@ -84,10 +66,10 @@ void QQuickViewPrivate::init(QQmlEngine* e) engine.data()->setIncubationController(q->incubationController()); { + // The content item has CppOwnership policy (set in QQuickWindow). Ensure the presence of a JS + // wrapper so that the garbage collector can see the policy. QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine.data()); - QV4::Scope scope(v4); - QV4::Scoped<QV4::QQuickRootItemMarker> v(scope, QV4::QQuickRootItemMarker::create(engine.data(), q)); - rootItemMarker.set(v4, v); + QV4::QObjectWrapper::wrap(v4, contentItem); } } diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h index 9c0d87984f..a090bdc9f7 100644 --- a/src/quick/items/qquickview_p.h +++ b/src/quick/items/qquickview_p.h @@ -108,38 +108,8 @@ public: QQuickView::ResizeMode resizeMode; QSize initialSize; QElapsedTimer frameTimer; - QV4::PersistentValue rootItemMarker; }; -namespace QV4 { -namespace Heap { - -struct QQuickRootItemMarker : Object { - inline void init(QQuickWindow *window) - { - Object::init(); - this->window = window; - } - - QQuickWindow *window; -}; - -} - -struct QQuickRootItemMarker : public Object -{ - V4_OBJECT2(QQuickRootItemMarker, Object) - - static Heap::QQuickRootItemMarker *create(QQmlEngine *engine, QQuickWindow *window); - - static void markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e); - -}; - - - -} - QT_END_NAMESPACE #endif // QQUICKVIEW_P_H diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp index c624d162a9..deb44ce34d 100644 --- a/src/quick/items/qquickwindowmodule.cpp +++ b/src/quick/items/qquickwindowmodule.cpp @@ -47,6 +47,7 @@ #include <private/qguiapplication_p.h> #include <private/qqmlengine_p.h> +#include <private/qv4qobjectwrapper_p.h> #include <qpa/qplatformintegration.h> QT_BEGIN_NAMESPACE @@ -104,12 +105,11 @@ void QQuickWindowQmlImpl::classBegin() if (e && !e->incubationController()) e->setIncubationController(incubationController()); } - Q_ASSERT(e); { + // The content item has CppOwnership policy (set in QQuickWindow). Ensure the presence of a JS + // wrapper so that the garbage collector can see the policy. QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(e); - QV4::Scope scope(v4); - QV4::ScopedObject v(scope, QV4::QQuickRootItemMarker::create(e, this)); - d->rootItemMarker = v; + QV4::QObjectWrapper::wrap(v4, d->contentItem); } } |