aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qsgtext.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2011-06-01 16:18:37 +0200
committerYoann Lopes <yoann.lopes@nokia.com>2011-06-01 16:18:37 +0200
commit6da49f13f80fa4a8f1b62424672f7ea081c6fa83 (patch)
tree187ac766a71b8e56fa4283484ed52b773b62e8f0 /src/declarative/items/qsgtext.cpp
parent0e2aaa5a28349d7c906005ae12dd8656ca07b53e (diff)
Make complex rich text works with the threaded renderer.
Painting must be done from the GUI thread.
Diffstat (limited to 'src/declarative/items/qsgtext.cpp')
-rw-r--r--src/declarative/items/qsgtext.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/declarative/items/qsgtext.cpp b/src/declarative/items/qsgtext.cpp
index fe181692f3..ae9bffc795 100644
--- a/src/declarative/items/qsgtext.cpp
+++ b/src/declarative/items/qsgtext.cpp
@@ -103,11 +103,11 @@ QSGTextPrivate::QSGTextPrivate()
lineHeightMode(QSGText::ProportionalHeight), lineCount(1), maximumLineCount(INT_MAX),
maximumLineCountValid(false),
texture(0),
- imageCacheDirty(true), updateOnComponentComplete(true),
+ imageCacheDirty(false), updateOnComponentComplete(true),
richText(false), singleline(false), cacheAllTextAsImage(true), internalWidthUpdate(false),
requireImplicitWidth(false), truncated(false), hAlignImplicit(true), rightToLeftText(false),
- layoutTextElided(false), richTextAsImage(false), naturalWidth(0), doc(0), layoutThread(0),
- nodeType(NodeIsNull)
+ layoutTextElided(false), richTextAsImage(false), textureImageCacheDirty(false), naturalWidth(0),
+ doc(0), layoutThread(0), nodeType(NodeIsNull)
{
cacheAllTextAsImage = enableImageCache();
}
@@ -580,9 +580,10 @@ void QSGTextPrivate::invalidateImageCache()
return;
imageCacheDirty = true;
- imageCache = QPixmap();
- }
- if (q->isComponentComplete())
+
+ if (q->isComponentComplete())
+ QCoreApplication::postEvent(q, new QEvent(QEvent::User));
+ } else if (q->isComponentComplete())
q->update();
}
@@ -591,6 +592,8 @@ void QSGTextPrivate::invalidateImageCache()
*/
void QSGTextPrivate::checkImageCache()
{
+ Q_Q(QSGText);
+
if (!imageCacheDirty)
return;
@@ -631,6 +634,8 @@ void QSGTextPrivate::checkImageCache()
}
imageCacheDirty = false;
+ textureImageCacheDirty = true;
+ q->update();
}
/*!
@@ -1080,9 +1085,8 @@ QSGNode *QSGText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
// XXX todo - some styled text can be done by the QSGTextNode
if (d->richTextAsImage || d->cacheAllTextAsImage || (!QSGDistanceFieldGlyphCache::distanceFieldEnabled() && d->style != Normal)) {
- bool wasDirty = d->imageCacheDirty;
-
- d->checkImageCache();
+ bool wasDirty = d->textureImageCacheDirty;
+ d->textureImageCacheDirty = false;
if (d->imageCache.isNull()) {
delete oldNode;
@@ -1142,6 +1146,17 @@ QSGNode *QSGText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
}
}
+bool QSGText::event(QEvent *e)
+{
+ Q_D(QSGText);
+ if (e->type() == QEvent::User) {
+ d->checkImageCache();
+ return true;
+ } else {
+ return QSGImplicitSizeItem::event(e);
+ }
+}
+
qreal QSGText::paintedWidth() const
{
Q_D(const QSGText);