File indexing completed on 2025-03-23 11:14:32
0001 /* 0002 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "kwin_export.h" 0010 0011 #include <QImage> 0012 #include <QObject> 0013 #include <QSize> 0014 #include <memory> 0015 0016 struct wl_resource; 0017 0018 namespace KWaylandServer 0019 { 0020 class ClientBufferPrivate; 0021 0022 /** 0023 * The ClientBuffer class represents a client buffer. 0024 * 0025 * While the ClientBuffer is referenced, it won't be destroyed. Note that the client can 0026 * still destroy the wl_buffer object while the ClientBuffer is referenced by the compositor. 0027 * You can use the isDestroyed() function to check whether the wl_buffer object has been 0028 * destroyed. 0029 */ 0030 class KWIN_EXPORT ClientBuffer : public QObject 0031 { 0032 Q_OBJECT 0033 Q_DECLARE_PRIVATE(ClientBuffer) 0034 0035 public: 0036 ~ClientBuffer() override; 0037 0038 /** 0039 * This enum type is used to specify the corner where the origin is. That's it, the 0040 * buffer corner where 0,0 is located. 0041 */ 0042 enum class Origin { 0043 TopLeft, 0044 BottomLeft, 0045 }; 0046 0047 bool isReferenced() const; 0048 bool isDestroyed() const; 0049 0050 void ref(); 0051 void unref(); 0052 0053 /** 0054 * Returns the wl_resource for this ClientBuffer. If the buffer is destroyed, @c null 0055 * will be returned. 0056 */ 0057 wl_resource *resource() const; 0058 0059 /** 0060 * Returns the size in the native pixels. The returned size is unaffected by buffer 0061 * scale or other surface transforms, e.g. @c wp_viewport. 0062 */ 0063 virtual QSize size() const = 0; 0064 virtual bool hasAlphaChannel() const = 0; 0065 virtual Origin origin() const = 0; 0066 0067 void markAsDestroyed(); ///< @internal 0068 0069 protected: 0070 ClientBuffer(ClientBufferPrivate &dd); 0071 ClientBuffer(wl_resource *resource, ClientBufferPrivate &dd); 0072 0073 void initialize(wl_resource *resource); 0074 std::unique_ptr<ClientBufferPrivate> d_ptr; 0075 }; 0076 0077 } // namespace KWaylandServer