2008-11-04 00:08:39 +01:00
|
|
|
/*
|
2010-10-14 14:09:23 +02:00
|
|
|
* Copyright 2008-2010 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2008-2010 Marco Martin <notmart@gmail.com>
|
2008-11-04 00:08:39 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "framesvg.h"
|
2009-01-13 22:46:07 +01:00
|
|
|
#include "private/framesvg_p.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
#include <QAtomicInt>
|
2008-11-04 00:08:39 +01:00
|
|
|
#include <QBitmap>
|
2010-09-27 19:19:06 +02:00
|
|
|
#include <QCryptographicHash>
|
|
|
|
#include <QPainter>
|
2008-12-15 23:17:59 +01:00
|
|
|
#include <QRegion>
|
2010-09-27 19:19:06 +02:00
|
|
|
#include <QSize>
|
|
|
|
#include <QStringBuilder>
|
2008-11-29 20:24:40 +01:00
|
|
|
#include <QTimer>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2013-07-29 19:05:59 +02:00
|
|
|
#include <QDebug>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2014-07-21 18:01:26 +02:00
|
|
|
#include "theme.h"
|
|
|
|
#include "private/svg_p.h"
|
|
|
|
#include "private/framesvg_helpers.h"
|
2015-12-15 22:56:40 +01:00
|
|
|
#include "debug_p.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2014-05-28 20:25:19 +02:00
|
|
|
QHash<ThemePrivate *, QHash<QString, FrameData *> > FrameSvgPrivate::s_sharedFrames;
|
2010-09-27 19:19:06 +02:00
|
|
|
|
2009-12-22 18:28:22 +01:00
|
|
|
// Any attempt to generate a frame whose width or height is larger than this
|
|
|
|
// will be rejected
|
|
|
|
static const int MAX_FRAME_SIZE = 100000;
|
|
|
|
|
2014-05-28 20:25:19 +02:00
|
|
|
FrameData::~FrameData()
|
|
|
|
{
|
2017-01-30 15:08:09 +01:00
|
|
|
for (auto it = references.constBegin(), end = references.constEnd(); it != end; ++it) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (it.key()->d->frame == this) {
|
|
|
|
it.key()->d->frame = nullptr;
|
|
|
|
}
|
2014-05-28 20:25:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
FrameSvg::FrameSvg(QObject *parent)
|
|
|
|
: Svg(parent),
|
|
|
|
d(new FrameSvgPrivate(this))
|
|
|
|
{
|
|
|
|
connect(this, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
d->frame = nullptr;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
FrameSvg::~FrameSvg()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvg::setImagePath(const QString &path)
|
|
|
|
{
|
|
|
|
if (path == imagePath()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-14 14:09:23 +02:00
|
|
|
clearCache();
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
setContainsMultipleImages(true);
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
Svg::d->setImagePath(path);
|
|
|
|
if (!d->repaintBlocked) {
|
|
|
|
d->updateFrameData();
|
2010-10-14 14:09:23 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvg::setEnabledBorders(const EnabledBorders borders)
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (borders == d->enabledBorders) {
|
2008-11-04 00:08:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
d->enabledBorders = borders;
|
2010-10-09 20:07:17 +02:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (!d->repaintBlocked) {
|
|
|
|
d->updateFrameData();
|
2010-10-09 20:07:17 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
FrameSvg::EnabledBorders FrameSvg::enabledBorders() const
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->enabledBorders;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2013-05-14 18:27:27 +02:00
|
|
|
void FrameSvg::setElementPrefix(Plasma::Types::Location location)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
switch (location) {
|
2014-04-26 01:45:47 +02:00
|
|
|
case Types::TopEdge:
|
2016-02-29 00:08:05 +01:00
|
|
|
setElementPrefix(QStringLiteral("north"));
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
|
|
|
case Types::BottomEdge:
|
2016-02-29 00:08:05 +01:00
|
|
|
setElementPrefix(QStringLiteral("south"));
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
|
|
|
case Types::LeftEdge:
|
2016-02-29 00:08:05 +01:00
|
|
|
setElementPrefix(QStringLiteral("west"));
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
|
|
|
case Types::RightEdge:
|
2016-02-29 00:08:05 +01:00
|
|
|
setElementPrefix(QStringLiteral("east"));
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
setElementPrefix(QString());
|
|
|
|
break;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
2009-05-31 07:38:42 +02:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
d->location = location;
|
|
|
|
}
|
|
|
|
|
2009-05-31 07:38:42 +02:00
|
|
|
void FrameSvg::setElementPrefix(const QString &prefix)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2015-11-27 21:03:48 +01:00
|
|
|
if (!hasElement(prefix % QLatin1String("-center"))) {
|
2008-11-04 00:08:39 +01:00
|
|
|
d->prefix.clear();
|
|
|
|
} else {
|
|
|
|
d->prefix = prefix;
|
|
|
|
if (!d->prefix.isEmpty()) {
|
|
|
|
d->prefix += '-';
|
|
|
|
}
|
|
|
|
}
|
2014-07-11 16:42:55 +02:00
|
|
|
d->requestedPrefix = prefix;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
d->location = Types::Floating;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (!d->repaintBlocked) {
|
|
|
|
d->updateFrameData();
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-26 01:45:47 +02:00
|
|
|
bool FrameSvg::hasElementPrefix(const QString &prefix) const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
//for now it simply checks if a center element exists,
|
|
|
|
//because it could make sense for certain themes to not have all the elements
|
|
|
|
if (prefix.isEmpty()) {
|
2015-11-27 21:03:48 +01:00
|
|
|
return hasElement(QStringLiteral("center"));
|
2008-11-04 00:08:39 +01:00
|
|
|
} else {
|
2015-11-27 21:03:48 +01:00
|
|
|
return hasElement(prefix % QLatin1String("-center"));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-14 18:27:27 +02:00
|
|
|
bool FrameSvg::hasElementPrefix(Plasma::Types::Location location) const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
switch (location) {
|
2014-04-26 01:45:47 +02:00
|
|
|
case Types::TopEdge:
|
2015-11-27 21:03:48 +01:00
|
|
|
return hasElementPrefix(QStringLiteral("north"));
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
|
|
|
case Types::BottomEdge:
|
2015-11-27 21:03:48 +01:00
|
|
|
return hasElementPrefix(QStringLiteral("south"));
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
|
|
|
case Types::LeftEdge:
|
2015-11-27 21:03:48 +01:00
|
|
|
return hasElementPrefix(QStringLiteral("west"));
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
|
|
|
case Types::RightEdge:
|
2015-11-27 21:03:48 +01:00
|
|
|
return hasElementPrefix(QStringLiteral("east"));
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return hasElementPrefix(QString());
|
|
|
|
break;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString FrameSvg::prefix()
|
|
|
|
{
|
2014-07-11 16:55:59 +02:00
|
|
|
return d->requestedPrefix;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvg::resizeFrame(const QSizeF &size)
|
|
|
|
{
|
2010-10-11 23:08:38 +02:00
|
|
|
if (imagePath().isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
if (size.isEmpty()) {
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "Invalid size" << size;
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2008-11-04 00:08:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
if (d->frame && size.toSize() == d->frame->frameSize) {
|
2008-11-04 00:08:39 +01:00
|
|
|
return;
|
|
|
|
}
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
d->pendingFrameSize = size.toSize();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (!d->repaintBlocked) {
|
Fix binding loop regression in FrameSVGItem
Summary:
d8a1a9eb084b19e552c789244267f7346e1b27a8 introduces an unintended code
change, resizeFrame() updates the margins and in turns calls
repaintNeeded. This isn't needed and is a binding loop if we ever have a
frameSVGItem whose size depends on it's own margins.
resizeFrame is different from setEnabledBorders / setElementPrefix /
theme changes because even though we need to create a new FrameData we
know any hints and margins won't change. FrameSvgItem::updateSizes
doesn't depend on the size in any way, so always gives the same result
as before. We still, however, need to call updateSizes to populate our
FrameData structure even if the results will be the same as the previous
FrameData.
This patch that introduces a flag to updateFrameData to determine if we
should emit that size hints may have changed or not.
Test Plan:
GDB showed where the loop was.
Read the old code, and looked for differences
Ran plasmashell, checked I had no binding loop, frames including button
which have
composeOverBorder which need the new FrameData all rendered correctly.
Reviewers: #plasma, #frameworks, mart
Subscribers: mart, broulik, plasma-devel
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4713
2017-02-22 13:26:01 +01:00
|
|
|
d->updateFrameData(FrameSvgPrivate::UpdateFrame);
|
2010-09-27 19:19:06 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QSizeF FrameSvg::frameSize() const
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (!d->frame) {
|
2008-11-04 00:08:39 +01:00
|
|
|
return QSize(-1, -1);
|
2009-06-10 19:11:02 +02:00
|
|
|
} else {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frameSize(d->frame);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-14 20:37:16 +02:00
|
|
|
qreal FrameSvg::marginSize(const Plasma::Types::MarginEdge edge) const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
if (!d->frame) {
|
|
|
|
return .0;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame->noBorderPadding) {
|
2008-11-04 00:08:39 +01:00
|
|
|
return .0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (edge) {
|
2013-05-10 19:29:13 +02:00
|
|
|
case Plasma::Types::TopMargin:
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->topMargin;
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2013-05-10 19:29:13 +02:00
|
|
|
case Plasma::Types::LeftMargin:
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->leftMargin;
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2013-05-10 19:29:13 +02:00
|
|
|
case Plasma::Types::RightMargin:
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->rightMargin;
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
//Plasma::BottomMargin
|
|
|
|
default:
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->bottomMargin;
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-21 21:13:12 +01:00
|
|
|
qreal FrameSvg::fixedMarginSize(const Plasma::Types::MarginEdge edge) const
|
|
|
|
{
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
if (!d->frame) {
|
|
|
|
return .0;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame->noBorderPadding) {
|
2014-02-21 21:13:12 +01:00
|
|
|
return .0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (edge) {
|
|
|
|
case Plasma::Types::TopMargin:
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->fixedTopMargin;
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
2014-02-21 21:13:12 +01:00
|
|
|
|
|
|
|
case Plasma::Types::LeftMargin:
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->fixedLeftMargin;
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
2014-02-21 21:13:12 +01:00
|
|
|
|
|
|
|
case Plasma::Types::RightMargin:
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->fixedRightMargin;
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
2014-02-21 21:13:12 +01:00
|
|
|
|
|
|
|
//Plasma::BottomMargin
|
|
|
|
default:
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->fixedBottomMargin;
|
2014-04-26 01:45:47 +02:00
|
|
|
break;
|
2014-02-21 21:13:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void FrameSvg::getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame->noBorderPadding) {
|
2008-11-04 00:08:39 +01:00
|
|
|
left = top = right = bottom = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
top = d->frame->topMargin;
|
|
|
|
left = d->frame->leftMargin;
|
|
|
|
right = d->frame->rightMargin;
|
|
|
|
bottom = d->frame->bottomMargin;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2014-02-21 21:13:12 +01:00
|
|
|
void FrameSvg::getFixedMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame->noBorderPadding) {
|
2014-02-21 21:13:12 +01:00
|
|
|
left = top = right = bottom = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
top = d->frame->fixedTopMargin;
|
|
|
|
left = d->frame->fixedLeftMargin;
|
|
|
|
right = d->frame->fixedRightMargin;
|
|
|
|
bottom = d->frame->fixedBottomMargin;
|
2014-02-21 21:13:12 +01:00
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
QRectF FrameSvg::contentsRect() const
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame) {
|
|
|
|
QRectF rect(QPoint(0,0), d->frame->frameSize);
|
|
|
|
return rect.adjusted(d->frame->leftMargin, d->frame->topMargin, -d->frame->rightMargin, -d->frame->bottomMargin);
|
2008-11-04 00:08:39 +01:00
|
|
|
} else {
|
|
|
|
return QRectF();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 22:46:07 +01:00
|
|
|
QPixmap FrameSvg::alphaMask() const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2014-04-26 01:45:47 +02:00
|
|
|
//FIXME: the distinction between overlay and
|
2010-03-05 23:37:44 +01:00
|
|
|
return d->alphaMask();
|
2009-01-13 22:46:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QRegion FrameSvg::mask() const
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
QString id = d->cacheId(d->frame, QString());
|
2014-07-11 18:37:43 +02:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
QRegion* obj = d->frame->cachedMasks.object(id);
|
2015-12-18 03:34:04 +01:00
|
|
|
QRegion result;
|
2014-07-11 18:37:43 +02:00
|
|
|
|
|
|
|
if (!obj) {
|
|
|
|
obj = new QRegion(QBitmap(d->alphaMask().alphaChannel().createMaskFromColor(Qt::black)));
|
2015-12-18 03:34:04 +01:00
|
|
|
result = *obj;
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
d->frame->cachedMasks.insert(id, obj);
|
2010-08-05 23:15:18 +02:00
|
|
|
}
|
2015-12-18 03:34:04 +01:00
|
|
|
else {
|
|
|
|
result = *obj;
|
|
|
|
}
|
|
|
|
return result;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvg::setCacheAllRenderedFrames(bool cache)
|
|
|
|
{
|
|
|
|
if (d->cacheAll && !cache) {
|
|
|
|
clearCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
d->cacheAll = cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FrameSvg::cacheAllRenderedFrames() const
|
|
|
|
{
|
|
|
|
return d->cacheAll;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvg::clearCache()
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame) {
|
|
|
|
d->frame->cachedBackground = QPixmap();
|
|
|
|
}
|
|
|
|
if (d->maskFrame) {
|
|
|
|
d->maskFrame->cachedBackground = QPixmap();
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap FrameSvg::framePixmap()
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame->cachedBackground.isNull()) {
|
|
|
|
d->generateBackground(d->frame);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
return d->frame->cachedBackground;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvg::paintFrame(QPainter *painter, const QRectF &target, const QRectF &source)
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame->cachedBackground.isNull()) {
|
|
|
|
d->generateBackground(d->frame);
|
|
|
|
if (d->frame->cachedBackground.isNull()) {
|
2008-11-04 00:08:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
painter->drawPixmap(target, d->frame->cachedBackground, source.isValid() ? source : target);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvg::paintFrame(QPainter *painter, const QPointF &pos)
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (d->frame->cachedBackground.isNull()) {
|
|
|
|
d->generateBackground(d->frame);
|
|
|
|
if (d->frame->cachedBackground.isNull()) {
|
2008-11-04 00:08:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
painter->drawPixmap(pos, d->frame->cachedBackground);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
//#define DEBUG_FRAMESVG_CACHE
|
|
|
|
FrameSvgPrivate::~FrameSvgPrivate()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_FRAMESVG_CACHE
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "*************" << q << q->imagePath() << "****************";
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-09-27 19:19:06 +02:00
|
|
|
#endif
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
// we remove all references from this widget to the frame, and delete it if we're the
|
|
|
|
// last user
|
|
|
|
if (frame && frame->removeRefs(q)) {
|
|
|
|
const QString key = cacheId(frame, frame->prefix);
|
2010-09-27 19:19:06 +02:00
|
|
|
#ifdef DEBUG_FRAMESVG_CACHE
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "2. Removing it" << key << frame << frame->refcount() << s_sharedFrames[theme()->d].contains(key);
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-09-27 19:19:06 +02:00
|
|
|
#endif
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
s_sharedFrames[frame->theme].remove(key);
|
|
|
|
delete frame;
|
2010-09-27 19:19:06 +02:00
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
//same thing for maskFrame
|
|
|
|
if (maskFrame && maskFrame->removeRefs(q)) {
|
|
|
|
const QString key = cacheId(maskFrame, maskFrame->prefix);
|
|
|
|
s_sharedFrames[maskFrame->theme].remove(key);
|
|
|
|
delete maskFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
#ifdef DEBUG_FRAMESVG_CACHE
|
2014-05-28 20:25:19 +02:00
|
|
|
QHashIterator<QString, FrameData *> it2(s_sharedFrames[theme()->d]);
|
2010-09-27 19:19:06 +02:00
|
|
|
int shares = 0;
|
|
|
|
while (it2.hasNext()) {
|
|
|
|
it2.next();
|
|
|
|
const int rc = it2.value()->refcount();
|
|
|
|
if (rc == 0) {
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << " LOST!" << it2.key() << rc << it2.value();// << it2.value()->references;
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-09-27 19:19:06 +02:00
|
|
|
} else {
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << " " << it2.key() << rc << it2.value();
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-09-27 19:19:06 +02:00
|
|
|
foreach (FrameSvg *data, it2.value()->references.keys()) {
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
qCDebug(LOG_PLASMA) << " " << (void *)data << it2.value()->references[data];
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-09-27 19:19:06 +02:00
|
|
|
}
|
|
|
|
shares += rc - 1;
|
|
|
|
}
|
|
|
|
}
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "#####################################" << s_sharedFrames[theme()->d].count() << ", pixmaps saved:" << shares;
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2010-09-27 19:19:06 +02:00
|
|
|
#endif
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame = nullptr;
|
|
|
|
maskFrame = nullptr;
|
2010-09-27 19:19:06 +02:00
|
|
|
}
|
|
|
|
|
2010-03-05 23:37:44 +01:00
|
|
|
QPixmap FrameSvgPrivate::alphaMask()
|
2009-10-10 23:34:51 +02:00
|
|
|
{
|
|
|
|
QString maskPrefix;
|
|
|
|
|
2015-11-27 21:03:48 +01:00
|
|
|
if (q->hasElement(QLatin1String("mask-") % prefix % QLatin1String("center"))) {
|
|
|
|
maskPrefix = QStringLiteral("mask-");
|
2009-10-10 23:34:51 +02:00
|
|
|
}
|
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
if (maskPrefix.isNull()) {
|
|
|
|
if (frame->cachedBackground.isNull()) {
|
|
|
|
generateBackground(frame);
|
|
|
|
if (frame->cachedBackground.isNull()) {
|
|
|
|
return QPixmap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return frame->cachedBackground;
|
|
|
|
} else {
|
2009-10-10 23:34:51 +02:00
|
|
|
// We are setting the prefix only temporary to generate
|
|
|
|
// the needed mask image
|
2017-03-22 14:01:28 +01:00
|
|
|
const QString maskRequestedPrefix = requestedPrefix.isEmpty() ? QStringLiteral("mask") : maskPrefix % requestedPrefix;
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
maskPrefix = maskPrefix % prefix;
|
2009-10-10 23:34:51 +02:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (!maskFrame) {
|
|
|
|
const QString key = cacheId(frame, maskPrefix);
|
2010-09-27 19:19:06 +02:00
|
|
|
// see if we can find a suitable candidate in the shared frames
|
|
|
|
// if successful, ref and insert, otherwise create a new one
|
|
|
|
// and insert that into both the shared frames and our frames.
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
maskFrame = s_sharedFrames[q->theme()->d].value(key);
|
2010-10-05 21:26:00 +02:00
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
if (maskFrame) {
|
|
|
|
maskFrame->ref(q);
|
|
|
|
} else {
|
|
|
|
maskFrame = new FrameData(*frame, q);
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
maskFrame->prefix = maskPrefix;
|
|
|
|
maskFrame->requestedPrefix = maskRequestedPrefix;
|
2016-03-12 13:02:34 +01:00
|
|
|
maskFrame->theme = q->theme()->d;
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
maskFrame->imagePath = q->imagePath();
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
s_sharedFrames[q->theme()->d].insert(key, maskFrame);
|
2010-09-27 19:19:06 +02:00
|
|
|
}
|
2014-06-13 17:14:30 +02:00
|
|
|
maskFrame->enabledBorders = frame->enabledBorders;
|
2010-09-27 19:19:06 +02:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
updateSizes(maskFrame);
|
2009-10-10 23:34:51 +02:00
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
// maskFrame = frame;
|
2014-06-13 17:14:30 +02:00
|
|
|
maskFrame->enabledBorders = frame->enabledBorders;
|
2009-10-10 23:34:51 +02:00
|
|
|
if (maskFrame->cachedBackground.isNull() || maskFrame->frameSize != frameSize(frame)) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
const QString oldKey = cacheId(maskFrame, maskPrefix);
|
2009-10-10 23:34:51 +02:00
|
|
|
maskFrame->frameSize = frameSize(frame).toSize();
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
const QString newKey = cacheId(maskFrame, maskPrefix);
|
2014-05-28 20:25:19 +02:00
|
|
|
if (s_sharedFrames[q->theme()->d].contains(oldKey)) {
|
|
|
|
s_sharedFrames[q->theme()->d].remove(oldKey);
|
|
|
|
s_sharedFrames[q->theme()->d].insert(newKey, maskFrame);
|
2010-10-05 21:26:00 +02:00
|
|
|
}
|
|
|
|
|
2009-10-10 23:34:51 +02:00
|
|
|
maskFrame->cachedBackground = QPixmap();
|
|
|
|
|
|
|
|
generateBackground(maskFrame);
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
2009-10-10 23:34:51 +02:00
|
|
|
if (maskFrame->cachedBackground.isNull()) {
|
|
|
|
return QPixmap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return maskFrame->cachedBackground;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void FrameSvgPrivate::generateBackground(FrameData *frame)
|
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (!frame->cachedBackground.isNull() || !q->hasElementPrefix(frame->requestedPrefix)) {
|
2008-11-04 00:08:39 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
const QString id = cacheId(frame, frame->prefix);
|
2009-08-04 23:19:20 +02:00
|
|
|
|
2009-09-28 23:54:00 +02:00
|
|
|
bool frameCached = !frame->cachedBackground.isNull();
|
|
|
|
bool overlayCached = false;
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
const bool overlayAvailable = !frame->prefix.startsWith(QLatin1String("mask-")) && q->hasElement(frame->prefix % QLatin1String("overlay"));
|
2009-09-28 23:54:00 +02:00
|
|
|
QPixmap overlay;
|
2009-05-13 18:37:13 +02:00
|
|
|
if (q->isUsingRenderingCache()) {
|
2014-05-19 14:58:19 +02:00
|
|
|
frameCached = q->theme()->findInCache(id, frame->cachedBackground) && !frame->cachedBackground.isNull();
|
2009-09-28 23:54:00 +02:00
|
|
|
|
|
|
|
if (overlayAvailable) {
|
2015-11-27 21:03:48 +01:00
|
|
|
overlayCached = q->theme()->findInCache(QLatin1String("overlay_") % id, overlay) && !overlay.isNull();
|
2009-05-13 18:37:13 +02:00
|
|
|
}
|
2009-05-01 18:28:10 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-09-28 23:54:00 +02:00
|
|
|
if (!frameCached) {
|
|
|
|
generateFrameBackground(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Overlays
|
|
|
|
QSize overlaySize;
|
2009-12-13 21:13:55 +01:00
|
|
|
QPoint actualOverlayPos = QPoint(0, 0);
|
2009-09-28 23:54:00 +02:00
|
|
|
if (overlayAvailable && !overlayCached) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
overlaySize = q->elementSize(frame->prefix % QLatin1String("overlay"));
|
2009-09-28 23:54:00 +02:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-pos-right"))) {
|
2009-12-13 21:13:55 +01:00
|
|
|
actualOverlayPos.setX(frame->frameSize.width() - overlaySize.width());
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
} else if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-pos-bottom"))) {
|
2009-12-13 21:13:55 +01:00
|
|
|
actualOverlayPos.setY(frame->frameSize.height() - overlaySize.height());
|
2014-04-26 01:45:47 +02:00
|
|
|
//Stretched or Tiled?
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
} else if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-stretch"))) {
|
2009-09-28 23:54:00 +02:00
|
|
|
overlaySize = frameSize(frame).toSize();
|
|
|
|
} else {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-horizontal"))) {
|
2009-09-28 23:54:00 +02:00
|
|
|
overlaySize.setWidth(frameSize(frame).width());
|
|
|
|
}
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-vertical"))) {
|
2009-09-28 23:54:00 +02:00
|
|
|
overlaySize.setHeight(frameSize(frame).height());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-05 23:37:44 +01:00
|
|
|
overlay = alphaMask();
|
2009-09-28 23:54:00 +02:00
|
|
|
QPainter overlayPainter(&overlay);
|
|
|
|
overlayPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
|
|
|
//Tiling?
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-horizontal")) ||
|
|
|
|
q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-vertical"))) {
|
2009-09-28 23:54:00 +02:00
|
|
|
|
|
|
|
QSize s = q->size();
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
q->resize(q->elementSize(frame->prefix % QLatin1String("overlay")));
|
2009-09-28 23:54:00 +02:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
overlayPainter.drawTiledPixmap(QRect(QPoint(0, 0), overlaySize), q->pixmap(frame->prefix % QLatin1String("overlay")));
|
2009-09-28 23:54:00 +02:00
|
|
|
q->resize(s);
|
|
|
|
} else {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
q->paint(&overlayPainter, QRect(actualOverlayPos, overlaySize), frame->prefix % QLatin1String("overlay"));
|
2009-09-28 23:54:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
overlayPainter.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!frameCached) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
cacheFrame(frame->prefix, frame->cachedBackground, overlayCached ? overlay : QPixmap());
|
2009-09-28 23:54:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!overlay.isNull()) {
|
|
|
|
QPainter p(&frame->cachedBackground);
|
|
|
|
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
2009-12-13 21:13:55 +01:00
|
|
|
p.drawPixmap(actualOverlayPos, overlay, QRect(actualOverlayPos, overlaySize));
|
2009-09-28 23:54:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvgPrivate::generateFrameBackground(FrameData *frame)
|
|
|
|
{
|
2015-12-15 22:56:40 +01:00
|
|
|
//qCDebug(LOG_PLASMA) << "generating background";
|
2015-03-10 18:02:15 +01:00
|
|
|
const QSize size = frameSize(frame).toSize() * q->devicePixelRatio();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-06-10 19:11:02 +02:00
|
|
|
if (!size.isValid()) {
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "Invalid frame size" << size;
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2008-11-04 00:08:39 +01:00
|
|
|
return;
|
|
|
|
}
|
2009-12-22 18:28:22 +01:00
|
|
|
if (size.width() >= MAX_FRAME_SIZE || size.height() >= MAX_FRAME_SIZE) {
|
2015-12-15 22:56:40 +01:00
|
|
|
qCWarning(LOG_PLASMA) << "Not generating frame background for a size whose width or height is more than" << MAX_FRAME_SIZE << size;
|
2009-12-22 18:28:22 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2014-07-14 16:32:10 +02:00
|
|
|
frame->cachedBackground = QPixmap(size);
|
2008-11-04 00:08:39 +01:00
|
|
|
frame->cachedBackground.fill(Qt::transparent);
|
|
|
|
QPainter p(&frame->cachedBackground);
|
|
|
|
p.setCompositionMode(QPainter::CompositionMode_Source);
|
|
|
|
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
|
|
|
|
2014-07-14 18:13:40 +02:00
|
|
|
QRect contentRect = contentGeometry(frame, size);
|
2014-07-21 15:44:25 +02:00
|
|
|
paintCenter(p, frame, contentRect, size);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2014-07-14 20:02:47 +02:00
|
|
|
paintCorner(p, frame, FrameSvg::LeftBorder|FrameSvg::TopBorder, contentRect);
|
|
|
|
paintCorner(p, frame, FrameSvg::RightBorder|FrameSvg::TopBorder, contentRect);
|
|
|
|
paintCorner(p, frame, FrameSvg::LeftBorder|FrameSvg::BottomBorder, contentRect);
|
|
|
|
paintCorner(p, frame, FrameSvg::RightBorder|FrameSvg::BottomBorder, contentRect);
|
2014-07-14 16:47:56 +02:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
// Sides
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
const int leftHeight = q->elementSize(frame->prefix % QLatin1String("left")).height();
|
2015-03-10 18:02:15 +01:00
|
|
|
paintBorder(p, frame, FrameSvg::LeftBorder, QSize(frame->leftWidth, leftHeight) * q->devicePixelRatio(), contentRect);
|
|
|
|
paintBorder(p, frame, FrameSvg::RightBorder, QSize(frame->rightWidth, leftHeight) * q->devicePixelRatio(), contentRect);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
const int topWidth = q->elementSize(frame->prefix % QLatin1String("top")).width();
|
2015-03-10 18:02:15 +01:00
|
|
|
paintBorder(p, frame, FrameSvg::TopBorder, QSize(topWidth, frame->topHeight) * q->devicePixelRatio(), contentRect);
|
|
|
|
paintBorder(p, frame, FrameSvg::BottomBorder, QSize(topWidth, frame->bottomHeight) * q->devicePixelRatio(), contentRect);
|
|
|
|
p.end();
|
|
|
|
|
|
|
|
frame->cachedBackground.setDevicePixelRatio(q->devicePixelRatio());
|
2014-07-14 20:02:47 +02:00
|
|
|
}
|
|
|
|
|
2014-07-14 18:13:40 +02:00
|
|
|
QRect FrameSvgPrivate::contentGeometry(FrameData* frame, const QSize& size) const
|
|
|
|
{
|
2015-03-10 18:02:15 +01:00
|
|
|
const QSize contentSize(size.width() - frame->leftWidth * q->devicePixelRatio() - frame->rightWidth * q->devicePixelRatio(),
|
|
|
|
size.height() - frame->topHeight * q->devicePixelRatio() - frame->bottomHeight * q->devicePixelRatio());
|
2014-07-14 18:13:40 +02:00
|
|
|
QRect contentRect(QPoint(0,0), contentSize);
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(frame->prefix % QLatin1String("left"))) {
|
2015-03-10 18:02:15 +01:00
|
|
|
contentRect.translate(frame->leftWidth * q->devicePixelRatio(), 0);
|
2014-07-14 18:13:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Corners
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (frame->enabledBorders & FrameSvg::TopBorder && q->hasElement(frame->prefix % QLatin1String("top"))) {
|
2015-03-10 18:02:15 +01:00
|
|
|
contentRect.translate(0, frame->topHeight * q->devicePixelRatio());
|
2014-07-14 18:13:40 +02:00
|
|
|
}
|
|
|
|
return contentRect;
|
2014-07-14 14:16:16 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
Fix binding loop regression in FrameSVGItem
Summary:
d8a1a9eb084b19e552c789244267f7346e1b27a8 introduces an unintended code
change, resizeFrame() updates the margins and in turns calls
repaintNeeded. This isn't needed and is a binding loop if we ever have a
frameSVGItem whose size depends on it's own margins.
resizeFrame is different from setEnabledBorders / setElementPrefix /
theme changes because even though we need to create a new FrameData we
know any hints and margins won't change. FrameSvgItem::updateSizes
doesn't depend on the size in any way, so always gives the same result
as before. We still, however, need to call updateSizes to populate our
FrameData structure even if the results will be the same as the previous
FrameData.
This patch that introduces a flag to updateFrameData to determine if we
should emit that size hints may have changed or not.
Test Plan:
GDB showed where the loop was.
Read the old code, and looked for differences
Ran plasmashell, checked I had no binding loop, frames including button
which have
composeOverBorder which need the new FrameData all rendered correctly.
Reviewers: #plasma, #frameworks, mart
Subscribers: mart, broulik, plasma-devel
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4713
2017-02-22 13:26:01 +01:00
|
|
|
void FrameSvgPrivate::updateFrameData(UpdateType updateType)
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
{
|
|
|
|
FrameData *fd = frame;
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
QString newKey;
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
if (fd) {
|
|
|
|
const QString oldKey = cacheId(fd, fd->prefix);
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
const QString oldPath = fd->imagePath;
|
|
|
|
const FrameSvg::EnabledBorders oldBorders = fd->enabledBorders;
|
|
|
|
const QSize currentSize = fd->frameSize;
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
fd->enabledBorders = enabledBorders;
|
|
|
|
fd->frameSize = pendingFrameSize;
|
|
|
|
fd->imagePath = q->imagePath();
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
newKey = cacheId(fd, prefix);
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
//reset frame to old values
|
|
|
|
fd->enabledBorders = oldBorders;
|
|
|
|
fd->frameSize = currentSize;
|
|
|
|
fd->imagePath = oldPath;
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
//FIXME: something more efficient than string comparison?
|
|
|
|
if (oldKey == newKey) {
|
|
|
|
return;
|
|
|
|
}
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
//qCDebug(LOG_PLASMA) << "looking for" << newKey;
|
|
|
|
FrameData *newFd = FrameSvgPrivate::s_sharedFrames[q->theme()->d].value(newKey);
|
|
|
|
if (newFd) {
|
|
|
|
//qCDebug(LOG_PLASMA) << "FOUND IT!" << newFd->refcount;
|
|
|
|
// we've found a math, so insert that new one and ref it ..
|
|
|
|
newFd->ref(q);
|
|
|
|
frame = newFd;
|
|
|
|
|
|
|
|
//.. then deref the old one and if it's no longer used, get rid of it
|
|
|
|
if (fd->deref(q)) {
|
|
|
|
//const QString oldKey = cacheId(fd, prefix);
|
|
|
|
//qCDebug(LOG_PLASMA) << "1. Removing it" << oldKey << fd->refcount;
|
|
|
|
FrameSvgPrivate::s_sharedFrames[fd->theme].remove(oldKey);
|
|
|
|
delete fd;
|
|
|
|
}
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
return;
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
}
|
|
|
|
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
if (fd->refcount() == 1) {
|
|
|
|
// we're the only user of it, let's remove it from the shared keys
|
|
|
|
// we don't want to deref it, however, as we'll still be using it
|
|
|
|
FrameSvgPrivate::s_sharedFrames[fd->theme].remove(oldKey);
|
|
|
|
} else {
|
|
|
|
// others are using it, but we wish to change its size. so deref it,
|
|
|
|
// then create a copy of it (we're automatically ref'd via the ctor),
|
|
|
|
// then insert it into our frames.
|
|
|
|
fd->deref(q);
|
|
|
|
fd = new FrameData(*fd, q);
|
|
|
|
}
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
} else {
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
fd = new FrameData(q, QString());
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
frame = fd;
|
|
|
|
fd->prefix = prefix;
|
|
|
|
fd->requestedPrefix = requestedPrefix;
|
|
|
|
//updateSizes();
|
|
|
|
fd->enabledBorders = enabledBorders;
|
|
|
|
fd->frameSize = pendingFrameSize;
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
fd->imagePath = q->imagePath();
|
|
|
|
//was fd just created empty now?
|
|
|
|
if (newKey.isEmpty()) {
|
|
|
|
newKey = cacheId(fd, prefix);
|
|
|
|
}
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
|
|
|
|
// we know it isn't in s_sharedFrames due to the check above, so insert it now
|
|
|
|
FrameSvgPrivate::s_sharedFrames[q->theme()->d].insert(newKey, fd);
|
|
|
|
fd->theme = q->theme()->d;
|
Fix binding loop regression in FrameSVGItem
Summary:
d8a1a9eb084b19e552c789244267f7346e1b27a8 introduces an unintended code
change, resizeFrame() updates the margins and in turns calls
repaintNeeded. This isn't needed and is a binding loop if we ever have a
frameSVGItem whose size depends on it's own margins.
resizeFrame is different from setEnabledBorders / setElementPrefix /
theme changes because even though we need to create a new FrameData we
know any hints and margins won't change. FrameSvgItem::updateSizes
doesn't depend on the size in any way, so always gives the same result
as before. We still, however, need to call updateSizes to populate our
FrameData structure even if the results will be the same as the previous
FrameData.
This patch that introduces a flag to updateFrameData to determine if we
should emit that size hints may have changed or not.
Test Plan:
GDB showed where the loop was.
Read the old code, and looked for differences
Ran plasmashell, checked I had no binding loop, frames including button
which have
composeOverBorder which need the new FrameData all rendered correctly.
Reviewers: #plasma, #frameworks, mart
Subscribers: mart, broulik, plasma-devel
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4713
2017-02-22 13:26:01 +01:00
|
|
|
if (updateType == UpdateFrameAndMargins) {
|
|
|
|
updateAndSignalSizes();
|
|
|
|
} else {
|
|
|
|
updateSizes(frame);
|
|
|
|
}
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
}
|
|
|
|
|
2014-07-21 15:44:25 +02:00
|
|
|
void FrameSvgPrivate::paintCenter(QPainter& p, FrameData* frame, const QRect& contentRect, const QSize& fullSize)
|
2014-07-14 17:00:39 +02:00
|
|
|
{
|
2014-07-21 15:44:25 +02:00
|
|
|
if (!contentRect.isEmpty()) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
const QString centerElementId = frame->prefix % QLatin1String("center");
|
2014-07-14 17:00:39 +02:00
|
|
|
if (frame->tileCenter) {
|
|
|
|
QSize centerTileSize = q->elementSize(centerElementId);
|
|
|
|
QPixmap center(centerTileSize);
|
|
|
|
center.fill(Qt::transparent);
|
|
|
|
|
|
|
|
QPainter centerPainter(¢er);
|
|
|
|
centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
|
|
|
|
q->paint(¢erPainter, QRect(QPoint(0, 0), centerTileSize),centerElementId);
|
|
|
|
|
|
|
|
if (frame->composeOverBorder) {
|
|
|
|
p.drawTiledPixmap(QRect(QPoint(0, 0), fullSize), center);
|
|
|
|
} else {
|
2015-03-10 18:02:15 +01:00
|
|
|
p.drawTiledPixmap(FrameSvgHelpers::sectionRect(FrameSvg::NoBorder, contentRect, fullSize * q->devicePixelRatio()), center);
|
2014-07-14 17:00:39 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (frame->composeOverBorder) {
|
|
|
|
q->paint(&p, QRect(QPoint(0, 0), fullSize),
|
|
|
|
centerElementId);
|
|
|
|
} else {
|
2015-03-10 18:02:15 +01:00
|
|
|
q->paint(&p, FrameSvgHelpers::sectionRect(FrameSvg::NoBorder, contentRect, fullSize * q->devicePixelRatio()), centerElementId);
|
2014-07-14 17:00:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame->composeOverBorder) {
|
|
|
|
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
|
|
|
p.drawPixmap(QRect(QPoint(0, 0), fullSize), alphaMask());
|
|
|
|
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-14 20:02:47 +02:00
|
|
|
void FrameSvgPrivate::paintBorder(QPainter& p, FrameData* frame, const FrameSvg::EnabledBorders borders, const QSize& size, const QRect& contentRect) const
|
2014-07-14 14:16:16 +02:00
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
QString side = frame->prefix % FrameSvgHelpers::borderToElementId(borders);
|
2014-07-14 16:37:00 +02:00
|
|
|
if (frame->enabledBorders & borders && q->hasElement(side) && !size.isEmpty()) {
|
2014-07-14 14:16:16 +02:00
|
|
|
if (frame->stretchBorders) {
|
2015-03-10 18:02:15 +01:00
|
|
|
q->paint(&p, FrameSvgHelpers::sectionRect(borders, contentRect, frame->frameSize * q->devicePixelRatio()), side);
|
2014-07-14 14:16:16 +02:00
|
|
|
} else {
|
2014-07-14 16:37:00 +02:00
|
|
|
QPixmap px(size);
|
2014-07-14 14:16:16 +02:00
|
|
|
px.fill(Qt::transparent);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2014-07-14 14:16:16 +02:00
|
|
|
QPainter sidePainter(&px);
|
2008-11-04 00:08:39 +01:00
|
|
|
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
|
2014-07-14 16:37:00 +02:00
|
|
|
q->paint(&sidePainter, QRect(QPoint(0, 0), size), side);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2015-03-10 18:02:15 +01:00
|
|
|
p.drawTiledPixmap(FrameSvgHelpers::sectionRect(borders, contentRect, frame->frameSize * q->devicePixelRatio()), px);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
2014-07-14 14:16:16 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2014-07-14 20:02:47 +02:00
|
|
|
void FrameSvgPrivate::paintCorner(QPainter& p, FrameData* frame, Plasma::FrameSvg::EnabledBorders border, const QRect& contentRect) const
|
2014-07-14 16:47:56 +02:00
|
|
|
{
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
QString corner = frame->prefix % FrameSvgHelpers::borderToElementId(border);
|
2014-07-14 16:47:56 +02:00
|
|
|
if (frame->enabledBorders & border && q->hasElement(corner)) {
|
2015-03-10 18:02:15 +01:00
|
|
|
q->paint(&p, FrameSvgHelpers::sectionRect(border, contentRect, frame->frameSize * q->devicePixelRatio()), corner);
|
2014-07-21 18:01:26 +02:00
|
|
|
}
|
2008-11-29 20:24:40 +01:00
|
|
|
}
|
|
|
|
|
2009-09-28 23:54:00 +02:00
|
|
|
QString FrameSvgPrivate::cacheId(FrameData *frame, const QString &prefixToSave) const
|
|
|
|
{
|
2010-09-27 19:19:06 +02:00
|
|
|
const QSize size = frameSize(frame).toSize();
|
2010-10-13 16:27:08 +02:00
|
|
|
const QLatin1Char s('_');
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
return QString::number(frame->enabledBorders) % s % QString::number(size.width()) % s % QString::number(size.height()) % s % QString::number(q->scaleFactor()) % s % QString::number(q->devicePixelRatio()) % s % prefixToSave % s % frame->imagePath;
|
2009-09-28 23:54:00 +02:00
|
|
|
}
|
2009-01-13 22:46:07 +01:00
|
|
|
|
2009-09-28 23:02:24 +02:00
|
|
|
void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const QPixmap &background, const QPixmap &overlay)
|
2008-11-29 20:24:40 +01:00
|
|
|
{
|
2009-05-13 18:37:13 +02:00
|
|
|
if (!q->isUsingRenderingCache()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-05-31 07:38:42 +02:00
|
|
|
//insert background
|
|
|
|
if (!frame) {
|
|
|
|
return;
|
|
|
|
}
|
2008-11-29 20:24:40 +01:00
|
|
|
|
2009-09-28 23:54:00 +02:00
|
|
|
const QString id = cacheId(frame, prefixToSave);
|
2008-11-29 20:24:40 +01:00
|
|
|
|
2015-12-15 22:56:40 +01:00
|
|
|
//qCDebug(LOG_PLASMA)<<"Saving to cache frame"<<id;
|
2009-01-13 22:46:07 +01:00
|
|
|
|
2014-05-19 14:58:19 +02:00
|
|
|
q->theme()->insertIntoCache(id, background, QString::number((qint64)q, 16) % prefixToSave);
|
2009-01-13 22:46:07 +01:00
|
|
|
|
2009-09-28 23:02:24 +02:00
|
|
|
if (!overlay.isNull()) {
|
|
|
|
//insert overlay
|
2015-11-27 21:03:48 +01:00
|
|
|
q->theme()->insertIntoCache(QLatin1String("overlay_") % id, overlay, QString::number((qint64)q, 16) % prefixToSave % QLatin1String("overlay"));
|
2009-09-28 23:02:24 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
void FrameSvgPrivate::updateSizes(FrameData *frame) const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2015-12-15 22:56:40 +01:00
|
|
|
//qCDebug(LOG_PLASMA) << "!!!!!!!!!!!!!!!!!!!!!! updating sizes" << prefix;
|
2008-11-04 00:08:39 +01:00
|
|
|
Q_ASSERT(frame);
|
|
|
|
|
2009-01-04 20:07:46 +01:00
|
|
|
QSize s = q->size();
|
|
|
|
q->resize();
|
2008-11-04 00:08:39 +01:00
|
|
|
frame->cachedBackground = QPixmap();
|
|
|
|
|
2014-02-21 21:13:12 +01:00
|
|
|
//This has the same size regardless the border is enabled or not
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->fixedTopHeight = q->elementSize(frame->prefix % QLatin1String("top")).height();
|
2014-02-21 21:13:12 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-top-margin"))) {
|
|
|
|
frame->fixedTopMargin = q->elementSize(frame->prefix % QLatin1String("hint-top-margin")).height();
|
2014-02-21 21:13:12 +01:00
|
|
|
} else {
|
|
|
|
frame->fixedTopMargin = frame->fixedTopHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
//The same, but its size depends from the margin being enabled
|
2008-11-04 00:08:39 +01:00
|
|
|
if (frame->enabledBorders & FrameSvg::TopBorder) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->topHeight = q->elementSize(frame->prefix % QLatin1String("top")).height();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-top-margin"))) {
|
|
|
|
frame->topMargin = q->elementSize(frame->prefix % QLatin1String("hint-top-margin")).height();
|
2008-11-04 00:08:39 +01:00
|
|
|
} else {
|
|
|
|
frame->topMargin = frame->topHeight;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
frame->topMargin = frame->topHeight = 0;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->fixedLeftWidth = q->elementSize(frame->prefix % QLatin1String("left")).width();
|
2014-02-21 21:13:12 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-left-margin"))) {
|
|
|
|
frame->fixedLeftMargin = q->elementSize(frame->prefix % QLatin1String("hint-left-margin")).width();
|
2014-02-21 21:13:12 +01:00
|
|
|
} else {
|
|
|
|
frame->fixedLeftMargin = frame->fixedLeftWidth;
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
if (frame->enabledBorders & FrameSvg::LeftBorder) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->leftWidth = q->elementSize(frame->prefix % QLatin1String("left")).width();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-left-margin"))) {
|
|
|
|
frame->leftMargin = q->elementSize(frame->prefix % QLatin1String("hint-left-margin")).width();
|
2008-11-04 00:08:39 +01:00
|
|
|
} else {
|
|
|
|
frame->leftMargin = frame->leftWidth;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
frame->leftMargin = frame->leftWidth = 0;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->fixedRightWidth = q->elementSize(frame->prefix % QLatin1String("right")).width();
|
2014-02-21 21:13:12 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-right-margin"))) {
|
|
|
|
frame->fixedRightMargin = q->elementSize(frame->prefix % QLatin1String("hint-right-margin")).width();
|
2014-02-21 21:13:12 +01:00
|
|
|
} else {
|
|
|
|
frame->fixedRightMargin = frame->fixedRightWidth;
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
if (frame->enabledBorders & FrameSvg::RightBorder) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->rightWidth = q->elementSize(frame->prefix % QLatin1String("right")).width();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-right-margin"))) {
|
|
|
|
frame->rightMargin = q->elementSize(frame->prefix % QLatin1String("hint-right-margin")).width();
|
2008-11-04 00:08:39 +01:00
|
|
|
} else {
|
|
|
|
frame->rightMargin = frame->rightWidth;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
frame->rightMargin = frame->rightWidth = 0;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->fixedBottomHeight = q->elementSize(frame->prefix % QLatin1String("bottom")).height();
|
2014-02-21 21:13:12 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-bottom-margin"))) {
|
|
|
|
frame->fixedBottomMargin = q->elementSize(frame->prefix % QLatin1String("hint-bottom-margin")).height();
|
2014-02-21 21:13:12 +01:00
|
|
|
} else {
|
|
|
|
frame->fixedBottomMargin = frame->fixedBottomHeight;
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
if (frame->enabledBorders & FrameSvg::BottomBorder) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->bottomHeight = q->elementSize(frame->prefix % QLatin1String("bottom")).height();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
if (q->hasElement(frame->prefix % QLatin1String("hint-bottom-margin"))) {
|
|
|
|
frame->bottomMargin = q->elementSize(frame->prefix % QLatin1String("hint-bottom-margin")).height();
|
2008-11-04 00:08:39 +01:00
|
|
|
} else {
|
|
|
|
frame->bottomMargin = frame->bottomHeight;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
frame->bottomMargin = frame->bottomHeight = 0;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
frame->composeOverBorder = (q->hasElement(frame->prefix % QLatin1String("hint-compose-over-border")) &&
|
|
|
|
q->hasElement(QLatin1String("mask-") % frame->prefix % QLatin1String("center")));
|
2010-05-06 16:16:03 +02:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
//since it's rectangular, topWidth and bottomWidth must be the same
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
//the ones that don't have a frame->prefix is for retrocompatibility
|
|
|
|
frame->tileCenter = (q->hasElement(QStringLiteral("hint-tile-center")) || q->hasElement(frame->prefix % QLatin1String("hint-tile-center")));
|
|
|
|
frame->noBorderPadding = (q->hasElement(QStringLiteral("hint-no-border-padding")) || q->hasElement(frame->prefix % QLatin1String("hint-no-border-padding")));
|
|
|
|
frame->stretchBorders = (q->hasElement(QStringLiteral("hint-stretch-borders")) || q->hasElement(frame->prefix % QLatin1String("hint-stretch-borders")));
|
2009-01-04 20:07:46 +01:00
|
|
|
q->resize(s);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvgPrivate::updateNeeded()
|
|
|
|
{
|
2014-07-11 16:42:55 +02:00
|
|
|
q->setElementPrefix(requestedPrefix);
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
//frame not created yet?
|
|
|
|
if (!frame) {
|
|
|
|
return;
|
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
q->clearCache();
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
updateSizes(frame);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvgPrivate::updateAndSignalSizes()
|
|
|
|
{
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
//frame not created yet?
|
|
|
|
if (!frame) {
|
|
|
|
return;
|
|
|
|
}
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
updateSizes(frame);
|
2008-11-04 00:08:39 +01:00
|
|
|
emit q->repaintNeeded();
|
|
|
|
}
|
|
|
|
|
2009-09-28 23:54:00 +02:00
|
|
|
QSizeF FrameSvgPrivate::frameSize(FrameData *frame) const
|
2009-06-10 19:11:02 +02:00
|
|
|
{
|
move setImagePath logic into updateFrameData()
Summary:
make sure the framedata creation/destruction is
completely in updateFrameData, makes easier to track
and possible to use the repaintsblocked logic.
now only one framedata instance should be created at startup.
CCBUG:376754
Test Plan:
* autotests pass, plasma runs ok, crash on 376754 not reproducible anymore
* possible to have a plasmashell session start without the creation of a single svg renderer (startups after the first when the cache is generated)
* on qml profiler, framesvgitem creation is ~12 msecs the first one created, ~2-300 musecs the subsequent ones, seems to be a bit better than before the whole refactor started
* tried against the latest patches that remove the binding loops, still correct rendering and no binding loop
* tried with both empty and existing cache in place
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #frameworks, #plasma
Differential Revision: https://phabricator.kde.org/D4707
2017-02-28 12:37:09 +01:00
|
|
|
if (!frame) {
|
|
|
|
return QSizeF();
|
|
|
|
}
|
|
|
|
|
2009-06-10 19:11:02 +02:00
|
|
|
if (!frame->frameSize.isValid()) {
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
updateSizes(frame);
|
2009-06-10 19:11:02 +02:00
|
|
|
frame->frameSize = q->size();
|
|
|
|
}
|
|
|
|
|
|
|
|
return frame->frameSize;
|
|
|
|
}
|
|
|
|
|
2010-09-27 19:19:06 +02:00
|
|
|
void FrameData::ref(FrameSvg *svg)
|
|
|
|
{
|
|
|
|
references[svg] = references[svg] + 1;
|
2015-12-15 22:56:40 +01:00
|
|
|
//qCDebug(LOG_PLASMA) << this << svg << references[svg];
|
2010-09-27 19:19:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FrameData::deref(FrameSvg *svg)
|
|
|
|
{
|
|
|
|
references[svg] = references[svg] - 1;
|
2015-12-15 22:56:40 +01:00
|
|
|
//qCDebug(LOG_PLASMA) << this << svg << references[svg];
|
2010-09-27 19:19:06 +02:00
|
|
|
if (references[svg] < 1) {
|
|
|
|
references.remove(svg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return references.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FrameData::removeRefs(FrameSvg *svg)
|
|
|
|
{
|
|
|
|
references.remove(svg);
|
|
|
|
return references.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FrameData::isUsed() const
|
|
|
|
{
|
|
|
|
return !references.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
int FrameData::refcount() const
|
|
|
|
{
|
|
|
|
return references.count();
|
|
|
|
}
|
2009-06-10 19:11:02 +02:00
|
|
|
|
2014-07-21 15:44:25 +02:00
|
|
|
QString FrameSvg::actualPrefix() const
|
|
|
|
{
|
|
|
|
return d->prefix;
|
|
|
|
}
|
|
|
|
|
don't regenerate frames when setting every property
Summary:
give frameSvg the concept of repaintBlocked(), that enables and
disables the regeneration of the frame data when a property is set.
the use case is when often, a lot of properties are set one after
the other (such as prefix, enabled borders, size)
collapse the formely similar, but a bit different logic of frame
regeneration is a single function for better maintanability.
QML FrameSvgItem sets repaintblocked when it starts and releases it just on oncomponentCompleted
Test Plan:
plasmashell still starts, autotests still work, all frames are rendered correctly
the destruction of old frames is cutted by 50%. in the qml profiler
the creation time of a framesvgitem slightly improved, on this machine from around 26 msecs to around 21, can still be improved, but at least the code is a bit simpler
Reviewers: #plasma
Subscribers: davidedmundson, plasma-devel, #frameworks
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D4414
2017-02-07 13:05:57 +01:00
|
|
|
bool FrameSvg::isRepaintBlocked() const
|
|
|
|
{
|
|
|
|
return d->repaintBlocked;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameSvg::setRepaintBlocked(bool blocked)
|
|
|
|
{
|
|
|
|
d->repaintBlocked = blocked;
|
|
|
|
|
|
|
|
if (!blocked) {
|
|
|
|
d->updateFrameData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
} // Plasma namespace
|
|
|
|
|
2012-02-08 23:33:03 +01:00
|
|
|
#include "moc_framesvg.cpp"
|