Skip to content

Commit 860ed07

Browse files
committed
drop, not release, prev buffer if 2nd buffer wl_surface.attach is sent
"A wl_buffer that has been attached and then replaced by another attach instead of committed will not receive a release event, and is not used by the compositor." - wl_surface::attach
1 parent b5fea0e commit 860ed07

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/protocols/core/Compositor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
7676

7777
pending.offset = {x, y};
7878

79+
if (pending.buffer)
80+
pending.buffer.drop();
81+
7982
auto buf = buffer ? CWLBufferResource::fromResource(buffer) : nullptr;
8083

8184
if (buf && buf->buffer) {

src/protocols/types/Buffer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,13 @@ SP<IHLBuffer> CHLBufferReference::operator->() const {
8888
CHLBufferReference::operator bool() const {
8989
return buffer;
9090
}
91+
92+
void CHLBufferReference::drop() {
93+
if (!buffer)
94+
return;
95+
96+
buffer->nLocks--;
97+
ASSERT(buffer->nLocks >= 0);
98+
99+
buffer = nullptr;
100+
}

src/protocols/types/Buffer.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <aquamarine/buffer/Buffer.hpp>
99

1010
class CSyncReleaser;
11+
class CHLBufferReference;
1112

1213
class IHLBuffer : public Aquamarine::IBuffer {
1314
public:
@@ -36,6 +37,8 @@ class IHLBuffer : public Aquamarine::IBuffer {
3637

3738
private:
3839
int nLocks = 0;
40+
41+
friend class CHLBufferReference;
3942
};
4043

4144
// for ref-counting. Releases in ~dtor
@@ -53,6 +56,9 @@ class CHLBufferReference {
5356
SP<IHLBuffer> operator->() const;
5457
operator bool() const;
5558

59+
// unlock and drop the buffer without sending release
60+
void drop();
61+
5662
CDRMSyncPointState release;
5763
SP<IHLBuffer> buffer;
5864
};

0 commit comments

Comments
 (0)