File indexing completed on 2024-11-10 04:57:06
0001 /* 0002 SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "screencastsource.h" 0010 0011 #include "opengl/gltexture.h" 0012 #include "opengl/glutils.h" 0013 #include <QImage> 0014 0015 namespace KWin 0016 { 0017 class Output; 0018 0019 class RegionScreenCastSource : public ScreenCastSource 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 explicit RegionScreenCastSource(const QRect ®ion, qreal scale, QObject *parent = nullptr); 0025 0026 quint32 drmFormat() const override; 0027 bool hasAlphaChannel() const override; 0028 QSize textureSize() const override; 0029 uint refreshRate() const override; 0030 0031 void render(GLFramebuffer *target) override; 0032 void render(spa_data *spa, spa_video_format format) override; 0033 std::chrono::nanoseconds clock() const override; 0034 0035 QRect region() const 0036 { 0037 return m_region; 0038 } 0039 qreal scale() const 0040 { 0041 return m_scale; 0042 } 0043 void updateOutput(Output *output); 0044 0045 private: 0046 void ensureTexture(); 0047 0048 const QRect m_region; 0049 const qreal m_scale; 0050 std::unique_ptr<GLFramebuffer> m_target; 0051 std::unique_ptr<GLTexture> m_renderedTexture; 0052 std::chrono::nanoseconds m_last; 0053 }; 0054 0055 } // namespace KWin