forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -504,6 +504,12 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
|
||||
#ifndef QMLDESIGNER_TEST
|
||||
const QString controlsStyle = m_designerSettings.value(DesignerSettingsKey::
|
||||
CONTROLS_STYLE).toString();
|
||||
|
||||
const bool smoothRendering = m_designerSettings.value(DesignerSettingsKey::SMOOTH_RENDERING)
|
||||
.toBool();
|
||||
|
||||
if (smoothRendering)
|
||||
environment.set("QMLPUPPET_SMOOTH_RENDERING", "true");
|
||||
#else
|
||||
const QString controlsStyle;
|
||||
#endif
|
||||
|
@@ -82,6 +82,7 @@ void DesignerSettings::fromSettings(QSettings *settings)
|
||||
restoreValue(settings, DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET, true);
|
||||
const QStringList defaultValue = QStringList() << "#222222" << "#999999";
|
||||
restoreValue(settings, DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR, defaultValue);
|
||||
restoreValue(settings, DesignerSettingsKey::SMOOTH_RENDERING, false);
|
||||
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
|
@@ -72,6 +72,7 @@ const char COLOR_PALETTE_FAVORITE[] = "ColorPaletteFavorite";
|
||||
const char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode";
|
||||
const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer";
|
||||
const char ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset";
|
||||
const char SMOOTH_RENDERING[] = "SmoothRendering";
|
||||
}
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant>
|
||||
|
@@ -182,6 +182,7 @@ DesignerSettings SettingsPageWidget::settings() const
|
||||
m_ui.designerAlwaysDesignModeCheckBox->isChecked());
|
||||
settings.insert(DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET,
|
||||
m_ui.askBeforeDeletingAssetCheckBox->isChecked());
|
||||
settings.insert(DesignerSettingsKey::SMOOTH_RENDERING, m_ui.smoothRendering->isChecked());
|
||||
|
||||
return settings;
|
||||
}
|
||||
@@ -264,6 +265,7 @@ void SettingsPageWidget::setSettings(const DesignerSettings &settings)
|
||||
m_ui.emulationGroupBox->setVisible(showAdvancedFeatures);
|
||||
m_ui.debugGroupBox->setVisible(showAdvancedFeatures);
|
||||
m_ui.featureTimelineEditorCheckBox->setVisible(standaloneMode);
|
||||
m_ui.smoothRendering->setChecked(settings.value(DesignerSettingsKey::SMOOTH_RENDERING).toBool());
|
||||
}
|
||||
|
||||
void SettingsPageWidget::apply()
|
||||
|
@@ -99,6 +99,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="smoothRendering">
|
||||
<property name="toolTip">
|
||||
<string>Enable Smooth Rendering in Form Editor</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="smoothRenderingLabel">
|
||||
<property name="text">
|
||||
<string>Smooth Rendering:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Reference in New Issue
Block a user