aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquickgridview.cpp10
-rw-r--r--src/quick/items/qquicklistview.cpp10
-rw-r--r--src/quick/items/qquickpathview.cpp10
-rw-r--r--src/quick/items/qquicktext.cpp5
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp12
-rw-r--r--src/quick/scenegraph/util/qsgdefaultpainternode.cpp1
-rw-r--r--src/quick/util/qquickstyledtext.cpp15
-rw-r--r--src/quick/util/qquickstyledtext_p.h3
8 files changed, 42 insertions, 24 deletions
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index da48fd869d..cb2611199e 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -1549,10 +1549,12 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
Note that cacheBuffer is not a pixel buffer - it only maintains additional
instantiated delegates.
- Setting this value can make scrolling the list smoother at the expense
- of additional memory usage. It is not a substitute for creating efficient
- delegates; the fewer objects and bindings in a delegate, the faster a view may be
- scrolled.
+ \note Setting this property is not a replacement for creating efficient delegates.
+ It can improve the smoothness of scrolling behavior at the expense of additional
+ memory usage. The fewer objects and bindings in a delegate, the faster a
+ view can be scrolled. It is important to realize that setting a cacheBuffer
+ will only postpone issues caused by slow-loading delegates, it is not a
+ solution for this scenario.
The cacheBuffer operates outside of any display margins specified by
displayMarginBeginning or displayMarginEnd.
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index f843b09592..074af7ebdc 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -2219,10 +2219,12 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation)
Note that cacheBuffer is not a pixel buffer - it only maintains additional
instantiated delegates.
- Setting this value can improve the smoothness of scrolling behavior at the expense
- of additional memory usage. It is not a substitute for creating efficient
- delegates; the fewer objects and bindings in a delegate, the faster a view can be
- scrolled.
+ \note Setting this property is not a replacement for creating efficient delegates.
+ It can improve the smoothness of scrolling behavior at the expense of additional
+ memory usage. The fewer objects and bindings in a delegate, the faster a
+ view can be scrolled. It is important to realize that setting a cacheBuffer
+ will only postpone issues caused by slow-loading delegates, it is not a
+ solution for this scenario.
The cacheBuffer operates outside of any display margins specified by
displayMarginBeginning or displayMarginEnd.
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 7bb52853bc..c7e476c4b5 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -1313,10 +1313,12 @@ void QQuickPathView::resetPathItemCount()
allowing creation to occur across multiple frames and reducing the
likelihood of skipping frames.
- Setting this value can improve the smoothness of scrolling behavior at the expense
- of additional memory usage. It is not a substitute for creating efficient
- delegates; the fewer objects and bindings in a delegate, the faster a view can be
- moved.
+ \note Setting this property is not a replacement for creating efficient delegates.
+ It can improve the smoothness of scrolling behavior at the expense of additional
+ memory usage. The fewer objects and bindings in a delegate, the faster a
+ view can be scrolled. It is important to realize that setting cacheItemCount
+ will only postpone issues caused by slow-loading delegates, it is not a
+ solution for this scenario.
\sa pathItemCount
*/
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 8b1d47ac0b..59331647e5 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -1153,7 +1153,10 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
foreach (QQuickStyledTextImgTag *image, imagesInLine) {
totalLineHeight = qMax(totalLineHeight, textTop + image->pos.y() + image->size.height());
- image->pos.setX(line.cursorToX(image->position));
+ const int leadX = line.cursorToX(image->position);
+ const int trailX = line.cursorToX(image->position, QTextLine::Trailing);
+ const bool rtl = trailX < leadX;
+ image->pos.setX(leadX + (rtl ? (-image->offset - image->size.width()) : image->offset));
image->pos.setY(image->pos.y() + height + textTop);
extra->visibleImgTags << image;
}
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index 1fc63db1b2..b28ca7725a 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -103,8 +103,10 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyph
glyph_t glyphIndex = *it;
int padding = QSG_DEFAULT_DISTANCEFIELD_GLYPH_CACHE_PADDING;
- int glyphWidth = qCeil(glyphData(glyphIndex).boundingRect.width()) + distanceFieldRadius() * 2;
- QSize glyphSize(glyphWidth + padding * 2, QT_DISTANCEFIELD_TILESIZE(doubleGlyphResolution()) + padding * 2);
+ QRectF boundingRect = glyphData(glyphIndex).boundingRect;
+ int glyphWidth = qCeil(boundingRect.width()) + distanceFieldRadius() * 2;
+ int glyphHeight = qCeil(boundingRect.height()) + distanceFieldRadius() * 2;
+ QSize glyphSize(glyphWidth + padding * 2, glyphHeight + padding * 2);
QRect alloc = m_areaAllocator->allocate(glyphSize);
if (alloc.isNull()) {
@@ -113,11 +115,13 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyph
glyph_t unusedGlyph = *m_unusedGlyphs.constBegin();
TexCoord unusedCoord = glyphTexCoord(unusedGlyph);
- int unusedGlyphWidth = qCeil(glyphData(unusedGlyph).boundingRect.width()) + distanceFieldRadius() * 2;
+ QRectF unusedGlyphBoundingRect = glyphData(unusedGlyph).boundingRect;
+ int unusedGlyphWidth = qCeil(unusedGlyphBoundingRect.width()) + distanceFieldRadius() * 2;
+ int unusedGlyphHeight = qCeil(unusedGlyphBoundingRect.height()) + distanceFieldRadius() * 2;
m_areaAllocator->deallocate(QRect(unusedCoord.x - padding,
unusedCoord.y - padding,
padding * 2 + unusedGlyphWidth,
- padding * 2 + QT_DISTANCEFIELD_TILESIZE(doubleGlyphResolution())));
+ padding * 2 + unusedGlyphHeight));
m_unusedGlyphs.remove(unusedGlyph);
m_glyphsTexture.remove(unusedGlyph);
diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
index 2deb993a6e..e56f586c90 100644
--- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
+++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
@@ -316,7 +316,6 @@ void QSGDefaultPainterNode::updateRenderTarget()
if (m_texture)
delete m_texture;
- texture->setTextureSize(m_size);
m_texture = texture;
}
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
index 83409e8b34..4139c87eda 100644
--- a/src/quick/util/qquickstyledtext.cpp
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -658,10 +658,13 @@ bool QQuickStyledTextPrivate::parseAnchorAttributes(const QChar *&ch, const QStr
void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut)
{
qreal imgWidth = 0.0;
+ QFontMetricsF fm(layout.font());
+ const qreal spaceWidth = fm.width(QChar::Nbsp);
+ const bool trailingSpace = textOut.endsWith(space);
if (!updateImagePositions) {
QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag;
- image->position = textOut.length() + 1;
+ image->position = textOut.length() + (trailingSpace ? 0 : 1);
QPair<QStringRef,QStringRef> attr;
do {
@@ -698,14 +701,16 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
}
imgWidth = image->size.width();
+ image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0;
imgTags->append(image);
} else {
// if we already have a list of img tags for this text
// we only want to update the positions of these tags.
QQuickStyledTextImgTag *image = imgTags->value(nbImages);
- image->position = textOut.length() + 1;
+ image->position = textOut.length() + (trailingSpace ? 0 : 1);
imgWidth = image->size.width();
+ image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0;
QPair<QStringRef,QStringRef> attr;
do {
attr = parseAttribute(ch, textIn);
@@ -713,9 +718,9 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
nbImages++;
}
- QFontMetricsF fm(layout.font());
- QString padding(qFloor(imgWidth / fm.width(QChar::Nbsp)), QChar::Nbsp);
- textOut += QLatin1Char(' ');
+ QString padding(qFloor(imgWidth / spaceWidth), QChar::Nbsp);
+ if (!trailingSpace)
+ textOut += QLatin1Char(' ');
textOut += padding;
textOut += QLatin1Char(' ');
}
diff --git a/src/quick/util/qquickstyledtext_p.h b/src/quick/util/qquickstyledtext_p.h
index ee3f42cb48..2a2e234224 100644
--- a/src/quick/util/qquickstyledtext_p.h
+++ b/src/quick/util/qquickstyledtext_p.h
@@ -68,7 +68,7 @@ class Q_AUTOTEST_EXPORT QQuickStyledTextImgTag
{
public:
QQuickStyledTextImgTag()
- : position(0), align(QQuickStyledTextImgTag::Bottom), pix(0)
+ : position(0), offset(0.0), align(QQuickStyledTextImgTag::Bottom), pix(0)
{ }
~QQuickStyledTextImgTag() { delete pix; }
@@ -83,6 +83,7 @@ public:
QPointF pos;
QSize size;
int position;
+ qreal offset; // this offset allows us to compensate for flooring reserved space
Align align;
QQuickPixmap *pix;
};