diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-10 04:29:10 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-10 04:29:10 (GMT) |
commit | 5471328d6565ca1759ea8008421a31dde2a0f036 (patch) | |
tree | 814ef54f4b20d8f32105bd725a7576d04c6be22c /src | |
parent | e93a22d8cb01a419fe9000bac166ed76f7fef3a5 (diff) | |
download | Qt-5471328d6565ca1759ea8008421a31dde2a0f036.zip Qt-5471328d6565ca1759ea8008421a31dde2a0f036.tar.gz Qt-5471328d6565ca1759ea8008421a31dde2a0f036.tar.bz2 |
Distinguish between tranform smoothness (from Item) and smoothness
of the painted chunks (often want the latter not the former).
Diffstat (limited to 'src')
3 files changed, 34 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp index 2f0a585..2c849c8 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp @@ -214,6 +214,7 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * QRegion topaint(clip); topaint &= content; QRegion uncached(content); + p->setRenderHints(QPainter::SmoothPixmapTransform, d->smooth); int cachesize=0; for (int i=0; i<d->imagecache.count(); ++i) { @@ -223,7 +224,7 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * if (!d->cachefrozen) { if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) { QPainter qp(&d->imagecache[i]->image); - qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smooth); + qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); qp.translate(-area.x(), -area.y()); if (d->fillColor.isValid()){ if(d->fillColor.alpha() < 255){ @@ -279,7 +280,7 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * img.fill(d->fillColor); { QPainter qp(&img); - qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smooth); + qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); qp.translate(-r.x(),-r.y()); drawContents(&qp, r); @@ -377,5 +378,30 @@ QColor QmlGraphicsPaintedItem::fillColor() const return d->fillColor; } +/*! + \qmlproperty bool PaintedItem::smoothCache + + Controls whether the cached tiles of which the item is composed are + rendered smoothly when they are generated. + + This is in addition toe Item::smooth, which controls the smooth painting of + the already-painted cached tiles under transformation. +*/ +bool QmlGraphicsPaintedItem::smoothCache() const +{ + Q_D(const QmlGraphicsPaintedItem); + return d->smoothCache; +} + +void QmlGraphicsPaintedItem::setSmoothCache(bool on) +{ + Q_D(QmlGraphicsPaintedItem); + if (d->smoothCache != on) { + d->smoothCache = on; + clearCache(); + } +} + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h index 99873a7..8d629b3 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem_p.h @@ -59,6 +59,7 @@ 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(bool smoothCache READ smoothCache WRITE setSmoothCache) public: QmlGraphicsPaintedItem(QmlGraphicsItem *parent=0); @@ -70,6 +71,9 @@ public: int cacheSize() const; void setCacheSize(int pixels); + bool smoothCache() const; + void setSmoothCache(bool on); + QColor fillColor() const; void setFillColor(const QColor&); diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h b/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h index a744557..a938ecf 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem_p_p.h @@ -63,7 +63,7 @@ class QmlGraphicsPaintedItemPrivate : public QmlGraphicsItemPrivate public: QmlGraphicsPaintedItemPrivate() - : max_imagecache_size(100000), fillColor(Qt::transparent), cachefrozen(false) + : max_imagecache_size(100000), fillColor(Qt::transparent), cachefrozen(false), smoothCache(true) { } @@ -82,6 +82,7 @@ public: QSize contentsSize; QColor fillColor; bool cachefrozen; + bool smoothCache; }; QT_END_NAMESPACE |