Commit Graph

34 Commits

Author SHA1 Message Date
Christophe Giboudeaux
1587ead53e Fix typos found by codespell
GIT_SILENT
2021-07-14 11:01:00 +02:00
Ahmad Samir
c0274df69a Run clang-format on all cpp/h files
NO_CHANGELOG
2021-03-13 17:35:34 +00:00
Ahmad Samir
9ae7d71b9a Add a trailing comma to enum
Should help produce better diffs and clang-format won't squash the enum
on one line.

GIT_SILENT
2021-03-13 17:35:34 +00:00
Marco Martin
f09b46bec6 Draft: Replace QString cache IDs with a struct-based version
As it turns out, QString::number() is quite expensive, especially when
using it in a code path that is called a lot of times. So instead, use a
struct with a custom hash method as cache ID. This is significantly
faster since we do not need to do memory allocations or string
conversions.
2020-12-17 11:31:27 +00:00
Mikel Johnson
c8e563efa7 [FrameSvg*] Rename shadowMargins to inset 2020-11-26 09:35:55 +00:00
Mikel Johnson
2f7563d6eb [FrameSvg] Cache shadow margins and honor prefixes 2020-11-26 09:35:55 +00:00
Arjen Hiemstra
16f852ea4c Ensure FrameSvg uses lastModified timestamp when using cache
This, I suspect, is the true source of bug 426674. FrameSvg would
request items from the cache without specifying any modification time
stamp, so we end up always retrieving the cached version. Since
lastModified is now a required parameter, we need to ensure this does
not happen anymore.

BUG: 426674
2020-09-23 14:08:52 +00:00
Andreas Cord-Landwehr
d10afb5d2a plasma-framework: Convert copyright statements to SPDX expressions 2020-08-13 19:08:54 +00:00
Aleix Pol
909364dfca Simplify reference counting of FrameData
Summary:
Leverages QSharedPointer for the reference counting.
Keeps the last value of the cacheId, as it can change sometimes and crash
the system.

Reviewers: #plasma, #frameworks, zzag

Reviewed By: #plasma, zzag

Subscribers: mart, zzag, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D17052
2018-11-22 19:09:13 +01:00
Aleix Pol
069acf600c Make sure private header fields are initialized 2018-11-12 03:11:25 +01:00
Friedrich W. H. Kossebau
30cbc2dc33 Use more nullptr 2018-07-02 00:16:21 +02:00
Vlad Zagorodniy
412a517576 FrameSvg: Do not wreck shared mask frames
Summary:
When trying to update the maskFrame, there is a chance that it is already
shared by several instances of FrameSvg. In that case, do not wreck maskFrame
and instead act as follows:

* deref it
* try to lookup a matching frame in the shared frames
* if there is the matching frame, use it
* otherwise create a new one

Reviewers: #plasma, #frameworks, mart

Reviewed By: #plasma, mart

Subscribers: mart, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D13384
2018-06-27 15:36:59 +03:00
Marco Martin
2b3e8dfe86 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 13:35:09 +01:00
David Edmundson
e301b63685 Fix binding loop regression in FrameSVGItem
Summary:
d8a1a9eb08 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 12:31:44 +00:00
Marco Martin
d8a1a9eb08 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:08:27 +01:00
David Rosca
974a2b5071 FrameSvg: Fix dangling pointers in sharedFrames when theme changes
Store theme pointer in FrameData and set it when adding to sharedFrames.

REVIEW: 127344
2016-03-12 13:02:34 +01:00
Marco Martin
285224a2ea don't risk to mix up frames with different pixelratio
BUG:345155
Change-Id: I0b2384831d755e02b944a49259ffeacd0d2fb71e
2015-03-25 17:06:47 +01:00
Aleix Pol
47c7688d02 Move some of the code and make some API public
It's unreasonable to use private API, so make everything public API so that
every user of FrameSvg have as much features exposed as possible.

Reviewed by David Edmundson
2014-07-21 15:44:25 +02:00
Aleix Pol
83895d8e26 Use proper sizes and positions 2014-07-14 20:02:47 +02:00
Aleix Pol
a8b37129d0 Refactor a contentGeometry method out of generateFrameBackground
Given the FrameData and the total size, we get to know where is the
contents going to be and gives us the information to extrapolate where to
put all the borders and corners.

Reviewed by David Edmundson
2014-07-14 18:13:40 +02:00
Aleix Pol
d574f51108 Move the central space painting into a separate function
Reviewed by David Edmundson
2014-07-14 17:00:39 +02:00
Aleix Pol
ae56796cb9 Move corner painting into a paintCorner function 2014-07-14 16:47:56 +02:00
Aleix Pol
f62b357b62 Prefer passing a size rather than a width and height 2014-07-14 16:37:00 +02:00
Aleix Pol
5b1fc96329 Small internal code refactoring
Create a paintBorder function that can generically paint framesvg borders.
This helps us reduce duplicated code as well as improving the readability
of the code.

Reviewed by David Edmundson
2014-07-14 14:16:16 +02:00
Aleix Pol
804a0d34da Fix cache implementation
It was weird.

Reviewed by the Handa-man.
2014-07-11 18:37:55 +02:00
Marco Martin
c77b2bf9a8 fix switch from a less complete to a more complete
if the old theme didn't have a prefix, but the new one has,
set the old (formerly nonexisting) prefix again
2014-07-11 16:42:55 +02:00
Marco Martin
3fdf999ba0 bit more complex bookeeping
since it is now possible to have different svg/framesvg with
different themes, s_sharedFrames must be indexed by theme first
what it's really the identifying thing is ThemePrivate, so it's indexed by that
this fixes a crash that occurs the second thime the theme gets changed

BUG:335472
2014-05-28 20:27:58 +02:00
Marco Martin
bbed0411b6 don't use another Thmeme copy 2014-05-19 14:58:19 +02:00
Kevin Ottens
72ba7b4146 Apply the astyle-kdelibs script 2014-04-26 01:48:37 +02:00
Marco Martin
c009c7f0cd concept of fixedMargins
sometimes we need to know what the margins are of a framesvg, even if some of them are disabled
2014-02-21 21:13:12 +01:00
Kevin Ottens
0e590217f8 Port away from kdebug 2013-07-30 08:05:09 +02:00
Marco Martin
812b9a06ab get rid of Plasma::Location 2013-05-14 18:27:27 +02:00
Marco Martin
fd97160327 remove the singleton usage from everywhere 2013-03-12 16:29:04 +01:00
Sebastian Kügler
7dfe957e66 The Big Move
All cpp code moves into the src/ subdirectory, as the Frameworks policy
suggests.

Directory structure should now be in line with other, future frameworks.
2013-02-14 17:17:12 +01:00