File indexing completed on 2024-05-19 16:34:47

0001 /*
0002     SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "scene/surfaceitem.h"
0010 
0011 class QOpenGLFramebufferObject;
0012 
0013 namespace KWin
0014 {
0015 
0016 class Deleted;
0017 class InternalWindow;
0018 
0019 /**
0020  * The SurfaceItemInternal class represents an internal surface in the scene.
0021  */
0022 class KWIN_EXPORT SurfaceItemInternal : public SurfaceItem
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     explicit SurfaceItemInternal(InternalWindow *window, Scene *scene, Item *parent = nullptr);
0028 
0029     Window *window() const;
0030 
0031     QVector<QRectF> shape() const override;
0032 
0033 private Q_SLOTS:
0034     void handleBufferGeometryChanged(Window *window, const QRectF &old);
0035     void handleWindowClosed(Window *original, Deleted *deleted);
0036 
0037 protected:
0038     std::unique_ptr<SurfacePixmap> createPixmap() override;
0039 
0040 private:
0041     Window *m_window;
0042 };
0043 
0044 class KWIN_EXPORT SurfacePixmapInternal final : public SurfacePixmap
0045 {
0046     Q_OBJECT
0047 
0048 public:
0049     explicit SurfacePixmapInternal(SurfaceItemInternal *item, QObject *parent = nullptr);
0050 
0051     QOpenGLFramebufferObject *fbo() const;
0052     QImage image() const;
0053 
0054     void create() override;
0055     void update() override;
0056     bool isValid() const override;
0057 
0058 private:
0059     SurfaceItemInternal *m_item;
0060     std::shared_ptr<QOpenGLFramebufferObject> m_fbo;
0061     QImage m_rasterBuffer;
0062 };
0063 
0064 } // namespace KWin