diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-20 07:05:16 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-20 07:05:16 (GMT) |
commit | 270ab71cc891b541f77176573c2db3e141aae938 (patch) | |
tree | 3d52b94ccf7b5c3543afe455d9d1c9c0713b7efe | |
parent | d83126a49e9b061a545aa51500bc3e647dd4f624 (diff) | |
download | Qt-270ab71cc891b541f77176573c2db3e141aae938.zip Qt-270ab71cc891b541f77176573c2db3e141aae938.tar.gz Qt-270ab71cc891b541f77176573c2db3e141aae938.tar.bz2 |
Fix painting onto devices with no system clip (eg. pixmaps).
Move pixelCacheSize to PaintedItem (remove its "cacheSize").
4 files changed, 18 insertions, 56 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp index b1b1210..2f467e7 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp @@ -223,10 +223,14 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * } QRegion topaint = p->clipRegion(); - if (topaint.isEmpty()) - topaint = effectiveClip; - else + if (topaint.isEmpty()) { + if (effectiveClip.isEmpty()) + topaint = QRect(0,0,p->device()->width(),p->device()->height()); + else + topaint = effectiveClip; + } else { topaint &= effectiveClip; + } topaint &= content; QRegion uncached(content); @@ -323,27 +327,26 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * } /*! - \qmlproperty int PaintedItem::cacheSize + \qmlproperty int PaintedItem::pixelCacheSize This property holds the maximum number of pixels of image cache to allow. The default is 0.1 megapixels. The cache will not be larger - than the (unscaled) size of the item. + than the (unscaled) size of the WebView. */ - /*! - \property QmlGraphicsPaintedItem::cacheSize + \property QmlGraphicsPaintedItem::pixelCacheSize The maximum number of pixels of image cache to allow. The default is 0.1 megapixels. The cache will not be larger than the (unscaled) size of the QmlGraphicsPaintedItem. */ -int QmlGraphicsPaintedItem::cacheSize() const +int QmlGraphicsPaintedItem::pixelCacheSize() const { Q_D(const QmlGraphicsPaintedItem); return d->max_imagecache_size; } -void QmlGraphicsPaintedItem::setCacheSize(int pixels) +void QmlGraphicsPaintedItem::setPixelCacheSize(int pixels) { Q_D(QmlGraphicsPaintedItem); if (pixels < d->max_imagecache_size) { @@ -369,6 +372,8 @@ void QmlGraphicsPaintedItem::setCacheSize(int pixels) d->max_imagecache_size = pixels; } + + /*! \property QmlGraphicsPaintedItem::fillColor @@ -419,5 +424,4 @@ void QmlGraphicsPaintedItem::setSmoothCache(bool on) } - QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h index 0805330..f6bb078 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h @@ -58,9 +58,10 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsPaintedItem : public QmlGraphicsItem Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize) Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged) - Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize) + Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize) Q_PROPERTY(bool smoothCache READ smoothCache WRITE setSmoothCache) + public: QmlGraphicsPaintedItem(QmlGraphicsItem *parent=0); ~QmlGraphicsPaintedItem(); @@ -68,8 +69,8 @@ public: QSize contentsSize() const; void setContentsSize(const QSize &); - int cacheSize() const; - void setCacheSize(int pixels); + int pixelCacheSize() const; + void setPixelCacheSize(int pixels); bool smoothCache() const; void setSmoothCache(bool on); diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index e165e59..aedf787 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -434,45 +434,6 @@ void QmlGraphicsWebView::paintPage(const QRect& r) } /*! - \qmlproperty int WebView::pixelCacheSize - - This property holds the maximum number of pixels of image cache to - allow. The default is 0.1 megapixels. The cache will not be larger - than the (unscaled) size of the WebView. -*/ -int QmlGraphicsWebView::pixelCacheSize() const -{ - Q_D(const QmlGraphicsWebView); - return d->max_imagecache_size; -} - -void QmlGraphicsWebView::setPixelCacheSize(int pixels) -{ - Q_D(QmlGraphicsWebView); - if (pixels < d->max_imagecache_size) { - int cachesize=0; - for (int i=0; i<d->imagecache.count(); ++i) { - QRect area = d->imagecache[i]->area; - cachesize += area.width()*area.height(); - } - while (d->imagecache.count() && cachesize > pixels) { - int oldest=-1; - int age=-1; - for (int i=0; i<d->imagecache.count(); ++i) { - int a = d->imagecache[i]->age; - if (a > age) { - oldest = i; - age = a; - } - } - cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height(); - d->imagecache.removeAt(oldest); - } - } - d->max_imagecache_size = pixels; -} - -/*! \qmlproperty list<object> WebView::javaScriptWindowObjects This property is a list of object that are available from within diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index fa7d19d..17546c1 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -100,7 +100,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged) Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged) - Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) @@ -166,9 +165,6 @@ public: QWebSettings *settings() const; QmlGraphicsWebSettings *settingsObject() const; - int pixelCacheSize() const; - void setPixelCacheSize(int pixels); - bool renderingEnabled() const; void setRenderingEnabled(bool); |