2020-08-03 01:22:19 +03:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
[scenes/opengl] Fix overlapping shadow tiles
Summary:
This problem appears if shadow corner tiles are too big and
some window has size smaller than 2 * shadowTileSize.
This change tries to address the problem above by exclusing
overlapping tile parts. If there are any two overlapping corners
then tile between them(top/right/bottom/left) is not rendered.
Also, because some corner tile parts can be excluded, corner tiles
are expected to be symmetrical(i.e. if we remove right half from
the top-left tile and left half from the top-right tile and
stick them together, they still look fine, there are no misalignments, etc).
Most shadows(e.g. shadows from Breeze) have such behaviour.
No tiles are overlapping
{F5728514, layout=center, size=full}
Overlapping tiles
{F5728516, layout=center, size=full}
And this is how it supposed to be
{F5728517, layout=center, size=full}
Test Plan:
* apply D11069 to Breeze
* in System Settings/Application Style/Window Decorations, choose "Very Large" shadow size
* open Konsole
* resize it to a minimum possible size
Reviewers: #kwin, graesslin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, ngraham, anemeth, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10811
2018-06-07 11:48:05 +03:00
|
|
|
|
2020-08-03 01:22:19 +03:00
|
|
|
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
[scenes/opengl] Fix overlapping shadow tiles
Summary:
This problem appears if shadow corner tiles are too big and
some window has size smaller than 2 * shadowTileSize.
This change tries to address the problem above by exclusing
overlapping tile parts. If there are any two overlapping corners
then tile between them(top/right/bottom/left) is not rendered.
Also, because some corner tile parts can be excluded, corner tiles
are expected to be symmetrical(i.e. if we remove right half from
the top-left tile and left half from the top-right tile and
stick them together, they still look fine, there are no misalignments, etc).
Most shadows(e.g. shadows from Breeze) have such behaviour.
No tiles are overlapping
{F5728514, layout=center, size=full}
Overlapping tiles
{F5728516, layout=center, size=full}
And this is how it supposed to be
{F5728517, layout=center, size=full}
Test Plan:
* apply D11069 to Breeze
* in System Settings/Application Style/Window Decorations, choose "Very Large" shadow size
* open Konsole
* resize it to a minimum possible size
Reviewers: #kwin, graesslin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, ngraham, anemeth, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10811
2018-06-07 11:48:05 +03:00
|
|
|
|
2020-08-03 01:22:19 +03:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
[scenes/opengl] Fix overlapping shadow tiles
Summary:
This problem appears if shadow corner tiles are too big and
some window has size smaller than 2 * shadowTileSize.
This change tries to address the problem above by exclusing
overlapping tile parts. If there are any two overlapping corners
then tile between them(top/right/bottom/left) is not rendered.
Also, because some corner tile parts can be excluded, corner tiles
are expected to be symmetrical(i.e. if we remove right half from
the top-left tile and left half from the top-right tile and
stick them together, they still look fine, there are no misalignments, etc).
Most shadows(e.g. shadows from Breeze) have such behaviour.
No tiles are overlapping
{F5728514, layout=center, size=full}
Overlapping tiles
{F5728516, layout=center, size=full}
And this is how it supposed to be
{F5728517, layout=center, size=full}
Test Plan:
* apply D11069 to Breeze
* in System Settings/Application Style/Window Decorations, choose "Very Large" shadow size
* open Konsole
* resize it to a minimum possible size
Reviewers: #kwin, graesslin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, ngraham, anemeth, abetts, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D10811
2018-06-07 11:48:05 +03:00
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
#include <KPluginFactory>
|
|
|
|
|
|
|
|
|
|
|
|
class FakeDecoWithShadows : public KDecoration2::Decoration
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit FakeDecoWithShadows(QObject *parent = nullptr, const QVariantList &args = QVariantList())
|
|
|
|
: Decoration(parent, args) {}
|
|
|
|
~FakeDecoWithShadows() override {}
|
|
|
|
|
|
|
|
void paint(QPainter *painter, const QRect &repaintRegion) override {
|
|
|
|
Q_UNUSED(painter)
|
|
|
|
Q_UNUSED(repaintRegion)
|
|
|
|
}
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void init() override {
|
|
|
|
const int shadowSize = 128;
|
|
|
|
const int offsetTop = 64;
|
|
|
|
const int offsetLeft = 48;
|
|
|
|
const QRect shadowRect(0, 0, 4 * shadowSize + 1, 4 * shadowSize + 1);
|
|
|
|
|
|
|
|
QImage shadowTexture(shadowRect.size(), QImage::Format_ARGB32_Premultiplied);
|
|
|
|
shadowTexture.fill(Qt::transparent);
|
|
|
|
|
|
|
|
const QMargins padding(
|
|
|
|
shadowSize - offsetLeft,
|
|
|
|
shadowSize - offsetTop,
|
|
|
|
shadowSize + offsetLeft,
|
|
|
|
shadowSize + offsetTop);
|
|
|
|
|
|
|
|
auto decoShadow = QSharedPointer<KDecoration2::DecorationShadow>::create();
|
|
|
|
decoShadow->setPadding(padding);
|
|
|
|
decoShadow->setInnerShadowRect(QRect(shadowRect.center(), QSize(1, 1)));
|
|
|
|
decoShadow->setShadow(shadowTexture);
|
|
|
|
|
|
|
|
setShadow(decoShadow);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
K_PLUGIN_FACTORY_WITH_JSON(
|
|
|
|
FakeDecoWithShadowsFactory,
|
|
|
|
"fakedecoration_with_shadows.json",
|
|
|
|
registerPlugin<FakeDecoWithShadows>();
|
|
|
|
)
|
|
|
|
|
|
|
|
#include "fakedecoration_with_shadows.moc"
|