From 5471328d6565ca1759ea8008421a31dde2a0f036 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 10 Nov 2009 14:29:10 +1000 Subject: Distinguish between tranform smoothness (from Item) and smoothness of the painted chunks (often want the latter not the former). --- .../graphicsitems/qmlgraphicspainteditem.cpp | 30 ++++++++++++++++++++-- .../graphicsitems/qmlgraphicspainteditem_p.h | 4 +++ .../graphicsitems/qmlgraphicspainteditem_p_p.h | 3 ++- 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; iimagecache.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 -- cgit v0.12