diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-20 01:02:53 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-20 01:02:53 +0200 |
commit | f06cbeb00b00e54826a67816663920cb468141a2 (patch) | |
tree | 9d073663750cfaf11ace6488f880be093b40b2bd /src/quick | |
parent | eef179c9eb2c2d24e67c27742618555267e45e89 (diff) | |
parent | 6734ee9a6ddb6a3870556514a70d904836258559 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I939b8ddc8b24e9c9853a72eb22da317023c7a2c4
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquickborderimage.cpp | 26 | ||||
-rw-r--r-- | src/quick/items/qquickitemview.cpp | 1 | ||||
-rw-r--r-- | src/quick/items/qquicklistview.cpp | 38 | ||||
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 10 | ||||
-rw-r--r-- | src/quick/items/qquicktableview_p_p.h | 1 | ||||
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 26 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgbasicinternalimagenode.cpp | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp | 25 |
8 files changed, 102 insertions, 27 deletions
diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp index d49829096f..e4e766a129 100644 --- a/src/quick/items/qquickborderimage.cpp +++ b/src/quick/items/qquickborderimage.cpp @@ -591,10 +591,18 @@ void QQuickBorderImagePrivate::calculateRects(const QQuickScaleGrid *border, *innerTargetRect = *targetRect; if (border) { - *innerSourceRect = QRectF(border->left() * devicePixelRatio / qreal(sourceSize.width()), - border->top() * devicePixelRatio / qreal(sourceSize.height()), - qMax<qreal>(0, sourceSize.width() - (border->right() + border->left()) * devicePixelRatio) / sourceSize.width(), - qMax<qreal>(0, sourceSize.height() - (border->bottom() + border->top()) * devicePixelRatio) / sourceSize.height()); + qreal borderLeft = border->left() * devicePixelRatio; + qreal borderRight = border->right() * devicePixelRatio; + qreal borderTop = border->top() * devicePixelRatio; + qreal borderBottom = border->bottom() * devicePixelRatio; + if (borderLeft + borderRight > sourceSize.width() && borderLeft < sourceSize.width()) + borderRight = sourceSize.width() - borderLeft; + if (borderTop + borderBottom > sourceSize.height() && borderTop < sourceSize.height()) + borderBottom = sourceSize.height() - borderTop; + *innerSourceRect = QRectF(QPointF(borderLeft / qreal(sourceSize.width()), + borderTop * devicePixelRatio / qreal(sourceSize.height())), + QPointF((sourceSize.width() - borderRight) / qreal(sourceSize.width()), + (sourceSize.height() - borderBottom) / qreal(sourceSize.height()))), *innerTargetRect = QRectF(border->left(), border->top(), qMax<qreal>(0, targetSize.width() - (border->right() + border->left())), @@ -604,14 +612,16 @@ void QQuickBorderImagePrivate::calculateRects(const QQuickScaleGrid *border, qreal hTiles = 1; qreal vTiles = 1; const QSizeF innerTargetSize = innerTargetRect->size() * devicePixelRatio; - if (innerSourceRect->width() != 0 - && horizontalTileMode != QQuickBorderImage::Stretch) { + if (innerSourceRect->width() <= 0) + hTiles = 0; + else if (horizontalTileMode != QQuickBorderImage::Stretch) { hTiles = innerTargetSize.width() / qreal(innerSourceRect->width() * sourceSize.width()); if (horizontalTileMode == QQuickBorderImage::Round) hTiles = qCeil(hTiles); } - if (innerSourceRect->height() != 0 - && verticalTileMode != QQuickBorderImage::Stretch) { + if (innerSourceRect->height() <= 0) + vTiles = 0; + else if (verticalTileMode != QQuickBorderImage::Stretch) { vTiles = innerTargetSize.height() / qreal(innerSourceRect->height() * sourceSize.height()); if (verticalTileMode == QQuickBorderImage::Round) vTiles = qCeil(vTiles); diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index a1a71bf3cd..8dafc16cf4 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -1185,6 +1185,7 @@ void QQuickItemView::modelUpdated(const QQmlChangeSet &changeSet, bool reset) { Q_D(QQuickItemView); if (reset) { + cancelFlick(); if (d->transitioner) d->transitioner->setPopulateTransitionEnabled(true); d->moveReason = QQuickItemViewPrivate::SetIndex; diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 540805ac28..908801ce1c 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -515,8 +515,8 @@ QString QQuickListViewPrivate::sectionAt(int modelIndex) qreal QQuickListViewPrivate::snapPosAt(qreal pos) { - if (FxViewItem *snapItem = snapItemAt(pos)) - return snapItem->position(); + if (FxListItemSG *snapItem = static_cast<FxListItemSG*>(snapItemAt(pos))) + return snapItem->itemPosition(); if (visibleItems.count()) { qreal firstPos = (*visibleItems.constBegin())->position(); qreal endPos = (*(--visibleItems.constEnd()))->position(); @@ -530,22 +530,35 @@ qreal QQuickListViewPrivate::snapPosAt(qreal pos) FxViewItem *QQuickListViewPrivate::snapItemAt(qreal pos) { + const qreal velocity = orient == QQuickListView::Vertical ? vData.velocity : hData.velocity; FxViewItem *snapItem = nullptr; + FxViewItem *prevItem = nullptr; qreal prevItemSize = 0; for (FxViewItem *item : qAsConst(visibleItems)) { if (item->index == -1) continue; - qreal itemTop = item->position(); - if (highlight && itemTop >= pos && item->endPosition() <= pos + highlight->size()) + + const FxListItemSG *listItem = static_cast<FxListItemSG *>(item); + qreal itemTop = listItem->position(); + qreal itemSize = listItem->size(); + if (highlight && itemTop >= pos && listItem->endPosition() <= pos + highlight->size()) return item; + if (listItem->section() && velocity > 0) { + if (itemTop + listItem->sectionSize() / 2 >= pos && itemTop - prevItemSize / 2 < pos) + snapItem = prevItem; + itemTop = listItem->itemPosition(); + itemSize = listItem->itemSize(); + } + // Middle of item and spacing (i.e. the middle of the distance between this item and the next - qreal halfwayToNextItem = itemTop + (item->size()+spacing) / 2; + qreal halfwayToNextItem = itemTop + (itemSize+spacing) / 2; qreal halfwayToPrevItem = itemTop - (prevItemSize+spacing) / 2; if (halfwayToNextItem >= pos && halfwayToPrevItem < pos) snapItem = item; - prevItemSize = item->size(); + prevItemSize = listItem->itemSize(); + prevItem = item; } return snapItem; } @@ -1530,15 +1543,15 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte pos = isContentFlowReversed() ? - header->position() + highlightRangeStart - size() : header->position() - highlightRangeStart; } else { if (isContentFlowReversed()) - pos = qMax(qMin(-topItem->position() + highlightRangeStart - size(), -maxExtent), -minExtent); + pos = qMax(qMin(-static_cast<FxListItemSG*>(topItem)->itemPosition() + highlightRangeStart - size(), -maxExtent), -minExtent); else - pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent); + pos = qMax(qMin(static_cast<FxListItemSG*>(topItem)->itemPosition() - highlightRangeStart, -maxExtent), -minExtent); } } else if (bottomItem && isInBounds) { if (isContentFlowReversed()) - pos = qMax(qMin(-bottomItem->position() + highlightRangeEnd - size(), -maxExtent), -minExtent); + pos = qMax(qMin(-static_cast<FxListItemSG*>(bottomItem)->itemPosition() + highlightRangeEnd - size(), -maxExtent), -minExtent); else - pos = qMax(qMin(bottomItem->position() - highlightRangeEnd, -maxExtent), -minExtent); + pos = qMax(qMin(static_cast<FxListItemSG*>(bottomItem)->itemPosition() - highlightRangeEnd, -maxExtent), -minExtent); } else { QQuickItemViewPrivate::fixup(data, minExtent, maxExtent); return; @@ -1568,7 +1581,10 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte timeline.reset(data.move); if (viewPos != position()) { if (fixupMode != Immediate) { - timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); + if (fixupMode == ExtentChanged && data.fixingUp) + timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::OutQuad), fixupDuration/2); + else + timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); data.fixingUp = true; } else { timeline.set(data.move, -viewPos); diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index d7060cbdea..4b13cde2d5 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -1664,6 +1664,7 @@ void QQuickTableViewPrivate::connectToModel() connect(aim, &QAbstractItemModel::columnsInserted, this, &QQuickTableViewPrivate::columnsInsertedCallback); connect(aim, &QAbstractItemModel::columnsRemoved, this, &QQuickTableViewPrivate::columnsRemovedCallback); connect(aim, &QAbstractItemModel::modelReset, this, &QQuickTableViewPrivate::modelResetCallback); + connect(aim, &QAbstractItemModel::layoutChanged, this, &QQuickTableViewPrivate::layoutChangedCallback); } else { QObjectPrivate::connect(model, &QQmlInstanceModel::modelUpdated, this, &QQuickTableViewPrivate::modelUpdated); } @@ -1689,6 +1690,7 @@ void QQuickTableViewPrivate::disconnectFromModel() disconnect(aim, &QAbstractItemModel::columnsInserted, this, &QQuickTableViewPrivate::columnsInsertedCallback); disconnect(aim, &QAbstractItemModel::columnsRemoved, this, &QQuickTableViewPrivate::columnsRemovedCallback); disconnect(aim, &QAbstractItemModel::modelReset, this, &QQuickTableViewPrivate::modelResetCallback); + disconnect(aim, &QAbstractItemModel::layoutChanged, this, &QQuickTableViewPrivate::layoutChangedCallback); } else { QObjectPrivate::disconnect(model, &QQmlInstanceModel::modelUpdated, this, &QQuickTableViewPrivate::modelUpdated); } @@ -1751,6 +1753,14 @@ void QQuickTableViewPrivate::columnsRemovedCallback(const QModelIndex &parent, i scheduleRebuildTable(RebuildOption::ViewportOnly); } +void QQuickTableViewPrivate::layoutChangedCallback(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint) +{ + Q_UNUSED(parents); + Q_UNUSED(hint); + + scheduleRebuildTable(RebuildOption::ViewportOnly); +} + void QQuickTableViewPrivate::modelResetCallback() { scheduleRebuildTable(RebuildOption::All); diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index a4f829addd..2ed04f8d29 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -356,6 +356,7 @@ public: void rowsRemovedCallback(const QModelIndex &parent, int begin, int end); void columnsInsertedCallback(const QModelIndex &parent, int begin, int end); void columnsRemovedCallback(const QModelIndex &parent, int begin, int end); + void layoutChangedCallback(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint); void modelResetCallback(); void _q_componentFinalized(); diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 059886f41c..d27ee54c89 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -774,6 +774,7 @@ bool QQuickWindowPrivate::deliverTouchAsMouse(QQuickItem *item, QQuickPointerEve void QQuickWindowPrivate::grabTouchPoints(QObject *grabber, const QVector<int> &ids) { + QQuickPointerEvent *ev = nullptr; for (int i = 0; i < ids.count(); ++i) { int id = ids.at(i); if (Q_UNLIKELY(id < 0)) { @@ -793,15 +794,26 @@ void QQuickWindowPrivate::grabTouchPoints(QObject *grabber, const QVector<int> & qCDebug(DBG_MOUSE_TARGET) << "grabTouchPoints: mouse grabber changed due to grabTouchPoints:" << touchMouseGrabber << "-> null"; } + // optimization to avoid the loop over devices below: + // all ids are probably from the same event, so we don't have to search + if (ev) { + auto point = ev->pointById(id); + if (point && point->exclusiveGrabber() != grabber) { + point->setExclusiveGrabber(grabber); + continue; // next id in the ids loop + } + } + // search all devices for a QQuickPointerEvent instance that is delivering the point with id const auto touchDevices = QQuickPointerDevice::touchDevices(); for (auto device : touchDevices) { - auto point = pointerEventInstance(device)->pointById(id); - if (!point) - continue; - QObject *oldGrabber = point->exclusiveGrabber(); - if (oldGrabber == grabber) - continue; - point->setExclusiveGrabber(grabber); + QQuickPointerEvent *pev = pointerEventInstance(device); + auto point = pev->pointById(id); + if (point) { + ev = pev; + if (point->exclusiveGrabber() != grabber) + point->setExclusiveGrabber(grabber); + break; // out of touchDevices loop + } } } } diff --git a/src/quick/scenegraph/qsgbasicinternalimagenode.cpp b/src/quick/scenegraph/qsgbasicinternalimagenode.cpp index c8699218ba..53271af9ab 100644 --- a/src/quick/scenegraph/qsgbasicinternalimagenode.cpp +++ b/src/quick/scenegraph/qsgbasicinternalimagenode.cpp @@ -484,7 +484,7 @@ void QSGBasicInternalImageNode::updateGeometry() int hTiles = ceilRight - floorLeft; int vTiles = ceilBottom - floorTop; - bool hasTiles = hTiles != 1 || vTiles != 1; + bool hasTiles = hTiles > 1 || vTiles > 1; bool fullTexture = innerSourceRect == QRectF(0, 0, 1, 1); // An image can be rendered as a single quad if: diff --git a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp index 56508af152..94912778f8 100644 --- a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp +++ b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp @@ -57,20 +57,34 @@ QSGDepthStencilBuffer::~QSGDepthStencilBuffer() m_manager->m_buffers.remove(m_format); } +#ifndef GL_DEPTH_STENCIL_ATTACHMENT +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#endif + void QSGDepthStencilBuffer::attach() { +#ifndef Q_OS_WASM m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer); m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_stencilBuffer); +#else + m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, m_stencilBuffer); +#endif } void QSGDepthStencilBuffer::detach() { +#ifndef Q_OS_WASM m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); +#else + m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, 0); +#endif } #ifndef GL_DEPTH24_STENCIL8_OES @@ -81,12 +95,17 @@ void QSGDepthStencilBuffer::detach() #define GL_DEPTH_COMPONENT24_OES 0x81A6 #endif +#ifndef GL_DEPTH_STENCIL +#define GL_DEPTH_STENCIL 0x84F9 +#endif + QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *context, const Format &format) : QSGDepthStencilBuffer(context, format) { const GLsizei width = format.size.width(); const GLsizei height = format.size.height(); +#ifndef Q_OS_WASM if (format.attachments == (DepthAttachment | StencilAttachment) && m_functions.hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil)) { @@ -138,6 +157,12 @@ QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *conte m_functions.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, width, height); } } +#else + m_functions.glGenRenderbuffers(1, &m_depthBuffer); + m_functions.glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); + m_functions.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height); + m_stencilBuffer = m_depthBuffer; +#endif } QSGDefaultDepthStencilBuffer::~QSGDefaultDepthStencilBuffer() |