aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2022-06-09 19:40:23 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2022-06-10 09:04:11 +0000
commitd8c605179ad4934c5f9a2060dd398a13821336c4 (patch)
treedddc4719928ae68bff1d63917daf4cb49b36d44a /share
parent8ca39444f4cadff3ae543877008cd9f6443380db (diff)
QmlDesigner: Add option for smooth rendering in form editor
Smooth rendering turns on MSAA and doubles the resolution for rendered items. With this option enabled everything stays smooth when zooming in. Around factor 8-10 pixels become clearly visible again, but it still looks relatively smooth. I added both MSAA and increased the resolution to one option, for simplicity. The smooth mode takes 4 times the shared memory, which should not be an issue in most cases. For now, the option is not the default. Task-number: QDS-7129 Task-number: QDS-7128 Change-Id: I8a778650bb40f8ba796960db9bc966e8a1efff4e Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp11
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp4
2 files changed, 11 insertions, 4 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
index 32f63a8cd6..e7a98b7427 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
@@ -405,6 +405,9 @@ QImage Qt5NodeInstanceServer::grabItem(QQuickItem *item)
QQuickItemPrivate *pItem = QQuickItemPrivate::get(item);
const bool renderEffects = qEnvironmentVariableIsSet("QMLPUPPET_RENDER_EFFECTS");
+ const bool smoothRendering = qEnvironmentVariableIsSet("QMLPUPPET_SMOOTH_RENDERING");
+
+ int scaleFactor = smoothRendering ? 2 : 1;
if (renderEffects) {
if (parentEffectItem(item))
@@ -470,6 +473,8 @@ QImage Qt5NodeInstanceServer::grabItem(QQuickItem *item)
// us to render it to a texture that we can grab to an image.
QSGRenderContext *rc = QQuickWindowPrivate::get(m_viewData.window.data())->context;
QSGLayer *layer = rc->sceneGraphContext()->createLayer(rc);
+ if (smoothRendering)
+ layer->setSamples(4);
layer->setItem(pItem->itemNode());
layer->setRect(QRectF(renderBoundingRect.x(),
@@ -478,8 +483,8 @@ QImage Qt5NodeInstanceServer::grabItem(QQuickItem *item)
-renderBoundingRect.height()));
const QSize minSize = rc->sceneGraphContext()->minimumFBOSize();
- layer->setSize(QSize(qMax(minSize.width(), int(renderBoundingRect.width())),
- qMax(minSize.height(), int(renderBoundingRect.height()))));
+ layer->setSize(QSize(qMax(minSize.width(), int(renderBoundingRect.width() * scaleFactor)),
+ qMax(minSize.height(), int(renderBoundingRect.height() * scaleFactor))));
layer->scheduleUpdate();
if (layer->updateTexture())
@@ -489,6 +494,8 @@ QImage Qt5NodeInstanceServer::grabItem(QQuickItem *item)
delete layer;
layer = nullptr;
+
+ renderImage.setDevicePixelRatio(scaleFactor);
});
m_viewData.renderControl->render();
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
index 41d0015ce5..5b1f3171ad 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
@@ -504,12 +504,12 @@ QImage QuickItemNodeInstance::renderImage() const
if (s_unifiedRenderPath) {
renderImage = nodeInstanceServer()->grabWindow();
renderImage = renderImage.copy(renderBoundingRect.toRect());
+ /* When grabbing an offscren window the device pixel ratio is 1 */
+ renderImage.setDevicePixelRatio(1);
} else {
renderImage = nodeInstanceServer()->grabItem(quickItem());
}
- /* When grabbing an offscren window the device pixel ratio is 1 */
- renderImage.setDevicePixelRatio(1);
#endif
return renderImage;