diff options
Diffstat (limited to 'src/quick')
88 files changed, 851 insertions, 701 deletions
diff --git a/src/quick/items/context2d/qquickcanvasitem_p.h b/src/quick/items/context2d/qquickcanvasitem_p.h index b3509a5e58..e490bdf9c3 100644 --- a/src/quick/items/context2d/qquickcanvasitem_p.h +++ b/src/quick/items/context2d/qquickcanvasitem_p.h @@ -162,12 +162,12 @@ private Q_SLOTS: void invalidateSceneGraph(); protected: - void componentComplete(); - void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &); - void updatePolish(); - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - void releaseResources(); + void componentComplete() Q_DECL_OVERRIDE; + void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &) Q_DECL_OVERRIDE; + void updatePolish() Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void releaseResources() Q_DECL_OVERRIDE; private: Q_DECLARE_PRIVATE(QQuickCanvasItem) Q_INVOKABLE void delayedCreate(); diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp index a52f1c8cd2..eac5e2cef8 100644 --- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp +++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp @@ -93,7 +93,7 @@ namespace { } void paint(QPainter *p) const { p->fillRect(m_rect, m_brush); } - QRectF boundingRect() const { return m_rect; } + QRectF boundingRect() const Q_DECL_OVERRIDE { return m_rect; } private: QRectF m_rect; @@ -110,7 +110,7 @@ namespace { } void paint(QPainter *p) const { p->fillPath(m_path, m_brush); } - QRectF boundingRect() const { return m_path.boundingRect(); } + QRectF boundingRect() const Q_DECL_OVERRIDE { return m_path.boundingRect(); } private: QPainterPath m_path; @@ -128,7 +128,7 @@ namespace { void paint(QPainter *p) const { p->strokePath(m_path, m_pen); } - QRectF boundingRect() const + QRectF boundingRect() const Q_DECL_OVERRIDE { qreal d = qMax(qreal(1), m_pen.widthF()); return m_path.boundingRect().adjusted(-d, -d, d, d); @@ -150,7 +150,7 @@ namespace { void paint(QPainter *p) const { p->drawImage(m_offset, m_image); } - QRectF boundingRect() const { return QRectF(m_image.rect()).translated(m_offset); } + QRectF boundingRect() const Q_DECL_OVERRIDE { return QRectF(m_image.rect()).translated(m_offset); } private: QImage m_image; diff --git a/src/quick/items/qquickanchors_p_p.h b/src/quick/items/qquickanchors_p_p.h index d07b4369f5..cd5f32c266 100644 --- a/src/quick/items/qquickanchors_p_p.h +++ b/src/quick/items/qquickanchors_p_p.h @@ -126,8 +126,8 @@ public: void updateMe(); // QQuickItemGeometryListener interface - void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &); - QQuickAnchorsPrivate *anchorPrivate() { return this; } + void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) Q_DECL_OVERRIDE; + QQuickAnchorsPrivate *anchorPrivate() Q_DECL_OVERRIDE { return this; } bool checkHValid() const; bool checkVValid() const; diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h index 789f56e6f7..d04cbdf851 100644 --- a/src/quick/items/qquickanimatedimage_p.h +++ b/src/quick/items/qquickanimatedimage_p.h @@ -71,7 +71,7 @@ public: int frameCount() const; // Extends QQuickImage's src property - virtual void setSource(const QUrl&); + void setSource(const QUrl&) Q_DECL_OVERRIDE; virtual QSize sourceSize(); Q_SIGNALS: @@ -86,8 +86,8 @@ private Q_SLOTS: void playingStatusChanged(); protected: - virtual void load(); - void componentComplete(); + void load() Q_DECL_OVERRIDE; + void componentComplete() Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QQuickAnimatedImage) diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index f1201cf549..f144345b6c 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -54,9 +54,9 @@ class QQuickAnimatedSpriteMaterial : public QSGMaterial public: QQuickAnimatedSpriteMaterial(); ~QQuickAnimatedSpriteMaterial(); - virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; } - virtual QSGMaterialShader *createShader() const; - virtual int compare(const QSGMaterial *other) const + QSGMaterialType *type() const Q_DECL_OVERRIDE { static QSGMaterialType type; return &type; } + QSGMaterialShader *createShader() const Q_DECL_OVERRIDE; + int compare(const QSGMaterial *other) const Q_DECL_OVERRIDE { return this - static_cast<const QQuickAnimatedSpriteMaterial *>(other); } @@ -100,7 +100,7 @@ public: setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/items/shaders/sprite.frag")); } - virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) + void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) Q_DECL_OVERRIDE { QQuickAnimatedSpriteMaterial *m = static_cast<QQuickAnimatedSpriteMaterial *>(newEffect); m->texture->bind(); @@ -113,14 +113,14 @@ public: program()->setUniformValue(m_matrix_id, state.combinedMatrix()); } - virtual void initialize() { + void initialize() Q_DECL_OVERRIDE { m_matrix_id = program()->uniformLocation("qt_Matrix"); m_opacity_id = program()->uniformLocation("qt_Opacity"); m_animData_id = program()->uniformLocation("animData"); m_animPos_id = program()->uniformLocation("animPos"); } - virtual char const *const *attributeNames() const { + char const *const *attributeNames() const Q_DECL_OVERRIDE { static const char *attr[] = { "vPos", "vTex", @@ -388,8 +388,8 @@ void QQuickAnimatedSprite::advance(int frames) //TODO-C: May not work when running - only when paused m_curFrame += frames; while (m_curFrame < 0) - m_curFrame += m_sprite->frames(); - m_curFrame = m_curFrame % m_sprite->frames(); + m_curFrame += m_spriteEngine->maxFrames(); + m_curFrame = m_curFrame % m_spriteEngine->maxFrames(); emit currentFrameChanged(m_curFrame); } @@ -529,7 +529,6 @@ QSGGeometryNode* QQuickAnimatedSprite::buildNode() indices[5] = 2; - m_timestamp.start(); m_node = new QSGGeometryNode(); m_node->setGeometry(g); m_node->setMaterial(m_material); @@ -574,43 +573,47 @@ void QQuickAnimatedSprite::prepareNextFrame() int timeInt = m_timestamp.elapsed() + m_pauseOffset; qreal time = timeInt / 1000.; - double frameAt; //double just for modf + int frameAt; qreal progress = 0.0; int lastFrame = m_curFrame; - if (!m_paused) { + if (m_running && !m_paused) { + const int nColumns = int(m_sheetSize.width()) / m_spriteEngine->spriteWidth(); //Advance State (keeps time for psuedostates) m_spriteEngine->updateSprites(timeInt); //Advance AnimatedSprite qreal animT = m_spriteEngine->spriteStart()/1000.0; - qreal frameCount = m_spriteEngine->spriteFrames(); - qreal frameDuration = m_spriteEngine->spriteDuration()/frameCount; + const int frameCountInRow = m_spriteEngine->spriteFrames(); + const qreal frameDuration = m_spriteEngine->spriteDuration()/frameCountInRow; if (frameDuration > 0) { qreal frame = (time - animT)/(frameDuration / 1000.0); bool lastLoop = m_loops > 0 && m_curLoop == m_loops-1; //don't visually interpolate for the last frame of the last loop - qreal max = lastLoop ? frameCount - qreal(1.0) : frameCount; - frame = qBound(qreal(0.0), frame, max); - progress = modf(frame,&frameAt); - if (m_curFrame > frameAt) //went around + const int max = lastLoop ? frameCountInRow - 1 : frameCountInRow; + frame = qBound(qreal(0.0), frame, qreal(max)); + double intpart; + progress = modf(frame,&intpart); + frameAt = (int)intpart; + const int rowIndex = m_spriteEngine->spriteY()/frameHeight(); + const int newFrame = rowIndex * nColumns + frameAt; + if (m_curFrame > newFrame) //went around m_curLoop++; - m_curFrame = frameAt; + m_curFrame = newFrame; } else { m_curFrame++; - if (m_curFrame >= frameCount){ + if (m_curFrame >= m_spriteEngine->maxFrames()) { // maxFrames: total number of frames including all rows m_curFrame = 0; m_curLoop++; - m_spriteEngine->advance(); } - frameAt = m_curFrame; + frameAt = m_curFrame % nColumns; + if (frameAt == 0) + m_spriteEngine->advance(); progress = 0; } if (m_loops > 0 && m_curLoop >= m_loops) { frameAt = 0; - if (m_running) { - m_running = false; - emit runningChanged(false); - } + m_running = false; + emit runningChanged(false); } } else { frameAt = m_curFrame; diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h index 0bc2c65b7c..546d239034 100644 --- a/src/quick/items/qquickanimatedsprite_p.h +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -343,8 +343,8 @@ private Q_SLOTS: protected: void reset(); - void componentComplete(); - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + void componentComplete() Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; private: bool isCurrentFrameChangedConnected(); void prepareNextFrame(); diff --git a/src/quick/items/qquickborderimage_p.h b/src/quick/items/qquickborderimage_p.h index 1d0898115d..a33098d3b1 100644 --- a/src/quick/items/qquickborderimage_p.h +++ b/src/quick/items/qquickborderimage_p.h @@ -66,7 +66,7 @@ public: TileMode verticalTileMode() const; void setVerticalTileMode(TileMode); - void setSource(const QUrl &url); + void setSource(const QUrl &url) Q_DECL_OVERRIDE; Q_SIGNALS: void horizontalTileModeChanged(); @@ -74,16 +74,16 @@ Q_SIGNALS: void sourceSizeChanged(); protected: - virtual void load(); - virtual void pixmapChange(); - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + void load() Q_DECL_OVERRIDE; + void pixmapChange() Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; private: void setGridScaledImage(const QQuickGridScaledImage& sci); private Q_SLOTS: void doUpdate(); - void requestFinished(); + void requestFinished() Q_DECL_OVERRIDE; void sciRequestFinished(); private: diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index 5641c323ab..e49347351c 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -71,7 +71,7 @@ public: { } - void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &); + void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) Q_DECL_OVERRIDE; void itemParentChanged(QQuickItem *, QQuickItem *parent); void updatePosition(); void restartDrag(); diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h index a0c985ddf7..35a5f3c880 100644 --- a/src/quick/items/qquickdroparea_p.h +++ b/src/quick/items/qquickdroparea_p.h @@ -160,10 +160,10 @@ Q_SIGNALS: void dropped(QQuickDropEvent *drop); protected: - void dragMoveEvent(QDragMoveEvent *event); - void dragEnterEvent(QDragEnterEvent *event); - void dragLeaveEvent(QDragLeaveEvent *event); - void dropEvent(QDropEvent *event); + void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE; + void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE; + void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QQuickDropArea) diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 9f1de39186..f851ef1bac 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -180,7 +180,7 @@ public: } protected: - virtual void finished() { + void finished() Q_DECL_OVERRIDE { if (!flickable) return; axisData->move.setValue(axisData->transitionTo); diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h index c8a1ba6984..c996d18b01 100644 --- a/src/quick/items/qquickflickable_p.h +++ b/src/quick/items/qquickflickable_p.h @@ -220,14 +220,14 @@ Q_SIGNALS: void pixelAlignedChanged(); protected: - virtual bool childMouseEventFilter(QQuickItem *, QEvent *); - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); - virtual void mouseReleaseEvent(QMouseEvent *event); + bool childMouseEventFilter(QQuickItem *, QEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QWheelEvent *event); + void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; #endif - virtual void timerEvent(QTimerEvent *event); + void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; QQuickFlickableVisibleArea *visibleArea(); @@ -244,11 +244,11 @@ protected: virtual qreal maxYExtent() const; qreal vWidth() const; qreal vHeight() const; - virtual void componentComplete(); + void componentComplete() Q_DECL_OVERRIDE; virtual void viewportMoved(Qt::Orientations orient); - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - void mouseUngrabEvent(); + void geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void mouseUngrabEvent() Q_DECL_OVERRIDE; bool sendMouseEvent(QQuickItem *item, QMouseEvent *event); bool xflick() const; diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h index bd8c8de168..af4a4bccbf 100644 --- a/src/quick/items/qquickflickable_p_p.h +++ b/src/quick/items/qquickflickable_p_p.h @@ -80,7 +80,7 @@ public: { Velocity(QQuickFlickablePrivate *p) : parent(p) {} - virtual void setValue(qreal v) { + void setValue(qreal v) Q_DECL_OVERRIDE { if (v != value()) { QQuickTimeLineValue::setValue(v); parent->updateVelocity(); @@ -185,7 +185,7 @@ public: qreal overShootDistance(qreal size); - void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &); + void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) Q_DECL_OVERRIDE; void draggingStarting(); void draggingEnding(); diff --git a/src/quick/items/qquickflipable.cpp b/src/quick/items/qquickflipable.cpp index 1d439eef05..a68457319b 100644 --- a/src/quick/items/qquickflipable.cpp +++ b/src/quick/items/qquickflipable.cpp @@ -51,7 +51,7 @@ public: transform = t; update(); } - virtual void applyTo(QMatrix4x4 *matrix) const { + void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE { *matrix *= transform; } private: @@ -64,7 +64,7 @@ class QQuickFlipablePrivate : public QQuickItemPrivate public: QQuickFlipablePrivate() : current(QQuickFlipable::Front), front(0), back(0), sideDirty(false) {} - virtual void transformChanged(); + void transformChanged() Q_DECL_OVERRIDE; void updateSide(); void setBackTransform(); diff --git a/src/quick/items/qquickflipable_p.h b/src/quick/items/qquickflipable_p.h index 0196e35315..9648b22ef6 100644 --- a/src/quick/items/qquickflipable_p.h +++ b/src/quick/items/qquickflipable_p.h @@ -72,7 +72,7 @@ Q_SIGNALS: void sideChanged(); protected: - virtual void updatePolish(); + void updatePolish() Q_DECL_OVERRIDE; private Q_SLOTS: void retransformBack(); diff --git a/src/quick/items/qquickframebufferobject.h b/src/quick/items/qquickframebufferobject.h index f6431dc38e..3c3ae77436 100644 --- a/src/quick/items/qquickframebufferobject.h +++ b/src/quick/items/qquickframebufferobject.h @@ -80,7 +80,7 @@ public: void releaseResources() Q_DECL_OVERRIDE; protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; protected: QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index 72edce4339..e3af926e22 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -115,7 +115,7 @@ public: void setPosition(qreal col, qreal row, bool immediate = false) { moveTo(pointForPosition(col, row), immediate); } - bool contains(qreal x, qreal y) const { + bool contains(qreal x, qreal y) const Q_DECL_OVERRIDE { return (x >= itemX() && x < itemX() + view->cellWidth() && y >= itemY() && y < itemY() + view->cellHeight()); } @@ -152,13 +152,13 @@ class QQuickGridViewPrivate : public QQuickItemViewPrivate Q_DECLARE_PUBLIC(QQuickGridView) public: - virtual Qt::Orientation layoutOrientation() const; - virtual bool isContentFlowReversed() const; + Qt::Orientation layoutOrientation() const Q_DECL_OVERRIDE; + bool isContentFlowReversed() const Q_DECL_OVERRIDE; - virtual qreal positionAt(int index) const; - virtual qreal endPositionAt(int index) const; - virtual qreal originPosition() const; - virtual qreal lastPosition() const; + qreal positionAt(int index) const Q_DECL_OVERRIDE; + qreal endPositionAt(int index) const Q_DECL_OVERRIDE; + qreal originPosition() const Q_DECL_OVERRIDE; + qreal lastPosition() const Q_DECL_OVERRIDE; qreal rowSize() const; qreal colSize() const; @@ -172,41 +172,41 @@ public: void resetColumns(); - virtual bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer); - virtual bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo); - - virtual FxViewItem *newViewItem(int index, QQuickItem *item); - virtual void initializeViewItem(FxViewItem *item); - virtual void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer); - virtual void repositionPackageItemAt(QQuickItem *item, int index); - virtual void resetFirstItemPosition(qreal pos = 0.0); - virtual void adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible); - - virtual void createHighlight(); - virtual void updateHighlight(); - virtual void resetHighlightPosition(); - - virtual void setPosition(qreal pos); - virtual void layoutVisibleItems(int fromModelIndex = 0); - virtual bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView); - virtual void translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult); - virtual bool needsRefillForAddedOrRemovedIndex(int index) const; - - virtual qreal headerSize() const; - virtual qreal footerSize() const; - virtual bool showHeaderForIndex(int index) const; - virtual bool showFooterForIndex(int index) const; - virtual void updateHeader(); - virtual void updateFooter(); - - virtual void changedVisibleIndex(int newIndex); - virtual void initializeCurrentItem(); - - virtual void updateViewport(); - virtual void fixupPosition(); - virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); - virtual bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QQuickTimeLineCallback::Callback fixupCallback, qreal velocity); + bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) Q_DECL_OVERRIDE; + bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) Q_DECL_OVERRIDE; + + FxViewItem *newViewItem(int index, QQuickItem *item) Q_DECL_OVERRIDE; + void initializeViewItem(FxViewItem *item) Q_DECL_OVERRIDE; + void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) Q_DECL_OVERRIDE; + void repositionPackageItemAt(QQuickItem *item, int index) Q_DECL_OVERRIDE; + void resetFirstItemPosition(qreal pos = 0.0) Q_DECL_OVERRIDE; + void adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible) Q_DECL_OVERRIDE; + + void createHighlight() Q_DECL_OVERRIDE; + void updateHighlight() Q_DECL_OVERRIDE; + void resetHighlightPosition() Q_DECL_OVERRIDE; + + void setPosition(qreal pos) Q_DECL_OVERRIDE; + void layoutVisibleItems(int fromModelIndex = 0) Q_DECL_OVERRIDE; + bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) Q_DECL_OVERRIDE; + void translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) Q_DECL_OVERRIDE; + bool needsRefillForAddedOrRemovedIndex(int index) const Q_DECL_OVERRIDE; + + qreal headerSize() const Q_DECL_OVERRIDE; + qreal footerSize() const Q_DECL_OVERRIDE; + bool showHeaderForIndex(int index) const Q_DECL_OVERRIDE; + bool showFooterForIndex(int index) const Q_DECL_OVERRIDE; + void updateHeader() Q_DECL_OVERRIDE; + void updateFooter() Q_DECL_OVERRIDE; + + void changedVisibleIndex(int newIndex) Q_DECL_OVERRIDE; + void initializeCurrentItem() Q_DECL_OVERRIDE; + + void updateViewport() Q_DECL_OVERRIDE; + void fixupPosition() Q_DECL_OVERRIDE; + void fixup(AxisData &data, qreal minExtent, qreal maxExtent) Q_DECL_OVERRIDE; + bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, + QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) Q_DECL_OVERRIDE; QQuickGridView::Flow flow; qreal cellWidth; diff --git a/src/quick/items/qquickgridview_p.h b/src/quick/items/qquickgridview_p.h index 7468a49ac1..b835b0a070 100644 --- a/src/quick/items/qquickgridview_p.h +++ b/src/quick/items/qquickgridview_p.h @@ -65,8 +65,8 @@ public: QQuickGridView(QQuickItem *parent=0); ~QQuickGridView(); - virtual void setHighlightFollowsCurrentItem(bool); - virtual void setHighlightMoveDuration(int); + void setHighlightFollowsCurrentItem(bool) Q_DECL_OVERRIDE; + void setHighlightMoveDuration(int) Q_DECL_OVERRIDE; Flow flow() const; void setFlow(Flow); @@ -97,10 +97,10 @@ Q_SIGNALS: void snapModeChanged(); protected: - virtual void viewportMoved(Qt::Orientations); - virtual void keyPressEvent(QKeyEvent *); - virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - virtual void initItem(int index, QObject *item); + void viewportMoved(Qt::Orientations) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void initItem(int index, QObject *item) Q_DECL_OVERRIDE; }; class QQuickGridViewAttached : public QQuickItemViewAttached diff --git a/src/quick/items/qquickimage_p.h b/src/quick/items/qquickimage_p.h index b359ff779d..eef5c3901d 100644 --- a/src/quick/items/qquickimage_p.h +++ b/src/quick/items/qquickimage_p.h @@ -73,7 +73,7 @@ public: qreal paintedWidth() const; qreal paintedHeight() const; - QRectF boundingRect() const; + QRectF boundingRect() const Q_DECL_OVERRIDE; HAlignment horizontalAlignment() const; void setHorizontalAlignment(HAlignment align); @@ -81,8 +81,8 @@ public: VAlignment verticalAlignment() const; void setVerticalAlignment(VAlignment align); - bool isTextureProvider() const { return true; } - QSGTextureProvider *textureProvider() const; + bool isTextureProvider() const Q_DECL_OVERRIDE { return true; } + QSGTextureProvider *textureProvider() const Q_DECL_OVERRIDE; bool mipmap() const; void setMipmap(bool use); @@ -99,12 +99,12 @@ private Q_SLOTS: protected: QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent); - void pixmapChange(); + void pixmapChange() Q_DECL_OVERRIDE; void updatePaintedGeometry(); void releaseResources() Q_DECL_OVERRIDE; - virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QQuickImage) diff --git a/src/quick/items/qquickimagebase_p.h b/src/quick/items/qquickimagebase_p.h index 4446268a2b..860cb2e670 100644 --- a/src/quick/items/qquickimagebase_p.h +++ b/src/quick/items/qquickimagebase_p.h @@ -91,7 +91,7 @@ Q_SIGNALS: protected: virtual void load(); - virtual void componentComplete(); + void componentComplete() Q_DECL_OVERRIDE; virtual void pixmapChange(); QQuickImageBase(QQuickImageBasePrivate &dd, QQuickItem *parent); diff --git a/src/quick/items/qquickimplicitsizeitem_p_p.h b/src/quick/items/qquickimplicitsizeitem_p_p.h index cdf768cbd9..c34e3424b0 100644 --- a/src/quick/items/qquickimplicitsizeitem_p_p.h +++ b/src/quick/items/qquickimplicitsizeitem_p_p.h @@ -60,8 +60,8 @@ public: { } - virtual void implicitWidthChanged(); - virtual void implicitHeightChanged(); + void implicitWidthChanged() Q_DECL_OVERRIDE; + void implicitHeightChanged() Q_DECL_OVERRIDE; }; QT_END_NAMESPACE diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 0fb8d0e2f8..b2ee5af6ff 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2843,10 +2843,8 @@ void QQuickItemPrivate::derefWindow() extra->opacityNode = 0; extra->clipNode = 0; extra->rootNode = 0; - extra->beforePaintNode = 0; } - groupNode = 0; paintNode = 0; for (int ii = 0; ii < childItems.count(); ++ii) { @@ -2971,7 +2969,6 @@ QQuickItemPrivate::QQuickItemPrivate() , implicitHeight(0) , baselineOffset(0) , itemNodeInstance(0) - , groupNode(0) , paintNode(0) { } @@ -7816,7 +7813,7 @@ QQuickItemPrivate::ExtraData::ExtraData() numItemsWithCursor(0), #endif effectRefCount(0), hideRefCount(0), - opacityNode(0), clipNode(0), rootNode(0), beforePaintNode(0), + opacityNode(0), clipNode(0), rootNode(0), acceptedMouseButtons(0), origin(QQuickItem::Center), transparentForPositioner(false) { diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h index c17f6a6a7d..e93e8c1439 100644 --- a/src/quick/items/qquickitem.h +++ b/src/quick/items/qquickitem.h @@ -376,7 +376,7 @@ Q_SIGNALS: void implicitHeightChanged(); protected: - virtual bool event(QEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; bool isComponentComplete() const; virtual void itemChange(ItemChange, const ItemChangeData &); diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 7ef0f903b5..e416facc6b 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -92,10 +92,10 @@ public: void complete(); protected: - void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); - void itemDestroyed(QQuickItem *item); - void itemChildAdded(QQuickItem *, QQuickItem *); - void itemChildRemoved(QQuickItem *, QQuickItem *); + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; + void itemChildAdded(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE; + void itemChildRemoved(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE; //void itemVisibilityChanged(QQuickItem *item) private: @@ -178,11 +178,11 @@ public: QQuickShaderEffectSource *effectSource() const { return m_effectSource; } - void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &); - void itemOpacityChanged(QQuickItem *); - void itemParentChanged(QQuickItem *, QQuickItem *); - void itemSiblingOrderChanged(QQuickItem *); - void itemVisibilityChanged(QQuickItem *); + void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) Q_DECL_OVERRIDE; + void itemOpacityChanged(QQuickItem *) Q_DECL_OVERRIDE; + void itemParentChanged(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE; + void itemSiblingOrderChanged(QQuickItem *) Q_DECL_OVERRIDE; + void itemVisibilityChanged(QQuickItem *) Q_DECL_OVERRIDE; void updateMatrix(); void updateGeometry(); @@ -352,7 +352,6 @@ public: QSGOpacityNode *opacityNode; QQuickDefaultClipNode *clipNode; QSGRootNode *rootNode; - QSGNode *beforePaintNode; // Although acceptedMouseButtons is inside ExtraData, we actually store // the LeftButton flag in the extra.flag() bit. This is because it is @@ -556,8 +555,7 @@ public: - itemNode - (opacityNode) - (clipNode) - - (effectNode) - - groupNode + - (rootNode) (shader effect source's root node) */ QSGOpacityNode *opacityNode() const { return extra.isAllocated()?extra->opacityNode:0; } @@ -565,7 +563,6 @@ public: QSGRootNode *rootNode() const { return extra.isAllocated()?extra->rootNode:0; } QSGTransformNode *itemNodeInstance; - QSGNode *groupNode; QSGNode *paintNode; virtual QSGTransformNode *createTransformNode(); @@ -681,8 +678,8 @@ Q_SIGNALS: void priorityChanged(); private: - virtual void keyPressed(QKeyEvent *event, bool post); - virtual void keyReleased(QKeyEvent *event, bool post); + void keyPressed(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; + void keyReleased(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; void setFocusNavigation(QQuickItem *currentItem, const char *dir, Qt::FocusReason reason = Qt::OtherFocusReason); }; @@ -765,7 +762,7 @@ public: return QQmlListProperty<QQuickItem>(this, d->targets); } - virtual void componentComplete(); + void componentComplete() Q_DECL_OVERRIDE; static QQuickKeysAttached *qmlAttachedProperties(QObject *); @@ -816,11 +813,11 @@ Q_SIGNALS: void volumeDownPressed(QQuickKeyEvent *event); private: - virtual void keyPressed(QKeyEvent *event, bool post); - virtual void keyReleased(QKeyEvent *event, bool post); + void keyPressed(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; + void keyReleased(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; #ifndef QT_NO_IM - virtual void inputMethodEvent(QInputMethodEvent *, bool post); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + void inputMethodEvent(QInputMethodEvent *, bool post) Q_DECL_OVERRIDE; + QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE; #endif const QByteArray keyToSignal(int key); @@ -868,7 +865,7 @@ QSGTransformNode *QQuickItemPrivate::itemNode() itemNodeInstance->setFlag(QSGNode::OwnedByParent, false); #ifdef QSG_RUNTIME_DESCRIPTION Q_Q(QQuickItem); - qsgnode_set_description(itemNodeInstance, QString::fromLatin1("QQuickItem(%1)").arg(QString::fromLatin1(q->metaObject()->className()))); + qsgnode_set_description(itemNodeInstance, QString::fromLatin1("QQuickItem(%1:%2)").arg(QString::fromLatin1(q->metaObject()->className())).arg(q->objectName())); #endif } return itemNodeInstance; @@ -876,21 +873,14 @@ QSGTransformNode *QQuickItemPrivate::itemNode() QSGNode *QQuickItemPrivate::childContainerNode() { - if (!groupNode) { - groupNode = new QSGNode(); - if (rootNode()) - rootNode()->appendChildNode(groupNode); - else if (clipNode()) - clipNode()->appendChildNode(groupNode); - else if (opacityNode()) - opacityNode()->appendChildNode(groupNode); - else - itemNode()->appendChildNode(groupNode); -#ifdef QSG_RUNTIME_DESCRIPTION - qsgnode_set_description(groupNode, QLatin1String("group")); -#endif - } - return groupNode; + if (rootNode()) + return rootNode(); + else if (clipNode()) + return clipNode(); + else if (opacityNode()) + return opacityNode(); + else + return itemNode(); } Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ChangeTypes) diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp index c7c40980dc..810b487e3a 100644 --- a/src/quick/items/qquickitemanimation.cpp +++ b/src/quick/items/qquickitemanimation.cpp @@ -210,7 +210,7 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act //### reverse should probably apply on a per-action basis bool reverse; QList<QQuickParentChange *> pc; - virtual void doAction() + void doAction() Q_DECL_OVERRIDE { for (int ii = 0; ii < actions.count(); ++ii) { const QQuickStateAction &action = actions.at(ii); diff --git a/src/quick/items/qquickitemanimation_p.h b/src/quick/items/qquickitemanimation_p.h index d16c9f8107..a1bc4b6bdf 100644 --- a/src/quick/items/qquickitemanimation_p.h +++ b/src/quick/items/qquickitemanimation_p.h @@ -69,10 +69,10 @@ Q_SIGNALS: void viaChanged(); protected: - virtual QAbstractAnimationJob* transition(QQuickStateActions &actions, + QAbstractAnimationJob* transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, - QObject *defaultTarget = 0); + QObject *defaultTarget = 0) Q_DECL_OVERRIDE; }; class QQuickAnchorAnimationPrivate; @@ -101,10 +101,10 @@ Q_SIGNALS: void easingChanged(const QEasingCurve&); protected: - virtual QAbstractAnimationJob* transition(QQuickStateActions &actions, + QAbstractAnimationJob* transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, - QObject *defaultTarget = 0); + QObject *defaultTarget = 0) Q_DECL_OVERRIDE; }; class QQuickItem; @@ -166,10 +166,10 @@ public: void setEndRotation(qreal); protected: - virtual QAbstractAnimationJob* transition(QQuickStateActions &actions, + QAbstractAnimationJob* transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, - QObject *defaultTarget = 0); + QObject *defaultTarget = 0) Q_DECL_OVERRIDE; Q_SIGNALS: void durationChanged(int); void easingChanged(const QEasingCurve &); diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h index 89c3bec465..3e7acdd26c 100644 --- a/src/quick/items/qquickitemview_p.h +++ b/src/quick/items/qquickitemview_p.h @@ -208,10 +208,10 @@ public: Q_INVOKABLE void positionViewAtEnd(); Q_REVISION(1) Q_INVOKABLE void forceLayout(); - virtual void setContentX(qreal pos); - virtual void setContentY(qreal pos); - virtual qreal originX() const; - virtual qreal originY() const; + void setContentX(qreal pos) Q_DECL_OVERRIDE; + void setContentY(qreal pos) Q_DECL_OVERRIDE; + qreal originX() const Q_DECL_OVERRIDE; + qreal originY() const Q_DECL_OVERRIDE; Q_SIGNALS: void modelChanged(); @@ -252,13 +252,13 @@ Q_SIGNALS: void highlightMoveDurationChanged(); protected: - virtual void updatePolish(); - virtual void componentComplete(); - virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - virtual qreal minYExtent() const; - virtual qreal maxYExtent() const; - virtual qreal minXExtent() const; - virtual qreal maxXExtent() const; + void updatePolish() Q_DECL_OVERRIDE; + void componentComplete() Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + qreal minYExtent() const Q_DECL_OVERRIDE; + qreal maxYExtent() const Q_DECL_OVERRIDE; + qreal minXExtent() const Q_DECL_OVERRIDE; + qreal maxXExtent() const Q_DECL_OVERRIDE; protected Q_SLOTS: void destroyRemoved(); diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h index 76fc326367..b053b1ea6e 100644 --- a/src/quick/items/qquickitemview_p_p.h +++ b/src/quick/items/qquickitemview_p_p.h @@ -181,7 +181,7 @@ public: virtual void animationFinished(QAbstractAnimationJob *); void refill(); void refill(qreal from, qreal to); - void mirrorChange(); + void mirrorChange() Q_DECL_OVERRIDE; FxViewItem *createItem(int modelIndex, bool asynchronous = false); virtual bool releaseItem(FxViewItem *item); @@ -211,7 +211,7 @@ public: void prepareVisibleItemTransitions(); void prepareRemoveTransitions(QHash<QQmlChangeSet::MoveKey, FxViewItem *> *removedItems); bool prepareNonVisibleItemTransition(FxViewItem *item, const QRectF &viewBounds); - virtual void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item); + void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) Q_DECL_OVERRIDE; int findMoveKeyIndex(QQmlChangeSet::MoveKey key, const QVector<QQmlChangeSet::Change> &changes) const; @@ -353,7 +353,7 @@ protected: virtual void updateSectionCriteria() {} virtual void updateSections() {} - virtual void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; }; diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp index 41ee9bb1f2..9c14133cbd 100644 --- a/src/quick/items/qquickitemviewtransition.cpp +++ b/src/quick/items/qquickitemviewtransition.cpp @@ -57,7 +57,7 @@ public: bool *m_wasDeleted; protected: - virtual void finished(); + void finished() Q_DECL_OVERRIDE; }; diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index d381fe2030..851204ccde 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -59,49 +59,49 @@ class QQuickListViewPrivate : public QQuickItemViewPrivate public: static QQuickListViewPrivate* get(QQuickListView *item) { return item->d_func(); } - virtual Qt::Orientation layoutOrientation() const; - virtual bool isContentFlowReversed() const; + Qt::Orientation layoutOrientation() const Q_DECL_OVERRIDE; + bool isContentFlowReversed() const Q_DECL_OVERRIDE; bool isRightToLeft() const; bool isBottomToTop() const; - virtual qreal positionAt(int index) const; - virtual qreal endPositionAt(int index) const; - virtual qreal originPosition() const; - virtual qreal lastPosition() const; + qreal positionAt(int index) const Q_DECL_OVERRIDE; + qreal endPositionAt(int index) const Q_DECL_OVERRIDE; + qreal originPosition() const Q_DECL_OVERRIDE; + qreal lastPosition() const Q_DECL_OVERRIDE; FxViewItem *itemBefore(int modelIndex) const; QString sectionAt(int modelIndex); qreal snapPosAt(qreal pos); FxViewItem *snapItemAt(qreal pos); - virtual void init(); - virtual void clear(); + void init() Q_DECL_OVERRIDE; + void clear() Q_DECL_OVERRIDE; - virtual bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer); - virtual bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo); - virtual void visibleItemsChanged(); + bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) Q_DECL_OVERRIDE; + bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) Q_DECL_OVERRIDE; + void visibleItemsChanged() Q_DECL_OVERRIDE; - virtual FxViewItem *newViewItem(int index, QQuickItem *item); - virtual void initializeViewItem(FxViewItem *item); - virtual bool releaseItem(FxViewItem *item); - virtual void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer); - virtual void repositionPackageItemAt(QQuickItem *item, int index); - virtual void resetFirstItemPosition(qreal pos = 0.0); - virtual void adjustFirstItem(qreal forwards, qreal backwards, int); - virtual void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult); + FxViewItem *newViewItem(int index, QQuickItem *item) Q_DECL_OVERRIDE; + void initializeViewItem(FxViewItem *item) Q_DECL_OVERRIDE; + bool releaseItem(FxViewItem *item) Q_DECL_OVERRIDE; + void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) Q_DECL_OVERRIDE; + void repositionPackageItemAt(QQuickItem *item, int index) Q_DECL_OVERRIDE; + void resetFirstItemPosition(qreal pos = 0.0) Q_DECL_OVERRIDE; + void adjustFirstItem(qreal forwards, qreal backwards, int) Q_DECL_OVERRIDE; + void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult) Q_DECL_OVERRIDE; - virtual void createHighlight(); - virtual void updateHighlight(); - virtual void resetHighlightPosition(); + void createHighlight() Q_DECL_OVERRIDE; + void updateHighlight() Q_DECL_OVERRIDE; + void resetHighlightPosition() Q_DECL_OVERRIDE; - virtual void setPosition(qreal pos); - virtual void layoutVisibleItems(int fromModelIndex = 0); + void setPosition(qreal pos) Q_DECL_OVERRIDE; + void layoutVisibleItems(int fromModelIndex = 0) Q_DECL_OVERRIDE; - virtual bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView); - virtual void translateAndTransitionItemsAfter(int afterIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult); + bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) Q_DECL_OVERRIDE; + void translateAndTransitionItemsAfter(int afterIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) Q_DECL_OVERRIDE; - virtual void updateSectionCriteria(); - virtual void updateSections(); + void updateSectionCriteria() Q_DECL_OVERRIDE; + void updateSections() Q_DECL_OVERRIDE; QQuickItem *getSectionItem(const QString §ion); void releaseSectionItem(QQuickItem *item); void releaseSectionItems(); @@ -109,25 +109,25 @@ public: void updateCurrentSection(); void updateStickySections(); - virtual qreal headerSize() const; - virtual qreal footerSize() const; - virtual bool showHeaderForIndex(int index) const; - virtual bool showFooterForIndex(int index) const; - virtual void updateHeader(); - virtual void updateFooter(); + qreal headerSize() const Q_DECL_OVERRIDE; + qreal footerSize() const Q_DECL_OVERRIDE; + bool showHeaderForIndex(int index) const Q_DECL_OVERRIDE; + bool showFooterForIndex(int index) const Q_DECL_OVERRIDE; + void updateHeader() Q_DECL_OVERRIDE; + void updateFooter() Q_DECL_OVERRIDE; bool hasStickyHeader() const; bool hasStickyFooter() const; - virtual void changedVisibleIndex(int newIndex); - virtual void initializeCurrentItem(); + void changedVisibleIndex(int newIndex) Q_DECL_OVERRIDE; + void initializeCurrentItem() Q_DECL_OVERRIDE; void updateAverage(); - void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); - virtual void fixupPosition(); - virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); - virtual bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QQuickTimeLineCallback::Callback fixupCallback, qreal velocity); + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void fixupPosition() Q_DECL_OVERRIDE; + void fixup(AxisData &data, qreal minExtent, qreal maxExtent) Q_DECL_OVERRIDE; + bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, + QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) Q_DECL_OVERRIDE; QQuickListView::Orientation orient; qreal visiblePos; @@ -319,7 +319,7 @@ public: else item->setWidth(size); } - bool contains(qreal x, qreal y) const { + bool contains(qreal x, qreal y) const Q_DECL_OVERRIDE { return (x >= itemX() && x < itemX() + item->width() && y >= itemY() && y < itemY() + item->height()); } diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h index a02fba258e..2801879b0f 100644 --- a/src/quick/items/qquicklistview_p.h +++ b/src/quick/items/qquicklistview_p.h @@ -126,7 +126,7 @@ public: QQuickViewSection *sectionCriteria(); QString currentSection() const; - virtual void setHighlightFollowsCurrentItem(bool); + void setHighlightFollowsCurrentItem(bool) Q_DECL_OVERRIDE; qreal highlightMoveVelocity() const; void setHighlightMoveVelocity(qreal); @@ -137,7 +137,7 @@ public: int highlightResizeDuration() const; void setHighlightResizeDuration(int); - virtual void setHighlightMoveDuration(int); + void setHighlightMoveDuration(int) Q_DECL_OVERRIDE; enum SnapMode { NoSnap, SnapToItem, SnapOneItem }; SnapMode snapMode() const; @@ -169,10 +169,10 @@ Q_SIGNALS: Q_REVISION(2) void footerPositioningChanged(); protected: - virtual void viewportMoved(Qt::Orientations orient); - virtual void keyPressEvent(QKeyEvent *); - virtual void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry); - virtual void initItem(int index, QObject *item); + void viewportMoved(Qt::Orientations orient) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void initItem(int index, QObject *item) Q_DECL_OVERRIDE; }; class QQuickListViewAttached : public QQuickItemViewAttached diff --git a/src/quick/items/qquickloader_p.h b/src/quick/items/qquickloader_p.h index 3e0cba5865..640897d507 100644 --- a/src/quick/items/qquickloader_p.h +++ b/src/quick/items/qquickloader_p.h @@ -88,8 +88,8 @@ Q_SIGNALS: void asynchronousChanged(); protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - void componentComplete(); + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void componentComplete() Q_DECL_OVERRIDE; private: void setSource(const QUrl &sourceUrl, bool needsClear); diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h index cae42a79ad..15e144855c 100644 --- a/src/quick/items/qquickloader_p_p.h +++ b/src/quick/items/qquickloader_p_p.h @@ -62,8 +62,8 @@ public: QQuickLoaderIncubator(QQuickLoaderPrivate *l, IncubationMode mode) : QQmlIncubator(mode), loader(l) {} protected: - virtual void statusChanged(Status); - virtual void setInitialState(QObject *); + void statusChanged(Status) Q_DECL_OVERRIDE; + void setInitialState(QObject *) Q_DECL_OVERRIDE; private: QQuickLoaderPrivate *loader; @@ -78,9 +78,9 @@ public: QQuickLoaderPrivate(); ~QQuickLoaderPrivate(); - void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); - void itemImplicitWidthChanged(QQuickItem *); - void itemImplicitHeightChanged(QQuickItem *); + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void itemImplicitWidthChanged(QQuickItem *) Q_DECL_OVERRIDE; + void itemImplicitHeightChanged(QQuickItem *) Q_DECL_OVERRIDE; void clear(); void initResize(); void load(); @@ -91,8 +91,8 @@ public: QUrl resolveSourceUrl(QQmlV4Function *args); QV4::ReturnedValue extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error); - virtual qreal getImplicitWidth() const; - virtual qreal getImplicitHeight() const; + qreal getImplicitWidth() const Q_DECL_OVERRIDE; + qreal getImplicitHeight() const Q_DECL_OVERRIDE; QUrl source; QQuickItem *item; diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h index 6d3e607d08..a1569548c9 100644 --- a/src/quick/items/qquickmultipointtoucharea_p.h +++ b/src/quick/items/qquickmultipointtoucharea_p.h @@ -228,13 +228,13 @@ Q_SIGNALS: void mouseEnabledChanged(); protected: - void touchEvent(QTouchEvent *); - bool childMouseEventFilter(QQuickItem *i, QEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseUngrabEvent(); - void touchUngrabEvent(); + void touchEvent(QTouchEvent *) Q_DECL_OVERRIDE; + bool childMouseEventFilter(QQuickItem *i, QEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseUngrabEvent() Q_DECL_OVERRIDE; + void touchUngrabEvent() Q_DECL_OVERRIDE; void addTouchPrototype(QQuickTouchPoint* prototype); void addTouchPoint(const QTouchEvent::TouchPoint *p); @@ -248,10 +248,10 @@ protected: bool sendMouseEvent(QMouseEvent *event); bool shouldFilter(QEvent *event); void grabGesture(); - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; #ifdef Q_OS_OSX - void hoverEnterEvent(QHoverEvent *event); - void hoverLeaveEvent(QHoverEvent *event); + void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; void setTouchEventsEnabled(bool enable); #endif diff --git a/src/quick/items/qquickpainteditem.h b/src/quick/items/qquickpainteditem.h index b5e04694bf..fc14574a8d 100644 --- a/src/quick/items/qquickpainteditem.h +++ b/src/quick/items/qquickpainteditem.h @@ -107,7 +107,7 @@ Q_SIGNALS: protected: QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent = 0); - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; void releaseResources() Q_DECL_OVERRIDE; private Q_SLOTS: diff --git a/src/quick/items/qquickpathview_p.h b/src/quick/items/qquickpathview_p.h index 74ee4908b2..e57557204e 100644 --- a/src/quick/items/qquickpathview_p.h +++ b/src/quick/items/qquickpathview_p.h @@ -193,14 +193,14 @@ Q_SIGNALS: void cacheItemCountChanged(); protected: - virtual void updatePolish(); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *); + void updatePolish() Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; bool sendMouseEvent(QMouseEvent *event); - bool childMouseEventFilter(QQuickItem *, QEvent *); - void mouseUngrabEvent(); - void componentComplete(); + bool childMouseEventFilter(QQuickItem *, QEvent *) Q_DECL_OVERRIDE; + void mouseUngrabEvent() Q_DECL_OVERRIDE; + void componentComplete() Q_DECL_OVERRIDE; private Q_SLOTS: void refill(); diff --git a/src/quick/items/qquickpathview_p_p.h b/src/quick/items/qquickpathview_p_p.h index cd52dd10bb..7c0e651b69 100644 --- a/src/quick/items/qquickpathview_p_p.h +++ b/src/quick/items/qquickpathview_p_p.h @@ -69,7 +69,7 @@ public: void init(); - void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE { if ((newGeometry.size() != oldGeometry.size()) && (!highlightItem || item != highlightItem)) { if (QQuickPathViewAttached *att = attached(item)) diff --git a/src/quick/items/qquickpincharea_p.h b/src/quick/items/qquickpincharea_p.h index b82db035e5..28db59fb55 100644 --- a/src/quick/items/qquickpincharea_p.h +++ b/src/quick/items/qquickpincharea_p.h @@ -268,15 +268,15 @@ Q_SIGNALS: void pinchFinished(QQuickPinchEvent *pinch); protected: - virtual bool childMouseEventFilter(QQuickItem *i, QEvent *e); - virtual void touchEvent(QTouchEvent *event); + bool childMouseEventFilter(QQuickItem *i, QEvent *e) Q_DECL_OVERRIDE; + void touchEvent(QTouchEvent *event) Q_DECL_OVERRIDE; - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - virtual void itemChange(ItemChange change, const ItemChangeData& value); + void geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData& value) Q_DECL_OVERRIDE; #ifdef Q_OS_OSX - void hoverEnterEvent(QHoverEvent *event); - void hoverLeaveEvent(QHoverEvent *event); + void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; void setTouchEventsEnabled(bool enable); #endif diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h index 7df4ee3b9a..164ea86c71 100644 --- a/src/quick/items/qquickpositioners_p.h +++ b/src/quick/items/qquickpositioners_p.h @@ -110,10 +110,10 @@ public: protected: QQuickBasePositioner(QQuickBasePositionerPrivate &dd, PositionerType at, QQuickItem *parent); - virtual void componentComplete(); - virtual void itemChange(ItemChange, const ItemChangeData &); + void componentComplete() Q_DECL_OVERRIDE; + void itemChange(ItemChange, const ItemChangeData &) Q_DECL_OVERRIDE; - virtual void updatePolish(); + void updatePolish() Q_DECL_OVERRIDE; Q_SIGNALS: void spacingChanged(); @@ -173,8 +173,8 @@ public: QQuickColumn(QQuickItem *parent=0); protected: - virtual void doPositioning(QSizeF *contentSize); - virtual void reportConflictingAnchors(); + void doPositioning(QSizeF *contentSize) Q_DECL_OVERRIDE; + void reportConflictingAnchors() Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QQuickColumn) }; @@ -197,8 +197,8 @@ Q_SIGNALS: void effectiveLayoutDirectionChanged(); protected: - virtual void doPositioning(QSizeF *contentSize); - virtual void reportConflictingAnchors(); + void doPositioning(QSizeF *contentSize) Q_DECL_OVERRIDE; + void reportConflictingAnchors() Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QQuickRow) Q_DECLARE_PRIVATE(QQuickRow) @@ -274,8 +274,8 @@ Q_SIGNALS: Q_REVISION(1) void verticalAlignmentChanged(VAlignment alignment); protected: - virtual void doPositioning(QSizeF *contentSize); - virtual void reportConflictingAnchors(); + void doPositioning(QSizeF *contentSize) Q_DECL_OVERRIDE; + void reportConflictingAnchors() Q_DECL_OVERRIDE; private: int m_rows; @@ -316,8 +316,8 @@ Q_SIGNALS: void effectiveLayoutDirectionChanged(); protected: - virtual void doPositioning(QSizeF *contentSize); - virtual void reportConflictingAnchors(); + void doPositioning(QSizeF *contentSize) Q_DECL_OVERRIDE; + void reportConflictingAnchors() Q_DECL_OVERRIDE; protected: QQuickFlow(QQuickFlowPrivate &dd, QQuickItem *parent); private: diff --git a/src/quick/items/qquickpositioners_p_p.h b/src/quick/items/qquickpositioners_p_p.h index e77997d4e9..cdcb09cf49 100644 --- a/src/quick/items/qquickpositioners_p_p.h +++ b/src/quick/items/qquickpositioners_p_p.h @@ -98,7 +98,7 @@ public: Qt::LayoutDirection layoutDirection; - void mirrorChange() { + void mirrorChange() Q_DECL_OVERRIDE { effectiveLayoutDirectionChange(); } bool isLeftToRight() const { @@ -108,24 +108,24 @@ public: return effectiveLayoutMirror ? layoutDirection == Qt::RightToLeft : layoutDirection == Qt::LeftToRight; } - virtual void itemSiblingOrderChanged(QQuickItem* other) + void itemSiblingOrderChanged(QQuickItem* other) Q_DECL_OVERRIDE { Q_UNUSED(other); setPositioningDirty(); } - void itemGeometryChanged(QQuickItem *, const QRectF &newGeometry, const QRectF &oldGeometry) + void itemGeometryChanged(QQuickItem *, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE { if (newGeometry.size() != oldGeometry.size()) setPositioningDirty(); } - virtual void itemVisibilityChanged(QQuickItem *) + void itemVisibilityChanged(QQuickItem *) Q_DECL_OVERRIDE { setPositioningDirty(); } - void itemDestroyed(QQuickItem *item) + void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE { Q_Q(QQuickBasePositioner); int index = q->positionedItems.find(QQuickBasePositioner::PositionedItem(item)); diff --git a/src/quick/items/qquickrectangle_p.h b/src/quick/items/qquickrectangle_p.h index 2e9eabd1d5..18922630f8 100644 --- a/src/quick/items/qquickrectangle_p.h +++ b/src/quick/items/qquickrectangle_p.h @@ -153,7 +153,7 @@ Q_SIGNALS: void radiusChanged(); protected: - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; private Q_SLOTS: void doUpdate(); diff --git a/src/quick/items/qquickrepeater_p.h b/src/quick/items/qquickrepeater_p.h index 159520a89d..d1ca686e78 100644 --- a/src/quick/items/qquickrepeater_p.h +++ b/src/quick/items/qquickrepeater_p.h @@ -77,8 +77,8 @@ private: void regenerate(); protected: - virtual void componentComplete(); - void itemChange(ItemChange change, const ItemChangeData &value); + void componentComplete() Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; private Q_SLOTS: void createdItem(int index, QObject *item); diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h index 99e88a653d..8c5da9e5d5 100644 --- a/src/quick/items/qquickshadereffect_p.h +++ b/src/quick/items/qquickshadereffect_p.h @@ -136,7 +136,7 @@ public: QString parseLog(); - virtual bool event(QEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; Q_SIGNALS: void fragmentShaderChanged(); @@ -149,10 +149,10 @@ Q_SIGNALS: void supportsAtlasTexturesChanged(); protected: - virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); - virtual void componentComplete(); - virtual void itemChange(ItemChange change, const ItemChangeData &value); + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + void componentComplete() Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; private Q_SLOTS: void updateGeometry(); diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h index 5bcf633fa3..684f8461d8 100644 --- a/src/quick/items/qquickshadereffectmesh_p.h +++ b/src/quick/items/qquickshadereffectmesh_p.h @@ -69,8 +69,8 @@ class QQuickGridMesh : public QQuickShaderEffectMesh Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged) public: QQuickGridMesh(QObject *parent = 0); - virtual QSGGeometry *updateGeometry(QSGGeometry *geometry, const QVector<QByteArray> &attributes, const QRectF &srcRect, const QRectF &rect); - virtual QString log() const { return m_log; } + QSGGeometry *updateGeometry(QSGGeometry *geometry, const QVector<QByteArray> &attributes, const QRectF &srcRect, const QRectF &rect) Q_DECL_OVERRIDE; + QString log() const Q_DECL_OVERRIDE { return m_log; } void setResolution(const QSize &res); QSize resolution() const; diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp index 43220a0e29..df379b8a3b 100644 --- a/src/quick/items/qquickshadereffectnode.cpp +++ b/src/quick/items/qquickshadereffectnode.cpp @@ -45,16 +45,16 @@ class QQuickCustomMaterialShader : public QSGMaterialShader { public: QQuickCustomMaterialShader(const QQuickShaderEffectMaterialKey &key, const QVector<QByteArray> &attributes); - virtual void deactivate(); - virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect); - virtual char const *const *attributeNames() const; + void deactivate() Q_DECL_OVERRIDE; + void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) Q_DECL_OVERRIDE; + char const *const *attributeNames() const Q_DECL_OVERRIDE; protected: friend class QQuickShaderEffectNode; - virtual void compile(); - virtual const char *vertexShader() const; - virtual const char *fragmentShader() const; + void compile() Q_DECL_OVERRIDE; + const char *vertexShader() const Q_DECL_OVERRIDE; + const char *fragmentShader() const Q_DECL_OVERRIDE; const QQuickShaderEffectMaterialKey m_key; QVector<QByteArray> m_attributes; diff --git a/src/quick/items/qquickshadereffectnode_p.h b/src/quick/items/qquickshadereffectnode_p.h index fc7c643aea..507db337aa 100644 --- a/src/quick/items/qquickshadereffectnode_p.h +++ b/src/quick/items/qquickshadereffectnode_p.h @@ -87,9 +87,9 @@ public: }; explicit QQuickShaderEffectMaterial(QQuickShaderEffectNode *node = 0); - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; - virtual int compare(const QSGMaterial *other) const; + QSGMaterialType *type() const Q_DECL_OVERRIDE; + QSGMaterialShader *createShader() const Q_DECL_OVERRIDE; + int compare(const QSGMaterial *other) const Q_DECL_OVERRIDE; QVector<QByteArray> attributes; QVector<UniformData> uniforms[QQuickShaderEffectMaterialKey::ShaderTypeCount]; @@ -129,7 +129,7 @@ public: QQuickShaderEffectNode(); virtual ~QQuickShaderEffectNode(); - virtual void preprocess(); + void preprocess() Q_DECL_OVERRIDE; Q_SIGNALS: void logAndStatusChanged(const QString &, int status); diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h index 69e65f927f..7add0b1033 100644 --- a/src/quick/items/qquickshadereffectsource_p.h +++ b/src/quick/items/qquickshadereffectsource_p.h @@ -112,8 +112,8 @@ public: bool recursive() const; void setRecursive(bool enabled); - bool isTextureProvider() const { return true; } - QSGTextureProvider *textureProvider() const; + bool isTextureProvider() const Q_DECL_OVERRIDE { return true; } + QSGTextureProvider *textureProvider() const Q_DECL_OVERRIDE; Q_INVOKABLE void scheduleUpdate(); @@ -135,11 +135,11 @@ private Q_SLOTS: void invalidateSceneGraph(); protected: - virtual void releaseResources(); - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + void releaseResources() Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; - virtual void itemGeometryChanged(QQuickItem *item, const QRectF &newRect, const QRectF &oldRect); - virtual void itemChange(ItemChange change, const ItemChangeData &value); + void itemGeometryChanged(QQuickItem *item, const QRectF &newRect, const QRectF &oldRect) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; private: void ensureTexture(); diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h index 1bd625001d..a38a284201 100644 --- a/src/quick/items/qquicksprite_p.h +++ b/src/quick/items/qquicksprite_p.h @@ -138,7 +138,7 @@ public: return m_frameDurationVariation; } - int variedDuration() const; + int variedDuration() const Q_DECL_OVERRIDE; bool frameSync() const { diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp index c5e70c9a8b..12020e879b 100644 --- a/src/quick/items/qquickspriteengine.cpp +++ b/src/quick/items/qquickspriteengine.cpp @@ -201,10 +201,12 @@ int QQuickSpriteEngine::spriteFrames(int sprite) extra = (m_sprites[state]->m_generatedCount - 1) - extra; - if (extra == m_sprites[state]->m_generatedCount - 1)//last state - return m_sprites[state]->frames() % m_sprites[state]->m_framesPerRow; - else - return m_sprites[state]->m_framesPerRow; + if (extra == m_sprites[state]->m_generatedCount - 1) {//last state + const int framesRemaining = m_sprites[state]->frames() % m_sprites[state]->m_framesPerRow; + if (framesRemaining > 0) + return framesRemaining; + } + return m_sprites[state]->m_framesPerRow; } int QQuickSpriteEngine::spriteDuration(int sprite)//Full duration, not per frame @@ -219,10 +221,12 @@ int QQuickSpriteEngine::spriteDuration(int sprite)//Full duration, not per frame if (m_sprites[state]->reverse()) extra = (m_sprites[state]->m_generatedCount - 1) - extra; - if (extra == m_sprites[state]->m_generatedCount - 1)//last state - return m_duration[sprite] % rowDuration; - else - return rowDuration; + if (extra == m_sprites[state]->m_generatedCount - 1) {//last state + const int durationRemaining = m_duration[sprite] % rowDuration; + if (durationRemaining > 0) + return durationRemaining; + } + return rowDuration; } int QQuickSpriteEngine::spriteY(int sprite) @@ -512,7 +516,9 @@ void QQuickStochasticEngine::start(int index, int state) else m_startTimes[index] = 0; m_goals[index] = -1; + m_addAdvance = false; restart(index); + m_addAdvance = true; } void QQuickStochasticEngine::stop(int index) diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h index 1705ab3ee3..227041f181 100644 --- a/src/quick/items/qquickspriteengine_p.h +++ b/src/quick/items/qquickspriteengine_p.h @@ -268,8 +268,8 @@ public: int spriteCount();//Like state count int maxFrames(); - virtual void restart(int index=0); - virtual void advance(int index=0); + void restart(int index=0) Q_DECL_OVERRIDE; + void advance(int index=0) Q_DECL_OVERRIDE; //Similar API to QQuickPixmap for async loading convenience bool isNull() { return status() == QQuickPixmap::Null; } diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp index a9a823c2ce..0bef823b3c 100644 --- a/src/quick/items/qquickspritesequence.cpp +++ b/src/quick/items/qquickspritesequence.cpp @@ -53,9 +53,9 @@ class QQuickSpriteSequenceMaterial : public QSGMaterial public: QQuickSpriteSequenceMaterial(); ~QQuickSpriteSequenceMaterial(); - virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; } - virtual QSGMaterialShader *createShader() const; - virtual int compare(const QSGMaterial *other) const + QSGMaterialType *type() const Q_DECL_OVERRIDE{ static QSGMaterialType type; return &type; } + QSGMaterialShader *createShader() const Q_DECL_OVERRIDE; + int compare(const QSGMaterial *other) const Q_DECL_OVERRIDE { return this - static_cast<const QQuickSpriteSequenceMaterial *>(other); } @@ -99,7 +99,7 @@ public: setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/items/shaders/sprite.frag")); } - virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) + void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) Q_DECL_OVERRIDE { QQuickSpriteSequenceMaterial *m = static_cast<QQuickSpriteSequenceMaterial *>(newEffect); m->texture->bind(); @@ -112,14 +112,14 @@ public: program()->setUniformValue(m_matrix_id, state.combinedMatrix()); } - virtual void initialize() { + void initialize() Q_DECL_OVERRIDE { m_matrix_id = program()->uniformLocation("qt_Matrix"); m_opacity_id = program()->uniformLocation("qt_Opacity"); m_animData_id = program()->uniformLocation("animData"); m_animPos_id = program()->uniformLocation("animPos"); } - virtual char const *const *attributeNames() const { + char const *const *attributeNames() const Q_DECL_OVERRIDE { static const char *attr[] = { "vPos", "vTex", diff --git a/src/quick/items/qquickspritesequence_p.h b/src/quick/items/qquickspritesequence_p.h index a32f5ead4f..3c22d8772c 100644 --- a/src/quick/items/qquickspritesequence_p.h +++ b/src/quick/items/qquickspritesequence_p.h @@ -114,7 +114,7 @@ private Q_SLOTS: protected: void reset(); - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; private: void prepareNextFrame(); QSGGeometryNode* buildNode(); diff --git a/src/quick/items/qquickstateoperations_p.h b/src/quick/items/qquickstateoperations_p.h index 79facf2445..a9e4be1e20 100644 --- a/src/quick/items/qquickstateoperations_p.h +++ b/src/quick/items/qquickstateoperations_p.h @@ -93,17 +93,17 @@ public: void setRotation(QQmlScriptString rotation); bool rotationIsSet() const; - virtual ActionList actions(); + ActionList actions() Q_DECL_OVERRIDE; - virtual void saveOriginals(); + void saveOriginals() Q_DECL_OVERRIDE; //virtual void copyOriginals(QQuickStateActionEvent*); - virtual void execute(Reason reason = ActualChange); - virtual bool isReversable(); - virtual void reverse(Reason reason = ActualChange); - virtual EventType type() const; - virtual bool override(QQuickStateActionEvent*other); - virtual void rewind(); - virtual void saveCurrentValues(); + void execute(Reason reason = ActualChange) Q_DECL_OVERRIDE; + bool isReversable() Q_DECL_OVERRIDE; + void reverse(Reason reason = ActualChange) Q_DECL_OVERRIDE; + EventType type() const Q_DECL_OVERRIDE; + bool override(QQuickStateActionEvent*other) Q_DECL_OVERRIDE; + void rewind() Q_DECL_OVERRIDE; + void saveCurrentValues() Q_DECL_OVERRIDE; }; class QQuickAnchorChanges; @@ -173,28 +173,28 @@ public: QQuickAnchorChanges(QObject *parent=0); ~QQuickAnchorChanges(); - virtual ActionList actions(); + ActionList actions() Q_DECL_OVERRIDE; QQuickAnchorSet *anchors(); QQuickItem *object() const; void setObject(QQuickItem *); - virtual void execute(Reason reason = ActualChange); - virtual bool isReversable(); - virtual void reverse(Reason reason = ActualChange); - virtual EventType type() const; - virtual bool override(QQuickStateActionEvent*other); - virtual bool changesBindings(); - virtual void saveOriginals(); - virtual bool needsCopy() { return true; } - virtual void copyOriginals(QQuickStateActionEvent*); - virtual void clearBindings(); - virtual void rewind(); - virtual void saveCurrentValues(); + void execute(Reason reason = ActualChange) Q_DECL_OVERRIDE; + bool isReversable() Q_DECL_OVERRIDE; + void reverse(Reason reason = ActualChange) Q_DECL_OVERRIDE; + EventType type() const Q_DECL_OVERRIDE; + bool override(QQuickStateActionEvent*other) Q_DECL_OVERRIDE; + bool changesBindings() Q_DECL_OVERRIDE; + void saveOriginals() Q_DECL_OVERRIDE; + bool needsCopy() Q_DECL_OVERRIDE { return true; } + void copyOriginals(QQuickStateActionEvent*) Q_DECL_OVERRIDE; + void clearBindings() Q_DECL_OVERRIDE; + void rewind() Q_DECL_OVERRIDE; + void saveCurrentValues() Q_DECL_OVERRIDE; QList<QQuickStateAction> additionalActions(); - virtual void saveTargetValues(); + void saveTargetValues() Q_DECL_OVERRIDE; }; QT_END_NAMESPACE diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h index c9f64d3fab..bc1a5198e8 100644 --- a/src/quick/items/qquicktext_p.h +++ b/src/quick/items/qquicktext_p.h @@ -186,15 +186,15 @@ public: FontSizeMode fontSizeMode() const; void setFontSizeMode(FontSizeMode mode); - virtual void componentComplete(); + void componentComplete() Q_DECL_OVERRIDE; int resourcesLoading() const; // mainly for testing qreal contentWidth() const; qreal contentHeight() const; - QRectF boundingRect() const; - QRectF clipRect() const; + QRectF boundingRect() const Q_DECL_OVERRIDE; + QRectF clipRect() const Q_DECL_OVERRIDE; Q_INVOKABLE void doLayout(); RenderType renderType() const; @@ -233,18 +233,18 @@ Q_SIGNALS: void renderTypeChanged(); protected: - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - virtual void itemChange(ItemChange change, const ItemChangeData &value); - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); - - void updatePolish(); - - void hoverEnterEvent(QHoverEvent *event); - void hoverMoveEvent(QHoverEvent *event); - void hoverLeaveEvent(QHoverEvent *event); + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + + void updatePolish() Q_DECL_OVERRIDE; + + void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; private Q_SLOTS: void q_imagesLoaded(); diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index 022c2ac9d5..04a78f9c21 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -72,7 +72,7 @@ public: void updateLayout(); bool determineHorizontalAlignment(); bool setHAlign(QQuickText::HAlignment, bool forceAlign = false); - void mirrorChange(); + void mirrorChange() Q_DECL_OVERRIDE; bool isLineLaidOutConnected(); void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height); @@ -154,8 +154,8 @@ public: static const QChar elideChar; - virtual qreal getImplicitWidth() const; - virtual qreal getImplicitHeight() const; + qreal getImplicitWidth() const Q_DECL_OVERRIDE; + qreal getImplicitHeight() const Q_DECL_OVERRIDE; void ensureDoc(); diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h index d0af4a1cc9..2fe083f1d2 100644 --- a/src/quick/items/qquicktextcontrol_p.h +++ b/src/quick/items/qquicktextcontrol_p.h @@ -162,9 +162,9 @@ public: bool cursorOn() const; protected: - virtual void timerEvent(QTimerEvent *e); + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; - virtual bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QQuickTextControl) diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h index 54e6dd229a..262dc04445 100644 --- a/src/quick/items/qquicktextedit_p.h +++ b/src/quick/items/qquicktextedit_p.h @@ -211,7 +211,7 @@ public: bool canUndo() const; bool canRedo() const; - virtual void componentComplete(); + void componentComplete() Q_DECL_OVERRIDE; /* FROM EDIT */ void setReadOnly(bool); @@ -220,7 +220,7 @@ public: QRectF cursorRectangle() const; #ifndef QT_NO_IM - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; #endif @@ -236,8 +236,8 @@ public: Q_INVOKABLE void moveCursorSelection(int pos); Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode); - QRectF boundingRect() const; - QRectF clipRect() const; + QRectF boundingRect() const Q_DECL_OVERRIDE; + QRectF clipRect() const Q_DECL_OVERRIDE; #ifndef QT_NO_IM bool isInputMethodComposing() const; @@ -332,28 +332,28 @@ private: void updateTotalLines(); protected: - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); + void geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry) Q_DECL_OVERRIDE; - bool event(QEvent *); - void keyPressEvent(QKeyEvent *); - void keyReleaseEvent(QKeyEvent *); - void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); + bool event(QEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; - void hoverEnterEvent(QHoverEvent *event); - void hoverMoveEvent(QHoverEvent *event); - void hoverLeaveEvent(QHoverEvent *event); + void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; // mouse filter? - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; #ifndef QT_NO_IM - void inputMethodEvent(QInputMethodEvent *e); + void inputMethodEvent(QInputMethodEvent *e) Q_DECL_OVERRIDE; #endif - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData); + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) Q_DECL_OVERRIDE; friend class QQuickTextUtil; friend class QQuickTextDocument; diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h index ffad3ebdcf..41a5107ccf 100644 --- a/src/quick/items/qquicktextedit_p_p.h +++ b/src/quick/items/qquicktextedit_p_p.h @@ -117,8 +117,8 @@ public: void relayoutDocument(); bool determineHorizontalAlignment(); bool setHAlign(QQuickTextEdit::HAlignment, bool forceAlign = false); - void mirrorChange(); - qreal getImplicitWidth() const; + void mirrorChange() Q_DECL_OVERRIDE; + qreal getImplicitWidth() const Q_DECL_OVERRIDE; Qt::LayoutDirection textDirection(const QString &text) const; bool isLinkHoveredConnected(); diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h index 4b94530587..ad2c579001 100644 --- a/src/quick/items/qquicktextinput_p.h +++ b/src/quick/items/qquicktextinput_p.h @@ -106,7 +106,7 @@ public: QQuickTextInput(QQuickItem * parent=0); ~QQuickTextInput(); - void componentComplete(); + void componentComplete() Q_DECL_OVERRIDE; enum EchoMode {//To match QLineEdit::EchoMode Normal, @@ -245,12 +245,12 @@ public: bool hasAcceptableInput() const; #ifndef QT_NO_IM - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; #endif - QRectF boundingRect() const; - QRectF clipRect() const; + QRectF boundingRect() const Q_DECL_OVERRIDE; + QRectF clipRect() const Q_DECL_OVERRIDE; bool canPaste() const; @@ -315,23 +315,23 @@ Q_SIGNALS: void renderTypeChanged(); protected: - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - void keyPressEvent(QKeyEvent* ev); + void geometryChanged(const QRectF &newGeometry, + const QRectF &oldGeometry) Q_DECL_OVERRIDE; + + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent* ev) Q_DECL_OVERRIDE; #ifndef QT_NO_IM - void inputMethodEvent(QInputMethodEvent *); + void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; #endif - void mouseUngrabEvent(); - bool event(QEvent *e); - void focusOutEvent(QFocusEvent *event); - void focusInEvent(QFocusEvent *event); - void timerEvent(QTimerEvent *event); - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data); + void mouseUngrabEvent() Q_DECL_OVERRIDE; + bool event(QEvent *e) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE; public Q_SLOTS: void selectAll(); diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h index 7d9f3ff9ce..9339bf9a30 100644 --- a/src/quick/items/qquicktextinput_p_p.h +++ b/src/quick/items/qquicktextinput_p_p.h @@ -145,7 +145,7 @@ public: void updateVerticalScroll(); bool determineHorizontalAlignment(); bool setHAlign(QQuickTextInput::HAlignment, bool forceAlign = false); - void mirrorChange(); + void mirrorChange() Q_DECL_OVERRIDE; bool sendMouseEventToInputContext(QMouseEvent *event); #ifndef QT_NO_IM Qt::InputMethodHints effectiveInputMethodHints() const; @@ -418,7 +418,7 @@ public: void updateLayout(); void updateBaselineOffset(); - qreal getImplicitWidth() const; + qreal getImplicitWidth() const Q_DECL_OVERRIDE; private: void removeSelectedText(); diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index 67ff79d20f..707b32755b 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -980,7 +980,18 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText continue; QTextCharFormat charFormat = fragment.charFormat(); - setPosition(blockPosition); + QFont font(charFormat.font()); + QFontMetricsF fontMetrics(font); + + int fontHeight = fontMetrics.descent() + fontMetrics.ascent(); + int valign = charFormat.verticalAlignment(); + if (valign == QTextCharFormat::AlignSuperScript) + setPosition(QPointF(blockPosition.x(), blockPosition.y() - fontHeight / 2)); + else if (valign == QTextCharFormat::AlignSubScript) + setPosition(QPointF(blockPosition.x(), blockPosition.y() + fontHeight / 6)); + else + setPosition(blockPosition); + if (text.contains(QChar::ObjectReplacementCharacter)) { QTextFrame *frame = qobject_cast<QTextFrame *>(textDocument->objectForFormat(charFormat)); if (frame && frame->frameFormat().position() == QTextFrameFormat::InFlow) { diff --git a/src/quick/items/qquicktranslate_p.h b/src/quick/items/qquicktranslate_p.h index ca49349f74..f95e13ac35 100644 --- a/src/quick/items/qquicktranslate_p.h +++ b/src/quick/items/qquicktranslate_p.h @@ -58,7 +58,7 @@ public: qreal y() const; void setY(qreal); - void applyTo(QMatrix4x4 *matrix) const; + void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE; Q_SIGNALS: void xChanged(); @@ -94,7 +94,7 @@ public: qreal zScale() const; void setZScale(qreal); - void applyTo(QMatrix4x4 *matrix) const; + void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE; Q_SIGNALS: void originChanged(); @@ -129,7 +129,7 @@ public: void setAxis(const QVector3D &axis); void setAxis(Qt::Axis axis); - void applyTo(QMatrix4x4 *matrix) const; + void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE; Q_SIGNALS: void originChanged(); @@ -153,7 +153,7 @@ public: QMatrix4x4 matrix() const; void setMatrix(const QMatrix4x4& matrix); - void applyTo(QMatrix4x4 *matrix) const; + void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE; Q_SIGNALS: void matrixChanged(); diff --git a/src/quick/items/qquickview.h b/src/quick/items/qquickview.h index d8017782aa..337d987243 100644 --- a/src/quick/items/qquickview.h +++ b/src/quick/items/qquickview.h @@ -90,14 +90,14 @@ private Q_SLOTS: void continueExecute(); protected: - virtual void resizeEvent(QResizeEvent *); - virtual void timerEvent(QTimerEvent*); - - virtual void keyPressEvent(QKeyEvent *); - virtual void keyReleaseEvent(QKeyEvent *); - virtual void mousePressEvent(QMouseEvent *); - virtual void mouseReleaseEvent(QMouseEvent *); - virtual void mouseMoveEvent(QMouseEvent *); + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent*) Q_DECL_OVERRIDE; + + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QQuickView) Q_DECLARE_PRIVATE(QQuickView) diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h index 2d3323a59c..54f60c87f0 100644 --- a/src/quick/items/qquickview_p.h +++ b/src/quick/items/qquickview_p.h @@ -71,7 +71,7 @@ public: ~QQuickViewPrivate(); void execute(); - void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; void initResize(); void updateSize(); void setRootObject(QObject *); diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index f6c1412aff..6e82be383b 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -143,7 +143,7 @@ public slots: void animationStopped() { incubate(); } protected: - virtual void incubatingObjectCountChanged(int count) + void incubatingObjectCountChanged(int count) Q_DECL_OVERRIDE { if (count && !m_renderLoop->interleaveIncubation()) incubateAgain(); @@ -364,19 +364,21 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size) animationController->advance(); emit q->beforeRendering(); runAndClearJobs(&beforeRenderingJobs); - int fboId = 0; - const qreal devicePixelRatio = q->effectiveDevicePixelRatio(); - renderer->setDeviceRect(QRect(QPoint(0, 0), size * devicePixelRatio)); - if (renderTargetId) { - fboId = renderTargetId; - renderer->setViewportRect(QRect(QPoint(0, 0), renderTargetSize)); - } else { - renderer->setViewportRect(QRect(QPoint(0, 0), size * devicePixelRatio)); - } - renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size)); - renderer->setDevicePixelRatio(devicePixelRatio); + if (!customRenderStage || !customRenderStage->render()) { + int fboId = 0; + const qreal devicePixelRatio = q->effectiveDevicePixelRatio(); + renderer->setDeviceRect(QRect(QPoint(0, 0), size * devicePixelRatio)); + if (renderTargetId) { + fboId = renderTargetId; + renderer->setViewportRect(QRect(QPoint(0, 0), renderTargetSize)); + } else { + renderer->setViewportRect(QRect(QPoint(0, 0), size * devicePixelRatio)); + } + renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size)); + renderer->setDevicePixelRatio(devicePixelRatio); - context->renderNextFrame(renderer, fboId); + context->renderNextFrame(renderer, fboId); + } emit q->afterRendering(); runAndClearJobs(&afterRenderingJobs); } @@ -399,6 +401,7 @@ QQuickWindowPrivate::QQuickWindowPrivate() , windowManager(0) , renderControl(0) , touchRecursionGuard(0) + , customRenderStage(0) , clearColor(Qt::white) , clearBeforeRendering(true) , persistentGLContext(true) @@ -418,6 +421,7 @@ QQuickWindowPrivate::QQuickWindowPrivate() QQuickWindowPrivate::~QQuickWindowPrivate() { + delete customRenderStage; } void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) @@ -1375,6 +1379,11 @@ bool QQuickWindow::event(QEvent *e) if (d->mouseGrabberItem) d->mouseGrabberItem->ungrabMouse(); break; + case QEvent::UpdateRequest: { + if (d->windowManager) + d->windowManager->handleUpdateRequest(this); + break; + } default: break; } @@ -2580,7 +2589,6 @@ void QQuickWindowPrivate::cleanupNodesOnShutdown(QQuickItem *item) p->extra->rootNode = 0; } - p->groupNode = 0; p->paintNode = 0; p->dirty(QQuickItemPrivate::Window); @@ -2635,6 +2643,21 @@ void QQuickWindowPrivate::updateDirtyNodes() } } +static inline QSGNode *qquickitem_before_paintNode(QQuickItemPrivate *d) +{ + if (!d->extra.isAllocated()) + return 0; + const QList<QQuickItem *> childItems = d->paintOrderChildItems(); + QQuickItem *before = 0; + for (int i=0; i<childItems.size(); ++i) { + if (Q_UNLIKELY(QQuickItemPrivate::get(childItems.at(i))->z() < 0)) + before = childItems.at(i); + else + break; + } + return Q_UNLIKELY(before) ? QQuickItemPrivate::get(before)->itemNode() : 0; +} + void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) { QQuickItemPrivate *itemPriv = QQuickItemPrivate::get(item); @@ -2674,69 +2697,69 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) if (clipEffectivelyChanged) { QSGNode *parent = itemPriv->opacityNode() ? (QSGNode *) itemPriv->opacityNode() : - (QSGNode *)itemPriv->itemNode(); - QSGNode *child = itemPriv->rootNode() ? (QSGNode *)itemPriv->rootNode() : - (QSGNode *)itemPriv->groupNode; + (QSGNode *) itemPriv->itemNode(); + QSGNode *child = itemPriv->rootNode(); if (item->clip()) { Q_ASSERT(itemPriv->clipNode() == 0); - itemPriv->extra.value().clipNode = new QQuickDefaultClipNode(item->clipRect()); - itemPriv->clipNode()->update(); + QQuickDefaultClipNode *clip = new QQuickDefaultClipNode(item->clipRect()); + itemPriv->extra.value().clipNode = clip; + clip->update(); - if (child) + if (!child) { + parent->reparentChildNodesTo(clip); + parent->appendChildNode(clip); + } else { parent->removeChildNode(child); - parent->appendChildNode(itemPriv->clipNode()); - if (child) - itemPriv->clipNode()->appendChildNode(child); + clip->appendChildNode(child); + parent->appendChildNode(clip); + } } else { - Q_ASSERT(itemPriv->clipNode() != 0); - parent->removeChildNode(itemPriv->clipNode()); - if (child) - itemPriv->clipNode()->removeChildNode(child); + QQuickDefaultClipNode *clip = itemPriv->clipNode(); + Q_ASSERT(clip); + parent->removeChildNode(clip); + if (child) { + clip->removeChildNode(child); + parent->appendChildNode(child); + } else { + clip->reparentChildNodesTo(parent); + } + delete itemPriv->clipNode(); itemPriv->extra->clipNode = 0; - if (child) - parent->appendChildNode(child); } } - if (dirty & QQuickItemPrivate::ChildrenUpdateMask) - itemPriv->childContainerNode()->removeAllChildNodes(); - if (effectRefEffectivelyChanged) { + if (dirty & QQuickItemPrivate::ChildrenUpdateMask) + itemPriv->childContainerNode()->removeAllChildNodes(); + QSGNode *parent = itemPriv->clipNode(); if (!parent) parent = itemPriv->opacityNode(); if (!parent) parent = itemPriv->itemNode(); - QSGNode *child = itemPriv->groupNode; if (itemPriv->extra.isAllocated() && itemPriv->extra->effectRefCount) { Q_ASSERT(itemPriv->rootNode() == 0); - itemPriv->extra->rootNode = new QSGRootNode; - - if (child) - parent->removeChildNode(child); - parent->appendChildNode(itemPriv->rootNode()); - if (child) - itemPriv->rootNode()->appendChildNode(child); + QSGRootNode *root = new QSGRootNode(); + itemPriv->extra->rootNode = root; + parent->reparentChildNodesTo(root); + parent->appendChildNode(root); } else { Q_ASSERT(itemPriv->rootNode() != 0); - parent->removeChildNode(itemPriv->rootNode()); - if (child) - itemPriv->rootNode()->removeChildNode(child); + QSGRootNode *root = itemPriv->rootNode(); + parent->removeChildNode(root); + root->reparentChildNodesTo(parent); delete itemPriv->rootNode(); itemPriv->extra->rootNode = 0; - if (child) - parent->appendChildNode(child); } } if (dirty & QQuickItemPrivate::ChildrenUpdateMask) { - QSGNode *groupNode = itemPriv->groupNode; - if (groupNode) - groupNode->removeAllChildNodes(); + QSGNode *parent = itemPriv->childContainerNode(); + parent->removeAllChildNodes(); QList<QQuickItem *> orderedChildren = itemPriv->paintOrderChildItems(); int ii = 0; @@ -2752,10 +2775,6 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) itemPriv->childContainerNode()->appendChildNode(childPrivate->itemNode()); } - QSGNode *beforePaintNode = itemPriv->groupNode ? itemPriv->groupNode->lastChild() : 0; - if (beforePaintNode || itemPriv->extra.isAllocated()) - itemPriv->extra.value().beforePaintNode = beforePaintNode; - if (itemPriv->paintNode) itemPriv->childContainerNode()->appendChildNode(itemPriv->paintNode); @@ -2783,20 +2802,22 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) ? itemPriv->opacity() : qreal(0); if (opacity != 1 && !itemPriv->opacityNode()) { - itemPriv->extra.value().opacityNode = new QSGOpacityNode; + QSGOpacityNode *node = new QSGOpacityNode; + itemPriv->extra.value().opacityNode = node; QSGNode *parent = itemPriv->itemNode(); QSGNode *child = itemPriv->clipNode(); if (!child) child = itemPriv->rootNode(); - if (!child) - child = itemPriv->groupNode; - if (child) + if (child) { parent->removeChildNode(child); - parent->appendChildNode(itemPriv->opacityNode()); - if (child) - itemPriv->opacityNode()->appendChildNode(child); + node->appendChildNode(child); + parent->appendChildNode(node); + } else { + parent->reparentChildNodesTo(node); + parent->appendChildNode(node); + } } if (itemPriv->opacityNode()) itemPriv->opacityNode()->setOpacity(opacity); @@ -2813,8 +2834,9 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) itemPriv->paintNode->parent() == itemPriv->childContainerNode()); if (itemPriv->paintNode && itemPriv->paintNode->parent() == 0) { - if (itemPriv->extra.isAllocated() && itemPriv->extra->beforePaintNode) - itemPriv->childContainerNode()->insertChildNodeAfter(itemPriv->paintNode, itemPriv->extra->beforePaintNode); + QSGNode *before = qquickitem_before_paintNode(itemPriv); + if (before) + itemPriv->childContainerNode()->insertChildNodeAfter(itemPriv->paintNode, before); else itemPriv->childContainerNode()->prependChildNode(itemPriv->paintNode); } @@ -2826,37 +2848,22 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) #ifndef QT_NO_DEBUG // Check consistency. - const QSGNode *nodeChain[] = { - itemPriv->itemNodeInstance, - itemPriv->opacityNode(), - itemPriv->clipNode(), - itemPriv->rootNode(), - itemPriv->groupNode, - itemPriv->paintNode, - }; - - int ip = 0; - for (;;) { - while (ip < 5 && nodeChain[ip] == 0) - ++ip; - if (ip == 5) - break; - int ic = ip + 1; - while (ic < 5 && nodeChain[ic] == 0) - ++ic; - const QSGNode *parent = nodeChain[ip]; - const QSGNode *child = nodeChain[ic]; - if (child == 0) { - Q_ASSERT(parent == itemPriv->groupNode || parent->childCount() == 0); - } else { - Q_ASSERT(parent == itemPriv->groupNode || parent->childCount() == 1); - Q_ASSERT(child->parent() == parent); - bool containsChild = false; - for (QSGNode *n = parent->firstChild(); n; n = n->nextSibling()) - containsChild |= (n == child); - Q_ASSERT(containsChild); - } - ip = ic; + + QList<QSGNode *> nodes; + nodes << itemPriv->itemNodeInstance + << itemPriv->opacityNode() + << itemPriv->clipNode() + << itemPriv->rootNode() + << itemPriv->paintNode; + nodes.removeAll(0); + + Q_ASSERT(nodes.first() == itemPriv->itemNodeInstance); + for (int i=1; i<nodes.size(); ++i) { + QSGNode *n = nodes.at(i); + // Failing this means we messed up reparenting + Q_ASSERT(n->parent() == nodes.at(i-1)); + // Only the paintNode and the one who is childContainer may have more than one child. + Q_ASSERT(n == itemPriv->paintNode || n == itemPriv->childContainerNode() || n->childCount() == 1); } #endif @@ -2925,6 +2932,15 @@ QOpenGLContext *QQuickWindow::openglContext() const } /*! + Returns true if the scene graph has been initialized; otherwise returns false. + */ +bool QQuickWindow::isSceneGraphInitialized() const +{ + Q_D(const QQuickWindow); + return d->context != 0 && d->context->isValid(); +} + +/*! \fn void QQuickWindow::frameSwapped() This signal is emitted when the frame buffers have been swapped. diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index 3cac691963..d02423d8af 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -115,7 +115,7 @@ public: QQmlIncubationController *incubationController() const; #ifndef QT_NO_ACCESSIBILITY - virtual QAccessibleInterface *accessibleRoot() const; + QAccessibleInterface *accessibleRoot() const Q_DECL_OVERRIDE; #endif // Scene graph specific functions @@ -139,6 +139,7 @@ public: bool isPersistentSceneGraph() const; QOpenGLContext *openglContext() const; + bool isSceneGraphInitialized() const; void scheduleRenderJob(QRunnable *job, RenderStage schedule); @@ -169,25 +170,25 @@ public Q_SLOTS: protected: QQuickWindow(QQuickWindowPrivate &dd, QWindow *parent = 0); - virtual void exposeEvent(QExposeEvent *); - virtual void resizeEvent(QResizeEvent *); + void exposeEvent(QExposeEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; - virtual void showEvent(QShowEvent *); - virtual void hideEvent(QHideEvent *); + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; // TODO Qt 6: reimplement QWindow::closeEvent to emit closing - virtual void focusInEvent(QFocusEvent *); - virtual void focusOutEvent(QFocusEvent *); + void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE; - virtual bool event(QEvent *); - virtual void keyPressEvent(QKeyEvent *); - virtual void keyReleaseEvent(QKeyEvent *); - virtual void mousePressEvent(QMouseEvent *); - virtual void mouseReleaseEvent(QMouseEvent *); - virtual void mouseDoubleClickEvent(QMouseEvent *); - virtual void mouseMoveEvent(QMouseEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QWheelEvent *); + void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; #endif private Q_SLOTS: diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index 6cd41950cb..10be57059c 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -89,6 +89,14 @@ class QQuickWindowIncubationController; class QOpenGLVertexArrayObjectHelper; +class Q_QUICK_PRIVATE_EXPORT QQuickCustomRenderStage +{ +public: + virtual ~QQuickCustomRenderStage() {} + virtual bool render() = 0; + virtual bool swap() = 0; +}; + class Q_QUICK_PRIVATE_EXPORT QQuickWindowPrivate : public QWindowPrivate { public: @@ -209,6 +217,7 @@ public: QQuickAnimatorController *animationController; QTouchEvent *delayedTouch; int touchRecursionGuard; + QQuickCustomRenderStage *customRenderStage; QColor clearColor; diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp index 371abd163b..bf41bc136f 100644 --- a/src/quick/items/qquickwindowmodule.cpp +++ b/src/quick/items/qquickwindowmodule.cpp @@ -89,7 +89,7 @@ Q_SIGNALS: void visibilityChanged(QWindow::Visibility visibility); protected: - void classBegin() { + void classBegin() Q_DECL_OVERRIDE { QQmlEngine* e = qmlEngine(this); //Give QQuickView behavior when created from QML with QQmlApplicationEngine if (QCoreApplication::instance()->property("__qml_using_qqmlapplicationengine") == QVariant(true)) { @@ -105,7 +105,7 @@ protected: } } - void componentComplete() { + void componentComplete() Q_DECL_OVERRIDE { m_complete = true; if (transientParent() && !transientParent()->isVisible()) { connect(transientParent(), &QQuickWindow::visibleChanged, this, diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 838251ed08..ef125e07a9 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -128,8 +128,9 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material) if (shader) return shader; - if (QSG_LOG_TIME_COMPILATION().isDebugEnabled() || QQuickProfiler::profilingSceneGraph()) + if (QSG_LOG_TIME_COMPILATION().isDebugEnabled()) qsg_renderer_timer.start(); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphContextFrame); QSGMaterialShader *s = material->createShader(); QOpenGLContext *ctx = QOpenGLContext::currentContext(); @@ -159,8 +160,7 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material) qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms", (int) qsg_renderer_timer.elapsed()); - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphContextFrame, ( - qsg_renderer_timer.nsecsElapsed())); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame); rewrittenShaders[type] = shader; return shader; @@ -173,8 +173,9 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate if (shader) return shader; - if (QSG_LOG_TIME_COMPILATION().isDebugEnabled() || QQuickProfiler::profilingSceneGraph()) + if (QSG_LOG_TIME_COMPILATION().isDebugEnabled()) qsg_renderer_timer.start(); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphContextFrame); QSGMaterialShader *s = static_cast<QSGMaterialShader *>(material->createShader()); context->compile(s, material); @@ -190,8 +191,7 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms (no rewrite)", (int) qsg_renderer_timer.elapsed()); - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphContextFrame, ( - qsg_renderer_timer.nsecsElapsed())); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame); return shader; } diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp index 58b6462d23..6271d12998 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.cpp +++ b/src/quick/scenegraph/coreapi/qsgnode.cpp @@ -575,6 +575,21 @@ void QSGNode::removeAllChildNodes() } } +/*! + * \internal + * + * Reparents all nodes of this node to \a newParent. + */ +void QSGNode::reparentChildNodesTo(QSGNode *newParent) +{ + Q_ASSERT_X(!newParent->parent(), "QSGNode::reparentChildNodesTo", "newParent is already part of a hierarchy"); + + for (QSGNode *c = firstChild(); c; c = c->nextSibling()) { + removeChildNode(c); + newParent->appendChildNode(c); + } +} + int QSGNode::childCount() const { diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index dfacd84288..059cbeebdf 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -132,6 +132,7 @@ public: void appendChildNode(QSGNode *node); void insertChildNodeBefore(QSGNode *node, QSGNode *before); void insertChildNodeAfter(QSGNode *node, QSGNode *after); + void reparentChildNodesTo(QSGNode *newParent); int childCount() const; QSGNode *childAtIndex(int i) const; diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp index dd089425f6..ce86408434 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp @@ -176,10 +176,11 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) m_is_rendering = true; - bool profileFrames = QSG_LOG_TIME_RENDERER().isDebugEnabled() || - QQuickProfiler::profilingSceneGraph(); + bool profileFrames = QSG_LOG_TIME_RENDERER().isDebugEnabled(); if (profileFrames) frameTimer.start(); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphRendererFrame); + qint64 bindTime = 0; qint64 renderTime = 0; @@ -189,6 +190,7 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) bindable.bind(); if (profileFrames) bindTime = frameTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); // Sanity check that attribute registers are disabled if (qsg_sanity_check) { @@ -206,6 +208,7 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) render(); if (profileFrames) renderTime = frameTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRendererFrame); m_is_rendering = false; m_changed_emitted = false; @@ -218,13 +221,6 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) int((updatePassTime - preprocessTime) / 1000000), int((bindTime - updatePassTime) / 1000000), int((renderTime - bindTime) / 1000000)); - - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphRendererFrame, ( - preprocessTime, - updatePassTime - preprocessTime, - bindTime - updatePassTime, - renderTime - bindTime)); - } /*! @@ -273,15 +269,16 @@ void QSGRenderer::preprocess() } } - bool profileFrames = QSG_LOG_TIME_RENDERER().isDebugEnabled()|| - QQuickProfiler::profilingSceneGraph(); + bool profileFrames = QSG_LOG_TIME_RENDERER().isDebugEnabled(); if (profileFrames) preprocessTime = frameTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); nodeUpdater()->updateStates(root); if (profileFrames) updatePassTime = frameTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); } void QSGRenderer::addNodesToPreprocess(QSGNode *node) diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index 80234d54f5..e0b96a45b6 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -153,10 +153,10 @@ void QSGDistanceFieldGlyphCache::update() if (m_pendingGlyphs.isEmpty()) return; - bool profileFrames = QSG_LOG_TIME_GLYPH().isDebugEnabled() || - QQuickProfiler::profilingSceneGraph(); + bool profileFrames = QSG_LOG_TIME_GLYPH().isDebugEnabled(); if (profileFrames) qsg_render_timer.start(); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphAdaptationLayerFrame); QList<QDistanceField> distanceFields; for (int i = 0; i < m_pendingGlyphs.size(); ++i) { @@ -169,6 +169,7 @@ void QSGDistanceFieldGlyphCache::update() int count = m_pendingGlyphs.size(); if (profileFrames) renderTime = qsg_render_timer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphAdaptationLayerFrame); m_pendingGlyphs.reset(); @@ -183,10 +184,8 @@ void QSGDistanceFieldGlyphCache::update() int(renderTime / 1000000), int((now - (renderTime / 1000000)))); } - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphAdaptationLayerFrame, ( - count, - renderTime, - qsg_render_timer.nsecsElapsed() - renderTime)); + Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(QQuickProfiler::SceneGraphAdaptationLayerFrame, + (qint64)count); } void QSGDistanceFieldGlyphCache::setGlyphsPosition(const QList<GlyphPosition> &glyphs) diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index b5bdbde3ad..2a0fae9f72 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -378,6 +378,7 @@ void QSGContext::renderContextInitialized(QSGRenderContext *renderContext) QByteArray all; foreach (const QByteArray &e, exts) all += ' ' + e; qCDebug(QSG_LOG_INFO) << "GL_EXTENSIONS: " << all.constData(); qCDebug(QSG_LOG_INFO) << "Max Texture Size: " << renderContext->maxTextureSize(); + qCDebug(QSG_LOG_INFO) << "Debug context: " << format.testOption(QSurfaceFormat::DebugContext); } d->mutex.unlock(); @@ -468,8 +469,11 @@ QSurfaceFormat QSGContext::defaultSurfaceFormat() const QSurfaceFormat format = QSurfaceFormat::defaultFormat(); static bool useDepth = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER"); static bool useStencil = qEnvironmentVariableIsEmpty("QSG_NO_STENCIL_BUFFER"); + static bool enableDebug = qEnvironmentVariableIsSet("QSG_OPENGL_DEBUG"); format.setDepthBufferSize(useDepth ? 24 : 0); format.setStencilBufferSize(useStencil ? 8 : 0); + if (enableDebug) + format.setOption(QSurfaceFormat::DebugContext); if (QQuickWindow::hasDefaultAlphaBuffer()) format.setAlphaBufferSize(8); format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 184b8248d5..91788d82d4 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -93,7 +93,7 @@ public: QOpenGLContext *openglContext() const { return m_gl; } QSGContext *sceneGraphContext() const { return m_sg; } - bool isValid() const { return m_gl; } + virtual bool isValid() const { return m_gl; } virtual void initialize(QOpenGLContext *context); virtual void invalidate(); diff --git a/src/quick/scenegraph/qsgdefaultlayer.cpp b/src/quick/scenegraph/qsgdefaultlayer.cpp index 450a9fbee0..2d114aebd5 100644 --- a/src/quick/scenegraph/qsgdefaultlayer.cpp +++ b/src/quick/scenegraph/qsgdefaultlayer.cpp @@ -57,7 +57,7 @@ namespace public: BindableFbo(QOpenGLFramebufferObject *fbo, QSGDepthStencilBuffer *depthStencil); virtual ~BindableFbo(); - virtual void bind() const; + void bind() const Q_DECL_OVERRIDE; private: QOpenGLFramebufferObject *m_fbo; QSGDepthStencilBuffer *m_depthStencil; diff --git a/src/quick/scenegraph/qsgdefaultlayer_p.h b/src/quick/scenegraph/qsgdefaultlayer_p.h index 44c74d7cfd..0615045d60 100644 --- a/src/quick/scenegraph/qsgdefaultlayer_p.h +++ b/src/quick/scenegraph/qsgdefaultlayer_p.h @@ -54,7 +54,7 @@ public: QSGDefaultLayer(QSGRenderContext *context); ~QSGDefaultLayer(); - virtual bool updateTexture(); + bool updateTexture() Q_DECL_OVERRIDE; // The item's "paint node", not effect node. QSGNode *item() const { return m_item; } diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index c66915d19d..ecfbe0323c 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -347,17 +347,17 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) } QElapsedTimer renderTimer; qint64 renderTime = 0, syncTime = 0, polishTime = 0; - bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled() || - QQuickProfiler::profilingSceneGraph(); + bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled(); if (profileFrames) renderTimer.start(); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphPolishFrame); cd->polishItems(); - if (profileFrames) { + if (profileFrames) polishTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphPolishFrame, (polishTime)); - } + Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame, + QQuickProfiler::SceneGraphRenderLoopFrame); emit window->afterAnimating(); @@ -365,11 +365,13 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (profileFrames) syncTime = renderTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); cd->renderSceneGraph(window->size()); if (profileFrames) renderTime = renderTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); if (data.grabOnly) { grabContent = qt_gl_read_framebuffer(window->size() * window->effectiveDevicePixelRatio(), false, false); @@ -377,13 +379,15 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) } if (alsoSwap && window->isVisible()) { - gl->swapBuffers(window); + if (!cd->customRenderStage || !cd->customRenderStage->swap()) + gl->swapBuffers(window); cd->fireFrameSwapped(); } qint64 swapTime = 0; if (profileFrames) swapTime = renderTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled()) { static QTime lastFrameTime = QTime::currentTime(); @@ -398,11 +402,6 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) lastFrameTime = QTime::currentTime(); } - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphRenderLoopFrame, ( - syncTime - polishTime, - renderTime - syncTime, - swapTime - renderTime)); - // Might have been set during syncSceneGraph() if (data.updatePending) maybeUpdate(window); diff --git a/src/quick/scenegraph/qsgrenderloop_p.h b/src/quick/scenegraph/qsgrenderloop_p.h index e9b58c60ba..8d3214db60 100644 --- a/src/quick/scenegraph/qsgrenderloop_p.h +++ b/src/quick/scenegraph/qsgrenderloop_p.h @@ -64,6 +64,7 @@ public: virtual void update(QQuickWindow *window) = 0; virtual void maybeUpdate(QQuickWindow *window) = 0; + virtual void handleUpdateRequest(QQuickWindow *) { } virtual QAnimationDriver *animationDriver() const = 0; diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 155b52b31a..5218552427 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -105,16 +105,6 @@ QT_BEGIN_NAMESPACE #define QSG_RT_PAD " (RT)" -static int get_env_int(const char *name, int defaultValue) -{ - QByteArray content = qgetenv(name); - - bool ok = false; - int value = content.toInt(&ok); - return ok ? value : defaultValue; -} - - static inline int qsgrl_animation_interval() { qreal refreshRate = QGuiApplication::primaryScreen()->refreshRate(); // To work around that some platforms wrongfully return 0 or something @@ -531,12 +521,12 @@ void QSGRenderThread::sync(bool inExpose) void QSGRenderThread::syncAndRender() { - bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled() || - QQuickProfiler::profilingSceneGraph(); + bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled(); if (profileFrames) { sinceLastTime = threadTimer.nsecsElapsed(); threadTimer.start(); } + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphRenderLoopFrame); QElapsedTimer waitTimer; waitTimer.start(); @@ -544,20 +534,24 @@ void QSGRenderThread::syncAndRender() qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "syncAndRender()"; syncResultedInChanges = false; + QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); - uint pending = pendingUpdate; + bool repaintRequested = (pendingUpdate & RepaintRequest) || d->customRenderStage; + bool syncRequested = pendingUpdate & SyncRequest; + bool exposeRequested = (pendingUpdate & ExposeRequest) == ExposeRequest; pendingUpdate = 0; - if (pending & SyncRequest) { + if (syncRequested) { qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- updatePending, doing sync"; - sync(pending == ExposeRequest); + sync(exposeRequested); } #ifndef QSG_NO_RENDER_TIMING if (profileFrames) syncTime = threadTimer.nsecsElapsed(); #endif + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); - if (!syncResultedInChanges && ((pending & RepaintRequest) == 0)) { + if (!syncResultedInChanges && !repaintRequested) { qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- no changes, render aborted"; int waitTime = vsyncDelta - (int) waitTimer.elapsed(); if (waitTime > 0) @@ -567,7 +561,6 @@ void QSGRenderThread::syncAndRender() qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- rendering started"; - QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); if (animatorDriver->isRunning()) { d->animationController->lock(); @@ -582,9 +575,12 @@ void QSGRenderThread::syncAndRender() d->renderSceneGraph(windowSize); if (profileFrames) renderTime = threadTimer.nsecsElapsed(); - gl->swapBuffers(window); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + if (!d->customRenderStage || !d->customRenderStage->swap()) + gl->swapBuffers(window); d->fireFrameSwapped(); } else { + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, 1); qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- window not ready, skipping render"; } @@ -595,7 +591,7 @@ void QSGRenderThread::syncAndRender() // that to avoid blocking the GUI thread in the case where it // has started rendering with a bad window, causing makeCurrent to // fail or if the window has a bad size. - if (pending == ExposeRequest) { + if (exposeRequested) { qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- wake Gui after initial expose"; waitCondition.wakeOne(); mutex.unlock(); @@ -609,10 +605,7 @@ void QSGRenderThread::syncAndRender() int(threadTimer.elapsed() - renderTime / 1000000)); - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphRenderLoopFrame, ( - syncTime, - renderTime - syncTime, - threadTimer.nsecsElapsed() - renderTime)); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); } @@ -695,8 +688,6 @@ QSGThreadedRenderLoop::QSGThreadedRenderLoop() m_animation_driver = sg->createAnimationDriver(this); - m_exhaust_delay = get_env_int("QML_EXHAUST_DELAY", 5); - connect(m_animation_driver, SIGNAL(started()), this, SLOT(animationStarted())); connect(m_animation_driver, SIGNAL(stopped()), this, SLOT(animationStopped())); @@ -710,10 +701,7 @@ QSGRenderContext *QSGThreadedRenderLoop::createRenderContext(QSGContext *sg) con void QSGThreadedRenderLoop::maybePostPolishRequest(Window *w) { - if (w->timerId == 0) { - qCDebug(QSG_LOG_RENDERLOOP) << "- posting update"; - w->timerId = startTimer(m_exhaust_delay, Qt::PreciseTimer); - } + w->window->requestUpdate(); } QAnimationDriver *QSGThreadedRenderLoop::animationDriver() const @@ -863,7 +851,6 @@ void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window) win.window = window; win.actualWindowFormat = window->format(); win.thread = new QSGRenderThread(this, QQuickWindowPrivate::get(window)->context); - win.timerId = 0; win.updateDuringSync = false; win.forceRenderPass = true; // also covered by polishAndSync(inExpose=true), but doesn't hurt m_windows << win; @@ -953,6 +940,14 @@ void QSGThreadedRenderLoop::handleObscurity(Window *w) } +void QSGThreadedRenderLoop::handleUpdateRequest(QQuickWindow *window) +{ + qCDebug(QSG_LOG_RENDERLOOP) << "- polish and sync update request"; + foreach (const Window &w, m_windows) + if (w.window == window) + polishAndSync(const_cast<Window *>(&w)); +} + void QSGThreadedRenderLoop::maybeUpdate(QQuickWindow *window) { Window *w = windowFor(m_windows, window); @@ -1080,8 +1075,6 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) QQuickWindow *window = w->window; if (!w->thread || !w->thread->window) { qCDebug(QSG_LOG_RENDERLOOP) << "- not exposed, abort"; - killTimer(w->timerId); - w->timerId = 0; return; } @@ -1091,8 +1084,6 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) w = windowFor(m_windows, window); if (!w || !w->thread || !w->thread->window) { qCDebug(QSG_LOG_RENDERLOOP) << "- removed after event flushing, abort"; - killTimer(w->timerId); - w->timerId = 0; return; } @@ -1101,16 +1092,17 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) qint64 polishTime = 0; qint64 waitTime = 0; qint64 syncTime = 0; - bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled() || - QQuickProfiler::profilingSceneGraph(); + bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled(); if (profileFrames) timer.start(); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphPolishAndSync); QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); d->polishItems(); if (profileFrames) polishTime = timer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); w->updateDuringSync = false; @@ -1125,6 +1117,7 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) qCDebug(QSG_LOG_RENDERLOOP) << "- wait for sync"; if (profileFrames) waitTime = timer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); w->thread->waitCondition.wait(&w->thread->mutex); m_lockedForSync = false; w->thread->mutex.unlock(); @@ -1132,9 +1125,7 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) if (profileFrames) syncTime = timer.nsecsElapsed(); - - killTimer(w->timerId); - w->timerId = 0; + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); if (m_animation_timer == 0 && m_animation_driver->isRunning()) { qCDebug(QSG_LOG_RENDERLOOP) << "- advancing animations"; @@ -1155,22 +1146,7 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphPolishAndSync, ( - polishTime, - waitTime - polishTime, - syncTime - waitTime, - timer.nsecsElapsed() - syncTime)); -} - -QSGThreadedRenderLoop::Window *QSGThreadedRenderLoop::windowForTimer(int timerId) const -{ - for (int i=0; i<m_windows.size(); ++i) { - if (m_windows.at(i).timerId == timerId) { - return const_cast<Window *>(&m_windows.at(i)); - break; - } - } - return 0; + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync); } bool QSGThreadedRenderLoop::event(QEvent *e) @@ -1183,15 +1159,8 @@ bool QSGThreadedRenderLoop::event(QEvent *e) qCDebug(QSG_LOG_RENDERLOOP) << "- ticking non-visual timer"; m_animation_driver->advance(); emit timeToIncubate(); - } else { - qCDebug(QSG_LOG_RENDERLOOP) << "- polish and sync timer"; - Window *w = windowForTimer(te->timerId()); - if (w) - polishAndSync(w); - else - killTimer(te->timerId()); + return true; } - return true; } default: diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h index 82f314a6af..b3db56e5f9 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h +++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h @@ -60,6 +60,8 @@ public: void update(QQuickWindow *window); void maybeUpdate(QQuickWindow *window); + void handleUpdateRequest(QQuickWindow *window); + QSGContext *sceneGraphContext() const; QSGRenderContext *createRenderContext(QSGContext *) const; @@ -80,7 +82,6 @@ private: QQuickWindow *window; QSGRenderThread *thread; QSurfaceFormat actualWindowFormat; - int timerId; uint updateDuringSync : 1; uint forceRenderPass : 1; }; @@ -89,7 +90,6 @@ private: void releaseResources(Window *window, bool inDestructor); bool checkAndResetForceUpdate(QQuickWindow *window); - Window *windowForTimer(int timerId) const; bool anyoneShowing() const; void initialize(); @@ -109,7 +109,6 @@ private: QList<Window> m_windows; int m_animation_timer; - int m_exhaust_delay; bool m_lockedForSync; }; diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 070d6b82fd..469cd1d21b 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -53,10 +53,14 @@ extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_ #define RLDEBUG(x) qCDebug(QSG_LOG_RENDERLOOP) << x; static QElapsedTimer qsg_render_timer; -#define QSG_RENDER_TIMING_SAMPLE(sampleName) \ +#define QSG_LOG_TIME_SAMPLE(sampleName) \ qint64 sampleName = 0; \ - if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled() || QQuickProfiler::profilingSceneGraph()) \ - sampleName = qsg_render_timer.nsecsElapsed() + if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled()) \ + sampleName = qsg_render_timer.nsecsElapsed(); \ + +#define QSG_RENDER_TIMING_SAMPLE(frameType, sampleName) \ + QSG_LOG_TIME_SAMPLE(sampleName) \ + Q_QUICK_SG_PROFILE_RECORD(frameType); QSGWindowsRenderLoop::QSGWindowsRenderLoop() @@ -346,7 +350,8 @@ void QSGWindowsRenderLoop::render() if (m_animationDriver->isRunning()) { RLDEBUG("advancing animations"); - QSG_RENDER_TIMING_SAMPLE(time_start); + QSG_LOG_TIME_SAMPLE(time_start); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphWindowsAnimations); m_animationDriver->advance(); RLDEBUG("animations advanced"); @@ -354,8 +359,7 @@ void QSGWindowsRenderLoop::render() "animations ticked in %dms", int((qsg_render_timer.nsecsElapsed() - time_start)/1000000)); - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphWindowsAnimations, ( - qsg_render_timer.nsecsElapsed() - time_start)); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphWindowsAnimations); // It is not given that animations triggered another maybeUpdate() // and thus another render pass, so to keep things running, @@ -390,27 +394,29 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window) if (!windowData(window)) return; - QSG_RENDER_TIMING_SAMPLE(time_start); + QSG_LOG_TIME_SAMPLE(time_start); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphPolishFrame); RLDEBUG(" - polishing"); d->polishItems(); - QSG_RENDER_TIMING_SAMPLE(time_polished); - - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphPolishFrame, (time_polished - time_start)); + QSG_LOG_TIME_SAMPLE(time_polished); + Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame, + QQuickProfiler::SceneGraphRenderLoopFrame); emit window->afterAnimating(); RLDEBUG(" - syncing"); d->syncSceneGraph(); - QSG_RENDER_TIMING_SAMPLE(time_synced); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_synced); RLDEBUG(" - rendering"); d->renderSceneGraph(window->size()); - QSG_RENDER_TIMING_SAMPLE(time_rendered); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_rendered); RLDEBUG(" - swapping"); - m_gl->swapBuffers(window); - QSG_RENDER_TIMING_SAMPLE(time_swapped); + if (!d->customRenderStage || !d->customRenderStage->swap()) + m_gl->swapBuffers(window); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_swapped); RLDEBUG(" - frameDone"); d->fireFrameSwapped(); @@ -423,10 +429,7 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window) << ", swap=" << (time_swapped - time_rendered) / 1000000 << " - " << window; - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphRenderLoopFrame, ( - time_synced - time_polished, - time_rendered - time_synced, - time_swapped - time_rendered)); + Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphRenderLoopFrame); } QT_END_NAMESPACE diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp index 5edcb5d67a..cb82d721ca 100644 --- a/src/quick/scenegraph/util/qsgatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgatlastexture.cpp @@ -377,10 +377,12 @@ void Atlas::bind(QSGTexture::Filtering filtering) // Upload all pending images.. for (int i=0; i<m_pending_uploads.size(); ++i) { - bool profileFrames = QSG_LOG_TIME_TEXTURE().isDebugEnabled() || - QQuickProfiler::profilingSceneGraph(); + bool profileFrames = QSG_LOG_TIME_TEXTURE().isDebugEnabled(); if (profileFrames) qsg_renderer_timer.start(); + // Skip bind, convert, swizzle; they're irrelevant + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, 3); if (m_externalFormat == GL_BGRA && !m_use_bgra_fallback) { @@ -393,12 +395,10 @@ void Atlas::bind(QSGTexture::Filtering filtering) << "ms (" << m_pending_uploads.at(i)->image().width() << "x" << m_pending_uploads.at(i)->image().height() << ")"; - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphTexturePrepare, ( - 0, // bind (not relevant) - 0, // convert (not relevant) - 0, // swizzle (not relevant) - qsg_renderer_timer.nsecsElapsed(), // (upload all of the above) - 0)); // mipmap (not used ever...) + // Skip mipmap; unused + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, 1); + Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphTexturePrepare); } GLenum f = filtering == QSGTexture::Nearest ? GL_NEAREST : GL_LINEAR; diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index fc5050014e..673323baa2 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -633,10 +633,12 @@ void QSGPlainTexture::bind() m_dirty_texture = false; - bool profileFrames = QSG_LOG_TIME_TEXTURE().isDebugEnabled() || - QQuickProfiler::profilingSceneGraph(); + bool profileFrames = QSG_LOG_TIME_TEXTURE().isDebugEnabled(); if (profileFrames) qsg_renderer_timer.start(); + Q_QUICK_SG_PROFILE_START_SYNCHRONIZED(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTextureDeletion); + if (m_image.isNull()) { if (m_texture_id && m_owns_texture) { @@ -645,8 +647,7 @@ void QSGPlainTexture::bind() (int) qsg_renderer_timer.elapsed(), m_texture_size.width(), m_texture_size.height()); - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphTextureDeletion, ( - qsg_renderer_timer.nsecsElapsed())); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTextureDeletion); } m_texture_id = 0; m_texture_size = QSize(); @@ -662,6 +663,7 @@ void QSGPlainTexture::bind() qint64 bindTime = 0; if (profileFrames) bindTime = qsg_renderer_timer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); // ### TODO: check for out-of-memory situations... @@ -692,6 +694,7 @@ void QSGPlainTexture::bind() qint64 convertTime = 0; if (profileFrames) convertTime = qsg_renderer_timer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); updateBindOptions(m_dirty_bind_options); @@ -734,12 +737,14 @@ void QSGPlainTexture::bind() qint64 swizzleTime = 0; if (profileFrames) swizzleTime = qsg_renderer_timer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, m_texture_size.width(), m_texture_size.height(), 0, externalFormat, GL_UNSIGNED_BYTE, tmp.constBits()); qint64 uploadTime = 0; if (profileFrames) uploadTime = qsg_renderer_timer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); if (mipmapFiltering() != QSGTexture::None) { funcs->glGenerateMipmap(GL_TEXTURE_2D); @@ -762,13 +767,7 @@ void QSGPlainTexture::bind() int((mipmapTime - uploadTime)/1000000), m_texture_size != m_image.size() ? " (scaled to GL_MAX_TEXTURE_SIZE)" : ""); } - - Q_QUICK_SG_PROFILE(QQuickProfiler::SceneGraphTexturePrepare, ( - bindTime, - convertTime - bindTime, - swizzleTime - convertTime, - uploadTime - swizzleTime, - qsg_renderer_timer.nsecsElapsed() - uploadTime)); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTexturePrepare); m_texture_rect = QRectF(0, 0, 1, 1); diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp index 3a84bf6219..be24ebe76d 100644 --- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp +++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp @@ -99,9 +99,12 @@ void QSGVertexColorMaterialShader::initialize() The geometry to be rendered with vertex color must have the following layout. Attribute position 0 must contain vertices. Attribute position 1 must contain colors, a tuple of 4 values with RGBA layout. Both floats in the range of 0 to 1 and unsigned bytes in - the range 0 to 255 are valid for the color values. The - QSGGeometry::defaultAttributes_ColoredPoint2D() constructs an attribute set - compatible with this material. + the range 0 to 255 are valid for the color values. + + \note The rendering pipeline expects pixels with premultiplied alpha. + + QSGGeometry::defaultAttributes_ColoredPoint2D() can be used to construct an attribute + set that is compatible with this material. The vertex color material respects both current opacity and current matrix when updating it's rendering state. diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index f29ec49b9f..536413bba9 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -405,21 +405,33 @@ void QQuickOpacityAnimatorJob::initialize(QQuickAnimatorController *controller) m_opacityNode = d->opacityNode(); if (!m_opacityNode) { m_opacityNode = new QSGOpacityNode(); - d->extra.value().opacityNode = m_opacityNode; - - QSGNode *child = d->clipNode(); - if (!child) - child = d->rootNode(); - if (!child) - child = d->groupNode; - if (child) { + /* The item node subtree is like this + * + * itemNode + * (opacityNode) optional + * (clipNode) optional + * (rootNode) optional + * children / paintNode + * + * If the opacity node doesn't exist, we need to insert it into + * the hierarchy between itemNode and clipNode or rootNode. If + * neither clip or root exists, we need to reparent all children + * from itemNode to opacityNode. + */ + QSGNode *iNode = d->itemNode(); + QSGNode *child = d->childContainerNode(); + if (child != iNode) { if (child->parent()) child->parent()->removeChildNode(child); m_opacityNode->appendChildNode(child); + iNode->appendChildNode(m_opacityNode); + } else { + iNode->reparentChildNodesTo(m_opacityNode); + iNode->appendChildNode(m_opacityNode); } - d->itemNode()->appendChildNode(m_opacityNode); + d->extra.value().opacityNode = m_opacityNode; } } diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 22ed9b7486..a2a8ef03c7 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -831,8 +831,10 @@ void QQuickPixmapStore::unreferencePixmap(QQuickPixmapData *data) shrinkCache(-1); // Shrink the cache in case it has become larger than cache_limit - if (m_timerId == -1 && m_unreferencedPixmaps && !m_destroying) + if (m_timerId == -1 && m_unreferencedPixmaps + && !m_destroying && !QCoreApplication::closingDown()) { m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000); + } } void QQuickPixmapStore::referencePixmap(QQuickPixmapData *data) diff --git a/src/quick/util/qquickprofiler.cpp b/src/quick/util/qquickprofiler.cpp index 3b34b7550b..c4441ed5dd 100644 --- a/src/quick/util/qquickprofiler.cpp +++ b/src/quick/util/qquickprofiler.cpp @@ -80,7 +80,7 @@ void QQuickProfilerData::toByteArrays(QList<QByteArray> &messages) const // RendererFrame: preprocessTime, updateTime, bindingTime, renderTime case QQuickProfiler::SceneGraphRendererFrame: ds << subtime_1 << subtime_2 << subtime_3 << subtime_4; break; // AdaptationLayerFrame: glyphCount (which is an integer), glyphRenderTime, glyphStoreTime - case QQuickProfiler::SceneGraphAdaptationLayerFrame: ds << subtime_1 << subtime_2 << subtime_3; break; + case QQuickProfiler::SceneGraphAdaptationLayerFrame: ds << subtime_3 << subtime_1 << subtime_2; break; // ContextFrame: compiling material time case QQuickProfiler::SceneGraphContextFrame: ds << subtime_1; break; // RenderLoop: syncTime, renderTime, swapTime diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h index 62e23cd393..ea37558741 100644 --- a/src/quick/util/qquickprofiler_p.h +++ b/src/quick/util/qquickprofiler_p.h @@ -51,6 +51,7 @@ #include <QUrl> #include <QSize> #include <QMutex> +#include <QThreadStorage> QT_BEGIN_NAMESPACE @@ -63,9 +64,38 @@ QT_BEGIN_NAMESPACE #define Q_QUICK_PROFILE(feature, Method)\ Q_QUICK_PROFILE_IF_ENABLED(feature, QQuickProfiler::Method) -#define Q_QUICK_SG_PROFILE(Type, Params)\ +#define Q_QUICK_SG_PROFILE_START(Type)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::sceneGraphFrame<Type> Params)) + (QQuickProfiler::startSceneGraphFrame<Type>())) + +#define Q_QUICK_SG_PROFILE_RECORD(Type)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::recordSceneGraphTimestamp<Type>())) + +#define Q_QUICK_SG_PROFILE_SKIP(Type, Skip)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::skipSceneGraphTimestamps<Type, Skip>())) + +#define Q_QUICK_SG_PROFILE_START_SYNCHRONIZED(Type1, Type2)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::startSceneGraphFrame<Type1, Type2>())) + +#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2) \ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::reportSceneGraphFrame<Type1, true, Type2>())) + +#define Q_QUICK_SG_PROFILE_REPORT(Type)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::reportSceneGraphFrame<Type, false>())) + +#define Q_QUICK_SG_PROFILE_END(Type)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::reportSceneGraphFrame<Type, true>())) + +#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, Payload)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::reportSceneGraphFrame<Type, true>(Payload))) + #define Q_QUICK_INPUT_PROFILE(Method)\ Q_QUICK_PROFILE(QQuickProfiler::ProfileInputEvents, Method) @@ -136,6 +166,39 @@ struct Q_AUTOTEST_EXPORT QQuickProfilerData Q_DECLARE_TYPEINFO(QQuickProfilerData, Q_MOVABLE_TYPE); +class QQuickProfilerSceneGraphData : public QQmlProfilerDefinitions { +private: + static const uint s_numSceneGraphTimings = 5; + + template<uint size> + struct TimingData { + qint64 values[size][s_numSceneGraphTimings + 1]; + int offsets[size]; + }; + + QThreadStorage<TimingData<NumRenderThreadFrameTypes> > renderThreadTimings; + TimingData<NumGUIThreadFrameTypes> guiThreadTimings; + +public: + template<SceneGraphFrameType type> + qint64 *timings() + { + if (type < NumRenderThreadFrameTypes) + return renderThreadTimings.localData().values[type]; + else + return guiThreadTimings.values[type - NumRenderThreadFrameTypes]; + } + + template<SceneGraphFrameType type> + int &offset() + { + if (type < NumRenderThreadFrameTypes) + return renderThreadTimings.localData().offsets[type]; + else + return guiThreadTimings.offsets[type - NumRenderThreadFrameTypes]; + } +}; + class Q_QUICK_PRIVATE_EXPORT QQuickProfiler : public QQmlAbstractProfilerAdapter { Q_OBJECT public: @@ -163,12 +226,62 @@ public: } } + template<SceneGraphFrameType FrameType1, SceneGraphFrameType FrameType2> + static void startSceneGraphFrame() + { + startSceneGraphFrame<FrameType1>(); + s_instance->m_sceneGraphData.offset<FrameType2>() = 0; + s_instance->m_sceneGraphData.timings<FrameType2>()[0] = + s_instance->m_sceneGraphData.timings<FrameType1>()[0]; + } + template<SceneGraphFrameType FrameType> - static void sceneGraphFrame(qint64 value1, qint64 value2 = -1, qint64 value3 = -1, - qint64 value4 = -1, qint64 value5 = -1) + static void startSceneGraphFrame() + { + s_instance->m_sceneGraphData.offset<FrameType>() = 0; + s_instance->m_sceneGraphData.timings<FrameType>()[0] = s_instance->timestamp(); + } + + template<SceneGraphFrameType FrameType> + static void recordSceneGraphTimestamp() + { + s_instance->m_sceneGraphData.timings<FrameType>() + [++s_instance->m_sceneGraphData.offset<FrameType>()] = s_instance->timestamp(); + } + + template<SceneGraphFrameType FrameType, uint Skip> + static void skipSceneGraphTimestamps() + { + qint64 *timings = s_instance->m_sceneGraphData.timings<FrameType>(); + const qint64 last = timings[s_instance->m_sceneGraphData.offset<FrameType>()]; + for (uint i = 0; i < Skip; ++i) + timings[++s_instance->m_sceneGraphData.offset<FrameType>()] = last; + } + + template<SceneGraphFrameType FrameType, bool Record> + static void reportSceneGraphFrame(quint64 payload = -1) + { + qint64 *timings = s_instance->m_sceneGraphData.timings<FrameType>(); + int &offset = s_instance->m_sceneGraphData.offset<FrameType>(); + if (Record) + timings[++offset] = s_instance->timestamp(); + s_instance->processMessage(QQuickProfilerData( + timings[offset], 1 << SceneGraphFrame, 1 << FrameType, + offset > 0 ? timings[1] - timings[0] : payload, + offset > 1 ? timings[2] - timings[1] : payload, + offset > 2 ? timings[3] - timings[2] : payload, + offset > 3 ? timings[4] - timings[3] : payload, + offset > 4 ? timings[5] - timings[4] : payload)); + } + + template<SceneGraphFrameType FrameType, bool Record, SceneGraphFrameType SwitchTo> + static void reportSceneGraphFrame(quint64 payload = -1) { - s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(), 1 << SceneGraphFrame, - 1 << FrameType, value1, value2, value3, value4, value5)); + reportSceneGraphFrame<FrameType, Record>(payload); + s_instance->m_sceneGraphData.offset<SwitchTo>() = 0; + s_instance->m_sceneGraphData.timings<SwitchTo>()[0] = + s_instance->m_sceneGraphData.timings<FrameType>() + [s_instance->m_sceneGraphData.offset<FrameType>()]; } template<PixmapEventType PixmapState> @@ -215,6 +328,7 @@ protected: QMutex m_dataMutex; QElapsedTimer m_timer; QVarLengthArray<QQuickProfilerData> m_data; + QQuickProfilerSceneGraphData m_sceneGraphData; QQuickProfiler(QQmlProfilerService *service); |