KWin
Loading...
Searching...
No Matches
decorationitem.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "scene/item.h"
10
11namespace KDecoration2
12{
13class Decoration;
14}
15
16namespace KWin
17{
18
19class Window;
20class Output;
21
22namespace Decoration
23{
24class DecoratedClientImpl;
25}
26
27class KWIN_EXPORT DecorationRenderer : public QObject
28{
29 Q_OBJECT
30
31public:
32 virtual void render(const QRegion &region) = 0;
33 void invalidate();
34
35 // TODO: Move damage tracking inside DecorationItem.
36 QRegion damage() const;
37 void addDamage(const QRegion &region);
38 void resetDamage();
39
40 qreal effectiveDevicePixelRatio() const;
41 qreal devicePixelRatio() const;
42 void setDevicePixelRatio(qreal dpr);
43
44 // Reserve some space for padding. We pad decoration parts to avoid texture bleeding.
45 static const int TexturePad = 1;
46
47Q_SIGNALS:
48 void damaged(const QRegion &region);
49
50protected:
52
53 Decoration::DecoratedClientImpl *client() const;
54
55 bool areImageSizesDirty() const
56 {
57 return m_imageSizesDirty;
58 }
60 {
61 m_imageSizesDirty = false;
62 }
63 void renderToPainter(QPainter *painter, const QRect &rect);
64
65private:
66 QPointer<Decoration::DecoratedClientImpl> m_client;
67 QRegion m_damage;
68 qreal m_devicePixelRatio = 1;
69 bool m_imageSizesDirty;
70};
71
75class KWIN_EXPORT DecorationItem : public Item
76{
77 Q_OBJECT
78
79public:
80 explicit DecorationItem(KDecoration2::Decoration *decoration, Window *window, Scene *scene, Item *parent = nullptr);
81
82 DecorationRenderer *renderer() const;
83 Window *window() const;
84
85 QList<QRectF> shape() const override final;
86 QRegion opaque() const override final;
87
88private Q_SLOTS:
89 void handleDecorationGeometryChanged();
90 void handleOutputChanged();
91 void handleOutputScaleChanged();
92
93protected:
94 void preprocess() override;
95 WindowQuadList buildQuads() const override;
96
97private:
98 Window *m_window;
99 QPointer<Output> m_output;
100 QPointer<KDecoration2::Decoration> m_decoration;
101 std::unique_ptr<DecorationRenderer> m_renderer;
102};
103
104} // namespace KWin
virtual void render(const QRegion &region)=0
void damaged(const QRegion &region)
bool areImageSizesDirty() const