summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2020-07-28 07:21:41 +0300
committerTomi Korpipaa <tomi.korpipaa@qt.io>2020-08-12 08:02:01 +0300
commite2f3a05959ff375996a9da8b0ab59dec7f508a80 (patch)
tree0de128e1693abc602e11d544a3dcffa480361905
parentb43e39c8a20e781a1b9ed24ad0bd963d06a5d1c1 (diff)
Scale QML stream item size up to nearest divisible-by-four size
Task-number: QT3DS-4144 Change-Id: Id1bd2387538a6cf865c59830730d80eb5f93652f Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Antti Määttä <antti.maatta@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/qmlstreamer/q3dsqmlstream.cpp6
-rw-r--r--src/qmlstreamer/q3dsqmlstreamrenderer.cpp11
-rw-r--r--src/qmlstreamer/q3dsqmlsubpresentationsettings.cpp2
3 files changed, 18 insertions, 1 deletions
diff --git a/src/qmlstreamer/q3dsqmlstream.cpp b/src/qmlstreamer/q3dsqmlstream.cpp
index bea6610..caf197f 100644
--- a/src/qmlstreamer/q3dsqmlstream.cpp
+++ b/src/qmlstreamer/q3dsqmlstream.cpp
@@ -74,10 +74,16 @@ QString Q3DSQmlStream::presentationId() const
/*!
* \qmlproperty Item QmlStream::item
* Contains the Item to be streamed as subpresentation.
+ * \note The Item width and height will be scaled up to the nearest divisible-by-four number to
+ * avoid rendering artefacts. If you wish to have pixel perfect outcome, define your QML stream
+ * items to use size that already has dimensions that are divisible by four.
*/
/*!
* \property Q3DSQmlStream::item
* Contains the QQuickItem to be streamed as subpresentation.
+ * \note The Item width and height will be scaled up to the nearest divisible-by-four number to
+ * avoid rendering artefacts. If you wish to have pixel perfect outcome, define your QML stream
+ * items to use size that already has dimensions that are divisible by four.
*/
QQuickItem *Q3DSQmlStream::item() const
{
diff --git a/src/qmlstreamer/q3dsqmlstreamrenderer.cpp b/src/qmlstreamer/q3dsqmlstreamrenderer.cpp
index f1879a6..c0cb630 100644
--- a/src/qmlstreamer/q3dsqmlstreamrenderer.cpp
+++ b/src/qmlstreamer/q3dsqmlstreamrenderer.cpp
@@ -392,6 +392,17 @@ void Q3DSQmlStreamRenderer::updateSizes()
{
if (m_rootItem->width() > 0 && m_rootItem->height() > 0) {
m_size = QSize(m_rootItem->width(), m_rootItem->height());
+ // Make the dimensions divisible by four; this prevents rendering artefacts
+ // In worst case scenario this increases the size by 3 pixels in each dimension
+ // TODO: Would it be possible to add transparent pixels around the original stream
+ // to meet the divisible by four -requirement, but render the original amount of pixels?
+ // That way the end result would still be pixel perfect, unlike with this implementation.
+ const int w = m_size.width();
+ const int h = m_size.height();
+ if (w % 4 != 0)
+ m_size.setWidth(w + 4 - w % 4);
+ if (h % 4 != 0)
+ m_size.setHeight(h + 4 - h % 4);
} else {
m_rootItem->setWidth(256);
m_rootItem->setHeight(256);
diff --git a/src/qmlstreamer/q3dsqmlsubpresentationsettings.cpp b/src/qmlstreamer/q3dsqmlsubpresentationsettings.cpp
index 664b9e4..739c6b5 100644
--- a/src/qmlstreamer/q3dsqmlsubpresentationsettings.cpp
+++ b/src/qmlstreamer/q3dsqmlsubpresentationsettings.cpp
@@ -58,7 +58,7 @@ Q3DSSubPresentationSettings::~Q3DSSubPresentationSettings()
}
/*!
- * \qmlproperty variant SubPresentationSettings::qmlStream
+ * \qmlproperty variant SubPresentationSettings::qmlStreams
* Contains the QML streams to be used as subpresentations.
*/
/*!