KWaylandServer

clientbuffer.h
1 /*
2  SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #pragma once
8 
9 #include <QImage>
10 #include <QObject>
11 #include <QSize>
12 
13 #include <KWaylandServer/kwaylandserver_export.h>
14 
15 struct wl_resource;
16 
17 namespace KWaylandServer
18 {
19 class ClientBufferPrivate;
20 
21 /**
22  * The ClientBuffer class represents a client buffer.
23  *
24  * While the ClientBuffer is referenced, it won't be destroyed. Note that the client can
25  * still destroy the wl_buffer object while the ClientBuffer is referenced by the compositor.
26  * You can use the isDestroyed() function to check whether the wl_buffer object has been
27  * destroyed.
28  */
29 class KWAYLANDSERVER_EXPORT ClientBuffer : public QObject
30 {
31  Q_OBJECT
32  Q_DECLARE_PRIVATE(ClientBuffer)
33 
34 public:
35  ~ClientBuffer() override;
36 
37  /**
38  * This enum type is used to specify the corner where the origin is. That's it, the
39  * buffer corner where 0,0 is located.
40  */
41  enum class Origin {
42  TopLeft,
43  BottomLeft,
44  };
45 
46  bool isReferenced() const;
47  bool isDestroyed() const;
48 
49  void ref();
50  void unref();
51 
52  /**
53  * Returns the wl_resource for this ClientBuffer. If the buffer is destroyed, @c null
54  * will be returned.
55  */
56  wl_resource *resource() const;
57 
58  /**
59  * Returns the size in the native pixels. The returned size is unaffected by buffer
60  * scale or other surface transforms, e.g. @c wp_viewport.
61  */
62  virtual QSize size() const = 0;
63  virtual bool hasAlphaChannel() const = 0;
64  virtual Origin origin() const = 0;
65 
66  void markAsDestroyed(); ///< @internal
67 
68 protected:
69  ClientBuffer(ClientBufferPrivate &dd);
70  ClientBuffer(wl_resource *resource, ClientBufferPrivate &dd);
71 
72  void initialize(wl_resource *resource);
74 };
75 
76 } // namespace KWaylandServer
Origin
This enum type is used to specify the corner where the origin is.
Definition: clientbuffer.h:41
The ClientBuffer class represents a client buffer.
Definition: clientbuffer.h:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.