From 0cd04bd666665bfdeafc0f55a93e532cd8978827 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Wed, 26 Mar 2025 15:11:19 +0000 Subject: surfacestate: track and apply updated state fixes #9729 --- src/protocols/core/Compositor.cpp | 42 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'src/protocols/core/Compositor.cpp') diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index 2dd374a8..974207a4 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -71,8 +71,8 @@ CWLSurfaceResource::CWLSurfaceResource(SP resource_) : resource(reso resource->setOnDestroy([this](CWlSurface* r) { destroy(); }); resource->setAttach([this](CWlSurface* r, wl_resource* buffer, int32_t x, int32_t y) { - pending.offset = {x, y}; - pending.newBuffer = true; + pending.offset = {x, y}; + pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_BUFFER | SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_OFFSET; if (!buffer) { pending.buffer.reset(); @@ -119,11 +119,23 @@ CWLSurfaceResource::CWLSurfaceResource(SP resource_) : resource(reso commitPendingState(pending); }); - resource->setDamage([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { pending.damage.add(CBox{x, y, w, h}); }); - resource->setDamageBuffer([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { pending.bufferDamage.add(CBox{x, y, w, h}); }); + resource->setDamage([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { + pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_DAMAGE; + pending.damage.add(CBox{x, y, w, h}); + }); + resource->setDamageBuffer([this](CWlSurface* r, int32_t x, int32_t y, int32_t w, int32_t h) { + pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_DAMAGE; + pending.bufferDamage.add(CBox{x, y, w, h}); + }); - resource->setSetBufferScale([this](CWlSurface* r, int32_t scale) { pending.scale = scale; }); - resource->setSetBufferTransform([this](CWlSurface* r, uint32_t tr) { pending.transform = (wl_output_transform)tr; }); + resource->setSetBufferScale([this](CWlSurface* r, int32_t scale) { + pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_SCALE; + pending.scale = scale; + }); + resource->setSetBufferTransform([this](CWlSurface* r, uint32_t tr) { + pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_TRANSFORM; + pending.transform = (wl_output_transform)tr; + }); resource->setSetInputRegion([this](CWlSurface* r, wl_resource* region) { if (!region) { @@ -131,6 +143,8 @@ CWLSurfaceResource::CWLSurfaceResource(SP resource_) : resource(reso return; } + pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_INPUT; + auto RG = CWLRegionResource::fromResource(region); pending.input = RG->region; }); @@ -141,13 +155,18 @@ CWLSurfaceResource::CWLSurfaceResource(SP resource_) : resource(reso return; } + pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_OPAQUE; + auto RG = CWLRegionResource::fromResource(region); pending.opaque = RG->region; }); resource->setFrame([this](CWlSurface* r, uint32_t id) { callbacks.emplace_back(makeShared(makeShared(pClient, 1, id))); }); - resource->setOffset([this](CWlSurface* r, int32_t x, int32_t y) { pending.offset = {x, y}; }); + resource->setOffset([this](CWlSurface* r, int32_t x, int32_t y) { + pending.updated |= SSurfaceState::eUpdatedProperties::SURFACE_UPDATED_OFFSET; + pending.offset = {x, y}; + }); } CWLSurfaceResource::~CWLSurfaceResource() { @@ -403,13 +422,8 @@ CBox CWLSurfaceResource::extends() { void CWLSurfaceResource::commitPendingState(SSurfaceState& state) { auto lastTexture = current.texture; - if (state.newBuffer) { - state.newBuffer = false; - current = state; - state.damage.clear(); - state.bufferDamage.clear(); - state.buffer.reset(); - } + current.updateFrom(state); + state.updated = 0; if (current.buffer) { if (current.buffer->buffer->isSynchronous()) -- cgit v1.2.3