File indexing completed on 2024-05-12 05:32:08
0001 /* 0002 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "scene/item.h" 0010 0011 namespace KWin 0012 { 0013 0014 class Shadow; 0015 class Window; 0016 0017 class KWIN_EXPORT ShadowTextureProvider 0018 { 0019 public: 0020 explicit ShadowTextureProvider(Shadow *shadow); 0021 virtual ~ShadowTextureProvider(); 0022 0023 Shadow *shadow() const { return m_shadow; } 0024 0025 virtual void update() = 0; 0026 0027 protected: 0028 Shadow *m_shadow; 0029 }; 0030 0031 /** 0032 * The ShadowItem class represents a nine-tile patch server-side drop-shadow. 0033 */ 0034 class KWIN_EXPORT ShadowItem : public Item 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 explicit ShadowItem(Shadow *shadow, Window *window, Scene *scene, Item *parent = nullptr); 0040 ~ShadowItem() override; 0041 0042 Shadow *shadow() const; 0043 ShadowTextureProvider *textureProvider() const; 0044 0045 protected: 0046 WindowQuadList buildQuads() const override; 0047 void preprocess() override; 0048 0049 private Q_SLOTS: 0050 void handleTextureChanged(); 0051 void updateGeometry(); 0052 0053 private: 0054 Window *m_window; 0055 Shadow *m_shadow = nullptr; 0056 std::unique_ptr<ShadowTextureProvider> m_textureProvider; 0057 bool m_textureDirty = true; 0058 }; 0059 0060 } // namespace KWin