aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-08-19 22:40:56 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-11-29 23:12:45 +0100
commit9b62f4c27ac3fb3dc563c7f4657094c14d752bac (patch)
tree4b950ad460a556526ab46f0cea02ee3f23cf5324 /src/quick/items/qquickitem_p.h
parentf7af78fced16e349b861a412ba467fd33d549377 (diff)
Allow any Item to act as a viewport for any of its children
The children that have the ItemObservesViewport flag set will have transformChanged() called whenever any parent moves, and can use clipRect() to avoid creating SG nodes that fall outside the viewport. So now the viewport can be narrower than the whole QQuickWindow; but the fallback is the window. It was always unclear why we had both boundingRect() and clipRect(), returning the same rectangular areas. Now clipRect() can actually be used for a rough pre-clipping, to limit the amount of vertex data going into the scene graph, which can save a lot of memory in some cases. setClip() sets the ItemIsViewport flag, for the sake of making it easy to do viewporting without writing C++; but it's well known that scissoring has a performance impact, so we recommend that users who are writing C++ anyway can set the flags in C++ rather than in QML. In case there are nested items with both flags ItemIsViewport and ItemObservesViewport, calling clipRect() on something inside the innermost viewport is recursive: we intersect all the viewports, going up the hierarchy to the window. So it's possible for the innermost item to be clipped down to a small "iris" where all the viewports are letting "light" pass through. [ChangeLog][QtQuick][QQuickItem] QQuickItem::clipRect() now provides the region visible in the viewport, and can be used to limit SG node vertices as an optimization in custom items, at the cost of having updatePaintNode() called more often. See docs about the new ItemObservesViewport and ItemIsViewport flags. Fixes: QTBUG-37364 Task-number: QTBUG-60491 Task-number: QTBUG-65741 Task-number: QTBUG-77521 Task-number: QTBUG-90734 Change-Id: I71a26c2dab4e991d7fb0f6679f1aa0c34e7a14ee Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quick/items/qquickitem_p.h')
-rw-r--r--src/quick/items/qquickitem_p.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 0d35cfd48c..51ef850d5f 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -441,7 +441,7 @@ public:
inline QQuickItem::TransformOrigin origin() const;
// Bit 0
- quint32 flags:5;
+ quint32 flags:7;
bool widthValidFlag:1;
bool heightValidFlag:1;
bool componentComplete:1;
@@ -451,9 +451,9 @@ public:
bool smooth:1;
bool antialiasing:1;
bool focus:1;
+ // Bit 16
bool activeFocus:1;
bool notifiedFocus:1;
- // Bit 16
bool notifiedActiveFocus:1;
bool filtersChildMouseEvents:1;
bool explicitVisible:1;
@@ -468,9 +468,9 @@ public:
bool inheritMirrorFromItem:1;
bool isAccessible:1;
bool culled:1;
+ // Bit 32
bool hasCursor:1;
bool subtreeCursorEnabled:1;
- // Bit 32
bool subtreeHoverEnabled:1;
bool activeFocusOnTab:1;
bool implicitAntialiasing:1;
@@ -486,6 +486,9 @@ public:
bool hasCursorHandler:1;
// set true when this item does not expect events via a subscene delivery agent; false otherwise
bool maybeHasSubsceneDeliveryAgent:1;
+ // set true if this item or any child wants QQuickItemPrivate::transformChanged() to visit all children
+ // (e.g. when parent has ItemIsViewport and child has ItemObservesViewport)
+ bool subtreeTransformChangedEnabled:1;
enum DirtyType {
TransformOrigin = 0x00000001,
@@ -617,7 +620,7 @@ public:
}
QPointF computeTransformOrigin() const;
- virtual void transformChanged(QQuickItem *transformedItem);
+ virtual bool transformChanged(QQuickItem *transformedItem);
QPointF adjustedPosForTransform(const QPointF &centroid,
const QPointF &startPos, const QVector2D &activeTranslatation,