[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.3/kdelibs/plasma
From: Marco Martin <notmart () gmail ! com>
Date: 2009-07-20 20:35:17
Message-ID: 1248122117.810437.16386.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1000103 by mart:
backport the fix for bug 200313
quite huge patch, i know :/
M +2 -2 framesvg.cpp
M +1 -1 svg.cpp
M +32 -11 theme.cpp
M +17 -0 theme.h
--- branches/KDE/4.3/kdelibs/plasma/framesvg.cpp #1000102:1000103
@@ -621,13 +621,13 @@
//kDebug()<<"Saving to cache frame"<<id;
- Theme::defaultTheme()->insertIntoCache(id, frame->cachedBackground);
+ Theme::defaultTheme()->insertIntoCache(id, frame->cachedBackground, \
QString::number((int)q)+prefixToSave);
//insert overlay
id = QString::fromLatin1("overlay_%7_%6_%5_%4_%3_%2_%1_").
arg(overlayPos.y()).arg(overlayPos.x()).arg(frame->enabledBorders).arg(size.width()).arg(size.height()).arg(prefixToSave).arg(q->imagePath());
- Theme::defaultTheme()->insertIntoCache(id, frame->cachedBackground);
+ Theme::defaultTheme()->insertIntoCache(id, frame->cachedBackground, \
QString::number((int)q)+prefixToSave+"overlay"); }
void FrameSvgPrivate::updateSizes()
--- branches/KDE/4.3/kdelibs/plasma/svg.cpp #1000102:1000103
@@ -238,7 +238,7 @@
}
if (cacheRendering) {
- actualTheme()->insertIntoCache(id, p);
+ actualTheme()->insertIntoCache(id, p, \
QString::number((int)q)+elementId); }
return p;
--- branches/KDE/4.3/kdelibs/plasma/theme.cpp #1000102:1000103
@@ -23,6 +23,7 @@
#include <QFile>
#include <QFileInfo>
#include <QTimer>
+#include <QPair>
#ifdef Q_WS_X11
#include <QX11Info>
#endif
@@ -150,6 +151,8 @@
KSharedConfigPtr svgElementsCache;
QHash<QString, QSet<QString> > invalidElements;
QHash<QString, QPixmap> pixmapsToCache;
+ QHash<QString, QString> keysToCache;
+ QHash<QString, QString> idsToCache;
QTimer *saveTimer;
#ifdef Q_WS_X11
@@ -236,16 +239,15 @@
void ThemePrivate::scheduledCacheUpdate()
{
- //kDebug()<< "Saving to cache:";
- QHash<QString, QPixmap>::const_iterator it = pixmapsToCache.constBegin();
-
- while (it != pixmapsToCache.constEnd()) {
- //kDebug()<< "Saving item to cache: " << it.key();
- pixmapCache->insert(it.key(), it.value());
- ++it;
+ QHashIterator<QString, QPixmap> it(pixmapsToCache);
+ while (it.hasNext()) {
+ it.next();
+ pixmapCache->insert(idsToCache[it.key()], it.value());
}
pixmapsToCache.clear();
+ keysToCache.clear();
+ idsToCache.clear();
}
void ThemePrivate::colorsChanged()
@@ -662,8 +664,13 @@
bool Theme::findInCache(const QString &key, QPixmap &pix)
{
if (d->useCache()) {
- if (d->pixmapsToCache.contains(key)) {
- pix = d->pixmapsToCache.value(key);
+ if (!d->keysToCache.contains(key)) {
+ return false;
+ }
+
+ const QString id = d->keysToCache[key];
+ if (d->pixmapsToCache.contains(id)) {
+ pix = d->pixmapsToCache.value(id);
return true;
}
@@ -686,11 +693,25 @@
void Theme::insertIntoCache(const QString& key, const QPixmap& pix)
{
if (d->useCache()) {
- d->pixmapsToCache.insert(key, pix);
- d->saveTimer->start(500);
+ d->pixmapCache->insert(key, pix);
}
}
+void Theme::insertIntoCache(const QString& key, const QPixmap& pix, const QString& \
id) +{
+ if (d->useCache()) {
+ d->pixmapsToCache.insert(id, pix);
+
+ if (d->idsToCache.contains(id)) {
+ d->keysToCache.remove(d->idsToCache[id]);
+ }
+
+ d->keysToCache.insert(key, id);
+ d->idsToCache.insert(id, key);
+ d->saveTimer->start(600);
+ }
+}
+
bool Theme::findInRectsCache(const QString &image, const QString &element, QRectF \
&rect) const {
if (!d->pixmapCache) {
--- branches/KDE/4.3/kdelibs/plasma/theme.h #1000102:1000103
@@ -239,6 +239,23 @@
void insertIntoCache(const QString& key, const QPixmap& pix);
/**
+ * Insert specified pixmap into the cache.
+ * If the cache already contains pixmap with the specified key then it is
+ * overwritten.
+ * The actual insert is delayed for optimization reasons and the id
+ * parameter is used to discard repeated inserts in the delay time, useful
+ * when for instance the graphics to inser comes from a quickly resizing
+ * object: the frames between the start and destination sizes aren't
+ * useful in the cache and just cause overhead.
+ *
+ * @param key the name to use in the cache for this pixmap
+ * @param pix the pixmap data to store in the cache
+ * @param id a name that identifies the caller class of this function in an \
unique fashion + * @since 4.3
+ **/
+ void insertIntoCache(const QString& key, const QPixmap& pix, const QString& \
id); +
+ /**
* Sets the maximum size of the cache (in kilobytes). If cache gets bigger
* the limit then some entries are removed
* Setting cache limit to 0 disables automatic cache size limiting.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic