39QSizeF QQuickItemSpy::requiredTextureSize()
const
41 QSizeF sz = mapRectToScene(QRectF(0, 0, width(), height())).size();
43 const qreal dpr = window() !=
nullptr ? window()->devicePixelRatio() : 1.0;
45 const qreal mappedWidth = sz.width() * dpr;
46 const qreal mappedHeight = sz.height() * dpr;
47 sz.setWidth(qIsFinite(mappedWidth) ? std::max(1.0, mappedWidth) : 1.0);
48 sz.setHeight(qIsFinite(mappedHeight) ? std::max(1.0, mappedHeight) : 1.0);
50 if (window() !=
nullptr && window()->rhi() !=
nullptr) {
51 QRhi *rhi = window()->rhi();
52 const int textureSizeMax = rhi->resourceLimit(QRhi::TextureSizeMax);
54 if (sz.width() > textureSizeMax || sz.height() > textureSizeMax) {
55 if (sz.width() > sz.height())
56 sz = QSizeF(textureSizeMax, sz.height() * (textureSizeMax / sz.width()));
58 sz = QSizeF(sz.width() * (textureSizeMax / sz.height()), textureSizeMax);
65void QQuickItemSpy::itemChange(ItemChange change,
const ItemChangeData &value)
67 if (change == ItemTransformHasChanged || change == ItemDevicePixelRatioHasChanged)
68 emit requiredTextureSizeChanged();
70 QQuickItem::itemChange(change, value);