2021-02-04 09:07:20 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "item.h"
|
|
|
|
|
|
|
|
namespace KDecoration2
|
|
|
|
{
|
|
|
|
class Decoration;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2021-08-12 09:07:38 +00:00
|
|
|
class AbstractClient;
|
|
|
|
class Deleted;
|
|
|
|
class Toplevel;
|
|
|
|
|
2021-04-26 16:38:40 +00:00
|
|
|
namespace Decoration
|
|
|
|
{
|
|
|
|
class DecoratedClientImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
class KWIN_EXPORT DecorationRenderer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void render(const QRegion ®ion) = 0;
|
|
|
|
void invalidate();
|
|
|
|
|
|
|
|
// TODO: Move damage tracking inside DecorationItem.
|
|
|
|
QRegion damage() const;
|
|
|
|
void addDamage(const QRegion ®ion);
|
|
|
|
void resetDamage();
|
|
|
|
|
2022-02-07 10:36:25 +00:00
|
|
|
qreal effectiveDevicePixelRatio() const;
|
2021-11-26 09:18:19 +00:00
|
|
|
qreal devicePixelRatio() const;
|
|
|
|
void setDevicePixelRatio(qreal dpr);
|
|
|
|
|
2021-12-16 16:36:47 +00:00
|
|
|
// Reserve some space for padding. We pad decoration parts to avoid texture bleeding.
|
|
|
|
static const int TexturePad = 1;
|
|
|
|
|
2021-04-26 16:38:40 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void damaged(const QRegion ®ion);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit DecorationRenderer(Decoration::DecoratedClientImpl *client);
|
|
|
|
|
|
|
|
Decoration::DecoratedClientImpl *client() const;
|
|
|
|
|
|
|
|
bool areImageSizesDirty() const {
|
|
|
|
return m_imageSizesDirty;
|
|
|
|
}
|
|
|
|
void resetImageSizesDirty() {
|
|
|
|
m_imageSizesDirty = false;
|
|
|
|
}
|
|
|
|
QImage renderToImage(const QRect &geo);
|
|
|
|
void renderToPainter(QPainter *painter, const QRect &rect);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QPointer<Decoration::DecoratedClientImpl> m_client;
|
|
|
|
QRegion m_damage;
|
2021-11-26 09:18:19 +00:00
|
|
|
qreal m_devicePixelRatio = 1;
|
2021-04-26 16:38:40 +00:00
|
|
|
bool m_imageSizesDirty;
|
|
|
|
};
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
/**
|
|
|
|
* The DecorationItem class represents a server-side decoration.
|
|
|
|
*/
|
|
|
|
class KWIN_EXPORT DecorationItem : public Item
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-08-12 09:07:38 +00:00
|
|
|
explicit DecorationItem(KDecoration2::Decoration *decoration, AbstractClient *window, Item *parent = nullptr);
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-04-26 16:38:40 +00:00
|
|
|
DecorationRenderer *renderer() const;
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void handleFrameGeometryChanged();
|
2021-08-12 09:07:38 +00:00
|
|
|
void handleWindowClosed(Toplevel *original, Deleted *deleted);
|
2021-11-26 09:18:19 +00:00
|
|
|
void handleOutputChanged();
|
|
|
|
void handleOutputScaleChanged();
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-04-26 16:38:40 +00:00
|
|
|
protected:
|
|
|
|
void preprocess() override;
|
2021-05-21 10:51:23 +00:00
|
|
|
WindowQuadList buildQuads() const override;
|
2021-04-26 16:38:40 +00:00
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
private:
|
2021-08-12 09:07:38 +00:00
|
|
|
Toplevel *m_window;
|
2021-11-26 09:18:19 +00:00
|
|
|
QPointer<AbstractOutput> m_output;
|
2021-02-04 09:07:20 +00:00
|
|
|
QPointer<KDecoration2::Decoration> m_decoration;
|
2021-04-26 16:38:40 +00:00
|
|
|
QScopedPointer<DecorationRenderer> m_renderer;
|
2021-02-04 09:07:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWin
|