On Sunday 30 November 2008, you wrote: > > On 2008-11-30 09:01:20, Aaron Seigo wrote: > > > hm. that seems a little suspect to me, but if grabbing the cached rects > > > is really that slow, then Theme::findInRectsCache is probably what > > > needs to be optimized. > > > > > > can you post the cachegrind output somewhere, along with the clock > > > configuration you used? > > It's not that it is very slow, it's that it was called 13 times for each > update. Quite a bit of overhead when you have the m_fancyHands enabled! > > http://aboyer.dyndns.org/kde/callgrind.out.before > http://aboyer.dyndns.org/kde/callgrind.out.after
hm .. indeed .. does the attached patch help with this? if so, this would get us this optimization for all uses of Plasma::Svg at the cost of a little extra memory overhead. looking at the callgrind output it looks like that the key is to try and avoid hitting KConfigGroup::readEntry. > >From the comments below, I guess the moral of the story is not to assume > > that the elements are properly positioned in the svg file. These changes > > now become pretty useless. I'll try to reduce the amount of actual > > painting instead of caching the rects. yeah, trying to reduce the painting will be the big win. -- Aaron J. Seigo humru othro a kohnu se GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43 KDE core developer sponsored by Qt Software
Index: svg.cpp
===================================================================
--- svg.cpp (revision 890270)
+++ svg.cpp (working copy)
@@ -233,19 +233,25 @@
}
renderer = 0;
+ localRectCache.clear();
}
QRectF elementRect(const QString &elementId)
{
- QRectF rect;
-
if (themed && path.isEmpty()) {
path = Plasma::Theme::defaultTheme()->imagePath(themePath);
}
- bool found = Theme::defaultTheme()->findInRectsCache(path, cacheId(elementId), rect);
+ QString id = cacheId(elementId);
+ if (localRectCache.contains(id)) {
+ return localRectCache[id];
+ }
+ QRectF rect;
+ bool found = Theme::defaultTheme()->findInRectsCache(path, id, rect);
+
if (found) {
+ localRectCache.insert(elementId, rect);
return rect;
}
@@ -332,6 +338,7 @@
Svg *q;
static QHash<QString, SharedSvgRenderer::Ptr> s_renderers;
+ QHash<QString, QRectF> localRectCache;
SharedSvgRenderer::Ptr renderer;
QString themePath;
QString path;
@@ -484,10 +491,9 @@
void Svg::setImagePath(const QString &svgFilePath)
{
- if (d->setImagePath(svgFilePath, this)) {
- }
- d->eraseRenderer();
- emit repaintNeeded();
+ d->setImagePath(svgFilePath, this);
+ d->eraseRenderer();
+ emit repaintNeeded();
}
QString Svg::imagePath() const
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Plasma-devel mailing list [email protected] https://mail.kde.org/mailman/listinfo/plasma-devel
