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
|
|
|
|
|
2022-05-25 09:38:59 +00:00
|
|
|
#include "core/output.h"
|
2022-12-15 20:35:22 +00:00
|
|
|
#include "scene/item.h"
|
2021-02-04 09:07:20 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2021-04-09 07:06:04 +00:00
|
|
|
class SurfacePixmap;
|
2022-04-22 17:39:12 +00:00
|
|
|
class Window;
|
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
|
|
|
|
|
|
|
void addDamage(const QRegion ®ion);
|
|
|
|
void resetDamage();
|
|
|
|
QRegion damage() const;
|
|
|
|
|
2021-05-19 06:22:05 +00:00
|
|
|
void discardPixmap();
|
|
|
|
void updatePixmap();
|
2022-12-29 23:20:37 +00:00
|
|
|
void destroyPixmap();
|
2021-05-19 06:22:05 +00:00
|
|
|
|
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();
|
|
|
|
|
2022-05-25 09:38:59 +00:00
|
|
|
virtual ContentType contentType() const;
|
|
|
|
|
2022-12-14 14:52:10 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void damaged();
|
|
|
|
|
2021-02-04 09:07:20 +00:00
|
|
|
protected:
|
2022-12-18 22:20:28 +00:00
|
|
|
explicit SurfaceItem(Scene *scene, Item *parent = nullptr);
|
2021-02-04 09:07:20 +00:00
|
|
|
|
2022-06-29 11:24:56 +00:00
|
|
|
virtual std::unique_ptr<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
|
|
|
|
|
|
|
QRegion m_damage;
|
2022-06-29 11:24:56 +00:00
|
|
|
std::unique_ptr<SurfacePixmap> m_pixmap;
|
|
|
|
std::unique_ptr<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:
|
2022-06-29 11:21:35 +00:00
|
|
|
explicit SurfacePixmap(std::unique_ptr<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;
|
|
|
|
|
|
|
|
bool isDiscarded() const;
|
|
|
|
void markAsDiscarded();
|
|
|
|
|
|
|
|
virtual void create() = 0;
|
|
|
|
virtual void update();
|
|
|
|
|
|
|
|
virtual bool isValid() const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QSize m_size;
|
|
|
|
bool m_hasAlphaChannel = false;
|
|
|
|
|
|
|
|
private:
|
2022-06-29 11:21:35 +00:00
|
|
|
std::unique_ptr<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
|