summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-06-24 03:10:47 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-06-24 03:10:47 (GMT)
commitf95bf069b13e0b72d0137d76302e7f30cbad8828 (patch)
treecf4c01f9df5e9a3e0b06b612f11809ac20257f8c /src
parent4cf724204b4e02f4169dfc8a52e2cadd3aa2f1e7 (diff)
downloadQt-f95bf069b13e0b72d0137d76302e7f30cbad8828.zip
Qt-f95bf069b13e0b72d0137d76302e7f30cbad8828.tar.gz
Qt-f95bf069b13e0b72d0137d76302e7f30cbad8828.tar.bz2
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.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp29
-rw-r--r--src/declarative/fx/qfxpainteditem.h7
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h3
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