Remove shadow related bits in Scene::Window

This commit is contained in:
Vlad Zahorodnii 2021-05-19 14:11:46 +03:00
parent 6f39d79d72
commit e4ec955d88
8 changed files with 33 additions and 78 deletions

View file

@ -34,7 +34,9 @@
#include "effects.h"
#include "platform.h"
#include "shadow.h"
#include "shadowitem.h"
#include "wayland_server.h"
#include "windowitem.h"
#include "workspace.h"
Q_DECLARE_METATYPE(KWin::WindowQuadList);
@ -638,8 +640,8 @@ void SceneOpenGLShadowTest::testShadowTileOverlaps()
// Get shadow.
QVERIFY(client->effectWindow());
QVERIFY(client->effectWindow()->sceneWindow());
QVERIFY(client->effectWindow()->sceneWindow()->shadow());
auto *shadow = client->effectWindow()->sceneWindow()->shadow();
auto *shadow = client->windowItem()->shadowItem()->shadow();
QVERIFY(shadow);
// Validate shadow quads.
const WindowQuadList &quads = shadow->shadowQuads();
@ -730,7 +732,7 @@ void SceneOpenGLShadowTest::testNoCornerShadowTiles()
QVERIFY(client->effectWindow());
QVERIFY(client->effectWindow()->sceneWindow());
KWin::Shadow *shadow = client->effectWindow()->sceneWindow()->shadow();
KWin::Shadow *shadow = client->windowItem()->shadowItem()->shadow();
QVERIFY(shadow != nullptr);
const WindowQuadList &quads = shadow->shadowQuads();
@ -810,7 +812,7 @@ void SceneOpenGLShadowTest::testDistributeHugeCornerTiles()
QVERIFY(client->effectWindow());
QVERIFY(client->effectWindow()->sceneWindow());
KWin::Shadow *shadow = client->effectWindow()->sceneWindow()->shadow();
KWin::Shadow *shadow = client->windowItem()->shadowItem()->shadow();
QVERIFY(shadow != nullptr);
WindowQuadList expectedQuads;

View file

@ -39,7 +39,9 @@
#include "platform.h"
#include "plugins/scenes/qpainter/scene_qpainter.h"
#include "shadow.h"
#include "shadowitem.h"
#include "wayland_server.h"
#include "windowitem.h"
#include "workspace.h"
Q_DECLARE_METATYPE(KWin::WindowQuadList)
@ -642,8 +644,8 @@ void SceneQPainterShadowTest::testShadowTileOverlaps()
// Get shadow.
QVERIFY(client->effectWindow());
QVERIFY(client->effectWindow()->sceneWindow());
QVERIFY(client->effectWindow()->sceneWindow()->shadow());
auto *shadow = client->effectWindow()->sceneWindow()->shadow();
auto *shadow = client->windowItem()->shadowItem()->shadow();
QVERIFY(shadow);
// Validate shadow quads.
const WindowQuadList &quads = shadow->shadowQuads();
@ -756,8 +758,8 @@ void SceneQPainterShadowTest::testShadowTextureReconstruction()
// Get SceneQPainterShadow's texture.
QVERIFY(client->effectWindow());
QVERIFY(client->effectWindow()->sceneWindow());
QVERIFY(client->effectWindow()->sceneWindow()->shadow());
auto &shadowTexture = static_cast<SceneQPainterShadow *>(client->effectWindow()->sceneWindow()->shadow())->shadowTexture();
auto *shadow = client->windowItem()->shadowItem()->shadow();
auto &shadowTexture = static_cast<SceneQPainterShadow *>(shadow)->shadowTexture();
QCOMPARE(shadowTexture, referenceShadowTexture);
}

View file

@ -17,10 +17,12 @@
#include "main.h"
#include "renderloop.h"
#include "screens.h"
#include "shadowitem.h"
#include "surfaceitem.h"
#include "toplevel.h"
#include "platform.h"
#include "wayland_server.h"
#include "windowitem.h"
#include <kwineffectquickview.h>
@ -287,10 +289,11 @@ void SceneQPainter::Window::renderSurfaceItem(QPainter *painter, SurfaceItem *su
void SceneQPainter::Window::renderShadow(QPainter* painter)
{
if (!toplevel->shadow()) {
const ShadowItem *shadowItem = windowItem()->shadowItem();
if (!shadowItem) {
return;
}
SceneQPainterShadow *shadow = static_cast<SceneQPainterShadow *>(toplevel->shadow());
SceneQPainterShadow *shadow = static_cast<SceneQPainterShadow *>(shadowItem->shadow());
const QImage &shadowTexture = shadow->shadowTexture();
const WindowQuadList &shadowQuads = shadow->shadowQuads();

View file

@ -470,7 +470,6 @@ void Scene::addToplevel(Toplevel *c)
c->effectWindow()->setSceneWindow(w);
c->updateShadow();
w->updateShadow(c->shadow());
}
void Scene::removeToplevel(Toplevel *toplevel)
@ -490,8 +489,8 @@ void Scene::windowClosed(Toplevel *toplevel, Deleted *deleted)
Q_ASSERT(m_windows.contains(toplevel));
Window *window = m_windows.take(toplevel);
window->updateToplevel(deleted);
if (window->shadow()) {
window->shadow()->setToplevel(deleted);
if (window->shadowItem()) {
window->shadowItem()->shadow()->setToplevel(deleted);
}
m_windows[deleted] = window;
}
@ -1056,27 +1055,6 @@ void Scene::Window::discardQuads()
cached_quad_list.reset();
}
const Shadow *Scene::Window::shadow() const
{
if (shadowItem()) {
return shadowItem()->shadow();
}
return nullptr;
}
Shadow *Scene::Window::shadow()
{
if (shadowItem()) {
return shadowItem()->shadow();
}
return nullptr;
}
void Scene::Window::updateShadow(Shadow* shadow)
{
m_windowItem->setShadow(shadow);
}
void Scene::Window::preprocess(Item *item)
{
item->preprocess();

View file

@ -350,9 +350,6 @@ public:
void updateToplevel(Deleted *deleted);
// creates initial quad list for the window
virtual WindowQuadList buildQuads(bool force = false) const;
void updateShadow(Shadow* shadow);
const Shadow* shadow() const;
Shadow* shadow();
void referencePreviousPixmap();
void unreferencePreviousPixmap();
void discardQuads();

View file

@ -12,8 +12,8 @@
#include "atoms.h"
#include "abstract_client.h"
#include "composite.h"
#include "effects.h"
#include "internal_client.h"
#include "scene.h"
#include "toplevel.h"
#include "wayland_server.h"
@ -45,9 +45,6 @@ Shadow::~Shadow()
Shadow *Shadow::createShadow(Toplevel *toplevel)
{
if (!effects) {
return nullptr;
}
Shadow *shadow = createShadowFromDecoration(toplevel);
if (!shadow && waylandServer()) {
shadow = createShadowFromWayland(toplevel);
@ -58,13 +55,6 @@ Shadow *Shadow::createShadow(Toplevel *toplevel)
if (!shadow) {
shadow = createShadowFromInternalWindow(toplevel);
}
if (!shadow) {
return nullptr;
}
if (toplevel->effectWindow() && toplevel->effectWindow()->sceneWindow()) {
toplevel->effectWindow()->sceneWindow()->updateShadow(shadow);
emit toplevel->shadowChanged();
}
return shadow;
}

View file

@ -19,6 +19,7 @@
#include "effects.h"
#include "screens.h"
#include "shadow.h"
#include "shadowitem.h"
#include "windowitem.h"
#include "workspace.h"
@ -427,31 +428,21 @@ bool Toplevel::isOnOutput(AbstractOutput *output) const
void Toplevel::updateShadow()
{
if (shadow()) {
if (!effectWindow()->sceneWindow()->shadow()->updateShadow()) {
effectWindow()->sceneWindow()->updateShadow(nullptr);
WindowItem *windowItem = this->windowItem();
if (!windowItem) {
return;
}
if (auto shadowItem = windowItem->shadowItem()) {
if (!shadowItem->shadow()->updateShadow()) {
windowItem->setShadow(nullptr);
}
emit shadowChanged();
} else {
Shadow::createShadow(this);
}
}
Shadow *Toplevel::shadow()
{
if (effectWindow() && effectWindow()->sceneWindow()) {
return effectWindow()->sceneWindow()->shadow();
} else {
return nullptr;
}
}
const Shadow *Toplevel::shadow() const
{
if (effectWindow() && effectWindow()->sceneWindow()) {
return effectWindow()->sceneWindow()->shadow();
} else {
return nullptr;
Shadow *shadow = Shadow::createShadow(this);
if (shadow) {
windowItem->setShadow(shadow);
emit shadowChanged();
}
}
}

View file

@ -463,14 +463,6 @@ public:
*/
void elevate(bool elevate);
/**
* Returns the pointer to the Toplevel's Shadow. A Shadow
* is only available if Compositing is enabled and the corresponding X window
* has the Shadow property set.
* @returns The Shadow belonging to this Toplevel, @c null if there's no Shadow.
*/
const Shadow *shadow() const;
Shadow *shadow();
/**
* Updates the Shadow associated with this Toplevel from X11 Property.
* Call this method when the Property changes or Compositing is started.