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