[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/parley-practice/parley/src/practice
From:       Daniel Laidig <d.laidig () gmx ! de>
Date:       2010-04-12 18:33:42
Message-ID: 20100412183342.E51CFAC898 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1114092 by laidig:

make use of the QImage cache in the theme renderer

 M  +1 -1      imagecache.cpp  
 M  +18 -5     themedbackgroundrenderer.cpp  


--- branches/work/parley-practice/parley/src/practice/imagecache.cpp #1114091:1114092
@@ -69,7 +69,7 @@
     QHashIterator<QString, QImage> i(c.m_images);
     while (i.hasNext()) {
         i.next();
-        dbg.nospace() << "\n\tcontains:" << i.key().leftJustified(20) << "," << \
i.value().size(); +        dbg.nospace() << "\n\tcontains: " << \
qPrintable(i.key().leftJustified(35)) << ": " << i.value().size();  pixels += \
i.value().size().width()*i.value().height();  }
 
--- branches/work/parley-practice/parley/src/practice/themedbackgroundrenderer.cpp \
#1114091:1114092 @@ -105,6 +105,7 @@
         renderRect(rect.first, rect.second, &p);
     }
 
+    kDebug() << "image renderd, cache:" << m_cache;
     return image;
 }
 
@@ -155,16 +156,28 @@
     if (itemRect.isNull() || rect.isNull())
         return;
 
-    kDebug() << "render item" << id;
-    kDebug() << "original item rect:" << itemRect << m_renderer.boundsOnElement(id);
+    kDebug() << "draw item" << id;
+//    kDebug() << "original item rect:" << itemRect << \
m_renderer.boundsOnElement(id);  itemRect = scaleRect(itemRect, rect, scaleBase, \
                aspectRatio);
-    kDebug() << "scaled" << itemRect;
+//    kDebug() << "scaled" << itemRect;
     itemRect = alignRect(itemRect, rect, edge, align, inside);
-    kDebug() << "aligned" << itemRect;
+//    kDebug() << "aligned" << itemRect;
     if (aspectRatio == Qt::KeepAspectRatioByExpanding) {
         //TODO: clip painter
     }
-    m_renderer.render(p, id, itemRect);
+    QImage image;
+    if (m_cache.imageSize(id) == itemRect.size()) {
+        kDebug() << "found in cache:" << id;
+        image = m_cache.getImage(id);
+    } else {
+        kDebug() << "not in cache, render svg:" << id;
+        image = QImage(itemRect.size(), QImage::Format_ARGB32_Premultiplied);
+        image.fill(QColor(Qt::transparent).rgba());
+        QPainter painter(&image);
+        m_renderer.render(&painter, id, QRect(QPoint(0, 0), itemRect.size()));
+        m_cache.updateImage(id, image);
+    }
+    p->drawImage(itemRect.topLeft(), image);
     if (aspectRatio == Qt::KeepAspectRatioByExpanding) {
         //TODO: unclip painter
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic