aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/doc/qtquick.qdocconf2
-rw-r--r--src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc2
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc13
-rw-r--r--src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc16
-rw-r--r--src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc6
-rw-r--r--src/quick/doc/src/qtquick.qdoc2
-rw-r--r--src/quick/handlers/qquickhoverhandler.cpp35
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler.cpp51
-rw-r--r--src/quick/handlers/qquicktaphandler.cpp10
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp58
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp179
-rw-r--r--src/quick/items/qquickanimatedimage.cpp3
-rw-r--r--src/quick/items/qquickanimatedimage_p.h1
-rw-r--r--src/quick/items/qquickborderimage.cpp2
-rw-r--r--src/quick/items/qquickborderimage_p_p.h2
-rw-r--r--src/quick/items/qquickdrag.cpp4
-rw-r--r--src/quick/items/qquickdroparea.cpp4
-rw-r--r--src/quick/items/qquickevents.cpp7
-rw-r--r--src/quick/items/qquickflickable.cpp4
-rw-r--r--src/quick/items/qquickflickablebehavior_p.h5
-rw-r--r--src/quick/items/qquickgridview.cpp24
-rw-r--r--src/quick/items/qquickitem.cpp5
-rw-r--r--src/quick/items/qquickitemsmodule.cpp4
-rw-r--r--src/quick/items/qquicklistview.cpp23
-rw-r--r--src/quick/items/qquickmousearea.cpp4
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp6
-rw-r--r--src/quick/items/qquickpathview.cpp180
-rw-r--r--src/quick/items/qquickrendercontrol.cpp3
-rw-r--r--src/quick/items/qquickscreen.cpp3
-rw-r--r--src/quick/items/qquicktableview.cpp16
-rw-r--r--src/quick/items/qquicktextcontrol.cpp8
-rw-r--r--src/quick/items/qquicktextcontrol_p_p.h2
-rw-r--r--src/quick/items/qquicktextedit.cpp6
-rw-r--r--src/quick/items/qquicktextinput.cpp25
-rw-r--r--src/quick/items/qquicktextnodeengine.cpp4
-rw-r--r--src/quick/items/qquickwindow.cpp24
-rw-r--r--src/quick/items/qquickwindow.h6
-rw-r--r--src/quick/items/qquickwindow_p.h2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp5
-rw-r--r--src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp48
-rw-r--r--src/quick/scenegraph/coreapi/qsgabstractrenderer.h10
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp30
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h14
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp105
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialrhishader.h12
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendererinterface.cpp34
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.cpp3
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.h1
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp5
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h1
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp38
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalimagenode.cpp4
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp4
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp5
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext_p.h13
-rw-r--r--src/quick/scenegraph/qsgdefaultspritenode.cpp8
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp28
-rw-r--r--src/quick/scenegraph/qsgopengllayer.cpp2
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp68
-rw-r--r--src/quick/scenegraph/qsgrhilayer.cpp5
-rw-r--r--src/quick/scenegraph/qsgrhishadereffectnode.cpp12
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp25
-rw-r--r--src/quick/scenegraph/qsgrhisupport_p.h3
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp162
-rw-r--r--src/quick/scenegraph/qsgwindowsrenderloop.cpp2
-rw-r--r--src/quick/scenegraph/scenegraph.pri8
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.cpp4
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp6
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial_p.h6
-rw-r--r--src/quick/scenegraph/util/qsgvertexcolormaterial.cpp4
-rw-r--r--src/quick/util/qquickanimatorjob.cpp2
-rw-r--r--src/quick/util/qquickfontmetrics.cpp7
74 files changed, 957 insertions, 484 deletions
diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf
index 13746b13de..6a4300c1bd 100644
--- a/src/quick/doc/qtquick.qdocconf
+++ b/src/quick/doc/qtquick.qdocconf
@@ -41,9 +41,11 @@ tagfile = ../../../doc/qtquick/qtquick.tags
depends += qtcore qtqml qtqmltest qtgui qtlinguist qtquickcontrols1 qtquickcontrols qtdoc qtquickdialogs qtsensors qtwidgets qmake qtmultimedia qtgraphicaleffects qtsql qtxmlpatterns
headerdirs += ..\
+ ../../quick \
../../quickwidgets
sourcedirs += .. \
+ ../../quick \
../../quickwidgets
exampledirs += ../../../examples/quick \
diff --git a/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc b/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc
index e4d837112f..7695bb57db 100644
--- a/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc
+++ b/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc
@@ -227,7 +227,7 @@ access to the data from QML:
The QSqlQueryModel class is good enough to implement a custom read-only
model that represents data in an SQL database. The
-\l{Qt Quick Controls 2 - Chat Tutorial}{chat tutorial} example
+\l{Qt Quick Controls - Chat Tutorial}{chat tutorial} example
demonstrates this very well by implementing a custom model to fetch the
contact details from an SQLite database.
diff --git a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
index 864d90274c..e09c430e43 100644
--- a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
@@ -1016,6 +1016,14 @@ with multiple windows.
\li Where applicable (Vulkan, Direct3D), enables the graphics API implementation's debug
and/or validation layers, if available.
+ \row
+ \li \c QSG_RHI_PREFER_SOFTWARE_RENDERER
+ \li \c 1
+ \li Requests choosing an adapter or physical device that uses software-based
+ rasterization. Applicable only when the underlying API has support for
+ enumerating adapters (for example, Direct3D or Vulkan), and is ignored
+ otherwise.
+
\endtable
Applications wishing to always run with a single given graphics API, can
@@ -1031,4 +1039,9 @@ with multiple windows.
equivalent in effect to running with both \c QSG_RHI and \c QSG_RHI_BACKEND
set.
+ All QRhi backends will choose the system default GPU adapter or physical
+ device, unless overridden by \c{QSG_RHI_PREFER_SOFTWARE_RENDERER} or a
+ backend-specific variable, such as, \c{QT_D3D_ADAPTER_INDEX} or
+ \c{QT_VK_PHYSICAL_DEVICE_INDEX}. No further adapter configurability is
+ provided at this time.
*/
diff --git a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
index dd7f21e81a..f4a1616943 100644
--- a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
+++ b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
@@ -45,9 +45,9 @@ UI. It is recommended to browse this list of UI controls before creating your
own custom UI control.
Besides these basic UI controls offered by Qt Quick itself, a rich set of UI
-controls are also available with Qt Quick Controls 2. They cater to the most
+controls are also available with Qt Quick Controls. They cater to the most
common use cases without any change, and offer a lot more possibilities with their
-customization options. In particular, Qt Quick Controls 2 provides styling
+customization options. In particular, Qt Quick Controls provides styling
options that align with the latest UI design trends. If these UI controls do not
satisfy your application's needs, only then it is recommended to create a
custom control.
@@ -55,7 +55,7 @@ custom control.
\section2 Related Information
\list
-\li \l{Qt Quick Controls 2}
+\li \l{Qt Quick Controls}
\li \l{Qt Quick}
\endlist
@@ -323,7 +323,7 @@ see \l {Choosing the Correct Integration Method Between C++ and QML}.
\section2 Related Information
\list
\li \l{Integrating QML and C++}
-\li \l{Qt Quick Controls 2 - Chat Tutorial}{Chat application tutorial}
+\li \l{Qt Quick Controls - Chat Tutorial}{Chat application tutorial}
\endlist
\section1 Using Qt Quick Layouts
@@ -426,7 +426,7 @@ developers to follow these tips:
\li Use anchors or the Qt Quick Layouts module to lay out the visual items.
\li Do not specify explicit width and height for a visual item.
\li Provide UI resources such as images and icons for each display resolution
- that your application supports. The Qt Quick Controls 2 gallery example
+ that your application supports. The Qt Quick Controls gallery example
demonstrates this well by providing the \c qt-logo.png for \c @2x, \c @3x,
and \c @4x resolutions, enabling the application to cater to high
resolution displays. Qt automatically chooses the appropriate
@@ -437,7 +437,7 @@ developers to follow these tips:
versions of an image, as is necessary with bitmap images.
\li Use font-based icons, such as Font Awesome. These scale to any display
resolution, and also allow colorization. The
- Qt Quick Controls 2 Text Editor example demonstrates this well.
+ Qt Quick Controls Text Editor example demonstrates this well.
\endlist
With this in place, your application's UI should scale depending
@@ -448,8 +448,8 @@ on the display resolution on offer.
\section2 Related Information
\list
- \li \l{Qt Quick Controls 2 - Gallery}{Gallery example}
- \li \l{Qt Quick Controls 2 - Text Editor}{Text Editor example}
+ \li \l{Qt Quick Controls - Gallery}{Gallery example}
+ \li \l{Qt Quick Controls - Text Editor}{Text Editor example}
\li \l{Font Awesome}
\li \l{Scalability}
\li \l{High DPI Displays}
diff --git a/src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc b/src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc
index 0669ec06c8..84741efa61 100644
--- a/src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc
+++ b/src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc
@@ -39,15 +39,15 @@ information about them.
The Qt Quick Designer enables designing Qt Quick-based UIs using simple
drag-n-drop gestures that most designers are familiar with. It offers UI
-elements from the Qt Quick and Qt Quick Controls 2 modules, as well as
+elements from the Qt Quick and Qt Quick Controls modules, as well as
integration for custom UI elements.
The following is a list of example applications that use UIs created by
the Qt Quick Designer:
\list
- \li \l{Qt Quick Controls 2 - Contact List}
- \li \l{Qt Quick Controls 2 - Flat Style}
+ \li \l{Qt Quick Controls - Contact List}
+ \li \l{Qt Quick Controls - Flat Style}
\endlist
\section2 QML Debugger and Profiler
diff --git a/src/quick/doc/src/qtquick.qdoc b/src/quick/doc/src/qtquick.qdoc
index 7f72217279..4b843f366b 100644
--- a/src/quick/doc/src/qtquick.qdoc
+++ b/src/quick/doc/src/qtquick.qdoc
@@ -43,7 +43,7 @@ QML types for creating user interfaces with the QML language, and a
\l{Qt Quick C++ Classes}{C++ API} for extending QML applications with C++ code.
\note A set of Qt Quick-based UI controls is also available to create user
-interfaces. See \l{Qt Quick Controls 2} for more information.
+interfaces. See \l{Qt Quick Controls} for more information.
For those new to QML and Qt Quick, please see
\l{QML Applications}
diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp
index d7566f0cd8..79cb288af8 100644
--- a/src/quick/handlers/qquickhoverhandler.cpp
+++ b/src/quick/handlers/qquickhoverhandler.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -47,14 +47,24 @@ Q_LOGGING_CATEGORY(lcHoverHandler, "qt.quick.handler.hover")
/*!
\qmltype HoverHandler
\instantiates QQuickHoverHandler
+ \inherits SinglePointHandler
\inqmlmodule QtQuick
\ingroup qtquick-input-handlers
\brief Handler for mouse and tablet hover.
- HoverHandler detects a hovering cursor. Since touchscreens don't generally
- offer hover events, in practice it detects a hovering mouse or tablet stylus.
+ HoverHandler detects a hovering mouse or tablet stylus cursor.
- \sa MouseArea
+ A binding to the \l hovered property is the easiest way to react when the
+ cursor enters or leaves the \l {PointerHandler::parent}{parent} Item.
+ The \l {SinglePointHandler::point}{point} property provides more detail,
+ including the cursor position. The
+ \l {PointerDeviceHandler::acceptedDevices}{acceptedDevices},
+ \l {PointerDeviceHandler::acceptedPointerTypes}{acceptedPointerTypes},
+ and \l {PointerDeviceHandler::acceptedModifiers}{acceptedModifiers}
+ properties can be used to narrow the behavior to detect hovering of
+ specific kinds of devices or while holding a modifier key.
+
+ \sa MouseArea, PointHandler
*/
QQuickHoverHandler::QQuickHoverHandler(QQuickItem *parent)
@@ -62,9 +72,6 @@ QQuickHoverHandler::QQuickHoverHandler(QQuickItem *parent)
{
// Tell QQuickPointerDeviceHandler::wantsPointerEvent() to ignore button state
d_func()->acceptedButtons = Qt::NoButton;
- // Rule out the touchscreen for now (can be overridden in QML in case a hover-detecting touchscreen exists)
- setAcceptedDevices(static_cast<QQuickPointerDevice::DeviceType>(
- static_cast<int>(QQuickPointerDevice::AllDevices) ^ static_cast<int>(QQuickPointerDevice::TouchScreen)));
}
QQuickHoverHandler::~QQuickHoverHandler()
@@ -93,10 +100,22 @@ bool QQuickHoverHandler::wantsPointerEvent(QQuickPointerEvent *event)
void QQuickHoverHandler::handleEventPoint(QQuickEventPoint *point)
{
- setHovered(true);
+ bool hovered = true;
+ if (point->state() == QQuickEventPoint::Released &&
+ point->pointerEvent()->device()->pointerType() == QQuickPointerDevice::Finger)
+ hovered = false;
+ setHovered(hovered);
setPassiveGrab(point);
}
+/*!
+ \qmlproperty bool QtQuick::HoverHandler::hovered
+ \readonly
+
+ Holds true whenever any pointing device cursor (mouse or tablet) is within
+ the bounds of the \c parent Item, extended by the
+ \l {PointerHandler::margin}{margin}, if any.
+*/
void QQuickHoverHandler::setHovered(bool hovered)
{
if (m_hovered != hovered) {
diff --git a/src/quick/handlers/qquickpointerdevicehandler.cpp b/src/quick/handlers/qquickpointerdevicehandler.cpp
index 449d726b78..90f31bf9fd 100644
--- a/src/quick/handlers/qquickpointerdevicehandler.cpp
+++ b/src/quick/handlers/qquickpointerdevicehandler.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -230,6 +230,55 @@ void QQuickPointerDeviceHandler::setAcceptedPointerTypes(QQuickPointerDevice::Po
}
}
\endqml
+
+ If you set \c acceptedModifiers to an OR combination of modifier keys,
+ it means \e all of those modifiers must be pressed to activate the handler:
+
+ \qml
+ Item {
+ TapHandler {
+ acceptedModifiers: Qt.ControlModifier | Qt.AltModifier | Qt.ShiftModifier
+ onTapped: console.log("control-alt-shift-tapped")
+ }
+ }
+ \endqml
+
+ The available modifiers are as follows:
+
+ \value NoModifier No modifier key is allowed.
+ \value ShiftModifier A Shift key on the keyboard must be pressed.
+ \value ControlModifier A Ctrl key on the keyboard must be pressed.
+ \value AltModifier An Alt key on the keyboard must be pressed.
+ \value MetaModifier A Meta key on the keyboard must be pressed.
+ \value KeypadModifier A keypad button must be pressed.
+ \value GroupSwitchModifier X11 only (unless activated on Windows by a command line argument).
+ A Mode_switch key on the keyboard must be pressed.
+ \value KeyboardModifierMask The handler does not care which modifiers are pressed.
+
+ If you need even more complex behavior than can be achieved with
+ combinations of multiple handlers with multiple modifier flags, you can
+ check the modifiers in JavaScript code:
+
+ \qml
+ Item {
+ TapHandler {
+ onTapped:
+ switch (point.modifiers) {
+ case Qt.ControlModifier | Qt.AltModifier:
+ console.log("CTRL+ALT");
+ break;
+ case Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier:
+ console.log("CTRL+META+ALT");
+ break;
+ default:
+ console.log("other modifiers", point.modifiers);
+ break;
+ }
+ }
+ }
+ \endqml
+
+ \sa Qt::KeyboardModifier
*/
void QQuickPointerDeviceHandler::setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers)
{
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp
index 5f9d2151d7..272ebe6b63 100644
--- a/src/quick/handlers/qquicktaphandler.cpp
+++ b/src/quick/handlers/qquicktaphandler.cpp
@@ -379,7 +379,7 @@ void QQuickTapHandler::updateTimeHeld()
That is, if you press and release a touchpoint or button within a time
period less than \l longPressThreshold, while any movement does not exceed
the drag threshold, then the \c tapped signal will be emitted at the time
- of release. The \c eventPoint signal parameter contains information
+ of release. The \a eventPoint signal parameter contains information
from the release event about the point that was tapped:
\snippet pointerHandlers/tapHandlerOnTapped.qml 0
@@ -392,7 +392,7 @@ void QQuickTapHandler::updateTimeHeld()
This signal is emitted when the \c parent Item is tapped once.
After an amount of time greater than QStyleHints::mouseDoubleClickInterval,
it can be tapped again; but if the time until the next tap is less,
- \l tapCount will increase. The \c eventPoint signal parameter contains
+ \l tapCount will increase. The \a eventPoint signal parameter contains
information from the release event about the point that was tapped.
*/
@@ -404,13 +404,13 @@ void QQuickTapHandler::updateTimeHeld()
short span of time (QStyleHints::mouseDoubleClickInterval()) and distance
(QStyleHints::mouseDoubleClickDistance() or
QStyleHints::touchDoubleTapDistance()). This signal always occurs after
- \l singleTapped, \l tapped, and \l tapCountChanged. The \c eventPoint
+ \l singleTapped, \l tapped, and \l tapCountChanged. The \a eventPoint
signal parameter contains information from the release event about the
point that was tapped.
*/
/*!
- \qmlsignal QtQuick::TapHandler::longPressed
+ \qmlsignal QtQuick::TapHandler::longPressed()
This signal is emitted when the \c parent Item is pressed and held for a
time period greater than \l longPressThreshold. That is, if you press and
@@ -420,7 +420,7 @@ void QQuickTapHandler::updateTimeHeld()
*/
/*!
- \qmlsignal QtQuick::TapHandler::tapCountChanged
+ \qmlsignal QtQuick::TapHandler::tapCountChanged()
This signal is emitted when the \c parent Item is tapped once or more (within
a specified time and distance span) and when the present \c tapCount differs
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index ac4e86d8da..b8e6d58af4 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -848,13 +848,15 @@ QSGTextureProvider *QQuickCanvasItem::textureProvider() const
The \a contextId parameter names the required context. The Canvas item
will return a context that implements the required drawing mode. After the
first call to getContext, any subsequent call to getContext with the same
- contextId will return the same context object.
+ contextId will return the same context object. Any additional arguments
+ (\a args) are currently ignored.
If the context type is not supported or the canvas has previously been
requested to provide a different and incompatible context type, \c null
will be returned.
Canvas only supports a 2d context.
+
*/
void QQuickCanvasItem::getContext(QQmlV4Function *args)
@@ -897,7 +899,7 @@ void QQuickCanvasItem::getContext(QQmlV4Function *args)
/*!
\qmlmethod int QtQuick::Canvas::requestAnimationFrame(callback)
- This function schedules callback to be invoked before composing the Qt Quick
+ This function schedules \a callback to be invoked before composing the Qt Quick
scene.
*/
@@ -960,7 +962,7 @@ void QQuickCanvasItem::requestPaint()
/*!
\qmlmethod QtQuick::Canvas::markDirty(rect area)
- Mark the given \a area as dirty, so that when this area is visible the
+ Marks the given \a area as dirty, so that when this area is visible the
canvas renderer will redraw it. This will trigger the \c paint signal.
\sa paint, requestPaint()
@@ -984,16 +986,16 @@ void QQuickCanvasItem::checkAnimationCallbacks()
}
/*!
- \qmlmethod bool QtQuick::Canvas::save(string filename)
+ \qmlmethod bool QtQuick::Canvas::save(string filename)
- Save the current canvas content into an image file \a filename.
- The saved image format is automatically decided by the \a filename's
- suffix.
+ Saves the current canvas content into an image file \a filename.
+ The saved image format is automatically decided by the \a filename's
+ suffix. Returns \c true on success.
- Note: calling this method will force painting the whole canvas, not just the
- current canvas visible window.
+ \note Calling this method will force painting the whole canvas, not just the
+ current canvas visible window.
- \sa canvasWindow, canvasSize, toDataURL()
+ \sa canvasWindow, canvasSize, toDataURL()
*/
bool QQuickCanvasItem::save(const QString &filename) const
{
@@ -1023,15 +1025,17 @@ QQmlRefPointer<QQuickCanvasPixmap> QQuickCanvasItem::loadedPixmap(const QUrl& ur
*/
/*!
- \qmlmethod QtQuick::Canvas::loadImage(url image)
- Loads the given \c image asynchronously.
+ \qmlmethod QtQuick::Canvas::loadImage(url image)
+
+ Loads the given \a image asynchronously.
- When the image is ready, \l imageLoaded will be emitted.
- The loaded image can be unloaded by the unloadImage() method.
+ Once the image is ready, imageLoaded() signal will be emitted.
+ The loaded image can be unloaded with the unloadImage() method.
- Note: Only loaded images can be painted on the Canvas item.
- \sa unloadImage, imageLoaded, isImageLoaded(),
- Context2D::createImageData(), Context2D::drawImage()
+ \note Only loaded images can be painted on the Canvas item.
+
+ \sa unloadImage(), imageLoaded(), isImageLoaded(),
+ Context2D::createImageData(), Context2D::drawImage()
*/
void QQuickCanvasItem::loadImage(const QUrl& url)
{
@@ -1051,14 +1055,15 @@ void QQuickCanvasItem::loadImage(const QUrl& url)
}
}
/*!
- \qmlmethod QtQuick::Canvas::unloadImage(url image)
- Unloads the \c image.
+ \qmlmethod QtQuick::Canvas::unloadImage(url image)
+
+ Unloads the \a image.
- Once an image is unloaded it cannot be painted by the canvas context
- unless it is loaded again.
+ Once an image is unloaded, it cannot be painted by the canvas context
+ unless it is loaded again.
- \sa loadImage(), imageLoaded, isImageLoaded(),
- Context2D::createImageData(), Context2D::drawImage
+ \sa loadImage(), imageLoaded(), isImageLoaded(),
+ Context2D::createImageData(), Context2D::drawImage
*/
void QQuickCanvasItem::unloadImage(const QUrl& url)
{
@@ -1067,10 +1072,11 @@ void QQuickCanvasItem::unloadImage(const QUrl& url)
}
/*!
- \qmlmethod QtQuick::Canvas::isImageError(url image)
- Returns true if the \a image failed to load.
+ \qmlmethod QtQuick::Canvas::isImageError(url image)
- \sa loadImage()
+ Returns \c true if the \a image failed to load, \c false otherwise.
+
+ \sa loadImage()
*/
bool QQuickCanvasItem::isImageError(const QUrl& url) const
{
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 48e5a4d4a2..54cda72a36 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -1148,6 +1148,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(const QV4::FunctionO
/*!
\qmlmethod object QtQuick::Context2D::setTransform(real a, real b, real c, real d, real e, real f)
+
Changes the transformation matrix to the matrix given by the arguments as described below.
Modifying the transformation matrix directly enables you to perform scaling,
@@ -1160,21 +1161,22 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(const QV4::FunctionO
\image qml-item-canvas-math.png
where:
\list
- \li \c{a} is the scale factor in the horizontal (x) direction
+ \li \a{a} is the scale factor in the horizontal (x) direction
\image qml-item-canvas-scalex.png
- \li \c{c} is the skew factor in the x direction
+ \li \a{c} is the skew factor in the x direction
\image qml-item-canvas-skewx.png
- \li \c{e} is the translation in the x direction
+ \li \a{e} is the translation in the x direction
\image qml-item-canvas-translate.png
- \li \c{b} is the skew factor in the y (vertical) direction
+ \li \a{b} is the skew factor in the y (vertical) direction
\image qml-item-canvas-skewy.png
- \li \c{d} is the scale factor in the y direction
+ \li \a{d} is the scale factor in the y direction
\image qml-item-canvas-scaley.png
- \li \c{f} is the translation in the y direction
+ \li \a{f} is the translation in the y direction
\image qml-item-canvas-translatey.png
\li the last row remains constant
\endlist
- The scale factors and skew factors are multiples; \c{e} and \c{f} are
+
+ The scale factors and skew factors are multiples; \a{e} and \a{f} are
coordinate space units, just like the units in the translate(x,y)
method.
@@ -1202,11 +1204,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_setTransform(const QV4::Fu
/*!
\qmlmethod object QtQuick::Context2D::transform(real a, real b, real c, real d, real e, real f)
- This method is very similar to setTransform(), but instead of replacing the old
- transform matrix, this method applies the given tranform matrix to the current matrix by multiplying to it.
+ This method is very similar to setTransform(), but instead of replacing
+ the old transform matrix, this method applies the given tranform matrix
+ to the current matrix by multiplying to it.
- The setTransform(a, b, c, d, e, f) method actually resets the current transform to the identity matrix,
- and then invokes the transform(a, b, c, d, e, f) method with the same arguments.
+ The setTransform(\a a, \a b, \a c, \a d, \a e, \a f) method actually
+ resets the current transform to the identity matrix, and then invokes
+ the transform(\a a, \a b, \a c, \a d, \a e, \a f) method with the same
+ arguments.
\sa setTransform()
*/
@@ -1626,9 +1631,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(const
}
/*!
- \qmlmethod object QtQuick::Context2D::createRadialGradient(real x0, real y0, real r0, real x1, real y1, real r1)
- Returns a CanvasGradient object that represents a radial gradient that paints along the cone given by the start circle with
- origin (x0, y0) and radius r0, and the end circle with origin (x1, y1) and radius r1.
+ \qmlmethod object QtQuick::Context2D::createRadialGradient(real x0, real y0, real r0, real x1, real y1, real r1)
+
+ Returns a CanvasGradient object that represents a radial gradient that
+ paints along the cone given by the start circle with origin (\a x0, \a y0)
+ and radius \a r0, and the end circle with origin (\a x1, \a y1) and radius
+ \a r1.
\sa CanvasGradient::addColorStop()
\sa createLinearGradient()
@@ -1679,8 +1687,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(const
/*!
\qmlmethod object QtQuick::Context2D::createConicalGradient(real x, real y, real angle)
- Returns a CanvasGradient object that represents a conical gradient that interpolate colors counter-clockwise around a center point (\c x, \c y)
- with start angle \c angle in units of radians.
+
+ Returns a CanvasGradient object that represents a conical gradient that
+ interpolates colors counter-clockwise around a center point (\a x, \a y)
+ with a start angle \a angle in units of radians.
\sa CanvasGradient::addColorStop()
\sa createLinearGradient()
@@ -2263,8 +2273,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_path(const QV4::FunctionObject
//rects
/*!
- \qmlmethod object QtQuick::Context2D::clearRect(real x, real y, real w, real h)
- Clears all pixels on the canvas in the given rectangle to transparent black.
+ \qmlmethod object QtQuick::Context2D::clearRect(real x, real y, real w, real h)
+
+ Clears all pixels on the canvas in the rectangle specified by
+ (\a x, \a y, \a w, \a h) to transparent black.
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2283,8 +2295,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(const QV4::Funct
}
/*!
- \qmlmethod object QtQuick::Context2D::fillRect(real x, real y, real w, real h)
- Paint the specified rectangular area using the fillStyle.
+ \qmlmethod object QtQuick::Context2D::fillRect(real x, real y, real w, real h)
+
+ Paints a rectangular area specified by (\a x, \a y, \a w, \a h) using fillStyle.
\sa fillStyle
*/
@@ -2301,14 +2314,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillRect(const QV4::Functi
}
/*!
- \qmlmethod object QtQuick::Context2D::strokeRect(real x, real y, real w, real h)
- Stroke the specified rectangle's path using the strokeStyle, lineWidth, lineJoin,
- and (if appropriate) miterLimit attributes.
-
- \sa strokeStyle
- \sa lineWidth
- \sa lineJoin
- \sa miterLimit
+ \qmlmethod object QtQuick::Context2D::strokeRect(real x, real y, real w, real h)
+
+ Strokes the path of the rectangle specified by (\a x, \a y, \a w, \a h) using
+ strokeStyle, lineWidth, lineJoin, and (if appropriate) miterLimit attributes.
+
+ \sa strokeStyle, lineWidth, lineJoin, miterLimit
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2332,7 +2343,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(const QV4::Func
circle whose center is at the point (\a x, \a y) and whose radius is
\a radius.
- Both \c startAngle and \c endAngle are measured from the x-axis in radians.
+ Both \a startAngle and \a endAngle are measured from the x-axis in radians.
\image qml-item-canvas-arc.png
@@ -2439,10 +2450,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(const QV4::Funct
/*!
\qmlmethod object QtQuick::Context2D::bezierCurveTo(real cp1x, real cp1y, real cp2x, real cp2y, real x, real y)
- Adds a cubic bezier curve between the current position and the given endPoint using the control points specified by (\c cp1x, cp1y),
- and (\c cp2x, \c cp2y).
- After the curve is added, the current position is updated to be at the end point (\c x, \c y) of the curve.
+ Adds a cubic bezier curve between the current position and the given endPoint using the control points specified by (\a {cp1x}, \a {cp1y}),
+ and (\a {cp2x}, \a {cp2y}).
+ After the curve is added, the current position is updated to be at the end point (\a {x}, \a {y}) of the curve.
The following code produces the path shown below:
+
\code
ctx.strokeStyle = Qt.rgba(0, 0, 0, 1);
ctx.lineWidth = 1;
@@ -2451,7 +2463,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(const QV4::Funct
ctx.bezierCurveTo(-10, 90, 210, 90, 180, 0);
ctx.stroke();
\endcode
+
\image qml-item-canvas-bezierCurveTo.png
+
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-beziercurveto}{W3C 2d context standard for bezierCurveTo}
\sa {http://www.openrise.com/lab/FlowerPower/}{The beautiful flower demo by using bezierCurveTo}
*/
@@ -2550,7 +2564,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(const QV4::FunctionOb
/*!
\qmlmethod object QtQuick::Context2D::lineTo(real x, real y)
- Draws a line from the current position to the point (x, y).
+ Draws a line from the current position to the point at (\a x, \a y).
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2574,7 +2588,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(const QV4::Function
/*!
\qmlmethod object QtQuick::Context2D::moveTo(real x, real y)
- Creates a new subpath with the given point.
+ Creates a new subpath with a point at (\a x, \a y).
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2595,11 +2609,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(const QV4::Function
}
/*!
- \qmlmethod object QtQuick::Context2D::quadraticCurveTo(real cpx, real cpy, real x, real y)
+ \qmlmethod object QtQuick::Context2D::quadraticCurveTo(real cpx, real cpy, real x, real y)
- Adds a quadratic bezier curve between the current point and the endpoint (\c x, \c y) with the control point specified by (\c cpx, \c cpy).
+ Adds a quadratic bezier curve between the current point and the endpoint
+ (\a x, \a y) with the control point specified by (\a cpx, \a cpy).
- See \l{http://www.w3.org/TR/2dcontext/#dom-context-2d-quadraticcurveto}{W3C 2d context standard for quadraticCurveTo}
+ \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-quadraticcurveto}{W3C 2d context standard for quadraticCurveTo}
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2623,9 +2638,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(const QV4
}
/*!
- \qmlmethod object QtQuick::Context2D::rect(real x, real y, real w, real h)
+ \qmlmethod object QtQuick::Context2D::rect(real x, real y, real w, real h)
- Adds a rectangle at position (\c x, \c y), with the given width \c w and height \c h, as a closed subpath.
+ Adds a rectangle at position (\a x, \a y), with the given width \a w and
+ height \a h, as a closed subpath.
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2640,10 +2656,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(const QV4::FunctionOb
}
/*!
- \qmlmethod object QtQuick::Context2D::roundedRect(real x, real y, real w, real h, real xRadius, real yRadius)
+ \qmlmethod object QtQuick::Context2D::roundedRect(real x, real y, real w, real h, real xRadius, real yRadius)
- Adds the given rectangle rect with rounded corners to the path. The \c xRadius and \c yRadius arguments specify the radius of the
- ellipses defining the corners of the rounded rectangle.
+ Adds a rounded-corner rectangle, specified by (\a x, \a y, \a w, \a h), to the path.
+ The \a xRadius and \a yRadius arguments specify the radius of the
+ ellipses defining the corners of the rounded rectangle.
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2663,12 +2680,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(const QV4::Fun
}
/*!
- \qmlmethod object QtQuick::Context2D::ellipse(real x, real y, real w, real h)
+ \qmlmethod object QtQuick::Context2D::ellipse(real x, real y, real w, real h)
- Creates an ellipse within the bounding rectangle defined by its top-left corner at (\a x, \ y), width \a w and height \a h,
- and adds it to the path as a closed subpath.
+ Creates an ellipse within the bounding rectangle defined by its top-left
+ corner at (\a x, \a y), width \a w and height \a h, and adds it to the
+ path as a closed subpath.
- The ellipse is composed of a clockwise curve, starting and finishing at zero degrees (the 3 o'clock position).
+ The ellipse is composed of a clockwise curve, starting and finishing at
+ zero degrees (the 3 o'clock position).
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2686,8 +2705,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(const QV4::Functio
/*!
\qmlmethod object QtQuick::Context2D::text(string text, real x, real y)
- Adds the given \c text to the path as a set of closed subpaths created from the current context font supplied.
- The subpaths are positioned so that the left end of the text's baseline lies at the point specified by (\c x, \c y).
+ Adds the given \a text to the path as a set of closed subpaths created
+ from the current context font supplied.
+
+ The subpaths are positioned so that the left end of the text's baseline
+ lies at the point specified by (\a x, \a y).
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -2712,9 +2734,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(const QV4::FunctionOb
Strokes the subpaths with the current stroke style.
- See \l{http://www.w3.org/TR/2dcontext/#dom-context-2d-stroke}{W3C 2d context standard for stroke}
-
- \sa strokeStyle
+ \sa strokeStyle, {http://www.w3.org/TR/2dcontext/#dom-context-2d-stroke}{W3C 2d context standard for stroke}
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)
{
@@ -2730,7 +2750,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(const QV4::Function
/*!
\qmlmethod object QtQuick::Context2D::isPointInPath(real x, real y)
- Returns true if the given point is in the current path.
+ Returns \c true if the point (\a x, \a y) is in the current path.
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-ispointinpath}{W3C 2d context standard for isPointInPath}
*/
@@ -2948,7 +2968,9 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(const QV4::Functio
/*!
\qmlmethod object QtQuick::Context2D::fillText(text, x, y)
- Fills the given text at the given position.
+
+ Fills the specified \a text at the given position (\a x, \a y).
+
\sa font
\sa textAlign
\sa textBaseline
@@ -2972,13 +2994,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(const QV4::Functi
RETURN_RESULT(*thisObject);
}
/*!
- \qmlmethod object QtQuick::Context2D::strokeText(text, x, y)
- Strokes the given text at the given position.
- \sa font
- \sa textAlign
- \sa textBaseline
- \sa fillText
- */
+ \qmlmethod object QtQuick::Context2D::strokeText(text, x, y)
+
+ Strokes the given \a text at a position specified by (\a x, \a y).
+
+ \sa font
+ \sa textAlign
+ \sa textBaseline
+ \sa fillText
+*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
QV4::Scope scope(b);
@@ -3414,8 +3438,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(const QV4:
}
/*!
- \qmlmethod CanvasImageData QtQuick::Context2D::getImageData(real sx, real sy, real sw, real sh)
- Returns an CanvasImageData object containing the image data for the given rectangle of the canvas.
+ \qmlmethod CanvasImageData QtQuick::Context2D::getImageData(real x, real y, real w, real h)
+
+ Returns an CanvasImageData object containing the image data for the canvas
+ rectangle specified by (\a x, \a y, \a w, \a h).
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -3441,8 +3467,13 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(const QV4::Fu
}
/*!
- \qmlmethod object QtQuick::Context2D::putImageData(CanvasImageData imageData, real dx, real dy, real dirtyX, real dirtyY, real dirtyWidth, real dirtyHeight)
- Paints the data from the given ImageData object onto the canvas. If a dirty rectangle (\a dirtyX, \a dirtyY, \a dirtyWidth, \a dirtyHeight) is provided, only the pixels from that rectangle are painted.
+ \qmlmethod object QtQuick::Context2D::putImageData(CanvasImageData imageData, real dx, real dy, real dirtyX, real dirtyY, real dirtyWidth, real dirtyHeight)
+
+ Paints the data from the given \a imageData object onto the canvas at
+ (\a dx, \a dy).
+
+ If a dirty rectangle (\a dirtyX, \a dirtyY, \a dirtyWidth, \a dirtyHeight)
+ is provided, only the pixels from that rectangle are painted.
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
@@ -3535,16 +3566,18 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(const QV4::Fu
*/
/*!
- \qmlmethod CanvasGradient QtQuick::CanvasGradient::addColorStop(real offsetof, string color)
- Adds a color stop with the given color to the gradient at the given offset.
- 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end.
+ \qmlmethod CanvasGradient QtQuick::CanvasGradient::addColorStop(real offset, string color)
- For example:
- \code
- var gradient = ctx.createLinearGradient(0, 0, 100, 100);
- gradient.addColorStop(0.3, Qt.rgba(1, 0, 0, 1));
- gradient.addColorStop(0.7, 'rgba(0, 255, 255, 1');
- \endcode
+ Adds a color stop with the given \a color to the gradient at the given \a offset.
+ 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end.
+
+ For example:
+
+ \code
+ var gradient = ctx.createLinearGradient(0, 0, 100, 100);
+ gradient.addColorStop(0.3, Qt.rgba(1, 0, 0, 1));
+ gradient.addColorStop(0.7, 'rgba(0, 255, 255, 1');
+ \endcode
*/
QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
{
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp
index bebefc1b22..18d492cd68 100644
--- a/src/quick/items/qquickanimatedimage.cpp
+++ b/src/quick/items/qquickanimatedimage.cpp
@@ -140,6 +140,7 @@ QQuickAnimatedImage::QQuickAnimatedImage(QQuickItem *parent)
{
connect(this, &QQuickImageBase::cacheChanged, this, &QQuickAnimatedImage::onCacheChanged);
connect(this, &QQuickImageBase::currentFrameChanged, this, &QQuickAnimatedImage::frameChanged);
+ connect(this, &QQuickImageBase::currentFrameChanged, this, &QQuickAnimatedImage::currentFrameChanged);
connect(this, &QQuickImageBase::frameCountChanged, this, &QQuickAnimatedImage::frameCountChanged);
}
@@ -466,7 +467,7 @@ void QQuickAnimatedImage::movieUpdate()
if (d->movie) {
d->setPixmap(*d->infoForCurrentFrame(qmlEngine(this)));
- emit currentFrameChanged();
+ emit QQuickImageBase::currentFrameChanged();
}
}
diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h
index d18e7c43c7..7f2199fd2a 100644
--- a/src/quick/items/qquickanimatedimage_p.h
+++ b/src/quick/items/qquickanimatedimage_p.h
@@ -102,6 +102,7 @@ Q_SIGNALS:
void playingChanged();
void pausedChanged();
void frameChanged();
+ void currentFrameChanged();
void frameCountChanged();
Q_REVISION(11) void speedChanged();
diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp
index 430fa1b094..462a44634e 100644
--- a/src/quick/items/qquickborderimage.cpp
+++ b/src/quick/items/qquickborderimage.cpp
@@ -327,7 +327,7 @@ void QQuickBorderImage::load()
QNetworkRequest req(d->url);
d->sciReply = qmlEngine(this)->networkAccessManager()->get(req);
qmlobject_connect(d->sciReply, QNetworkReply, SIGNAL(finished()),
- this, QQuickBorderImage, SLOT(sciRequestFinished()))
+ this, QQuickBorderImage, SLOT(sciRequestFinished()));
#endif
}
} else {
diff --git a/src/quick/items/qquickborderimage_p_p.h b/src/quick/items/qquickborderimage_p_p.h
index 0f4e7acc05..17dab7d121 100644
--- a/src/quick/items/qquickborderimage_p_p.h
+++ b/src/quick/items/qquickborderimage_p_p.h
@@ -86,7 +86,7 @@ public:
if (!border) {
border = new QQuickScaleGrid(q);
qmlobject_connect(border, QQuickScaleGrid, SIGNAL(borderChanged()),
- q, QQuickBorderImage, SLOT(doUpdate()))
+ q, QQuickBorderImage, SLOT(doUpdate()));
}
return border;
}
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index 4840333923..ff4d9b0fd1 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -754,7 +754,11 @@ void QQuickDragAttached::cancel()
This signal is emitted when a drag finishes and the drag was started with the
\l startDrag() method or started automatically using the \l dragType property.
+ \a dropAction holds the action accepted by the target item.
+
The corresponding handler is \c onDragFinished.
+
+ \sa drop()
*/
Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedActions)
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index f96d6b6244..76be8cc261 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -211,7 +211,7 @@ qreal QQuickDropAreaDrag::y() const
/*!
\qmlsignal QtQuick::DropArea::positionChanged(DragEvent drag)
- This signal is emitted when the position of a drag has changed.
+ This signal is emitted when the position of a \a drag has changed.
The corresponding handler is \c onPositionChanged.
*/
@@ -313,7 +313,7 @@ void QQuickDropArea::dragLeaveEvent(QDragLeaveEvent *)
/*!
\qmlsignal QtQuick::DropArea::dropped(DragEvent drop)
- This signal is emitted when a drop event occurs within the bounds of
+ This signal is emitted when a \a drop event occurs within the bounds of
a DropArea.
The corresponding handler is \c onDropped.
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index b0cfbaad6d..7d51a55a0c 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -41,6 +41,7 @@
#include <QtCore/qmap.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qtouchdevice_p.h>
+#include <QtGui/private/qevent_p.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickpointerhandler_p.h>
#include <QtQuick/private/qquickwindow_p.h>
@@ -1828,6 +1829,7 @@ QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(QQuickItem *item, bool i
// but that would require changing tst_qquickwindow::touchEvent_velocity(): it expects transformed velocity
bool anyPressOrReleaseInside = false;
+ bool anyStationaryWithModifiedPropertyInside = false;
bool anyGrabber = false;
QMatrix4x4 transformMatrix(QQuickItemPrivate::get(item)->windowToItemTransform());
for (int i = 0; i < m_pointCount; ++i) {
@@ -1860,6 +1862,8 @@ QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(QQuickItem *item, bool i
anyPressOrReleaseInside = true;
const QTouchEvent::TouchPoint *tp = touchPointById(p->pointId());
if (tp) {
+ if (isInside && tp->d->stationaryWithModifiedProperty)
+ anyStationaryWithModifiedPropertyInside = true;
eventStates |= tp->state();
QTouchEvent::TouchPoint tpCopy = *tp;
tpCopy.setPos(item->mapFromScene(tpCopy.scenePos()));
@@ -1873,7 +1877,8 @@ QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(QQuickItem *item, bool i
// Now touchPoints will have only points which are inside the item.
// But if none of them were just pressed inside, and the item has no other reason to care, ignore them anyway.
- if (eventStates == Qt::TouchPointStationary || touchPoints.isEmpty() || (!anyPressOrReleaseInside && !anyGrabber && !isFiltering))
+ if ((eventStates == Qt::TouchPointStationary && !anyStationaryWithModifiedPropertyInside) ||
+ touchPoints.isEmpty() || (!anyPressOrReleaseInside && !anyGrabber && !isFiltering))
return nullptr;
// if all points have the same state, set the event type accordingly
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index cf3cd9f48e..d9ec7de611 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -266,9 +266,9 @@ void QQuickFlickablePrivate::init()
QQml_setParent_noEvent(contentItem, q);
contentItem->setParentItem(q);
qmlobject_connect(&timeline, QQuickTimeLine, SIGNAL(completed()),
- q, QQuickFlickable, SLOT(timelineCompleted()))
+ q, QQuickFlickable, SLOT(timelineCompleted()));
qmlobject_connect(&velocityTimeline, QQuickTimeLine, SIGNAL(completed()),
- q, QQuickFlickable, SLOT(velocityTimelineCompleted()))
+ q, QQuickFlickable, SLOT(velocityTimelineCompleted()));
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setAcceptTouchEvents(false); // rely on mouse events synthesized from touch
q->setFiltersChildMouseEvents(true);
diff --git a/src/quick/items/qquickflickablebehavior_p.h b/src/quick/items/qquickflickablebehavior_p.h
index ae7fe71359..fbce62f075 100644
--- a/src/quick/items/qquickflickablebehavior_p.h
+++ b/src/quick/items/qquickflickablebehavior_p.h
@@ -93,6 +93,11 @@
#define QML_FLICK_MULTIFLICK_THRESHOLD 1250
#endif
+// If the time (ms) between the last move and the release exceeds this, then velocity will be zero.
+#ifndef QML_FLICK_VELOCITY_DECAY_TIME
+#define QML_FLICK_VELOCITY_DECAY_TIME 50
+#endif
+
// Multiflick acceleration minimum contentSize/viewSize ratio
#ifndef QML_FLICK_MULTIFLICK_RATIO
#define QML_FLICK_MULTIFLICK_RATIO 10
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index fecfa5fd2d..e69e9cff46 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -1761,7 +1761,7 @@ void QQuickGridView::setSnapMode(SnapMode mode)
\list
\li The view is first created
- \li The view's \l model changes
+ \li The view's \l model changes in such a way that the visible delegates are completely replaced
\li The view's \l model is \l {QAbstractItemModel::reset()}{reset}, if the model is a QAbstractItemModel subclass
\endlist
@@ -1779,6 +1779,28 @@ void QQuickGridView::setSnapMode(SnapMode mode)
When the view is initialized, the view will create all the necessary items for the view,
then animate them to their correct positions within the view over one second.
+ However when scrolling the view later, the populate transition does not
+ run, even though delegates are being instantiated as they become visible.
+ When the model changes in a way that new delegates become visible, the
+ \l add transition is the one that runs. So you should not depend on the
+ \c populate transition to initialize properties in the delegate, because it
+ does not apply to every delegate. If your animation sets the \c to value of
+ a property, the property should initially have the \c to value, and the
+ animation should set the \c from value in case it is animated:
+
+ \code
+ GridView {
+ ...
+ delegate: Rectangle {
+ opacity: 1 // not necessary because it's the default; but don't set 0
+ ...
+ }
+ populate: Transition {
+ NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 1000 }
+ }
+ }
+ \endcode
+
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 52a1d59e77..796ab6cdd7 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -5083,7 +5083,7 @@ QQuickStateGroup *QQuickItemPrivate::_states()
if (!componentComplete)
_stateGroup->classBegin();
qmlobject_connect(_stateGroup, QQuickStateGroup, SIGNAL(stateChanged(QString)),
- q, QQuickItem, SIGNAL(stateChanged(QString)))
+ q, QQuickItem, SIGNAL(stateChanged(QString)));
}
return _stateGroup;
@@ -5686,6 +5686,7 @@ void QQuickItem::setRotation(qreal r)
color: "red"
x: 25; y: 25; width: 50; height: 50
scale: 1.4
+ transformOrigin: Item.TopLeft
}
}
\endqml
@@ -8489,7 +8490,7 @@ void QQuickItemLayer::setMipmap(bool mipmap)
\note ShaderEffectSource.RGB and ShaderEffectSource.Alpha should
be used with caution, as support for these formats in the underlying
- hardare and driver is often not present.
+ hardware and driver is often not present.
\sa {Item Layers}
*/
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 6da197c4d0..f7943630c4 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -245,7 +245,6 @@ static void qt_quickitems_defineModule()
// events
qmlRegisterTypesAndRevisions<
QQuickCloseEvent,
- QQuickDropEvent,
QQuickGrabGestureEvent,
QQuickKeyEvent,
QQuickMouseEvent,
@@ -278,7 +277,7 @@ static void qt_quickitems_defineModule()
qmlRegisterTypesAndRevisions<QQuickAnimatedImage>(uri, major);
#else
qmlRegisterTypeNotAvailable(
- uri, major, minor, "AnimatedImage",
+ uri, major, 15, "AnimatedImage",
QCoreApplication::translate("QQuickAnimatedImage",
"Qt was built without support for QMovie"));
#endif
@@ -289,6 +288,7 @@ static void qt_quickitems_defineModule()
#if QT_CONFIG(quick_draganddrop)
qmlRegisterTypesAndRevisions<
+ QQuickDropEvent,
QQuickDrag,
QQuickDropArea,
QQuickDropAreaDrag,
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 95a36ab4d4..725d35f325 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -2744,7 +2744,7 @@ void QQuickListView::setFooterPositioning(QQuickListView::FooterPositioning posi
\list
\li The view is first created
- \li The view's \l model changes
+ \li The view's \l model changes in such a way that the visible delegates are completely replaced
\li The view's \l model is \l {QAbstractItemModel::reset()}{reset}, if the model is a QAbstractItemModel subclass
\endlist
@@ -2762,6 +2762,27 @@ void QQuickListView::setFooterPositioning(QQuickListView::FooterPositioning posi
When the view is initialized, the view will create all the necessary items for the view,
then animate them to their correct positions within the view over one second.
+ However when scrolling the view later, the populate transition does not
+ run, even though delegates are being instantiated as they become visible.
+ When the model changes in a way that new delegates become visible, the
+ \l add transition is the one that runs. So you should not depend on the
+ \c populate transition to initialize properties in the delegate, because it
+ does not apply to every delegate. If your animation sets the \c to value of
+ a property, the property should initially have the \c to value, and the
+ animation should set the \c from value in case it is animated:
+
+ \code
+ ListView {
+ ...
+ delegate: Rectangle {
+ opacity: 1 // not necessary because it's the default
+ }
+ populate: Transition {
+ NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 1000 }
+ }
+ }
+ \endcode
+
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index a8f09dc8be..ddf34798d7 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -431,7 +431,7 @@ bool QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent *ev, QQuickItem *i
This signal is emitted in response to both mouse wheel and trackpad scroll gestures.
- The \l {WheelEvent}{wheel} parameter provides information about the event, including the x and y
+ The \a wheel parameter provides information about the event, including the x and y
position, any buttons currently pressed, and information about the wheel movement, including
angleDelta and pixelDelta.
@@ -1069,7 +1069,7 @@ void QQuickMouseArea::itemChange(ItemChange change, const ItemChangeData &value)
Q_D(QQuickMouseArea);
switch (change) {
case ItemVisibleHasChanged:
- if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) {
+ if (d->effectiveEnable && d->enabled && acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) {
if (!d->hovered) {
QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition;
d->lastScenePos = d->window->mapFromGlobal(cursorPos.toPoint());
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index 3eca535a67..b02e58fae4 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -40,6 +40,7 @@
#include "qquickmultipointtoucharea_p.h"
#include <QtQuick/qquickwindow.h>
#include <private/qsgadaptationlayer_p.h>
+#include <private/qevent_p.h>
#include <private/qquickitem_p.h>
#include <private/qguiapplication_p.h>
#include <QEvent>
@@ -410,7 +411,7 @@ void QQuickTouchPoint::setUniqueId(const QPointingDeviceUniqueId &id)
area should grab the current touch points. By default they will not be grabbed; to grab them call \c gesture.grab(). If the
gesture is not grabbed, the nesting Flickable, for example, would also have an opportunity to grab.
- The gesture object also includes information on the current set of \c touchPoints and the \c dragThreshold.
+ The \a gesture object also includes information on the current set of \c touchPoints and the \c dragThreshold.
The corresponding handler is \c onGestureStarted.
*/
@@ -655,7 +656,8 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event)
// (we may have just obtained enough points to start tracking them -- in that case moved or stationary count as newly pressed)
addTouchPoint(&p);
started = true;
- } else if (touchPointState & Qt::TouchPointMoved) {
+ } else if ((touchPointState & Qt::TouchPointMoved) || p.d->stationaryWithModifiedProperty) {
+ // React to a stationary point with a property change (velocity, pressure) as if the point moved. (QTBUG-77142)
QQuickTouchPoint* dtp = static_cast<QQuickTouchPoint*>(_touchPoints.value(id));
Q_ASSERT(dtp);
_movedTouchPoints.append(dtp);
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 4e81573356..6976665134 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -60,8 +60,9 @@
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateLifecycle)
+Q_LOGGING_CATEGORY(lcPathView, "qt.quick.pathview")
-const qreal MinimumFlickVelocity = 75.0;
+static const qreal MinimumFlickVelocity = 75;
static QQmlOpenMetaObjectType *qPathViewAttachedType = nullptr;
@@ -90,8 +91,8 @@ void QQuickPathViewAttached::setValue(const QByteArray &name, const QVariant &va
}
QQuickPathViewPrivate::QQuickPathViewPrivate()
- : path(nullptr), currentIndex(0), currentItemOffset(0.0), startPc(0)
- , offset(0.0), offsetAdj(0.0), mappedRange(1.0), mappedCache(0.0)
+ : path(nullptr), currentIndex(0), currentItemOffset(0), startPc(0)
+ , offset(0), offsetAdj(0), mappedRange(1), mappedCache(0)
, stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
, autoHighlight(true), highlightUp(false), layoutScheduled(false)
, moving(false), flicking(false), dragging(false), inRequest(false), delegateValidated(false)
@@ -117,10 +118,10 @@ void QQuickPathViewPrivate::init()
q->setFlag(QQuickItem::ItemIsFocusScope);
q->setFiltersChildMouseEvents(true);
qmlobject_connect(&tl, QQuickTimeLine, SIGNAL(updated()),
- q, QQuickPathView, SLOT(ticked()))
+ q, QQuickPathView, SLOT(ticked()));
timer.invalidate();
qmlobject_connect(&tl, QQuickTimeLine, SIGNAL(completed()),
- q, QQuickPathView, SLOT(movementEnding()))
+ q, QQuickPathView, SLOT(movementEnding()));
}
QQuickItem *QQuickPathViewPrivate::getItem(int modelIndex, qreal z, bool async)
@@ -163,7 +164,7 @@ void QQuickPathView::createdItem(int index, QObject *object)
att->setOnPath(false);
}
item->setParentItem(this);
- d->updateItem(item, 1.0);
+ d->updateItem(item, 1);
} else {
d->requestedIndex = -1;
if (!d->inRequest)
@@ -184,13 +185,13 @@ void QQuickPathView::initItem(int index, QObject *object)
if (att) {
att->m_view = this;
qreal percent = d->positionOfIndex(index);
- if (percent < 1.0 && d->path) {
+ if (percent < 1 && d->path) {
const auto attributes = d->path->attributes();
for (const QString &attr : attributes)
att->setValue(attr.toUtf8(), d->path->attributeAt(attr, percent));
item->setZ(d->requestedZ);
}
- att->setOnPath(percent < 1.0);
+ att->setOnPath(percent < 1);
}
}
}
@@ -264,17 +265,17 @@ void QQuickPathViewPrivate::updateMappedRange()
mappedRange = qreal(modelCount)/pathItems;
mappedCache = qreal(cacheSize)/pathItems/2; // Half of cache at each end
} else {
- mappedRange = 1.0;
- mappedCache = 0.0;
+ mappedRange = 1;
+ mappedCache = 0;
}
}
qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const
{
- qreal pos = -1.0;
+ qreal pos = -1;
if (model && index >= 0 && index < modelCount) {
- qreal start = 0.0;
+ qreal start = 0;
if (haveHighlightRange && (highlightRangeMode != QQuickPathView::NoHighlightRange
|| snapMode != QQuickPathView::NoSnap))
start = highlightRangeStart;
@@ -282,10 +283,10 @@ qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const
globalPos = std::fmod(globalPos, qreal(modelCount)) / modelCount;
if (pathItems != -1 && pathItems < modelCount) {
globalPos += start / mappedRange;
- globalPos = std::fmod(globalPos, qreal(1.0));
+ globalPos = std::fmod(globalPos, qreal(1));
pos = globalPos * mappedRange;
} else {
- pos = std::fmod(globalPos + start, qreal(1.0));
+ pos = std::fmod(globalPos + start, qreal(1));
}
}
@@ -296,7 +297,7 @@ qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const
// account the circular space.
bool QQuickPathViewPrivate::isInBound(qreal position, qreal lower, qreal upper) const
{
- if (lower == upper)
+ if (qFuzzyCompare(lower, upper))
return true;
if (lower > upper) {
if (position > upper && position > lower)
@@ -358,7 +359,7 @@ void QQuickPathViewPrivate::updateHighlight()
} else {
qreal target = currentIndex;
- offsetAdj = 0.0;
+ offsetAdj = 0;
tl.reset(moveHighlight);
moveHighlight.setValue(highlightPosition);
@@ -367,14 +368,14 @@ void QQuickPathViewPrivate::updateHighlight()
if (target - highlightPosition > modelCount/2) {
highlightUp = false;
qreal distance = modelCount - target + highlightPosition;
- tl.move(moveHighlight, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * highlightPosition / distance));
+ tl.move(moveHighlight, 0, QEasingCurve(QEasingCurve::InQuad), int(duration * highlightPosition / distance));
tl.set(moveHighlight, modelCount-0.01);
tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * (modelCount-target) / distance));
} else if (target - highlightPosition <= -modelCount/2) {
highlightUp = true;
qreal distance = modelCount - highlightPosition + target;
tl.move(moveHighlight, modelCount-0.01, QEasingCurve(QEasingCurve::InQuad), int(duration * (modelCount-highlightPosition) / distance));
- tl.set(moveHighlight, 0.0);
+ tl.set(moveHighlight, 0);
tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * target / distance));
} else {
highlightUp = highlightPosition - target < 0;
@@ -386,9 +387,9 @@ void QQuickPathViewPrivate::updateHighlight()
void QQuickPathViewPrivate::setHighlightPosition(qreal pos)
{
- if (pos != highlightPosition) {
- qreal start = 0.0;
- qreal end = 1.0;
+ if (!(qFuzzyCompare(pos, highlightPosition))) {
+ qreal start = 0;
+ qreal end = 1;
if (haveHighlightRange && highlightRangeMode != QQuickPathView::NoHighlightRange) {
start = highlightRangeStart;
end = highlightRangeEnd;
@@ -399,7 +400,7 @@ void QQuickPathViewPrivate::setHighlightPosition(qreal pos)
qreal relativeHighlight = std::fmod(pos + offset, range) / range;
if (!highlightUp && relativeHighlight > end / mappedRange) {
- qreal diff = 1.0 - relativeHighlight;
+ qreal diff = 1 - relativeHighlight;
setOffset(offset + diff * range);
} else if (highlightUp && relativeHighlight >= (end - start) / mappedRange) {
qreal diff = relativeHighlight - (end - start) / mappedRange;
@@ -410,7 +411,7 @@ void QQuickPathViewPrivate::setHighlightPosition(qreal pos)
qreal pathPos = positionOfIndex(pos);
updateItem(highlightItem, pathPos);
if (QQuickPathViewAttached *att = attached(highlightItem))
- att->setOnPath(pathPos < 1.0);
+ att->setOnPath(pathPos < 1);
}
}
@@ -435,10 +436,10 @@ void QQuickPathViewPrivate::updateItem(QQuickItem *item, qreal percent)
const auto attributes = path->attributes();
for (const QString &attr : attributes)
att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
- att->setOnPath(percent < 1.0);
+ att->setOnPath(percent < 1);
}
- QQuickItemPrivate::get(item)->setCulled(percent >= 1.0);
- QPointF pf = path->pointAtPercent(qMin(percent, qreal(1.0)));
+ QQuickItemPrivate::get(item)->setCulled(percent >= 1);
+ QPointF pf = path->pointAtPercent(qMin(percent, qreal(1)));
item->setX(pf.x() - item->width()/2);
item->setY(pf.y() - item->height()/2);
}
@@ -668,7 +669,7 @@ void QQuickPathView::setModel(const QVariant &m)
d->currentIndex = 0;
emit currentIndexChanged();
}
- if (d->offset != 0.0) {
+ if (!(qFuzzyIsNull(d->offset))) {
d->offset = 0;
emit offsetChanged();
}
@@ -820,7 +821,7 @@ void QQuickPathView::decrementCurrentIndex()
\qmlproperty real QtQuick::PathView::offset
The offset specifies how far along the path the items are from their initial positions.
- This is a real number that ranges from 0.0 to the count of items in the model.
+ This is a real number that ranges from \c 0 to the count of items in the model.
*/
qreal QQuickPathView::offset() const
{
@@ -839,7 +840,7 @@ void QQuickPathView::setOffset(qreal offset)
void QQuickPathViewPrivate::setOffset(qreal o)
{
Q_Q(QQuickPathView);
- if (offset != o) {
+ if (!qFuzzyCompare(offset, o)) {
if (isValid() && q->isComponentComplete()) {
qreal oldOffset = offset;
offset = std::fmod(o, qreal(modelCount));
@@ -882,7 +883,6 @@ void QQuickPathViewPrivate::setAdjustedOffset(qreal o)
\sa highlightItem, highlightRangeMode
*/
-
QQmlComponent *QQuickPathView::highlight() const
{
Q_D(const QQuickPathView);
@@ -901,25 +901,26 @@ void QQuickPathView::setHighlight(QQmlComponent *highlight)
}
/*!
- \qmlproperty Item QtQuick::PathView::highlightItem
+ \qmlproperty Item QtQuick::PathView::highlightItem
- \c highlightItem holds the highlight item, which was created
- from the \l highlight component.
+ \c highlightItem holds the highlight item, which was created
+ from the \l highlight component.
- \sa highlight
+ \sa highlight
*/
QQuickItem *QQuickPathView::highlightItem() const
{
Q_D(const QQuickPathView);
return d->highlightItem;
}
+
/*!
\qmlproperty real QtQuick::PathView::preferredHighlightBegin
\qmlproperty real QtQuick::PathView::preferredHighlightEnd
\qmlproperty enumeration QtQuick::PathView::highlightRangeMode
These properties set the preferred range of the highlight (current item)
- within the view. The preferred values must be in the range 0.0-1.0.
+ within the view. The preferred values must be in the range from \c 0 to \c 1.
Valid values for \c highlightRangeMode are:
@@ -960,7 +961,7 @@ qreal QQuickPathView::preferredHighlightBegin() const
void QQuickPathView::setPreferredHighlightBegin(qreal start)
{
Q_D(QQuickPathView);
- if (d->highlightRangeStart == start || start < 0 || start > 1.0)
+ if (qFuzzyCompare(d->highlightRangeStart, start) || start < 0 || start > 1)
return;
d->highlightRangeStart = start;
d->haveHighlightRange = d->highlightRangeStart <= d->highlightRangeEnd;
@@ -977,7 +978,7 @@ qreal QQuickPathView::preferredHighlightEnd() const
void QQuickPathView::setPreferredHighlightEnd(qreal end)
{
Q_D(QQuickPathView);
- if (d->highlightRangeEnd == end || end < 0 || end > 1.0)
+ if (qFuzzyCompare(d->highlightRangeEnd, end) || end < 0 || end > 1)
return;
d->highlightRangeEnd = end;
d->haveHighlightRange = d->highlightRangeStart <= d->highlightRangeEnd;
@@ -1048,7 +1049,7 @@ qreal QQuickPathView::dragMargin() const
void QQuickPathView::setDragMargin(qreal dragMargin)
{
Q_D(QQuickPathView);
- if (d->dragMargin == dragMargin)
+ if (qFuzzyCompare(d->dragMargin, dragMargin))
return;
d->dragMargin = dragMargin;
emit dragMarginChanged();
@@ -1069,7 +1070,7 @@ qreal QQuickPathView::flickDeceleration() const
void QQuickPathView::setFlickDeceleration(qreal dec)
{
Q_D(QQuickPathView);
- if (d->deceleration == dec)
+ if (qFuzzyCompare(d->deceleration, dec))
return;
d->deceleration = dec;
emit flickDecelerationChanged();
@@ -1090,7 +1091,7 @@ qreal QQuickPathView::maximumFlickVelocity() const
void QQuickPathView::setMaximumFlickVelocity(qreal vel)
{
Q_D(QQuickPathView);
- if (vel == d->maximumFlickVelocity)
+ if (qFuzzyCompare(vel, d->maximumFlickVelocity))
return;
d->maximumFlickVelocity = vel;
emit maximumFlickVelocityChanged();
@@ -1580,7 +1581,7 @@ QQuickItem *QQuickPathView::itemAtIndex(int index) const
QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
{
const auto pathLength = path->path().length();
- qreal samples = qMin(pathLength / 5, qreal(500.0));
+ qreal samples = qMin(pathLength / 5, qreal(500));
qreal res = pathLength / samples;
qreal mindist = 1e10; // big number
@@ -1601,7 +1602,7 @@ QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercen
// now refine
qreal approxPc = nearPc;
- for (qreal i = approxPc-1.0; i < approxPc+1.0; i += 1/(2*res)) {
+ for (qreal i = approxPc-1; i < approxPc+1; i += 1/(2*res)) {
QPointF pt = path->pointAtPercent(i/samples);
QPointF diff = pt - point;
qreal dist = diff.x()*diff.x() + diff.y()*diff.y();
@@ -1623,6 +1624,7 @@ void QQuickPathViewPrivate::addVelocitySample(qreal v)
velocityBuffer.append(v);
if (velocityBuffer.count() > QML_FLICK_SAMPLEBUFFER)
velocityBuffer.remove(0);
+ qCDebug(lcPathView) << "instantaneous velocity" << v;
}
qreal QQuickPathViewPrivate::calcVelocity() const
@@ -1635,6 +1637,7 @@ qreal QQuickPathViewPrivate::calcVelocity() const
velocity += v;
}
velocity /= count;
+ qCDebug(lcPathView) << "average velocity" << velocity << "based on" << count << "samples";
}
return velocity;
}
@@ -1642,7 +1645,7 @@ qreal QQuickPathViewPrivate::calcVelocity() const
qint64 QQuickPathViewPrivate::computeCurrentTime(QInputEvent *event) const
{
if (0 != event->timestamp())
- return event->timestamp();
+ return qint64(event->timestamp());
return timer.elapsed();
}
@@ -1669,7 +1672,7 @@ void QQuickPathViewPrivate::handleMousePressEvent(QMouseEvent *event)
if (item->contains(item->mapFromScene(event->windowPos())))
break;
}
- if (idx == items.count() && dragMargin == 0.) // didn't click on an item
+ if (idx == items.count() && qFuzzyIsNull(dragMargin)) // didn't click on an item
return;
startPoint = pointNear(event->localPos(), &startPc);
@@ -1680,11 +1683,12 @@ void QQuickPathViewPrivate::handleMousePressEvent(QMouseEvent *event)
return;
}
-
- if (tl.isActive() && flicking && flickDuration && qreal(tl.time())/flickDuration < 0.8)
+ if (tl.isActive() && flicking && flickDuration && qreal(tl.time()) / flickDuration < 0.8) {
stealMouse = true; // If we've been flicked then steal the click.
- else
+ q->grabMouse(); // grab it right now too, just to be sure (QTBUG-77173)
+ } else {
stealMouse = false;
+ }
q->setKeepMouseGrab(stealMouse);
timer.start();
@@ -1730,7 +1734,7 @@ void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event)
moveReason = QQuickPathViewPrivate::Mouse;
int count = pathItems == -1 ? modelCount : qMin(pathItems, modelCount);
qreal diff = (newPc - startPc)*count;
- if (diff) {
+ if (!qFuzzyIsNull(diff)) {
q->setOffset(offset + diff);
if (diff > modelCount/2)
@@ -1740,7 +1744,7 @@ void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event)
qint64 elapsed = currentTimestamp - lastPosTime;
if (elapsed > 0)
- addVelocitySample(diff / (qreal(elapsed) / 1000.));
+ addVelocitySample(diff / (qreal(elapsed) / 1000));
}
if (!moving) {
moving = true;
@@ -1765,7 +1769,7 @@ void QQuickPathView::mouseReleaseEvent(QMouseEvent *event)
}
}
-void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *)
+void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *event)
{
Q_Q(QQuickPathView);
stealMouse = false;
@@ -1779,6 +1783,12 @@ void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *)
}
qreal velocity = calcVelocity();
+ qint64 elapsed = computeCurrentTime(event) - lastPosTime;
+ // Let the velocity linearly decay such that it becomes 0 if elapsed time > QML_FLICK_VELOCITY_DECAY_TIME
+ // The intention is that if you are flicking at some speed, then stop in one place for some time before releasing,
+ // the previous velocity is lost. (QTBUG-77173, QTBUG-59052)
+ velocity *= qreal(qMax(0LL, QML_FLICK_VELOCITY_DECAY_TIME - elapsed)) / QML_FLICK_VELOCITY_DECAY_TIME;
+ qCDebug(lcPathView) << "after elapsed time" << elapsed << "velocity decayed to" << velocity;
qreal count = pathItems == -1 ? modelCount : qMin(pathItems, modelCount);
const auto averageItemLength = path->path().length() / count;
qreal pixelVelocity = averageItemLength * velocity;
@@ -1796,32 +1806,32 @@ void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *)
|| snapMode != QQuickPathView::NoSnap)) {
if (snapMode == QQuickPathView::SnapOneItem) {
// encourage snapping one item in direction of motion
- if (velocity > 0.)
+ if (velocity > 0)
dist = qRound(0.5 + offset) - offset;
else
dist = qRound(0.5 - offset) + offset;
} else {
// + 0.25 to encourage moving at least one item in the flick direction
- dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0) + 0.25));
+ dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2) + 0.25));
// round to nearest item.
- if (velocity > 0.)
+ if (velocity > 0)
dist = qRound(dist + offset) - offset;
else
dist = qRound(dist - offset) + offset;
}
// Calculate accel required to stop on item boundary
- if (dist <= 0.) {
- dist = 0.;
- accel = 0.;
+ if (dist <= 0) {
+ dist = 0;
+ accel = 0;
} else {
- accel = v2 / (2.0f * qAbs(dist));
+ accel = v2 / (2 * qAbs(dist));
}
} else {
- dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0)));
+ dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2)));
}
- flickDuration = static_cast<int>(1000 * qAbs(velocity) / accel);
- offsetAdj = 0.0;
+ flickDuration = int(1000 * qAbs(velocity) / accel);
+ offsetAdj = 0;
moveOffset.setValue(offset);
tl.accel(moveOffset, velocity, accel, dist);
tl.callback(QQuickTimeLineCallback(&moveOffset, fixOffsetCallback, this));
@@ -1995,7 +2005,7 @@ void QQuickPathView::refill()
else
qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ":" << item;
}
- if (pos < 1.0) {
+ if (pos < 1) {
d->updateItem(item, pos);
if (idx == d->currentIndex) {
currentVisible = true;
@@ -2005,9 +2015,9 @@ void QQuickPathView::refill()
} else {
d->updateItem(item, pos);
if (QQuickPathViewAttached *att = d->attached(item))
- att->setOnPath(pos < 1.0);
- if (!d->isInBound(pos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) {
- qCDebug(lcItemViewDelegateLifecycle) << "release" << idx << "@" << pos << ", !isInBound: lower" << (d->mappedRange - d->mappedCache) << "upper" << (1.0 + d->mappedCache);
+ att->setOnPath(pos < 1);
+ if (!d->isInBound(pos, d->mappedRange - d->mappedCache, 1 + d->mappedCache)) {
+ qCDebug(lcItemViewDelegateLifecycle) << "release" << idx << "@" << pos << ", !isInBound: lower" << (d->mappedRange - d->mappedCache) << "upper" << (1 + d->mappedCache);
d->releaseItem(item);
it = d->items.erase(it);
} else {
@@ -2023,12 +2033,12 @@ void QQuickPathView::refill()
int endIdx = 0;
qreal endPos;
int startIdx = 0;
- qreal startPos = 0.0;
+ qreal startPos = 0;
const bool wasEmpty = d->items.isEmpty();
if (!wasEmpty) {
//Find the beginning and end, items may not be in sorted order
- endPos = -1.0;
- startPos = 2.0;
+ endPos = -1;
+ startPos = 2;
for (QQuickItem * item : qAsConst(d->items)) {
int idx = d->model->indexOf(item, nullptr);
@@ -2057,10 +2067,10 @@ void QQuickPathView::refill()
if (idx >= d->modelCount)
idx = 0;
qreal nextPos = d->positionOfIndex(idx);
- while ((d->isInBound(nextPos, endPos, 1.0 + d->mappedCache) || !d->items.count())
+ while ((d->isInBound(nextPos, endPos, 1 + d->mappedCache) || !d->items.count())
&& d->items.count() < count+d->cacheSize) {
qCDebug(lcItemViewDelegateLifecycle) << "append" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
- QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0);
+ QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1);
if (!item) {
waiting = true;
break;
@@ -2092,7 +2102,7 @@ void QQuickPathView::refill()
while (!waiting && d->isInBound(nextPos, d->mappedRange - d->mappedCache, startPos)
&& d->items.count() < count+d->cacheSize) {
qCDebug(lcItemViewDelegateLifecycle) << "prepend" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
- QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0);
+ QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1);
if (!item) {
waiting = true;
break;
@@ -2125,9 +2135,9 @@ void QQuickPathView::refill()
QQuickItem *lastItem = d->items.at(0);
while (idx != endIdx) {
nextPos = d->positionOfIndex(idx);
- if (d->isInBound(nextPos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) {
+ if (d->isInBound(nextPos, d->mappedRange - d->mappedCache, 1 + d->mappedCache)) {
//This gets the reference from the delegate model, and will not re-create
- QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0);
+ QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1);
if (!item) {
waiting = true;
break;
@@ -2161,13 +2171,13 @@ void QQuickPathView::refill()
bool currentChanged = false;
if (!currentVisible) {
- d->currentItemOffset = 1.0;
+ d->currentItemOffset = 1;
if (d->currentItem) {
- d->updateItem(d->currentItem, 1.0);
+ d->updateItem(d->currentItem, 1);
} else if (!waiting && d->currentIndex >= 0 && d->currentIndex < d->modelCount) {
if ((d->currentItem = d->getItem(d->currentIndex, d->currentIndex))) {
currentChanged = true;
- d->updateItem(d->currentItem, 1.0);
+ d->updateItem(d->currentItem, 1);
if (QQuickPathViewAttached *att = d->attached(d->currentItem))
att->setIsCurrentItem(true);
}
@@ -2361,7 +2371,7 @@ void QQuickPathViewPrivate::createCurrentItem()
}
} else if (currentIndex >= 0 && currentIndex < modelCount) {
if ((currentItem = getItem(currentIndex, currentIndex))) {
- updateItem(currentItem, 1.0);
+ updateItem(currentItem, 1);
if (QQuickPathViewAttached *att = attached(currentItem))
att->setIsCurrentItem(true);
}
@@ -2395,7 +2405,7 @@ void QQuickPathViewPrivate::updateCurrent()
void QQuickPathViewPrivate::fixOffsetCallback(void *d)
{
- ((QQuickPathViewPrivate *)d)->fixOffset();
+ static_cast<QQuickPathViewPrivate *>(d)->fixOffset();
}
void QQuickPathViewPrivate::fixOffset()
@@ -2420,7 +2430,7 @@ void QQuickPathViewPrivate::snapToIndex(int index, MovementReason reason)
qreal targetOffset = std::fmod(qreal(modelCount - index), qreal(modelCount));
moveReason = reason;
- offsetAdj = 0.0;
+ offsetAdj = 0;
tl.reset(moveOffset);
moveOffset.setValue(offset);
@@ -2432,20 +2442,20 @@ void QQuickPathViewPrivate::snapToIndex(int index, MovementReason reason)
if (!duration || qAbs(offset - targetOffset) < threshold || (qFuzzyIsNull(targetOffset) && qAbs(modelCount - offset) < threshold)) {
tl.set(moveOffset, targetOffset);
- } else if (moveDirection == QQuickPathView::Positive || (moveDirection == QQuickPathView::Shortest && targetOffset - offset > modelCount/2.0)) {
+ } else if (moveDirection == QQuickPathView::Positive || (moveDirection == QQuickPathView::Shortest && targetOffset - offset > modelCount/2)) {
qreal distance = modelCount - targetOffset + offset;
if (targetOffset > moveOffset) {
- tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance));
+ tl.move(moveOffset, 0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance));
tl.set(moveOffset, modelCount);
- tl.move(moveOffset, targetOffset, QEasingCurve(offset == 0.0 ? QEasingCurve::InOutQuad : QEasingCurve::OutQuad), int(duration * (modelCount-targetOffset) / distance));
+ tl.move(moveOffset, targetOffset, QEasingCurve(qFuzzyIsNull(offset) ? QEasingCurve::InOutQuad : QEasingCurve::OutQuad), int(duration * (modelCount-targetOffset) / distance));
} else {
tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration);
}
- } else if (moveDirection == QQuickPathView::Negative || targetOffset - offset <= -modelCount/2.0) {
+ } else if (moveDirection == QQuickPathView::Negative || targetOffset - offset <= -modelCount/2) {
qreal distance = modelCount - offset + targetOffset;
if (targetOffset < moveOffset) {
- tl.move(moveOffset, modelCount, QEasingCurve(targetOffset == 0 ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance));
- tl.set(moveOffset, 0.0);
+ tl.move(moveOffset, modelCount, QEasingCurve(qFuzzyIsNull(targetOffset) ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance));
+ tl.set(moveOffset, 0);
tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * targetOffset / distance));
} else {
tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration);
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index 83b3372ed9..addd52cb1d 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -188,8 +188,7 @@ void QQuickRenderControlPrivate::windowDestroyed()
if (window) {
rc->invalidate();
- delete QQuickWindowPrivate::get(window)->animationController;
- QQuickWindowPrivate::get(window)->animationController = nullptr;
+ QQuickWindowPrivate::get(window)->animationController.reset();
#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
if (QOpenGLContext::currentContext())
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index b057fd9d8f..b17e505f4f 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -229,7 +229,8 @@ QT_BEGIN_NAMESPACE
/*!
\qmlattachedmethod int Screen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)
- Returns the rotation angle, in degrees, between the two specified angles.
+ Returns the rotation angle, in degrees, between the specified screen
+ orientations \a a and \a b.
*/
/*!
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 75e0a1018f..95fac30808 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -54,6 +54,7 @@
/*!
\qmltype TableView
\inqmlmodule QtQuick
+ \since 5.12
\ingroup qtquick-views
\inherits Flickable
\brief Provides a table view of items to display data from a model.
@@ -1823,18 +1824,9 @@ void QQuickTableViewPrivate::beginRebuildTable()
void QQuickTableViewPrivate::layoutAfterLoadingInitialTable()
{
- if (rebuildOptions.testFlag(RebuildOption::LayoutOnly)
- || rowHeightProvider.isUndefined() || columnWidthProvider.isUndefined()) {
- // Since we don't have both size providers, we need to calculate the
- // size of each row and column based on the size of the delegate items.
- // This couldn't be done while we were loading the initial rows and
- // columns, since during the process, we didn't have all the items
- // available yet for the calculation. So we do it now. The exception
- // is if we specifically only requested a relayout.
- clearEdgeSizeCache();
- relayoutTableItems();
- syncLoadedTableRectFromLoadedTable();
- }
+ clearEdgeSizeCache();
+ relayoutTableItems();
+ syncLoadedTableRectFromLoadedTable();
if (syncView || rebuildOptions.testFlag(RebuildOption::All)) {
// We try to limit how often we update the content size. The main reason is that is has a
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index 5c4ecd60aa..ab3b0c4605 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -794,8 +794,6 @@ void QQuickTextControl::timerEvent(QTimerEvent *e)
d->cursorOn = !d->cursorOn;
d->repaintCursor();
- } else if (e->timerId() == d->tripleClickTimer.timerId()) {
- d->tripleClickTimer.stop();
}
}
@@ -1058,7 +1056,7 @@ void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &po
commitPreedit();
#endif
- if (tripleClickTimer.isActive()
+ if ((e->timestamp() < (timestampAtLastDoubleClick + QGuiApplication::styleHints()->mouseDoubleClickInterval()))
&& ((pos - tripleClickPoint).toPoint().manhattanLength() < QGuiApplication::styleHints()->startDragDistance())) {
cursor.movePosition(QTextCursor::StartOfBlock);
@@ -1068,7 +1066,7 @@ void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &po
anchorOnMousePress = QString();
- tripleClickTimer.stop();
+ timestampAtLastDoubleClick = 0; // do not enter this condition in case of 4(!) rapid clicks
} else {
int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
if (cursorPos == -1) {
@@ -1267,7 +1265,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin
selectedWordOnDoubleClick = cursor;
tripleClickPoint = pos;
- tripleClickTimer.start(QGuiApplication::styleHints()->mouseDoubleClickInterval(), q);
+ timestampAtLastDoubleClick = e->timestamp();
if (doEmit) {
selectionChanged();
#if QT_CONFIG(clipboard)
diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h
index 5648c31e21..d52200b49d 100644
--- a/src/quick/items/qquicktextcontrol_p_p.h
+++ b/src/quick/items/qquicktextcontrol_p_p.h
@@ -143,7 +143,7 @@ public:
QTextBlock blockWithMarkerUnderMousePress;
QBasicTimer cursorBlinkTimer;
- QBasicTimer tripleClickTimer;
+ ulong timestampAtLastDoubleClick = 0; // will only be set at a double click
#if QT_CONFIG(im)
int preeditCursor;
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 7414d7fd6a..c4e9c0d316 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -1074,7 +1074,7 @@ int QQuickTextEdit::positionAt(qreal x, qreal y) const
}
/*!
- \qmlmethod QtQuick::TextEdit::moveCursorSelection(int position, SelectionMode mode = TextEdit.SelectCharacters)
+ \qmlmethod QtQuick::TextEdit::moveCursorSelection(int position, SelectionMode mode)
Moves the cursor to \a position and updates the selection according to the optional \a mode
parameter. (To only move the cursor, set the \l cursorPosition property.)
@@ -1085,7 +1085,7 @@ int QQuickTextEdit::positionAt(qreal x, qreal y) const
text range.
The selection mode specifies whether the selection is updated on a per character or a per word
- basis. If not specified the selection mode will default to TextEdit.SelectCharacters.
+ basis. If not specified the selection mode will default to \c {TextEdit.SelectCharacters}.
\list
\li TextEdit.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at
@@ -2828,7 +2828,7 @@ QString QQuickTextEdit::getFormattedText(int start, int end) const
/*!
\qmlmethod QtQuick::TextEdit::insert(int position, string text)
- Inserts \a text into the TextEdit at position.
+ Inserts \a text into the TextEdit at \a position.
*/
void QQuickTextEdit::insert(int position, const QString &text)
{
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 598ebb7a68..b1ad6a1c15 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1359,8 +1359,8 @@ void QQuickTextInput::createCursor()
/*!
\qmlmethod rect QtQuick::TextInput::positionToRectangle(int pos)
- This function takes a character position and returns the rectangle that the
- cursor would occupy, if it was placed at that character position.
+ This function takes a character position \a pos and returns the rectangle
+ that the cursor would occupy, if it was placed at that character position.
This is similar to setting the cursorPosition, and then querying the cursor
rectangle, but the cursorPosition is not changed.
@@ -1390,10 +1390,10 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
}
/*!
- \qmlmethod int QtQuick::TextInput::positionAt(real x, real y, CursorPosition position = CursorBetweenCharacters)
+ \qmlmethod int QtQuick::TextInput::positionAt(real x, real y, CursorPosition position)
This function returns the character position at
- x and y pixels from the top left of the textInput. Position 0 is before the
+ \a x and \a y pixels from the top left of the textInput. Position 0 is before the
first character, position 1 is after the first character but before the second,
and so on until position text.length, which is after all characters.
@@ -1403,12 +1403,13 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
the first line and if it is below the text the position of the nearest character
on the last line will be returned.
- The cursor position type specifies how the cursor position should be resolved.
+ The cursor \a position parameter specifies how the cursor position should be resolved:
- \list
- \li TextInput.CursorBetweenCharacters - Returns the position between characters that is nearest x.
- \li TextInput.CursorOnCharacter - Returns the position before the character that is nearest x.
- \endlist
+ \value TextInput.CursorBetweenCharacters
+ Returns the position between characters that is nearest x.
+ This is the default value.
+ \value TextInput.CursorOnCharacter
+ Returns the position before the character that is nearest x.
*/
void QQuickTextInput::positionAt(QQmlV4Function *args) const
@@ -2132,7 +2133,7 @@ void QQuickTextInput::redo()
/*!
\qmlmethod QtQuick::TextInput::insert(int position, string text)
- Inserts \a text into the TextInput at position.
+ Inserts \a text into the TextInput at \a position.
*/
void QQuickTextInput::insert(int position, const QString &text)
@@ -2539,7 +2540,7 @@ void QQuickTextInput::moveCursorSelection(int position)
}
/*!
- \qmlmethod QtQuick::TextInput::moveCursorSelection(int position, SelectionMode mode = TextInput.SelectCharacters)
+ \qmlmethod QtQuick::TextInput::moveCursorSelection(int position, SelectionMode mode)
Moves the cursor to \a position and updates the selection according to the optional \a mode
parameter. (To only move the cursor, set the \l cursorPosition property.)
@@ -2550,7 +2551,7 @@ void QQuickTextInput::moveCursorSelection(int position)
text range.
The selection mode specifies whether the selection is updated on a per character or a per word
- basis. If not specified the selection mode will default to TextInput.SelectCharacters.
+ basis. If not specified the selection mode will default to \c {TextInput.SelectCharacters}.
\list
\li TextInput.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp
index c4a8370f34..7af90f0f8e 100644
--- a/src/quick/items/qquicktextnodeengine.cpp
+++ b/src/quick/items/qquicktextnodeengine.cpp
@@ -781,8 +781,8 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode,
for (int i = 0; i < m_backgrounds.size(); ++i) {
const QRectF &rect = m_backgrounds.at(i).first;
const QColor &color = m_backgrounds.at(i).second;
-
- parentNode->addRectangleNode(rect, color);
+ if (color.alpha() != 0)
+ parentNode->addRectangleNode(rect, color);
}
// Add all text with unselected color first
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index d1f4f49abd..e67d531135 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -424,6 +424,13 @@ void QQuickWindowPrivate::syncSceneGraph()
{
Q_Q(QQuickWindow);
+ // Calculate the dpr the same way renderSceneGraph() will.
+ qreal devicePixelRatio = q->effectiveDevicePixelRatio();
+ if (renderTargetId && !QQuickRenderControl::renderWindowFor(q))
+ devicePixelRatio = 1;
+
+ context->prepareSync(devicePixelRatio);
+
animationController->beforeNodeSync();
emit q->beforeSynchronizing();
@@ -500,10 +507,10 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa
renderer->setDeviceRect(rect);
renderer->setViewportRect(rect);
if (QQuickRenderControl::renderWindowFor(q)) {
- renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size), false);
+ renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
renderer->setDevicePixelRatio(devicePixelRatio);
} else {
- renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size()), false);
+ renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size()));
renderer->setDevicePixelRatio(1);
}
} else {
@@ -520,7 +527,10 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa
renderer->setDeviceRect(rect);
renderer->setViewportRect(rect);
const bool flipY = rhi ? !rhi->isYUpInNDC() : false;
- renderer->setProjectionMatrixToRect(QRectF(QPoint(0, 0), logicalSize), flipY);
+ QSGAbstractRenderer::MatrixTransformFlags matrixFlags = 0;
+ if (flipY)
+ matrixFlags |= QSGAbstractRenderer::MatrixTransformFlipY;
+ renderer->setProjectionMatrixToRect(QRectF(QPoint(0, 0), logicalSize), matrixFlags);
renderer->setDevicePixelRatio(devicePixelRatio);
}
@@ -641,7 +651,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control)
q->setVulkanInstance(QSGRhiSupport::vulkanInstance());
#endif
- animationController = new QQuickAnimatorController(q);
+ animationController.reset(new QQuickAnimatorController(q));
QObject::connect(context, SIGNAL(initialized()), q, SIGNAL(sceneGraphInitialized()), Qt::DirectConnection);
QObject::connect(context, SIGNAL(invalidated()), q, SIGNAL(sceneGraphInvalidated()), Qt::DirectConnection);
@@ -4749,7 +4759,7 @@ void QQuickWindow::resetOpenGLState()
*/
/*!
- \return a pointer to a GraphicsStateInfo struct describing some of the
+ \return a reference to a GraphicsStateInfo struct describing some of the
RHI's internal state, in particular, the double or tripple buffering status
of the backend (such as, the Vulkan or Metal integrations). This is
relevant when the underlying graphics APIs is Vulkan or Metal, and the
@@ -4757,14 +4767,14 @@ void QQuickWindow::resetOpenGLState()
its own often-changing resources, such as, uniform buffers, in order to
avoid stalling the pipeline.
*/
-const QQuickWindow::GraphicsStateInfo *QQuickWindow::graphicsStateInfo()
+const QQuickWindow::GraphicsStateInfo &QQuickWindow::graphicsStateInfo()
{
Q_D(QQuickWindow);
if (d->rhi) {
d->rhiStateInfo.currentFrameSlot = d->rhi->currentFrameSlot();
d->rhiStateInfo.framesInFlight = d->rhi->resourceLimit(QRhi::FramesInFlight);
}
- return &d->rhiStateInfo;
+ return d->rhiStateInfo;
}
/*!
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index db382de459..bec1ace2a6 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -145,10 +145,10 @@ public:
void resetOpenGLState();
#endif
struct GraphicsStateInfo {
- int currentFrameSlot = 0;
- int framesInFlight = 0;
+ int currentFrameSlot;
+ int framesInFlight;
};
- const GraphicsStateInfo *graphicsStateInfo();
+ const GraphicsStateInfo &graphicsStateInfo();
void beginExternalCommands();
void endExternalCommands();
QQmlIncubationController *incubationController() const;
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index 6876662a81..432ed99a53 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -254,7 +254,7 @@ public:
QSGRenderLoop *windowManager;
QQuickRenderControl *renderControl;
- QQuickAnimatorController *animationController;
+ QScopedPointer<QQuickAnimatorController> animationController;
QScopedPointer<QTouchEvent> delayedTouch;
int pointerEventRecursionGuard;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
index f5a41410ee..c97dcb9326 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
@@ -100,7 +100,7 @@ void QSGSoftwareRenderLoop::windowDestroyed(QQuickWindow *window)
rc->invalidate();
}
- delete d->animationController;
+ d->animationController.reset();
}
void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window, bool isNewExpose)
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
index 2d4dcd928d..c6b463bb02 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
@@ -292,7 +292,7 @@ bool QSGSoftwareRenderThread::event(QEvent *e)
QCoreApplication::processEvents();
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
if (wme->destroying)
- delete wd->animationController;
+ wd->animationController.reset();
}
if (wme->destroying)
active = false;
@@ -844,7 +844,8 @@ void QSGSoftwareThreadedRenderLoop::handleExposure(QQuickWindow *window)
if (!w->thread->isRunning()) {
qCDebug(QSG_RASTER_LOG_RENDERLOOP, "starting render thread");
// Push a few things to the render thread.
- QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController;
+ QQuickAnimatorController *controller
+ = QQuickWindowPrivate::get(w->window)->animationController.get();
if (controller->thread() != w->thread)
controller->moveToThread(w->thread);
if (w->thread->thread() == QThread::currentThread()) {
diff --git a/src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp b/src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp
index 679ad1d445..62ed342244 100644
--- a/src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp
@@ -73,6 +73,22 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \enum QSGAbstractRenderer::MatrixTransformFlag
+
+ Used with setProjectionMatrixToRect() to indicate the expectations towards
+ the generated projection matrix.
+
+ \value MatrixTransformFlipY The traditional assumption in Qt Quick is that
+ Y points up in the normalized device coordinate system. There is at least
+ one modern graphics API where this is not the case (Vulkan). This flag can
+ then be used to get a projection that is appropriate for such an API.
+
+ \sa setProjectionMatrixToRect()
+
+ \since 5.14
+ */
+
+/*!
\fn void QSGAbstractRenderer::renderScene(GLuint fboId = 0)
Render the scene to the specified \a fboId
@@ -224,14 +240,38 @@ QRect QSGAbstractRenderer::viewportRect() const
Convenience method that calls setProjectionMatrix() with an
orthographic matrix generated from \a rect.
- \a flipY must be \c true when the graphics API uses Y down in its
- normalized device coordinate system (for example, Vulkan), \c false
- otherwise.
+ \note This function assumes that the graphics API uses Y up in its
+ normalized device coordinate system.
\sa setProjectionMatrix(), projectionMatrix()
*/
-void QSGAbstractRenderer::setProjectionMatrixToRect(const QRectF &rect, bool flipY)
+void QSGAbstractRenderer::setProjectionMatrixToRect(const QRectF &rect)
+{
+ QMatrix4x4 matrix;
+ matrix.ortho(rect.x(),
+ rect.x() + rect.width(),
+ rect.y() + rect.height(),
+ rect.y(),
+ 1,
+ -1);
+ setProjectionMatrix(matrix);
+ setProjectionMatrixWithNativeNDC(matrix);
+}
+
+/*!
+ Convenience method that calls setProjectionMatrix() with an
+ orthographic matrix generated from \a rect.
+
+ Set MatrixTransformFlipY in \a flags when the graphics API uses Y down in
+ its normalized device coordinate system (for example, Vulkan).
+
+ \sa setProjectionMatrix(), projectionMatrix()
+
+ \since 5.14
+ */
+void QSGAbstractRenderer::setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags)
{
+ const bool flipY = flags.testFlag(MatrixTransformFlipY);
QMatrix4x4 matrix;
matrix.ortho(rect.x(),
rect.x() + rect.width(),
diff --git a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h
index 08e600e0b8..1594352dab 100644
--- a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h
+++ b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h
@@ -63,6 +63,13 @@ public:
Q_DECLARE_FLAGS(ClearMode, ClearModeBit)
Q_FLAG(ClearMode)
+ enum MatrixTransformFlag
+ {
+ MatrixTransformFlipY = 0x01
+ };
+ Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag)
+ Q_FLAG(MatrixTransformFlags)
+
~QSGAbstractRenderer() override;
void setRootNode(QSGRootNode *node);
@@ -75,7 +82,8 @@ public:
inline void setViewportRect(const QSize &size) { setViewportRect(QRect(QPoint(), size)); }
QRect viewportRect() const;
- void setProjectionMatrixToRect(const QRectF &rect, bool flipY = false);
+ void setProjectionMatrixToRect(const QRectF &rect);
+ void setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags);
void setProjectionMatrix(const QMatrix4x4 &matrix);
void setProjectionMatrixWithNativeNDC(const QMatrix4x4 &matrix);
QMatrix4x4 projectionMatrix() const;
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index a566a2bed6..9f24bf036b 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -400,14 +400,14 @@ void ShaderManager::clearCachedRendererData()
}
}
-QRhiShaderResourceBindings *ShaderManager::srb(const QVector<QRhiShaderResourceBinding> &bindings)
+QRhiShaderResourceBindings *ShaderManager::srb(const ShaderResourceBindingList &bindings)
{
auto it = srbCache.constFind(bindings);
if (it != srbCache.constEnd())
return *it;
QRhiShaderResourceBindings *srb = context->rhi()->newShaderResourceBindings();
- srb->setBindings(bindings);
+ srb->setBindings(bindings.cbegin(), bindings.cend());
if (srb->build()) {
srbCache.insert(bindings, srb);
} else {
@@ -1123,6 +1123,9 @@ void Renderer::releaseCachedResources()
m_pipelines.clear();
m_samplers.clear();
m_dummyTexture = nullptr;
+
+ if (m_rhi)
+ m_rhi->releaseCachedResources();
}
void Renderer::invalidateAndRecycleBatch(Batch *b)
@@ -2846,8 +2849,10 @@ void Renderer::updateClipState(const QSGClipNode *clipList, Batch *batch) // RHI
else {
if (qsg_topology(g->drawingMode()) != m_stencilClipCommon.topology)
qWarning("updateClipState: Clip list entries have different primitive topologies, this is not currently supported.");
+#if 0 // ### restore once the 5.14 submodule update is done
if (qsg_vertexInputFormat(*a) != m_stencilClipCommon.inputLayout.attributes().first().format())
qWarning("updateClipState: Clip list entries have different vertex input layouts, this is must not happen.");
+#endif
}
#endif
@@ -3250,7 +3255,7 @@ bool Renderer::ensurePipelineState(Element *e, const ShaderManager::Shader *sms)
// Build a new one. This is potentially expensive.
QRhiGraphicsPipeline *ps = m_rhi->newGraphicsPipeline();
- ps->setShaderStages(sms->programRhi.shaderStages);
+ ps->setShaderStages(sms->programRhi.shaderStages.cbegin(), sms->programRhi.shaderStages.cend());
ps->setVertexInputLayout(sms->programRhi.inputLayout);
ps->setShaderResourceBindings(e->srb);
ps->setRenderPassDescriptor(renderPassDescriptor());
@@ -3423,9 +3428,9 @@ static void materialToRendererGraphicsState(GraphicsState *dst,
}
void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
- const QSGMaterialRhiShader::RenderState &renderState,
+ QSGMaterialRhiShader::RenderState &renderState,
QSGMaterial *material,
- QVector<QRhiShaderResourceBinding> *bindings,
+ ShaderManager::ShaderResourceBindingList *bindings,
const Batch *batch,
int ubufOffset,
int ubufRegionSize) // RHI only, [prepare step]
@@ -3437,6 +3442,7 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
if (pd->ubufBinding >= 0) {
m_current_uniform_data = &pd->masterUniformData;
const bool changed = shader->updateUniformData(renderState, material, m_currentMaterial);
+ m_current_uniform_data = nullptr;
if (changed || !batch->ubufDataValid)
m_resourceUpdates->updateDynamicBuffer(batch->ubuf, ubufOffset, ubufRegionSize, pd->masterUniformData.constData());
@@ -3513,7 +3519,7 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms,
}
void Renderer::updateMaterialStaticData(ShaderManager::Shader *sms,
- const QSGMaterialRhiShader::RenderState &renderState,
+ QSGMaterialRhiShader::RenderState &renderState,
QSGMaterial *material,
Batch *batch,
bool *gstateChanged) // RHI only, [prepare step]
@@ -3621,12 +3627,12 @@ bool Renderer::prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *rende
}
}
- const QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty)));
+ QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty)));
bool pendingGStatePop = false;
updateMaterialStaticData(sms, renderState, material, batch, &pendingGStatePop);
- QVector<QRhiShaderResourceBinding> bindings;
+ ShaderManager::ShaderResourceBindingList bindings;
updateMaterialDynamicData(sms, renderState, material, &bindings, batch, 0, ubufSize);
#ifndef QT_NO_DEBUG
@@ -3798,8 +3804,9 @@ bool Renderer::prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *ren
}
}
+ QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty)));
bool pendingGStatePop = false;
- updateMaterialStaticData(sms, rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))),
+ updateMaterialStaticData(sms, renderState,
material, batch, &pendingGStatePop);
int ubufOffset = 0;
@@ -3818,8 +3825,9 @@ bool Renderer::prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *ren
m_current_projection_matrix(2, 3) = 1.0f - e->order * m_zRange;
}
- QVector<QRhiShaderResourceBinding> bindings;
- updateMaterialDynamicData(sms, rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))),
+ QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty)));
+ ShaderManager::ShaderResourceBindingList bindings;
+ updateMaterialDynamicData(sms, renderState,
material, &bindings, batch, ubufOffset, ubufSize);
#ifndef QT_NO_DEBUG
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 4e374522d4..297df2232a 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -642,7 +642,7 @@ public:
struct {
QSGMaterialRhiShader *program = nullptr;
QRhiVertexInputLayout inputLayout;
- QVector<QRhiGraphicsShaderStage> shaderStages;
+ QVarLengthArray<QRhiGraphicsShaderStage, 2> shaderStages;
} programRhi;
float lastOpacity;
@@ -656,7 +656,9 @@ public:
void clearCachedRendererData();
- QRhiShaderResourceBindings *srb(const QVector<QRhiShaderResourceBinding> &bindings);
+ using ShaderResourceBindingList = QVarLengthArray<QRhiShaderResourceBinding, 8>;
+
+ QRhiShaderResourceBindings *srb(const ShaderResourceBindingList &bindings);
public Q_SLOTS:
void invalidated();
@@ -672,7 +674,7 @@ private:
QOpenGLShaderProgram *blitProgram;
QSGDefaultRenderContext *context;
- QHash<QVector<QRhiShaderResourceBinding>, QRhiShaderResourceBindings *> srbCache;
+ QHash<ShaderResourceBindingList, QRhiShaderResourceBindings *> srbCache;
};
struct GraphicsState
@@ -796,10 +798,10 @@ private:
void renderBatches();
bool ensurePipelineState(Element *e, const ShaderManager::Shader *sms);
QRhiTexture *dummyTexture();
- void updateMaterialDynamicData(ShaderManager::Shader *sms, const QSGMaterialRhiShader::RenderState &renderState,
- QSGMaterial *material, QVector<QRhiShaderResourceBinding> *bindings,
+ void updateMaterialDynamicData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState,
+ QSGMaterial *material, ShaderManager::ShaderResourceBindingList *bindings,
const Batch *batch, int ubufOffset, int ubufRegionSize);
- void updateMaterialStaticData(ShaderManager::Shader *sms, const QSGMaterialRhiShader::RenderState &renderState,
+ void updateMaterialStaticData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState,
QSGMaterial *material, Batch *batch, bool *gstateChanged);
void checkLineWidth(QSGGeometry *g);
bool prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *renderBatch);
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp
index 5218b6b1d5..a28eee5288 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.cpp
+++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp
@@ -576,6 +576,10 @@ const void *QSGGeometry::indexData() const
\value IntType
\value UnsignedIntType
\value FloatType
+ \value Bytes2Type Added in Qt 5.14.
+ \value Bytes3Type Added in Qt 5.14.
+ \value Bytes4Type Added in Qt 5.14.
+ \value DoubleType Added in Qt 5.14.
*/
/*!
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp
index 03f74df6b7..117d477f9a 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp
@@ -301,9 +301,9 @@ void QSGMaterialRhiShader::setFlag(Flags flags, bool on)
memcpy calls) when updating material states. When \a oldMaterial is null,
this shader was just activated.
*/
-bool QSGMaterialRhiShader::updateUniformData(const RenderState &state,
- QSGMaterial *newMaterial,
- QSGMaterial *oldMaterial)
+bool QSGMaterialRhiShader::updateUniformData(RenderState &state,
+ QSGMaterial *newMaterial,
+ QSGMaterial *oldMaterial)
{
Q_UNUSED(state);
Q_UNUSED(newMaterial);
@@ -334,11 +334,11 @@ bool QSGMaterialRhiShader::updateUniformData(const RenderState &state,
\a oldMaterial can be used to minimize changes. When \a oldMaterial is null,
this shader was just activated.
*/
-void QSGMaterialRhiShader::updateSampledImage(const RenderState &state,
- int binding,
- QSGTexture **texture,
- QSGMaterial *newMaterial,
- QSGMaterial *oldMaterial)
+void QSGMaterialRhiShader::updateSampledImage(RenderState &state,
+ int binding,
+ QSGTexture **texture,
+ QSGMaterial *newMaterial,
+ QSGMaterial *oldMaterial)
{
Q_UNUSED(state);
Q_UNUSED(binding);
@@ -367,8 +367,8 @@ void QSGMaterialRhiShader::updateSampledImage(const RenderState &state,
The subclass specific state can be extracted from \a newMaterial. When \a
oldMaterial is null, this shader was just activated.
*/
-bool QSGMaterialRhiShader::updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps,
- QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
+bool QSGMaterialRhiShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
+ QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_UNUSED(state);
Q_UNUSED(ps);
@@ -426,12 +426,77 @@ bool QSGMaterialRhiShader::updateGraphicsPipelineState(const RenderState &state,
*/
/*!
+ \class QSGMaterialRhiShader::GraphicsPipelineState
+
+ \brief Describes state changes that the material wants to apply to the
+ currently active graphics pipeline state.
+
+ \inmodule QtQuick
+ \since 5.14
+
+ Unlike QSGMaterialShader, directly issuing state change commands with the
+ underlying graphics API is not possible with QSGMaterialRhiShader. This is
+ mainly because the concept of individually changeable states is considered
+ deprecated and not supported with modern graphics APIs.
+
+ Therefore, it is up to QSGMaterialRhiShader to expose a data structure with
+ the set of supported states, which the material can change in its
+ updatePipelineState() implementation, if there is one. The scenegraph will
+ then internally apply these changes to the active graphics pipeline state,
+ then rolling them back as appropriate.
+ */
+
+/*!
+ \enum QSGMaterialRhiShader::GraphicsPipelineState::BlendFactor
+ \since 5.14
+
+ \value Zero
+ \value One
+ \value SrcColor
+ \value OneMinusSrcColor
+ \value DstColor
+ \value OneMinusDstColor
+ \value SrcAlpha
+ \value OneMinusSrcAlpha
+ \value DstAlpha
+ \value OneMinusDstAlpha
+ \value ConstantColor
+ \value OneMinusConstantColor
+ \value ConstantAlpha
+ \value OneMinusConstantAlpha
+ \value SrcAlphaSaturate
+ \value Src1Color
+ \value OneMinusSrc1Color
+ \value Src1Alpha
+ \value OneMinusSrc1Alpha
+ */
+
+/*!
+ \enum QSGMaterialRhiShader::GraphicsPipelineState::ColorMaskComponent
+ \since 5.14
+
+ \value R
+ \value G
+ \value B
+ \value A
+ */
+
+/*!
+ \enum QSGMaterialRhiShader::GraphicsPipelineState::CullMode
+ \since 5.14
+
+ \value CullNone
+ \value CullFront
+ \value CullBack
+ */
+
+/*!
Returns the accumulated opacity to be used for rendering.
*/
float QSGMaterialRhiShader::RenderState::opacity() const
{
Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->currentOpacity();
+ return float(static_cast<const QSGRenderer *>(m_data)->currentOpacity());
}
/*!
@@ -440,7 +505,7 @@ float QSGMaterialRhiShader::RenderState::opacity() const
float QSGMaterialRhiShader::RenderState::determinant() const
{
Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->determinant();
+ return float(static_cast<const QSGRenderer *>(m_data)->determinant());
}
/*!
@@ -459,7 +524,7 @@ QMatrix4x4 QSGMaterialRhiShader::RenderState::combinedMatrix() const
float QSGMaterialRhiShader::RenderState::devicePixelRatio() const
{
Q_ASSERT(m_data);
- return static_cast<const QSGRenderer *>(m_data)->devicePixelRatio();
+ return float(static_cast<const QSGRenderer *>(m_data)->devicePixelRatio());
}
/*!
@@ -511,7 +576,10 @@ QRect QSGMaterialRhiShader::RenderState::deviceRect() const
/*!
Returns a pointer to the data for the uniform (constant) buffer in the
- shader.
+ shader. Uniform data must only be updated from
+ QSGMaterialRhiShader::updateUniformData(). The return value is null in the
+ other reimplementable functions, such as,
+ QSGMaterialRhiShader::updateSampledImage().
\note It is strongly recommended to declare the uniform block with \c
std140 in the shader, and to carefully study the standard uniform block
@@ -525,11 +593,8 @@ QRect QSGMaterialRhiShader::RenderState::deviceRect() const
\note Avoid copying from C++ POD types, such as, structs, in order to
update multiple members at once, unless it has been verified that the
layouts of the C++ struct and the GLSL uniform block match.
-
- \note Uniform data must only be updated from
- QSGMaterialRhiShader::updateUniformData().
*/
-QByteArray *QSGMaterialRhiShader::RenderState::uniformData() const
+QByteArray *QSGMaterialRhiShader::RenderState::uniformData()
{
Q_ASSERT(m_data);
return static_cast<const QSGRenderer *>(m_data)->currentUniformData();
@@ -541,7 +606,7 @@ QByteArray *QSGMaterialRhiShader::RenderState::uniformData() const
QSGMaterialRhiShader::updateSampledImage() to enqueue texture image
content updates.
*/
-QRhiResourceUpdateBatch *QSGMaterialRhiShader::RenderState::resourceUpdateBatch() const
+QRhiResourceUpdateBatch *QSGMaterialRhiShader::RenderState::resourceUpdateBatch()
{
Q_ASSERT(m_data);
return static_cast<const QSGRenderer *>(m_data)->currentResourceUpdateBatch();
@@ -550,7 +615,7 @@ QRhiResourceUpdateBatch *QSGMaterialRhiShader::RenderState::resourceUpdateBatch(
/*!
Returns the current QRhi.
*/
-QRhi *QSGMaterialRhiShader::RenderState::rhi() const
+QRhi *QSGMaterialRhiShader::RenderState::rhi()
{
Q_ASSERT(m_data);
return static_cast<const QSGRenderer *>(m_data)->currentRhi();
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h
index 01991135ec..86208516cd 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h
@@ -76,9 +76,9 @@ public:
float determinant() const;
float devicePixelRatio() const;
- QByteArray *uniformData() const;
- QRhiResourceUpdateBatch *resourceUpdateBatch() const;
- QRhi *rhi() const;
+ QByteArray *uniformData();
+ QRhiResourceUpdateBatch *resourceUpdateBatch();
+ QRhi *rhi();
private:
friend class QSGRenderer;
@@ -146,13 +146,13 @@ public:
QSGMaterialRhiShader();
virtual ~QSGMaterialRhiShader();
- virtual bool updateUniformData(const RenderState &state,
+ virtual bool updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
- virtual void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+ virtual void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
- virtual bool updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps,
+ virtual bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
Flags flags() const;
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
index bc68199e08..0fee1486cf 100644
--- a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
@@ -78,11 +78,11 @@ QT_BEGIN_NAMESPACE
\value OpenGL OpenGL ES 2.0 or higher
\value Direct3D12 Direct3D 12
\value OpenVG OpenVG via EGL
- \value OpenGLRhi OpenGL ES 2.0 or higher via a graphics abstraction layer
- \value Direct3D11Rhi Direct3D 11 via a graphics abstraction layer
- \value VulkanRhi Vulkan 1.0 via a graphics abstraction layer
- \value MetalRhi Metal via a graphics abstraction layer
- \value NullRhi Null (no output) via a graphics abstraction layer
+ \value OpenGLRhi OpenGL ES 2.0 or higher via a graphics abstraction layer. This value was introduced in Qt 5.14.
+ \value Direct3D11Rhi Direct3D 11 via a graphics abstraction layer. This value was introduced in Qt 5.14.
+ \value VulkanRhi Vulkan 1.0 via a graphics abstraction layer. This value was introduced in Qt 5.14.
+ \value MetalRhi Metal via a graphics abstraction layer. This value was introduced in Qt 5.14.
+ \value NullRhi Null (no output) via a graphics abstraction layer. This value was introduced in Qt 5.14.
*/
/*!
@@ -111,33 +111,36 @@ QT_BEGIN_NAMESPACE
used by the scenegraph, when running with the software backend.
\value RhiResource The resource is a pointer to the QRhi instance used by
- the scenegraph, when applicable.
+ the scenegraph, when applicable. This value was introduced in Qt 5.14.
\value PhysicalDeviceResource The resource is a pointer to the pysical
device object used by the scenegraph, when applicable. For example, a
\c{VkPhysicalDevice *}. Note that with Vulkan the returned value is a
- pointer to the VkPhysicalDevice, not the handle itself.
+ pointer to the VkPhysicalDevice, not the handle itself. This value was
+ introduced in Qt 5.14.
\value OpenGLContextResource The resource is a pointer to the
QOpenGLContext used by the scenegraph (on the render thread), when
- applicable.
+ applicable. This value was introduced in Qt 5.14.
\value DeviceContextResource The resource is a pointer to the device
context used by the scenegraph, when applicable. For example, a
- \c{ID3D11DeviceContext *}.
+ \c{ID3D11DeviceContext *}. This value was introduced in Qt 5.14.
\value CommandEncoderResource The resource is a pointer to the currently
active render command encoder object used by the scenegraph, when
applicable. For example, a \c{MTLRenderCommandEncoder *}. This object has
limited validity, and is only valid while the scene graph is recording a
- render pass for the next frame.
+ render pass for the next frame. This value was introduced in Qt 5.14.
\value VulkanInstanceResource The resource is a pointer to the
- QVulkanInstance used by the scenegraph, when applicable.
+ QVulkanInstance used by the scenegraph, when applicable. This value was
+ introduced in Qt 5.14.
\value RenderPassResource The resource is a pointer to the render pass used
by the scenegraph, describing the color and depth/stecil attachments and
- how they are used. For example, a \c{VkRenderPass *}.
+ how they are used. For example, a \c{VkRenderPass *}. This value was
+ introduced in Qt 5.14.
*/
/*!
@@ -145,8 +148,9 @@ QT_BEGIN_NAMESPACE
\value UnknownShadingLanguage Not yet known due to no window and scenegraph associated
\value GLSL GLSL or GLSL ES
\value HLSL HLSL
- \value RhiShader Consumes QShader instances containing shader
- variants for multiple target languages and bytecode formats
+ \value RhiShader Consumes QShader instances containing shader variants for
+ multiple target languages and intermediate formats. This value was introduced in
+ Qt 5.14.
*/
/*!
@@ -222,6 +226,8 @@ void *QSGRendererInterface::getResource(QQuickWindow *window, const char *resour
instead of directly calling the native graphics API.
\note This function can be called on any thread.
+
+ \since 5.14
*/
bool QSGRendererInterface::isApiRhiBased(GraphicsApi api)
{
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp
index c47401e5c0..edcee96bdb 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.cpp
+++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp
@@ -717,6 +717,9 @@ void QSGTexture::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUp
d->updateRhiTexture(rhi, resourceUpdates);
}
+/*!
+ \internal
+ */
void QSGTexture::setWorkResourceUpdateBatch(QRhiResourceUpdateBatch *resourceUpdates)
{
Q_D(QSGTexture);
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.h b/src/quick/scenegraph/coreapi/qsgtexture.h
index 4cd2a5cddd..2efdd8b7c3 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.h
+++ b/src/quick/scenegraph/coreapi/qsgtexture.h
@@ -141,6 +141,7 @@ class Q_QUICK_EXPORT QSGDynamicTexture : public QSGTexture
Q_OBJECT
public:
+ QSGDynamicTexture() = default;
virtual bool updateTexture() = 0;
protected:
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 97fd49e4c7..17eb1e312c 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -341,6 +341,11 @@ void QSGRenderContext::invalidate()
{
}
+void QSGRenderContext::prepareSync(qreal devicePixelRatio)
+{
+ Q_UNUSED(devicePixelRatio);
+}
+
void QSGRenderContext::beginNextFrame(QSGRenderer *renderer,
RenderPassCallback mainPassRecordingStart,
RenderPassCallback mainPassRecordingEnd,
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 4e712ab7c3..244bcfabd1 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -174,6 +174,7 @@ public:
using RenderPassCallback = void (*)(void *);
+ virtual void prepareSync(qreal devicePixelRatio);
virtual void beginNextFrame(QSGRenderer *renderer,
RenderPassCallback mainPassRecordingStart,
RenderPassCallback mainPassRecordingEnd,
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 8fc8c711c6..be6ef25feb 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -410,9 +410,9 @@ class QSGTextMaskRhiShader : public QSGMaterialRhiShader
public:
QSGTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat);
- bool updateUniformData(const RenderState &state,
+ bool updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
- void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+ void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
protected:
@@ -428,7 +428,7 @@ QSGTextMaskRhiShader::QSGTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat)
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/textmask.frag.qsb"));
}
-bool QSGTextMaskRhiShader::updateUniformData(const RenderState &state,
+bool QSGTextMaskRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type());
@@ -471,7 +471,7 @@ bool QSGTextMaskRhiShader::updateUniformData(const RenderState &state,
return changed;
}
-void QSGTextMaskRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+void QSGTextMaskRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *)
{
Q_UNUSED(state);
@@ -498,10 +498,10 @@ public:
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/8bittextmask.frag.qsb"));
}
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
-bool QSG8BitTextMaskRhiShader::updateUniformData(const RenderState &state,
+bool QSG8BitTextMaskRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
@@ -532,8 +532,8 @@ public:
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/24bittextmask.frag.qsb"));
}
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
- bool updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps,
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
@@ -544,7 +544,7 @@ public:
// framebuffer update and blending always on... Could we do gamma correction in
// the shader for text? (but that's bad for blending?)
-bool QSG24BitTextMaskRhiShader::updateUniformData(const RenderState &state,
+bool QSG24BitTextMaskRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
@@ -565,7 +565,7 @@ bool QSG24BitTextMaskRhiShader::updateUniformData(const RenderState &state,
return changed;
}
-bool QSG24BitTextMaskRhiShader::updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps,
+bool QSG24BitTextMaskRhiShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_UNUSED(state);
@@ -596,10 +596,10 @@ public:
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/32bitcolortext.frag.qsb"));
}
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
-bool QSG32BitColorTextRhiShader::updateUniformData(const RenderState &state,
+bool QSG32BitColorTextRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
@@ -636,11 +636,11 @@ public:
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/styledtext.frag.qsb"));
}
- bool updateUniformData(const RenderState &state,
+ bool updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
-bool QSGStyledTextRhiShader::updateUniformData(const RenderState &state,
+bool QSGStyledTextRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = QSG8BitTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial);
@@ -751,15 +751,15 @@ void QSGTextMaskMaterial::updateCache(QFontEngine::GlyphFormat glyphFormat)
void *cacheKey;
if (m_rhi) {
cacheKey = m_rhi;
- // ### no idea what the QWindow is (esp. since we are not even
- // rendering at this point), and anyway is the original logic correct
- // even...
- devicePixelRatio = qGuiApp->devicePixelRatio();
+ // Get the dpr the modern way. This value retrieved via the
+ // rendercontext matches what RenderState::devicePixelRatio()
+ // exposes to the material shaders later on.
+ devicePixelRatio = m_rc->currentDevicePixelRatio();
} else {
ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());
Q_ASSERT(ctx != nullptr);
cacheKey = ctx;
- devicePixelRatio = qsg_device_pixel_ratio(ctx);
+ devicePixelRatio = qsg_device_pixel_ratio(ctx); // this is technically incorrect, see other branch above
}
QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio);
diff --git a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
index d1711f7524..500d4e6e95 100644
--- a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
@@ -66,7 +66,7 @@ class SmoothTextureMaterialRhiShader : public QSGTextureMaterialRhiShader
public:
SmoothTextureMaterialRhiShader();
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
@@ -136,7 +136,7 @@ SmoothTextureMaterialRhiShader::SmoothTextureMaterialRhiShader()
setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/smoothtexture.frag.qsb"));
}
-bool SmoothTextureMaterialRhiShader::updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
+bool SmoothTextureMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = false;
QByteArray *buf = state.uniformData();
diff --git a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp
index 417b63dee3..5e4affbf90 100644
--- a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp
@@ -111,7 +111,7 @@ class SmoothColorMaterialRhiShader : public QSGMaterialRhiShader
public:
SmoothColorMaterialRhiShader();
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
SmoothColorMaterialRhiShader::SmoothColorMaterialRhiShader()
@@ -120,7 +120,7 @@ SmoothColorMaterialRhiShader::SmoothColorMaterialRhiShader()
setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/smoothcolor.frag.qsb"));
}
-bool SmoothColorMaterialRhiShader::updateUniformData(const RenderState &state, QSGMaterial *, QSGMaterial *oldMaterial)
+bool SmoothColorMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *oldMaterial)
{
bool changed = false;
QByteArray *buf = state.uniformData();
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index f43b5436a6..e8c3ac4abb 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -200,6 +200,11 @@ void QSGDefaultRenderContext::invalidate()
emit invalidated();
}
+void QSGDefaultRenderContext::prepareSync(qreal devicePixelRatio)
+{
+ m_currentDevicePixelRatio = devicePixelRatio;
+}
+
static QBasicMutex qsg_framerender_mutex;
void QSGDefaultRenderContext::beginNextFrame(QSGRenderer *renderer,
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
index 6a3462ae2b..2fdb3a48dd 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h
+++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
@@ -104,6 +104,7 @@ public:
void initialize(const QSGRenderContext::InitParams *params) override;
void invalidate() override;
+ void prepareSync(qreal devicePixelRatio) override;
void beginNextFrame(QSGRenderer *renderer,
RenderPassCallback mainPassRecordingStart,
RenderPassCallback mainPassRecordingEnd,
@@ -151,6 +152,17 @@ public:
return m_currentFrameRenderPass;
}
+ qreal currentDevicePixelRatio() const
+ {
+ // Valid starting from QQuickWindow::syncSceneGraph(). This takes the
+ // redirections, e.g. QQuickWindow::setRenderTarget(), into account.
+ // This calculation logic matches what the renderer does, so this is
+ // the same value that gets exposed in RenderState::devicePixelRatio()
+ // to material shaders. This getter is useful to perform dpr-related
+ // operations in the sync phase (in updatePaintNode()).
+ return m_currentDevicePixelRatio;
+ }
+
protected:
static QString fontKey(const QRawFont &font);
@@ -166,6 +178,7 @@ protected:
QSGRhiAtlasTexture::Manager *m_rhiAtlasManager;
QRhiCommandBuffer *m_currentFrameCommandBuffer;
QRhiRenderPassDescriptor *m_currentFrameRenderPass;
+ qreal m_currentDevicePixelRatio;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultspritenode.cpp b/src/quick/scenegraph/qsgdefaultspritenode.cpp
index 4d4d9f6971..6422a252d9 100644
--- a/src/quick/scenegraph/qsgdefaultspritenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultspritenode.cpp
@@ -141,9 +141,9 @@ class SpriteMaterialRhiShader : public QSGMaterialRhiShader
public:
SpriteMaterialRhiShader();
- bool updateUniformData(const RenderState &state,
+ bool updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
- void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+ void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
@@ -153,7 +153,7 @@ SpriteMaterialRhiShader::SpriteMaterialRhiShader()
setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/sprite.frag.qsb"));
}
-bool SpriteMaterialRhiShader::updateUniformData(const RenderState &state,
+bool SpriteMaterialRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
#ifdef QT_NO_DEBUG
@@ -186,7 +186,7 @@ bool SpriteMaterialRhiShader::updateUniformData(const RenderState &state,
return changed;
}
-void SpriteMaterialRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+void SpriteMaterialRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
if (binding != 1)
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index 9121363159..e8e9f76d04 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -212,10 +212,10 @@ class QSGDistanceFieldTextMaterialRhiShader : public QSGMaterialRhiShader
public:
QSGDistanceFieldTextMaterialRhiShader(bool alphaTexture);
- bool updateUniformData(const RenderState &state,
+ bool updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
- void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+ void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
protected:
@@ -235,7 +235,7 @@ QSGDistanceFieldTextMaterialRhiShader::QSGDistanceFieldTextMaterialRhiShader(boo
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/distancefieldtext.frag.qsb"));
}
-bool QSGDistanceFieldTextMaterialRhiShader::updateUniformData(const RenderState &state,
+bool QSGDistanceFieldTextMaterialRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type());
@@ -291,7 +291,7 @@ bool QSGDistanceFieldTextMaterialRhiShader::updateUniformData(const RenderState
return changed;
}
-void QSGDistanceFieldTextMaterialRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+void QSGDistanceFieldTextMaterialRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *)
{
Q_UNUSED(state);
@@ -432,7 +432,7 @@ class DistanceFieldStyledTextMaterialRhiShader : public QSGDistanceFieldTextMate
public:
DistanceFieldStyledTextMaterialRhiShader(bool alphaTexture);
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
DistanceFieldStyledTextMaterialRhiShader::DistanceFieldStyledTextMaterialRhiShader(bool alphaTexture)
@@ -440,7 +440,7 @@ DistanceFieldStyledTextMaterialRhiShader::DistanceFieldStyledTextMaterialRhiShad
{
}
-bool DistanceFieldStyledTextMaterialRhiShader::updateUniformData(const RenderState &state,
+bool DistanceFieldStyledTextMaterialRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = QSGDistanceFieldTextMaterialRhiShader::updateUniformData(state, newMaterial, oldMaterial);
@@ -548,7 +548,7 @@ class DistanceFieldOutlineTextMaterialRhiShader : public DistanceFieldStyledText
public:
DistanceFieldOutlineTextMaterialRhiShader(bool alphaTexture);
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
DistanceFieldOutlineTextMaterialRhiShader::DistanceFieldOutlineTextMaterialRhiShader(bool alphaTexture)
@@ -564,7 +564,7 @@ DistanceFieldOutlineTextMaterialRhiShader::DistanceFieldOutlineTextMaterialRhiSh
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb"));
}
-bool DistanceFieldOutlineTextMaterialRhiShader::updateUniformData(const RenderState &state,
+bool DistanceFieldOutlineTextMaterialRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = DistanceFieldStyledTextMaterialRhiShader::updateUniformData(state, newMaterial, oldMaterial);
@@ -670,7 +670,7 @@ class DistanceFieldShiftedStyleTextMaterialRhiShader : public DistanceFieldStyle
public:
DistanceFieldShiftedStyleTextMaterialRhiShader(bool alphaTexture);
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
DistanceFieldShiftedStyleTextMaterialRhiShader::DistanceFieldShiftedStyleTextMaterialRhiShader(bool alphaTexture)
@@ -686,7 +686,7 @@ DistanceFieldShiftedStyleTextMaterialRhiShader::DistanceFieldShiftedStyleTextMat
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb"));
}
-bool DistanceFieldShiftedStyleTextMaterialRhiShader::updateUniformData(const RenderState &state,
+bool DistanceFieldShiftedStyleTextMaterialRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = DistanceFieldStyledTextMaterialRhiShader::updateUniformData(state, newMaterial, oldMaterial);
@@ -809,8 +809,8 @@ class QSGHiQSubPixelDistanceFieldTextMaterialRhiShader : public QSGDistanceField
public:
QSGHiQSubPixelDistanceFieldTextMaterialRhiShader(bool alphaTexture);
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
- bool updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps,
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
@@ -829,7 +829,7 @@ QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::QSGHiQSubPixelDistanceFieldTex
QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb"));
}
-bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateUniformData(const RenderState &state,
+bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = QSGDistanceFieldTextMaterialRhiShader::updateUniformData(state, newMaterial, oldMaterial);
@@ -855,7 +855,7 @@ bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateUniformData(const R
return changed;
}
-bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps,
+bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_UNUSED(state);
diff --git a/src/quick/scenegraph/qsgopengllayer.cpp b/src/quick/scenegraph/qsgopengllayer.cpp
index 8db4cba58a..ae5032231d 100644
--- a/src/quick/scenegraph/qsgopengllayer.cpp
+++ b/src/quick/scenegraph/qsgopengllayer.cpp
@@ -408,7 +408,7 @@ void QSGOpenGLLayer::grab()
m_mirrorVertical ? m_rect.bottom() : m_rect.top(),
m_mirrorHorizontal ? -m_rect.width() : m_rect.width(),
m_mirrorVertical ? -m_rect.height() : m_rect.height());
- m_renderer->setProjectionMatrixToRect(mirrored, false);
+ m_renderer->setProjectionMatrixToRect(mirrored);
m_renderer->setClearColor(Qt::transparent);
if (m_multisampling) {
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index f15105168e..ba231f8159 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -190,6 +190,7 @@ public:
QSGRenderContext *createRenderContext(QSGContext *) const override { return rc; }
void releaseSwapchain(QQuickWindow *window);
+ void handleDeviceLoss();
bool eventFilter(QObject *watched, QEvent *event) override;
@@ -435,7 +436,26 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window)
gl->doneCurrent();
}
- delete d->animationController;
+ d->animationController.reset();
+}
+
+void QSGGuiThreadRenderLoop::handleDeviceLoss()
+{
+ if (!rhi || !rhi->isDeviceLost())
+ return;
+
+ qWarning("Graphics device lost, cleaning up scenegraph and releasing RHI");
+
+ for (auto it = m_windows.constBegin(), itEnd = m_windows.constEnd(); it != itEnd; ++it)
+ QQuickWindowPrivate::get(it.key())->cleanupNodesOnShutdown();
+
+ rc->invalidate();
+
+ for (auto it = m_windows.constBegin(), itEnd = m_windows.constEnd(); it != itEnd; ++it)
+ releaseSwapchain(it.key());
+
+ delete rhi;
+ rhi = nullptr;
}
void QSGGuiThreadRenderLoop::releaseSwapchain(QQuickWindow *window)
@@ -488,8 +508,11 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
const bool enableRhi = rhiSupport->isRhiEnabled();
if (enableRhi && !rhi) {
- offscreenSurface = rhiSupport->maybeCreateOffscreenSurface(window);
+ if (!offscreenSurface)
+ offscreenSurface = rhiSupport->maybeCreateOffscreenSurface(window);
+
rhi = rhiSupport->createRhi(window, offscreenSurface);
+
if (rhi) {
if (rhiSupport->isProfilingRequested())
QSGRhiProfileConnection::instance()->initialize(rhi);
@@ -561,6 +584,14 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab
+ // QQ is always premul alpha. Decide based on alphaBufferSize in
+ // requestedFormat(). (the platform plugin can override format() but
+ // what matters here is what the application wanted, hence using the
+ // requested one)
+ const bool alpha = window->requestedFormat().alphaBufferSize() > 0;
+ if (alpha)
+ flags |= QRhiSwapChain::SurfaceHasPreMulAlpha;
+
cd->swapchain = rhi->newSwapChain();
cd->depthStencilForSwapchain = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil,
QSize(),
@@ -568,7 +599,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
QRhiRenderBuffer::UsedWithSwapChainOnly);
cd->swapchain->setWindow(window);
cd->swapchain->setDepthStencil(cd->depthStencilForSwapchain);
- qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d", rhiSampleCount);
+ qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d. Alpha channel requested = %s",
+ rhiSampleCount, alpha ? "yes" : "no");
cd->swapchain->setSampleCount(rhiSampleCount);
cd->swapchain->setFlags(flags);
cd->rpDescForSwapchain = cd->swapchain->newCompatibleRenderPassDescriptor();
@@ -634,17 +666,25 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
if (previousOutputSize != effectiveOutputSize || cd->swapchainJustBecameRenderable) {
if (cd->swapchainJustBecameRenderable)
qCDebug(QSG_LOG_RENDERLOOP, "just became exposed");
- cd->swapchainJustBecameRenderable = false;
- cd->depthStencilForSwapchain->setPixelSize(effectiveOutputSize);
- cd->depthStencilForSwapchain->build();
cd->hasActiveSwapchain = cd->swapchain->buildOrResize();
+ if (!cd->hasActiveSwapchain && rhi->isDeviceLost()) {
+ handleDeviceLoss();
+ return;
+ }
+ cd->swapchainJustBecameRenderable = false;
cd->hasRenderableSwapchain = cd->hasActiveSwapchain;
- if (!cd->hasActiveSwapchain)
- qWarning("Failed to build or resize swapchain");
- else
+
+ if (cd->hasActiveSwapchain) {
+ // surface size atomicity: now that buildOrResize() succeeded,
+ // query the size that was used in there by the swapchain, and
+ // that is the size we will use while preparing the next frame.
+ effectiveOutputSize = cd->swapchain->currentPixelSize();
qCDebug(QSG_LOG_RENDERLOOP) << "rhi swapchain size" << effectiveOutputSize;
+ } else {
+ qWarning("Failed to build or resize swapchain");
+ }
}
Q_ASSERT(rhi == cd->rhi);
@@ -653,7 +693,7 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
QRhi::FrameOpResult frameResult = rhi->beginFrame(cd->swapchain, frameFlags);
if (frameResult != QRhi::FrameOpSuccess) {
if (frameResult == QRhi::FrameOpDeviceLost)
- qWarning("Device lost");
+ handleDeviceLoss();
else if (frameResult == QRhi::FrameOpError)
qWarning("Failed to start frame");
// out of date is not worth warning about - it may happen even during resizing on some platforms
@@ -692,7 +732,13 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
QRhi::EndFrameFlags flags = 0;
if (!needsPresent)
flags |= QRhi::SkipPresent;
- rhi->endFrame(cd->swapchain, flags);
+ QRhi::FrameOpResult frameResult = rhi->endFrame(cd->swapchain, flags);
+ if (frameResult != QRhi::FrameOpSuccess) {
+ if (frameResult == QRhi::FrameOpDeviceLost)
+ handleDeviceLoss();
+ else if (frameResult == QRhi::FrameOpError)
+ qWarning("Failed to end frame");
+ }
} else if (needsPresent) {
if (!cd->customRenderStage || !cd->customRenderStage->swap())
gl->swapBuffers(window);
diff --git a/src/quick/scenegraph/qsgrhilayer.cpp b/src/quick/scenegraph/qsgrhilayer.cpp
index 80ca40d50a..757410eded 100644
--- a/src/quick/scenegraph/qsgrhilayer.cpp
+++ b/src/quick/scenegraph/qsgrhilayer.cpp
@@ -388,7 +388,10 @@ void QSGRhiLayer::grab()
m_mirrorHorizontal ? -m_rect.width() : m_rect.width(),
m_mirrorVertical ? m_rect.height() : -m_rect.height());
}
- m_renderer->setProjectionMatrixToRect(mirrored, !m_rhi->isYUpInNDC());
+ QSGAbstractRenderer::MatrixTransformFlags matrixFlags = 0;
+ if (!m_rhi->isYUpInNDC())
+ matrixFlags |= QSGAbstractRenderer::MatrixTransformFlipY;
+ m_renderer->setProjectionMatrixToRect(mirrored, matrixFlags);
m_renderer->setClearColor(Qt::transparent);
m_renderer->setRenderTarget(m_rt);
m_renderer->setCommandBuffer(m_context->currentFrameCommandBuffer());
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
index fe9cecb51b..6f6544548c 100644
--- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp
+++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
@@ -211,9 +211,9 @@ class QSGRhiShaderEffectMaterialShader : public QSGMaterialRhiShader
public:
QSGRhiShaderEffectMaterialShader(const QSGRhiShaderEffectMaterial *material);
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
- void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
- bool updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
QSGRhiShaderEffectMaterialShader::QSGRhiShaderEffectMaterialShader(const QSGRhiShaderEffectMaterial *material)
@@ -228,7 +228,7 @@ static inline QColor qsg_premultiply_color(const QColor &c)
return QColor::fromRgbF(c.redF() * c.alphaF(), c.greenF() * c.alphaF(), c.blueF() * c.alphaF(), c.alphaF());
}
-bool QSGRhiShaderEffectMaterialShader::updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
+bool QSGRhiShaderEffectMaterialShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_UNUSED(oldMaterial);
QSGRhiShaderEffectMaterial *mat = static_cast<QSGRhiShaderEffectMaterial *>(newMaterial);
@@ -381,7 +381,7 @@ bool QSGRhiShaderEffectMaterialShader::updateUniformData(const RenderState &stat
return changed;
}
-void QSGRhiShaderEffectMaterialShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+void QSGRhiShaderEffectMaterialShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_UNUSED(oldMaterial);
@@ -426,7 +426,7 @@ void QSGRhiShaderEffectMaterialShader::updateSampledImage(const RenderState &sta
*texture = mat->m_dummyTexture;
}
-bool QSGRhiShaderEffectMaterialShader::updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps,
+bool QSGRhiShaderEffectMaterialShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
Q_UNUSED(state);
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp
index e050938cc9..12c6742342 100644
--- a/src/quick/scenegraph/qsgrhisupport.cpp
+++ b/src/quick/scenegraph/qsgrhisupport.cpp
@@ -101,7 +101,8 @@ QSGRhiSupport::QSGRhiSupport()
m_enableRhi(false),
m_debugLayer(false),
m_profile(false),
- m_shaderEffectDebug(false)
+ m_shaderEffectDebug(false),
+ m_preferSoftwareRenderer(false)
{
}
@@ -140,7 +141,7 @@ void QSGRhiSupport::applySettings()
}
} else {
// check env.vars., fall back to platform-specific defaults when backend is not set
- m_enableRhi = qEnvironmentVariableIntValue("QSG_RHI");
+ m_enableRhi = uint(qEnvironmentVariableIntValue("QSG_RHI"));
const QByteArray rhiBackend = qgetenv("QSG_RHI_BACKEND");
if (rhiBackend == QByteArrayLiteral("gl")
|| rhiBackend == QByteArrayLiteral("gles2")
@@ -171,12 +172,18 @@ void QSGRhiSupport::applySettings()
return;
// validation layers (Vulkan) or debug layer (D3D)
- m_debugLayer = qEnvironmentVariableIntValue("QSG_RHI_DEBUG_LAYER");
+ m_debugLayer = uint(qEnvironmentVariableIntValue("QSG_RHI_DEBUG_LAYER"));
// EnableProfiling + DebugMarkers
- m_profile = qEnvironmentVariableIntValue("QSG_RHI_PROFILE");
+ m_profile = uint(qEnvironmentVariableIntValue("QSG_RHI_PROFILE"));
- m_shaderEffectDebug = qEnvironmentVariableIntValue("QSG_RHI_SHADEREFFECT_DEBUG");
+ m_shaderEffectDebug = uint(qEnvironmentVariableIntValue("QSG_RHI_SHADEREFFECT_DEBUG"));
+
+ m_preferSoftwareRenderer = uint(qEnvironmentVariableIntValue("QSG_RHI_PREFER_SOFTWARE_RENDERER"));
+
+ m_killDeviceFrameCount = qEnvironmentVariableIntValue("QSG_RHI_SIMULATE_DEVICE_LOSS");
+ if (m_killDeviceFrameCount > 0 && m_rhiBackend == QRhi::D3D11)
+ qDebug("Graphics device will be reset every %d frames", m_killDeviceFrameCount);
const char *backendName = "unknown";
switch (m_rhiBackend) {
@@ -201,6 +208,8 @@ void QSGRhiSupport::applySettings()
qCDebug(QSG_LOG_INFO,
"Using QRhi with backend %s\n graphics API debug/validation layers: %d\n QRhi profiling and debug markers: %d",
backendName, m_debugLayer, m_profile);
+ if (m_preferSoftwareRenderer)
+ qCDebug(QSG_LOG_INFO, "Prioritizing software renderers");
}
QSGRhiSupport *QSGRhiSupport::staticInst()
@@ -459,6 +468,8 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf
QRhi::Flags flags = 0;
if (isProfilingRequested())
flags |= QRhi::EnableProfiling | QRhi::EnableDebugMarkers;
+ if (isSoftwareRendererRequested())
+ flags |= QRhi::PreferSoftwareRenderer;
QRhi::Implementation backend = rhiBackend();
if (backend == QRhi::Null) {
@@ -489,6 +500,10 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf
if (backend == QRhi::D3D11) {
QRhiD3D11InitParams rhiParams;
rhiParams.enableDebugLayer = isDebugLayerRequested();
+ if (m_killDeviceFrameCount > 0) {
+ rhiParams.framesUntilKillingDeviceViaTdr = m_killDeviceFrameCount;
+ rhiParams.repeatDeviceKill = true;
+ }
rhi = QRhi::create(backend, &rhiParams, flags);
}
#endif
diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h
index f2d5837bba..d008ecd0af 100644
--- a/src/quick/scenegraph/qsgrhisupport_p.h
+++ b/src/quick/scenegraph/qsgrhisupport_p.h
@@ -114,6 +114,7 @@ public:
bool isDebugLayerRequested() const { return m_debugLayer; }
bool isProfilingRequested() const { return m_profile; }
bool isShaderEffectDebuggingRequested() const { return m_shaderEffectDebug; }
+ bool isSoftwareRendererRequested() const { return m_preferSoftwareRenderer; }
QSurface::SurfaceType windowSurfaceType() const;
@@ -138,11 +139,13 @@ private:
uint rhi : 1;
} m_requested;
QRhi::Implementation m_rhiBackend = QRhi::Null;
+ int m_killDeviceFrameCount;
uint m_set : 1;
uint m_enableRhi : 1;
uint m_debugLayer : 1;
uint m_profile : 1;
uint m_shaderEffectDebug : 1;
+ uint m_preferSoftwareRenderer : 1;
};
// Sends QRhi resource statistics over a QTcpSocket. To be initialized by the
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 9bcb96a65a..86d9590863 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -199,7 +199,7 @@ public:
WMSyncEvent(QQuickWindow *c, bool inExpose, bool force)
: WMWindowEvent(c, WM_RequestSync)
, size(c->size())
- , dpr(c->effectiveDevicePixelRatio())
+ , dpr(float(c->effectiveDevicePixelRatio()))
, syncInExpose(inExpose)
, forceRenderPass(force)
{}
@@ -306,8 +306,7 @@ public:
delete offscreenSurface;
}
- void invalidateOpenGL(QQuickWindow *window, bool inDestructor, QOffscreenSurface *backupSurface);
- void initializeOpenGL();
+ void invalidateGraphics(QQuickWindow *window, bool inDestructor, QOffscreenSurface *backupSurface);
bool event(QEvent *) override;
void run() override;
@@ -340,6 +339,9 @@ public:
ExposeRequest = 0x04 | RepaintRequest | SyncRequest
};
+ void ensureRhi();
+ void handleDeviceLoss();
+
QSGThreadedRenderLoop *wm;
QOpenGLContext *gl;
bool enableRhi;
@@ -419,9 +421,9 @@ bool QSGRenderThread::event(QEvent *e)
WMTryReleaseEvent *wme = static_cast<WMTryReleaseEvent *>(e);
if (!window || wme->inDestructor) {
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- setting exit flag and invalidating OpenGL");
- invalidateOpenGL(wme->window, wme->inDestructor, wme->needsFallback ? offscreenSurface : nullptr);
+ invalidateGraphics(wme->window, wme->inDestructor, wme->needsFallback ? offscreenSurface : nullptr);
active = gl || rhi;
- Q_ASSERT_X(!wme->inDestructor || !active, "QSGRenderThread::invalidateOpenGL()", "Thread's active state is not set to false when shutting down");
+ Q_ASSERT_X(!wme->inDestructor || !active, "QSGRenderThread::invalidateGraphics()", "Thread's active state is not set to false when shutting down");
if (sleeping)
stopEventProcessing = true;
} else {
@@ -512,9 +514,9 @@ bool QSGRenderThread::event(QEvent *e)
return QThread::event(e);
}
-void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor, QOffscreenSurface *fallback)
+void QSGRenderThread::invalidateGraphics(QQuickWindow *window, bool inDestructor, QOffscreenSurface *fallback)
{
- qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "invalidateOpenGL()");
+ qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "invalidateGraphics()");
if (!gl && !rhi)
return;
@@ -562,7 +564,7 @@ void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor,
QCoreApplication::processEvents();
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
if (inDestructor)
- delete dd->animationController;
+ dd->animationController.reset();
if (current && gl)
gl->doneCurrent();
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- invalidating scene graph");
@@ -615,7 +617,7 @@ void QSGRenderThread::sync(bool inExpose, bool inGrab)
QSGDefaultRenderContext::InitParams rcParams;
rcParams.sampleCount = qMax(1, gl->format().samples());
rcParams.openGLContext = gl;
- rcParams.initialSurfacePixelSize = windowSize * dpr;
+ rcParams.initialSurfacePixelSize = windowSize * qreal(dpr);
rcParams.maybeSurface = window;
sgrc->initialize(&rcParams);
}
@@ -658,6 +660,19 @@ void QSGRenderThread::sync(bool inExpose, bool inGrab)
}
}
+void QSGRenderThread::handleDeviceLoss()
+{
+ if (!rhi || !rhi->isDeviceLost())
+ return;
+
+ qWarning("Graphics device lost, cleaning up scenegraph and releasing RHI");
+ QQuickWindowPrivate::get(window)->cleanupNodesOnShutdown();
+ sgrc->invalidate();
+ wm->releaseSwapchain(window);
+ delete rhi;
+ rhi = nullptr;
+}
+
void QSGRenderThread::syncAndRender(QImage *grabImage)
{
bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled();
@@ -699,17 +714,21 @@ void QSGRenderThread::syncAndRender(QImage *grabImage)
if (previousOutputSize != effectiveOutputSize || cd->swapchainJustBecameRenderable) {
if (cd->swapchainJustBecameRenderable)
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "just became exposed");
- cd->swapchainJustBecameRenderable = false;
- cd->depthStencilForSwapchain->setPixelSize(effectiveOutputSize);
- cd->depthStencilForSwapchain->build();
cd->hasActiveSwapchain = cd->swapchain->buildOrResize();
+ if (!cd->hasActiveSwapchain && rhi->isDeviceLost()) {
+ handleDeviceLoss();
+ QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest)));
+ return;
+ }
+ cd->swapchainJustBecameRenderable = false;
cd->hasRenderableSwapchain = cd->hasActiveSwapchain;
+
if (!cd->hasActiveSwapchain)
qWarning("Failed to build or resize swapchain");
else
- qCDebug(QSG_LOG_RENDERLOOP) << "rhi swapchain size" << effectiveOutputSize;
+ qCDebug(QSG_LOG_RENDERLOOP) << "rhi swapchain size" << cd->swapchain->currentPixelSize();
}
Q_ASSERT(rhi == cd->rhi);
@@ -718,13 +737,12 @@ void QSGRenderThread::syncAndRender(QImage *grabImage)
QRhi::FrameOpResult frameResult = rhi->beginFrame(cd->swapchain, frameFlags);
if (frameResult != QRhi::FrameOpSuccess) {
if (frameResult == QRhi::FrameOpDeviceLost)
- qWarning("Device lost");
+ handleDeviceLoss();
else if (frameResult == QRhi::FrameOpError)
qWarning("Failed to start frame");
// try again later
if (frameResult == QRhi::FrameOpDeviceLost || frameResult == QRhi::FrameOpSwapChainOutOfDate)
QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest)));
-
// Before returning we need to ensure the same wake up logic that
// would have happened if beginFrame() had suceeded.
if (exposeRequested) {
@@ -789,8 +807,9 @@ void QSGRenderThread::syncAndRender(QImage *grabImage)
}
}
if (current) {
+ const QSize outputSize = rhi ? cd->swapchain->currentPixelSize() : windowSize;
- d->renderSceneGraph(windowSize);
+ d->renderSceneGraph(outputSize);
if (profileFrames)
renderTime = threadTimer.nsecsElapsed();
@@ -810,7 +829,15 @@ void QSGRenderThread::syncAndRender(QImage *grabImage)
QRhi::EndFrameFlags flags = 0;
if (grabImage)
flags |= QRhi::SkipPresent;
- rhi->endFrame(cd->swapchain, flags);
+ QRhi::FrameOpResult frameResult = rhi->endFrame(cd->swapchain, flags);
+ if (frameResult != QRhi::FrameOpSuccess) {
+ if (frameResult == QRhi::FrameOpDeviceLost)
+ handleDeviceLoss();
+ else if (frameResult == QRhi::FrameOpError)
+ qWarning("Failed to end frame");
+ if (frameResult == QRhi::FrameOpDeviceLost || frameResult == QRhi::FrameOpSwapChainOutOfDate)
+ QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest)));
+ }
} else {
if (!cd->customRenderStage || !cd->customRenderStage->swap())
gl->swapBuffers(window);
@@ -884,6 +911,57 @@ void QSGRenderThread::processEventsAndWaitForMore()
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "--- done processEventsAndWaitForMore()");
}
+void QSGRenderThread::ensureRhi()
+{
+ if (!rhi) {
+ QSGRhiSupport *rhiSupport = QSGRhiSupport::instance();
+ rhi = rhiSupport->createRhi(window, offscreenSurface);
+ if (rhi) {
+ rhiSampleCount = rhiSupport->chooseSampleCountForWindowWithRhi(window, rhi);
+ if (rhiSupport->isProfilingRequested())
+ QSGRhiProfileConnection::instance()->initialize(rhi); // ### this breaks down with multiple windows
+ } else {
+ qWarning("Failed to create QRhi on the render thread; scenegraph is not functional");
+ return;
+ }
+ }
+ if (!sgrc->rhi() && windowSize.width() > 0 && windowSize.height() > 0) {
+ rhi->makeThreadLocalNativeContextCurrent();
+ QSGDefaultRenderContext::InitParams rcParams;
+ rcParams.rhi = rhi;
+ rcParams.sampleCount = rhiSampleCount;
+ rcParams.openGLContext = nullptr;
+ rcParams.initialSurfacePixelSize = windowSize * qreal(dpr);
+ rcParams.maybeSurface = window;
+ sgrc->initialize(&rcParams);
+ }
+ QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
+ if (rhi && !cd->swapchain) {
+ cd->rhi = rhi;
+ QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab
+ // QQ is always premul alpha. Decide based on alphaBufferSize in
+ // requestedFormat(). (the platform plugin can override format() but
+ // what matters here is what the application wanted, hence using the
+ // requested one)
+ const bool alpha = window->requestedFormat().alphaBufferSize() > 0;
+ if (alpha)
+ flags |= QRhiSwapChain::SurfaceHasPreMulAlpha;
+ cd->swapchain = rhi->newSwapChain();
+ cd->depthStencilForSwapchain = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil,
+ QSize(),
+ rhiSampleCount,
+ QRhiRenderBuffer::UsedWithSwapChainOnly);
+ cd->swapchain->setWindow(window);
+ cd->swapchain->setDepthStencil(cd->depthStencilForSwapchain);
+ qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d. Alpha channel requested = %s.",
+ rhiSampleCount, alpha ? "yes" : "no");
+ cd->swapchain->setSampleCount(rhiSampleCount);
+ cd->swapchain->setFlags(flags);
+ cd->rpDescForSwapchain = cd->swapchain->newCompatibleRenderPassDescriptor();
+ cd->swapchain->setRenderPassDescriptor(cd->rpDescForSwapchain);
+ }
+}
+
void QSGRenderThread::run()
{
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "run()");
@@ -899,55 +977,20 @@ void QSGRenderThread::run()
if (window) {
if (enableRhi) {
- if (!rhi) {
- QSGRhiSupport *rhiSupport = QSGRhiSupport::instance();
- rhi = rhiSupport->createRhi(window, offscreenSurface);
- if (rhi) {
- rhiSampleCount = rhiSupport->chooseSampleCountForWindowWithRhi(window, rhi);
- if (rhiSupport->isProfilingRequested())
- QSGRhiProfileConnection::instance()->initialize(rhi); // ### this breaks down with multiple windows
- } else {
- qWarning("Failed to create QRhi on the render thread; scenegraph is not functional");
- }
- }
- if (!sgrc->rhi() && windowSize.width() > 0 && windowSize.height() > 0) {
- rhi->makeThreadLocalNativeContextCurrent();
- QSGDefaultRenderContext::InitParams rcParams;
- rcParams.rhi = rhi;
- rcParams.sampleCount = rhiSampleCount;
- rcParams.openGLContext = gl;
- rcParams.initialSurfacePixelSize = windowSize * dpr;
- rcParams.maybeSurface = window;
- sgrc->initialize(&rcParams);
- }
- QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
- if (rhi && !cd->swapchain) {
- cd->rhi = rhi;
- QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab
- cd->swapchain = rhi->newSwapChain();
- cd->depthStencilForSwapchain = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil,
- QSize(),
- rhiSampleCount,
- QRhiRenderBuffer::UsedWithSwapChainOnly);
- cd->swapchain->setWindow(window);
- cd->swapchain->setDepthStencil(cd->depthStencilForSwapchain);
- qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d", rhiSampleCount);
- cd->swapchain->setSampleCount(rhiSampleCount);
- cd->swapchain->setFlags(flags);
- cd->rpDescForSwapchain = cd->swapchain->newCompatibleRenderPassDescriptor();
- cd->swapchain->setRenderPassDescriptor(cd->rpDescForSwapchain);
- }
+ ensureRhi();
+ if (rhi)
+ syncAndRender();
} else {
if (!sgrc->openglContext() && windowSize.width() > 0 && windowSize.height() > 0 && gl->makeCurrent(window)) {
QSGDefaultRenderContext::InitParams rcParams;
rcParams.sampleCount = qMax(1, gl->format().samples());
rcParams.openGLContext = gl;
- rcParams.initialSurfacePixelSize = windowSize * dpr;
+ rcParams.initialSurfacePixelSize = windowSize * qreal(dpr);
rcParams.maybeSurface = window;
sgrc->initialize(&rcParams);
}
+ syncAndRender();
}
- syncAndRender();
}
processEvents();
@@ -1259,7 +1302,8 @@ void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window)
}
}
- QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController;
+ QQuickAnimatorController *controller
+ = QQuickWindowPrivate::get(w->window)->animationController.get();
if (controller->thread() != w->thread)
controller->moveToThread(w->thread);
@@ -1354,6 +1398,8 @@ void QSGThreadedRenderLoop::maybeUpdate(Window *w)
return;
QThread *current = QThread::currentThread();
+ if (current == w->thread && w->thread->rhi && w->thread->rhi->isDeviceLost())
+ return;
if (current != QCoreApplication::instance()->thread() && (current != w->thread || !m_lockedForSync)) {
qWarning() << "Updates can only be scheduled from GUI thread or from QQuickItem::updatePaintNode()";
return;
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index 220c70c299..5b48b86568 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -269,7 +269,7 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window)
m_gl->doneCurrent();
}
- delete d->animationController;
+ d->animationController.reset();
}
bool QSGWindowsRenderLoop::anyoneShowing() const
diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri
index c345f3b16d..56d97226fb 100644
--- a/src/quick/scenegraph/scenegraph.pri
+++ b/src/quick/scenegraph/scenegraph.pri
@@ -94,7 +94,6 @@ qtConfig(opengl(es1|es2)?) {
# rhi, still tied to OpenGL-enabled Qt builds for now
HEADERS += \
- $$PWD/qsgrhisupport_p.h \
$$PWD/qsgrhitextureglyphcache_p.h \
$$PWD/util/qsgrhiatlastexture_p.h \
$$PWD/qsgrhilayer_p.h \
@@ -102,7 +101,6 @@ qtConfig(opengl(es1|es2)?) {
$$PWD/qsgrhidistancefieldglyphcache_p.h
SOURCES += \
- $$PWD/qsgrhisupport.cpp \
$$PWD/qsgrhitextureglyphcache.cpp \
$$PWD/qsgrhilayer.cpp \
$$PWD/qsgrhishadereffectnode.cpp \
@@ -118,7 +116,8 @@ HEADERS += \
$$PWD/qsgbasicinternalrectanglenode_p.h \
$$PWD/qsgbasicinternalimagenode_p.h \
$$PWD/qsgbasicglyphnode_p.h \
- $$PWD/qsgrenderloop_p.h
+ $$PWD/qsgrenderloop_p.h \
+ $$PWD/qsgrhisupport_p.h
SOURCES += \
$$PWD/qsgadaptationlayer.cpp \
@@ -127,7 +126,8 @@ SOURCES += \
$$PWD/qsgbasicinternalrectanglenode.cpp \
$$PWD/qsgbasicinternalimagenode.cpp \
$$PWD/qsgbasicglyphnode.cpp \
- $$PWD/qsgrenderloop.cpp
+ $$PWD/qsgrenderloop.cpp \
+ $$PWD/qsgrhisupport.cpp
qtConfig(opengl(es1|es2)?) {
SOURCES += \
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
index f121d2a9e2..87941bf31a 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
@@ -121,7 +121,7 @@ class FlatColorMaterialRhiShader : public QSGMaterialRhiShader
public:
FlatColorMaterialRhiShader();
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
FlatColorMaterialRhiShader::FlatColorMaterialRhiShader()
@@ -130,7 +130,7 @@ FlatColorMaterialRhiShader::FlatColorMaterialRhiShader()
setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/flatcolor.frag.qsb"));
}
-bool FlatColorMaterialRhiShader::updateUniformData(const RenderState &state,
+bool FlatColorMaterialRhiShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial,
QSGMaterial *oldMaterial)
{
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index df4e5cfde2..67b8748119 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -125,7 +125,7 @@ QSGOpaqueTextureMaterialRhiShader::QSGOpaqueTextureMaterialRhiShader()
setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/opaquetexture.frag.qsb"));
}
-bool QSGOpaqueTextureMaterialRhiShader::updateUniformData(const RenderState &state, QSGMaterial *, QSGMaterial *)
+bool QSGOpaqueTextureMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *)
{
bool changed = false;
QByteArray *buf = state.uniformData();
@@ -139,7 +139,7 @@ bool QSGOpaqueTextureMaterialRhiShader::updateUniformData(const RenderState &sta
return changed;
}
-void QSGOpaqueTextureMaterialRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture,
+void QSGOpaqueTextureMaterialRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
if (binding != 1)
@@ -473,7 +473,7 @@ QSGTextureMaterialRhiShader::QSGTextureMaterialRhiShader()
setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/texture.frag.qsb"));
}
-bool QSGTextureMaterialRhiShader::updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
+bool QSGTextureMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
bool changed = false;
QByteArray *buf = state.uniformData();
diff --git a/src/quick/scenegraph/util/qsgtexturematerial_p.h b/src/quick/scenegraph/util/qsgtexturematerial_p.h
index 7ef17af526..d1ef7d1d7f 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial_p.h
+++ b/src/quick/scenegraph/util/qsgtexturematerial_p.h
@@ -75,8 +75,8 @@ class Q_QUICK_PRIVATE_EXPORT QSGOpaqueTextureMaterialRhiShader : public QSGMater
public:
QSGOpaqueTextureMaterialRhiShader();
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
- void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
class QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader
@@ -96,7 +96,7 @@ class QSGTextureMaterialRhiShader : public QSGOpaqueTextureMaterialRhiShader
public:
QSGTextureMaterialRhiShader();
- bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
index 23f57141a6..c27dd7d1f0 100644
--- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
@@ -100,7 +100,7 @@ class QSGVertexColorMaterialRhiShader : public QSGMaterialRhiShader
public:
QSGVertexColorMaterialRhiShader();
- bool updateUniformData(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
};
QSGVertexColorMaterialRhiShader::QSGVertexColorMaterialRhiShader()
@@ -109,7 +109,7 @@ QSGVertexColorMaterialRhiShader::QSGVertexColorMaterialRhiShader()
setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/vertexcolor.frag.qsb"));
}
-bool QSGVertexColorMaterialRhiShader::updateUniformData(const RenderState &state,
+bool QSGVertexColorMaterialRhiShader::updateUniformData(RenderState &state,
QSGMaterial * /*newEffect*/,
QSGMaterial * /*oldEffect*/)
{
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp
index 92d62c8d24..0112a4b337 100644
--- a/src/quick/util/qquickanimatorjob.cpp
+++ b/src/quick/util/qquickanimatorjob.cpp
@@ -207,7 +207,7 @@ void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)
stop();
} else if (!m_controller && m_job) {
- m_controller = QQuickWindowPrivate::get(window)->animationController;
+ m_controller = QQuickWindowPrivate::get(window)->animationController.get();
if (window->isSceneGraphInitialized())
readyToAnimate();
else
diff --git a/src/quick/util/qquickfontmetrics.cpp b/src/quick/util/qquickfontmetrics.cpp
index 42b3038c48..c9a9008180 100644
--- a/src/quick/util/qquickfontmetrics.cpp
+++ b/src/quick/util/qquickfontmetrics.cpp
@@ -327,10 +327,13 @@ QRectF QQuickFontMetrics::tightBoundingRect(const QString &text) const
/*!
\qmlmethod string QtQuick::FontMetrics::elidedText(string text, enumeration mode, real width, int flags)
- This method returns a returns an elided version of the string (i.e., a
+ This method returns an elided version of the string (i.e., a
string with "..." in it) if the string \a text is wider than \a width.
Otherwise, returns the original string.
+ The \a mode argument specifies the text elide mode; that is, where
+ the ellipsis should appear when displaying text that doesn't fit.
+
The \a flags argument is optional and currently only supports
\l {Qt::TextShowMnemonic}.
@@ -338,7 +341,7 @@ QRectF QQuickFontMetrics::tightBoundingRect(const QString &text) const
\l {QQuickTextMetrics::elidedText}{elidedText} property of
\l {QQuickTextMetrics::elidedText}{TextMetrics}.
- \sa {QFontMetricsF::elidedText()}
+ \sa Qt::TextElideMode, QFontMetricsF::elidedText()
*/
QString QQuickFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags) const
{