summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxpainteditem.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-06-23 06:07:11 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-06-23 06:07:11 (GMT)
commit6d7120dc2081e10c46ffe8467b047affe81ed747 (patch)
treec454785971f36b8cab970f919d6a89c03685a260 /src/declarative/fx/qfxpainteditem.cpp
parentb418419f23cec0880b6b351d304b1a755f82ab73 (diff)
parentdd792c28d89fbdc23de0d40143f0ca900c6c4daa (diff)
downloadQt-6d7120dc2081e10c46ffe8467b047affe81ed747.zip
Qt-6d7120dc2081e10c46ffe8467b047affe81ed747.tar.gz
Qt-6d7120dc2081e10c46ffe8467b047affe81ed747.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx/qfxpainteditem.cpp')
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index 44adba7..29d11ff 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -337,4 +337,51 @@ void QFxPaintedItem::paintGLContents(GLPainter &p)
#endif
}
+/*!
+ \qmlproperty int PaintedItem::cacheSize
+
+ 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.
+*/
+
+/*!
+ \property QFxPaintedItem::cacheSize
+
+ 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 QFxPaintedItem.
+*/
+int QFxPaintedItem::cacheSize() const
+{
+ Q_D(const QFxPaintedItem);
+ return d->max_imagecache_size;
+}
+
+void QFxPaintedItem::setCacheSize(int pixels)
+{
+ Q_D(QFxPaintedItem);
+ 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;
+}
+
QT_END_NAMESPACE