File indexing completed on 2024-11-10 04:57:08
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #pragma once 0010 0011 #include "core/output.h" 0012 #include "effect/effect.h" 0013 #include "effect/timeline.h" 0014 0015 namespace KWin 0016 { 0017 class GLFramebuffer; 0018 class GLShader; 0019 class GLTexture; 0020 0021 class ScreenTransformEffect : public Effect 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 ScreenTransformEffect(); 0027 ~ScreenTransformEffect() override; 0028 0029 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; 0030 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::Output *screen) override; 0031 0032 bool isActive() const override; 0033 0034 int requestedEffectChainPosition() const override 0035 { 0036 return 99; 0037 } 0038 static bool supported(); 0039 0040 private: 0041 struct Snapshot 0042 { 0043 std::shared_ptr<GLTexture> texture; 0044 std::shared_ptr<GLFramebuffer> framebuffer; 0045 }; 0046 0047 struct ScreenState 0048 { 0049 TimeLine m_timeLine; 0050 Snapshot m_prev; 0051 Snapshot m_current; 0052 QRect m_oldGeometry; 0053 OutputTransform m_oldTransform; 0054 qreal m_angle = 0; 0055 }; 0056 0057 void addScreen(Output *screen); 0058 void removeScreen(Output *screen); 0059 0060 QHash<Output *, ScreenState> m_states; 0061 0062 std::unique_ptr<GLShader> m_shader; 0063 int m_previousTextureLocation = -1; 0064 int m_currentTextureLocation = -1; 0065 int m_modelViewProjectioMatrixLocation = -1; 0066 int m_blendFactorLocation = -1; 0067 bool m_capturing = false; 0068 }; 0069 0070 } // namespace KWin