Added antialiasing property to QSGPaintedItem.
authorYoann Lopes <yoann.lopes@nokia.com>
Tue, 3 May 2011 12:41:52 +0000 (14:41 +0200)
committerYoann Lopes <yoann.lopes@nokia.com>
Tue, 3 May 2011 12:41:52 +0000 (14:41 +0200)
examples/declarative/painteditem/main.cpp
src/declarative/items/qsgpainteditem.cpp
src/declarative/items/qsgpainteditem.h
src/declarative/items/qsgpainteditem_p.h

index 1308325..10bd430 100644 (file)
@@ -47,6 +47,11 @@ class MyPaintItem : public QSGPaintedItem
 {
     Q_OBJECT
 public:
+    MyPaintItem() : QSGPaintedItem()
+    {
+        setAntialiasing(true);
+    }
+
     virtual void paint(QPainter *p)
     {
         QRectF rect(0, 0, width(), height());
index 8eb8afe..e0d63fa 100644 (file)
@@ -186,6 +186,37 @@ void QSGPaintedItem::setOpaquePainting(bool opaque)
     QSGItem::update();
 }
 
+/*!
+    Returns true if antialiased painting is enabled; otherwise, false is returned.
+
+    By default, antialiasing is not enabled.
+
+    \sa setAntialiasing()
+*/
+bool QSGPaintedItem::antialiasing() const
+{
+    Q_D(const QSGPaintedItem);
+    return d->antialiasing;
+}
+
+/*!
+    If \a enable is true, antialiased painting is enabled.
+
+    By default, antialiasing is not enabled.
+
+    \sa antialiasing()
+*/
+void QSGPaintedItem::setAntialiasing(bool enable)
+{
+    Q_D(QSGPaintedItem);
+
+    if (d->antialiasing == enable)
+        return;
+
+    d->antialiasing = enable;
+    update();
+}
+
 QSize QSGPaintedItem::contentsSize() const
 {
     // XXX todo
@@ -337,7 +368,7 @@ QSGNode *QSGPaintedItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
 
     node->setPreferredRenderTarget(d->renderTarget);
     node->setSize(QSize(d->width, d->height));
-    node->setSmoothPainting(d->smooth);
+    node->setSmoothPainting(d->antialiasing);
     node->setLinearFiltering(d->smooth);
     node->setOpaquePainting(d->opaquePainting);
     node->setFillColor(d->fillColor);
index 23becfe..8525524 100644 (file)
@@ -75,6 +75,9 @@ public:
     bool opaquePainting() const;
     void setOpaquePainting(bool opaque);
 
+    bool antialiasing() const;
+    void setAntialiasing(bool enable);
+
     QSize contentsSize() const;
     void setContentsSize(const QSize &);
     void resetContentsSize();
index c49da50..ee76319 100644 (file)
@@ -60,6 +60,7 @@ public:
     bool geometryDirty : 1;
     bool contentsDirty : 1;
     bool opaquePainting: 1;
+    bool antialiasing: 1;
 };
 
 QT_END_NAMESPACE