From fcf88c88c1d730028e0fbc46cadce040d6fb7e02 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 24 Jun 2009 10:24:19 +1000 Subject: Fix issue with render hints not being restored properly. --- src/declarative/fx/qfximage.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 40389c4..58d597a 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -336,7 +336,8 @@ void QFxImage::paintContents(QPainter &p) if (d->pix.isNull()) return; - QPainter::RenderHints oldHints = p.renderHints(); + bool oldAA = p.testRenderHint(QPainter::Antialiasing); + bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform); if (d->smooth) p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); @@ -428,8 +429,10 @@ void QFxImage::paintContents(QPainter &p) QRect(pix.width()-sgr, pix.height() - sgb, sgr, sgb)); } - if (d->smooth) - p.setRenderHints(oldHints); + if (d->smooth) { + p.setRenderHint(QPainter::Antialiasing, oldAA); + p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); + } } #elif defined(QFX_RENDER_OPENGL) uint QFxImage::glSimpleItemData(float *vertices, float *texVertices, -- cgit v0.12 From 124f5714e8e6ec1945d536e622b51304f2b32dd7 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 24 Jun 2009 11:07:26 +1000 Subject: Fix performance regression. --- src/declarative/qml/qmlbasicscript.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp index a679532..f02a176 100644 --- a/src/declarative/qml/qmlbasicscript.cpp +++ b/src/declarative/qml/qmlbasicscript.cpp @@ -830,7 +830,8 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c if (n.type == QmlBasicScriptNodeCache::Invalid || state == Reset) { context->engine()->d_func()->loadCache(n, QLatin1String(id), static_cast(context->d_ptr)); - state = Incremental; + if (state != Reset) + state = Incremental; } if(!n.isValid()) @@ -855,7 +856,8 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c } else if (n.type == QmlBasicScriptNodeCache::Invalid || state == Reset) { context->engine()->d_func()->fetchCache(n, QLatin1String(id), obj); guard(n); - state = Incremental; + if (state != Reset) + state = Incremental; } else if (!valid(n, obj)) { clearCache(dataCache); *cached = Reset; -- cgit v0.12 From 3900421868b910703ddc51185d1d5b6e67540e8e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 24 Jun 2009 11:34:06 +1000 Subject: Clean up some code that has moved to QFxPaintedItem --- src/declarative/fx/qfxpainteditem.cpp | 1 - src/declarative/fx/qfxwebview.cpp | 7 ------- src/declarative/fx/qfxwebview.h | 1 - 3 files changed, 9 deletions(-) diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 29d11ff..37eea9a 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -156,7 +156,6 @@ void QFxPaintedItem::setSmooth(bool smooth) Q_D(QFxPaintedItem); if (d->smooth == smooth) return; d->smooth = smooth; - clearCache(); update(); } diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index adb33e8..f4a06ce 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -428,12 +428,6 @@ void QFxWebView::setInteractive(bool i) emit interactiveChanged(); } -void QFxWebView::updateCacheForVisibility() -{ - if (!isVisible()) - clearCache(); -} - void QFxWebView::expandToWebPage() { Q_D(QFxWebView); @@ -845,7 +839,6 @@ void QFxWebView::setPage(QWebPage *page) d->idealheight>0 ? d->idealheight : -1)); d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff); d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); - connect(this,SIGNAL(visibleChanged()),this,SLOT(updateCacheForVisibility())); connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect))); connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SIGNAL(urlChanged())); connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index c9a62cc..0ac1895 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -179,7 +179,6 @@ Q_SIGNALS: void doubleClick(); private Q_SLOTS: - void updateCacheForVisibility(); void expandToWebPage(); void paintPage(const QRect&); void doLoadProgress(int p); -- cgit v0.12 From 4cf724204b4e02f4169dfc8a52e2cadd3aa2f1e7 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 24 Jun 2009 11:34:41 +1000 Subject: Don't be smooth while moving (or zooming). --- demos/declarative/webbrowser/webbrowser.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index a38d032..5f8be04 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -197,7 +197,7 @@ Item { cacheSize: 4000000 url: WebBrowser.url - smooth: true + smooth: !Flick.moving focusable: true focus: true @@ -421,7 +421,7 @@ Item { SetPropertyAction { target: WebView property: "smooth" - value: true + value: !Flick.moving } } } -- cgit v0.12 From f95bf069b13e0b72d0137d76302e7f30cbad8828 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 24 Jun 2009 13:10:47 +1000 Subject: Allow fill color to be specified, as solid fill makes for much faster painting. Better would be for the paint engine to work this out for itself, but that is often difficult. --- src/declarative/fx/qfxpainteditem.cpp | 29 ++++++++++++++++++++++++++++- src/declarative/fx/qfxpainteditem.h | 7 +++++++ src/declarative/fx/qfxpainteditem_p.h | 3 ++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 37eea9a..65589f2 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -303,7 +303,8 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) for (int i = 0; i < rects.count(); ++i) { const QRect &r = rects.at(i); QPixmap img(r.size()); - img.fill(Qt::transparent); + if (d->fillColor.isValid()) + img.fill(d->fillColor); { QPainter qp(&img); qp.translate(-r.x(),-r.y()); @@ -383,4 +384,30 @@ void QFxPaintedItem::setCacheSize(int pixels) d->max_imagecache_size = pixels; } +/*! + \property QFxPaintedItem::fillColor + + The color to be used to fill the item prior to calling drawContents(). + By default, this is Qt::transparent. + + Performance improvements can be achieved if subclasses call this with either an + invalid color (QColor()), or an appropriate solid color. +*/ +void QFxPaintedItem::setFillColor(const QColor& c) +{ + Q_D(QFxPaintedItem); + if (d->fillColor == c) + return; + d->fillColor = c; + emit fillColorChanged(); + update(); +} + +QColor QFxPaintedItem::fillColor() const +{ + Q_D(const QFxPaintedItem); + return d->fillColor; +} + + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h index b7db2d9..6cb8fe7 100644 --- a/src/declarative/fx/qfxpainteditem.h +++ b/src/declarative/fx/qfxpainteditem.h @@ -59,6 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize) Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth) + Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged) Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize) public: @@ -80,11 +81,17 @@ public: int cacheSize() const; void setCacheSize(int pixels); + QColor fillColor() const; + void setFillColor(const QColor&); + protected: QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent); virtual void drawContents(QPainter *p, const QRect &) = 0; +Q_SIGNALS: + void fillColorChanged(); + protected Q_SLOTS: void dirtyCache(const QRect &); void clearCache(); diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h index 21ac556..4e953a0 100644 --- a/src/declarative/fx/qfxpainteditem_p.h +++ b/src/declarative/fx/qfxpainteditem_p.h @@ -68,7 +68,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate public: QFxPaintedItemPrivate() - : max_imagecache_size(100000), smooth(false) + : max_imagecache_size(100000), smooth(false), fillColor(Qt::transparent) { } @@ -89,6 +89,7 @@ public: int max_imagecache_size; bool smooth; QSize contentsSize; + QColor fillColor; }; QT_END_NAMESPACE -- cgit v0.12 From e97fbd6ee845c27faf71926b19ae18c52ee7ab90 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 24 Jun 2009 13:12:00 +1000 Subject: Optimize by using solid background. --- demos/declarative/webbrowser/webbrowser.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 5f8be04..889ab87 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -198,6 +198,7 @@ Item { url: WebBrowser.url smooth: !Flick.moving + fillColor: "white" focusable: true focus: true -- cgit v0.12