KWaylandServer

clientbuffer.cpp
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 #include "clientbuffer.h"
8 #include "clientbuffer_p.h"
9 
10 #include "qwayland-server-wayland.h"
11 
12 namespace KWaylandServer
13 {
14 ClientBuffer::ClientBuffer(ClientBufferPrivate &dd)
15  : d_ptr(&dd)
16 {
17 }
18 
19 ClientBuffer::ClientBuffer(wl_resource *resource, ClientBufferPrivate &dd)
20  : d_ptr(&dd)
21 {
22  initialize(resource);
23 }
24 
25 ClientBuffer::~ClientBuffer()
26 {
27 }
28 
29 void ClientBuffer::initialize(wl_resource *resource)
30 {
31  Q_D(ClientBuffer);
32  d->resource = resource;
33 }
34 
35 wl_resource *ClientBuffer::resource() const
36 {
37  Q_D(const ClientBuffer);
38  return d->resource;
39 }
40 
41 bool ClientBuffer::isReferenced() const
42 {
43  Q_D(const ClientBuffer);
44  return d->refCount > 0;
45 }
46 
47 bool ClientBuffer::isDestroyed() const
48 {
49  Q_D(const ClientBuffer);
50  return d->isDestroyed;
51 }
52 
53 void ClientBuffer::ref()
54 {
55  Q_D(ClientBuffer);
56  d->refCount++;
57 }
58 
59 void ClientBuffer::unref()
60 {
61  Q_D(ClientBuffer);
62  Q_ASSERT(d->refCount > 0);
63  --d->refCount;
64  if (!isReferenced()) {
65  if (isDestroyed()) {
66  delete this;
67  } else {
68  wl_buffer_send_release(d->resource);
69  }
70  }
71 }
72 
74 {
75  Q_D(ClientBuffer);
76  if (!isReferenced()) {
77  delete this;
78  } else {
79  d->resource = nullptr;
80  d->isDestroyed = true;
81  }
82 }
83 
84 } // namespace KWaylandServer
KCRASH_EXPORT void initialize()
The ClientBuffer class represents a client buffer.
Definition: clientbuffer.h:29
wl_resource * resource() const
Returns the wl_resource for this ClientBuffer.
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.