[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: D15514: [libbreezecommon] Use box blur instead of FFT approach
From: Vlad Zagorodniy <noreply () phabricator ! kde ! org>
Date: 2018-09-14 20:12:32
Message-ID: 3a6cabcd75e637497b18d705af208fbe () localhost ! localdomain
[Download RAW message or body]
[Attachment #2 (text/plain)]
zzag created this revision.
zzag added reviewers: KWin, Plasma.
Herald added a project: Plasma.
Herald added a subscriber: plasma-devel.
zzag requested review of this revision.
REVISION SUMMARY
Creation of shadows (especially for "Large" and "Very large" sizes) is
a computation expensive task because we have to blur alpha channel of a
shadow texture (which then will be tinted with desired shadow color).
Currently, we use the following approach:
- for blur radius less than 64, use naive 2-pass algorithm;
- for blur radius greater than or equal to 64, use FFT.
Even though the FFT approach is doing its the best, it still takes
impresive amount of time to blur the alpha channel.
What makes things even worse is that while we're blurring the alpha
channel, we're blocking the main thread of KWin (decorations are not
rendered in their own thread). This can result in frame drops (2 or 3
frames, something like that).
So, the only viable alternative is to use an approximation of the Gaussian
blur. As such an approximation, I picked the box blur because it's quite
simple, it's fast, and it takes small amount of iterations to have something
similar to the true Gaussian blur.
In general, there are no big differences between true gaussian shadows
and approximated shadows:
Before:
F6264173: FFT shadows <https://phabricator.kde.org/F6264173>
After:
F6264175: after.png <https://phabricator.kde.org/F6264175>
As a win, it takes much less time to generate decoration shadows.
REPOSITORY
R31 Breeze
BRANCH
zzag/box-shadow-helper-box-blur
REVISION DETAIL
https://phabricator.kde.org/D15514
AFFECTED FILES
CMakeLists.txt
cmake/Modules/FindFFTW.cmake
libbreezecommon/CMakeLists.txt
libbreezecommon/breezeboxshadowhelper.cpp
To: zzag, #kwin, #plasma
Cc: plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, \
abetts, sebas, apol, mart
[Attachment #3 (text/html)]
<table><tr><td style="">zzag created this revision.<br />zzag added reviewers: KWin, \
Plasma.<br />Herald added a project: Plasma.<br />Herald added a subscriber: \
plasma-devel.<br />zzag requested review of this revision. </td><a \
style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; \
color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; \
background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; \
border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D15514">View \
Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Creation \
of shadows (especially for "Large" and "Very large" sizes) is<br \
/> a computation expensive task because we have to blur alpha channel of a<br />
shadow texture (which then will be tinted with desired shadow color).</p>
<p>Currently, we use the following approach:</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">for blur radius less than 64, use naive 2-pass \
algorithm;</li> <li class="remarkup-list-item">for blur radius greater than or equal \
to 64, use FFT.</li> </ul>
<p>Even though the FFT approach is doing its the best, it still takes<br />
impresive amount of time to blur the alpha channel.</p>
<p>What makes things even worse is that while we're blurring the alpha<br />
channel, we're blocking the main thread of KWin (decorations are not<br />
rendered in their own thread). This can result in frame drops (2 or 3<br />
frames, something like that).</p>
<p>So, the only viable alternative is to use an approximation of the Gaussian<br />
blur. As such an approximation, I picked the box blur because it's quite<br />
simple, it's fast, and it takes small amount of iterations to have something<br \
/> similar to the true Gaussian blur.</p>
<p>In general, there are no big differences between true gaussian shadows<br />
and approximated shadows:</p>
<p>Before:<br />
<a href="https://phabricator.kde.org/F6264173" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">F6264173: FFT shadows</a></p>
<p>After:<br />
<a href="https://phabricator.kde.org/F6264175" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">F6264175: after.png</a></p>
<p>As a win, it takes much less time to generate decoration \
shadows.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R31 \
Breeze</div></div></div><br \
/><div><strong>BRANCH</strong><div><div>zzag/box-shadow-helper-box-blur</div></div></div><br \
/><div><strong>REVISION DETAIL</strong><div><a \
href="https://phabricator.kde.org/D15514">https://phabricator.kde.org/D15514</a></div></div><br \
/><div><strong>AFFECTED FILES</strong><div><div>CMakeLists.txt<br /> \
cmake/Modules/FindFFTW.cmake<br /> libbreezecommon/CMakeLists.txt<br />
libbreezecommon/breezeboxshadowhelper.cpp</div></div></div><br /><div><strong>To: \
</strong>zzag, KWin, Plasma<br /><strong>Cc: </strong>plasma-devel, ragreen, Pitel, \
ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart<br \
/></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic