Initialize scale factor to the last scale factor set on any instance
Summary: Plasma::Svg initializes SvgPrivate::scaleFactor to 1.0. On systems with a higher value for Units:devicePixelRatio, that means Svg::setScaleFactor gets called with a different value right after instanciation and a fair amount of work is done twice. This patch introduces a static SvgPrivate::s_lastScaleFactor, initialized to 1.0 but updated in Svg::setScaleFactor. SvgPrivate::scaleFactor is then initialized to the static every time its instanciated. That means after the first time Svg::setScaleFactor is called with e.g. 2.0, subsequent Svg instances get initialized with 2.0. This ends up shaving a decent amount of time off of startup on scaled systems. Reviewers: #plasma, davidedmundson, broulik Subscribers: plasma-devel, #frameworks Tags: #plasma, #frameworks Differential Revision: https://phabricator.kde.org/D9119
This commit is contained in:
parent
fae6558dae
commit
15f470fafc
@ -97,6 +97,7 @@ public:
|
|||||||
|
|
||||||
static QHash<QString, SharedSvgRenderer::Ptr> s_renderers;
|
static QHash<QString, SharedSvgRenderer::Ptr> s_renderers;
|
||||||
static QWeakPointer<Theme> s_systemColorsCache;
|
static QWeakPointer<Theme> s_systemColorsCache;
|
||||||
|
static qreal s_lastScaleFactor;
|
||||||
|
|
||||||
Svg *q;
|
Svg *q;
|
||||||
QWeakPointer<Theme> theme;
|
QWeakPointer<Theme> theme;
|
||||||
|
@ -146,7 +146,7 @@ SvgPrivate::SvgPrivate(Svg *svg)
|
|||||||
colorGroup(Plasma::Theme::NormalColorGroup),
|
colorGroup(Plasma::Theme::NormalColorGroup),
|
||||||
lastModified(0),
|
lastModified(0),
|
||||||
devicePixelRatio(1.0),
|
devicePixelRatio(1.0),
|
||||||
scaleFactor(1.0),
|
scaleFactor(s_lastScaleFactor),
|
||||||
status(Svg::Status::Normal),
|
status(Svg::Status::Normal),
|
||||||
multipleImages(false),
|
multipleImages(false),
|
||||||
themed(false),
|
themed(false),
|
||||||
@ -700,6 +700,7 @@ void SvgPrivate::colorsChanged()
|
|||||||
|
|
||||||
QHash<QString, SharedSvgRenderer::Ptr> SvgPrivate::s_renderers;
|
QHash<QString, SharedSvgRenderer::Ptr> SvgPrivate::s_renderers;
|
||||||
QWeakPointer<Theme> SvgPrivate::s_systemColorsCache;
|
QWeakPointer<Theme> SvgPrivate::s_systemColorsCache;
|
||||||
|
qreal SvgPrivate::s_lastScaleFactor = 1.0;
|
||||||
|
|
||||||
Svg::Svg(QObject *parent)
|
Svg::Svg(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
@ -746,6 +747,7 @@ void Svg::setScaleFactor(qreal ratio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->scaleFactor = floor(ratio);
|
d->scaleFactor = floor(ratio);
|
||||||
|
d->s_lastScaleFactor = d->scaleFactor;
|
||||||
//not resize() because we want to do it unconditionally
|
//not resize() because we want to do it unconditionally
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user