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 KWin
|
|
|
|
{
|
|
|
|
|
2021-08-12 09:07:38 +00:00
|
|
|
class Deleted;
|
2021-04-09 07:06:04 +00:00
|
|
|
class SurfacePixmap;
|
2021-08-12 09:07:38 +00:00
|
|
|
class Toplevel;
|
2021-04-09 07:06:04 +00:00
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
/**
|
|
|
|
* The SurfaceItem class represents a surface with some contents.
|
|
|
|
*/
|
|
|
|
class KWIN_EXPORT SurfaceItem : public Item
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-07-21 19:25:42 +00:00
|
|
|
QMatrix4x4 surfaceToBufferMatrix() const;
|
|
|
|
void setSurfaceToBufferMatrix(const QMatrix4x4 &matrix);
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-08-12 09:07:38 +00:00
|
|
|
Toplevel *window() const;
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
virtual QRegion shape() const;
|
|
|
|
virtual QRegion opaque() const;
|
|
|
|
|
|
|
|
void addDamage(const QRegion ®ion);
|
|
|
|
void resetDamage();
|
|
|
|
QRegion damage() const;
|
|
|
|
|
2021-05-19 06:22:05 +00:00
|
|
|
void discardPixmap();
|
|
|
|
void updatePixmap();
|
|
|
|
|
2021-04-09 07:06:04 +00:00
|
|
|
SurfacePixmap *pixmap() const;
|
|
|
|
SurfacePixmap *previousPixmap() const;
|
2021-02-04 09:07:20 +00:00
|
|
|
|
|
|
|
void referencePreviousPixmap();
|
|
|
|
void unreferencePreviousPixmap();
|
|
|
|
|
|
|
|
protected:
|
2021-08-12 09:07:38 +00:00
|
|
|
explicit SurfaceItem(Toplevel *window, Item *parent = nullptr);
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-04-09 07:06:04 +00:00
|
|
|
virtual SurfacePixmap *createPixmap() = 0;
|
2021-02-04 09:07:20 +00:00
|
|
|
void preprocess() override;
|
2021-05-21 10:51:23 +00:00
|
|
|
WindowQuadList buildQuads() const override;
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2021-08-12 09:07:38 +00:00
|
|
|
void handleWindowClosed(Toplevel *original, Deleted *deleted);
|
|
|
|
|
|
|
|
Toplevel *m_window;
|
2021-02-04 09:07:20 +00:00
|
|
|
QRegion m_damage;
|
2021-04-09 07:06:04 +00:00
|
|
|
QScopedPointer<SurfacePixmap> m_pixmap;
|
|
|
|
QScopedPointer<SurfacePixmap> m_previousPixmap;
|
2021-07-21 19:25:42 +00:00
|
|
|
QMatrix4x4 m_surfaceToBufferMatrix;
|
2021-02-04 09:07:20 +00:00
|
|
|
int m_referencePixmapCounter = 0;
|
|
|
|
};
|
|
|
|
|
2021-10-20 14:58:58 +00:00
|
|
|
class KWIN_EXPORT SurfaceTexture
|
2021-04-09 07:06:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-10-20 14:58:58 +00:00
|
|
|
virtual ~SurfaceTexture();
|
2021-04-09 07:06:04 +00:00
|
|
|
|
|
|
|
virtual bool isValid() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class KWIN_EXPORT SurfacePixmap : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-10-20 14:58:58 +00:00
|
|
|
explicit SurfacePixmap(SurfaceTexture *texture, QObject *parent = nullptr);
|
2021-04-09 07:06:04 +00:00
|
|
|
|
2021-10-20 14:58:58 +00:00
|
|
|
SurfaceTexture *texture() const;
|
2021-04-09 07:06:04 +00:00
|
|
|
|
|
|
|
bool hasAlphaChannel() const;
|
|
|
|
QSize size() const;
|
|
|
|
QRect contentsRect() const;
|
|
|
|
|
|
|
|
bool isDiscarded() const;
|
|
|
|
void markAsDiscarded();
|
|
|
|
|
|
|
|
virtual void create() = 0;
|
|
|
|
virtual void update();
|
|
|
|
|
|
|
|
virtual bool isValid() const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QSize m_size;
|
|
|
|
QRect m_contentsRect;
|
|
|
|
bool m_hasAlphaChannel = false;
|
|
|
|
|
|
|
|
private:
|
2021-10-20 14:58:58 +00:00
|
|
|
QScopedPointer<SurfaceTexture> m_texture;
|
2021-04-09 07:06:04 +00:00
|
|
|
bool m_isDiscarded = false;
|
|
|
|
};
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
} // namespace KWin
|