diff options
| author | Laszlo Agocs <laszlo.agocs@qt.io> | 2024-08-12 16:44:04 +0200 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-08-27 10:54:07 +0000 |
| commit | f1a9c01e682c4f11f9e336cdcf040993a379e860 (patch) | |
| tree | 8f732cc718cdc3fd062d6c0557654819d7847981 | |
| parent | d187875817e855e89fb349bee82f619874e70abb (diff) | |
QQuickWidget: Clamp texture size
Copy the behavior from QQuickRhiItem, which handles this correctly.
The older QQuickWidget seems to lack that logic for some reason.
Also add a qWarning to make it clear what is happening, because
clamping the texture size may cause unexpected results in the
visual output.
Pick-to: 6.6 6.5
Fixes: QTBUG-123636
Change-Id: I08d4ac23f709c85dc975c030fd198127d7eb4d23
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 431da3b90556e0ffceaff4aea878c480818cdd69)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c07953df95adb0d99098b88857c150be1c191d96)
| -rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index b99838f337..5efcfc7812 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -1123,7 +1123,17 @@ void QQuickWidget::createFramebufferObject() else samples = 0; - const QSize fboSize = size() * devicePixelRatio(); + const int minTexSize = d->rhi->resourceLimit(QRhi::TextureSizeMin); + const int maxTexSize = d->rhi->resourceLimit(QRhi::TextureSizeMax); + + QSize fboSize = size() * devicePixelRatio(); + if (fboSize.width() > maxTexSize || fboSize.height() > maxTexSize) { + qWarning("QQuickWidget: Requested backing texture size is %dx%d, but the maximum texture size for the 3D API implementation is %dx%d", + fboSize.width(), fboSize.height(), + maxTexSize, maxTexSize); + } + fboSize.setWidth(qMin(maxTexSize, qMax(minTexSize, fboSize.width()))); + fboSize.setHeight(qMin(maxTexSize, qMax(minTexSize, fboSize.height()))); // Could be a simple hide - show, in which case the previous texture is just fine. if (!d->outputTexture) { |
