5933a21641
This is the first tiny step towards the layer-based compositing in kwin. The RenderLayer represents a layer with some contents. The actual contents is represented by the RenderLayerDelegate class. Currently, the RenderLayer is just a simple class responsible for geometry, and repaints, but it will grow in the future. For example, render layers need to form a tree. The next (missing) biggest component in the layer-based compositing are output layers. When output layers are added, each render layer would have an output layer assigned to it or have its output layer inherited from the parent. The render layer tree wouldn't be affected by changes to the output layer tree so transition between software and hardware cursors can be seamless. The next big milestone will be to try to port some of existing kwin functionality to the RenderLayer, e.g. software cursor or screen edges.
94 lines
2.5 KiB
C++
94 lines
2.5 KiB
C++
/*
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "kwin_export.h"
|
|
|
|
#include <QMap>
|
|
#include <QObject>
|
|
#include <QRegion>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
class OutputLayer;
|
|
class RenderLayerDelegate;
|
|
class RenderLoop;
|
|
|
|
/**
|
|
* The RenderLayer class represents a composited layer.
|
|
*
|
|
* The contents of the layer is represented by the RenderLayerDelegate. The render layer
|
|
* takes the ownership of the delegate.
|
|
*
|
|
* Each render layer has a hardware layer assigned to it, represented by OutputLayer. If
|
|
* the output layer is not set explicitly, it's inherited from the parent render layer.
|
|
* Output layers can be freely assigned or unassigned to render layers.
|
|
*/
|
|
class KWIN_EXPORT RenderLayer : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit RenderLayer(RenderLoop *loop, RenderLayer *superlayer = nullptr);
|
|
~RenderLayer() override;
|
|
|
|
OutputLayer *outputLayer() const;
|
|
void setOutputLayer(OutputLayer *layer);
|
|
|
|
RenderLoop *loop() const;
|
|
RenderLayerDelegate *delegate() const;
|
|
void setDelegate(RenderLayerDelegate *delegate);
|
|
|
|
QList<RenderLayer *> sublayers() const;
|
|
RenderLayer *superlayer() const;
|
|
void setSuperlayer(RenderLayer *layer);
|
|
|
|
bool isVisible() const;
|
|
void setVisible(bool visible);
|
|
|
|
QPoint mapToGlobal(const QPoint &point) const;
|
|
QRegion mapToGlobal(const QRegion ®ion) const;
|
|
QRect mapToGlobal(const QRect &rect) const;
|
|
|
|
QPoint mapFromGlobal(const QPoint &point) const;
|
|
QRegion mapFromGlobal(const QRegion ®ion) const;
|
|
QRect mapFromGlobal(const QRect &rect) const;
|
|
|
|
QRect rect() const;
|
|
QRect boundingRect() const;
|
|
|
|
QRect geometry() const;
|
|
void setGeometry(const QRect &rect);
|
|
|
|
void addRepaint(const QRegion ®ion);
|
|
void addRepaint(const QRect &rect);
|
|
void addRepaint(int x, int y, int width, int height);
|
|
void addRepaintFull();
|
|
QRegion repaints() const;
|
|
void resetRepaints();
|
|
|
|
private:
|
|
void addSublayer(RenderLayer *sublayer);
|
|
void removeSublayer(RenderLayer *sublayer);
|
|
void updateBoundingRect();
|
|
void updateEffectiveVisibility();
|
|
bool computeEffectiveVisibility() const;
|
|
|
|
RenderLoop *m_loop;
|
|
QScopedPointer<RenderLayerDelegate> m_delegate;
|
|
QRegion m_repaints;
|
|
QRect m_boundingRect;
|
|
QRect m_geometry;
|
|
OutputLayer *m_outputLayer = nullptr;
|
|
RenderLayer *m_superlayer = nullptr;
|
|
QList<RenderLayer *> m_sublayers;
|
|
bool m_effectiveVisible = true;
|
|
bool m_explicitVisible = true;
|
|
};
|
|
|
|
} // namespace KWin
|