summaryrefslogtreecommitdiff
path: root/src/protocols/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocols/core')
-rw-r--r--src/protocols/core/Compositor.cpp52
-rw-r--r--src/protocols/core/Compositor.hpp48
-rw-r--r--src/protocols/core/Shm.cpp5
-rw-r--r--src/protocols/core/Shm.hpp2
4 files changed, 30 insertions, 77 deletions
diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp
index f7af9504..a9fe33db 100644
--- a/src/protocols/core/Compositor.cpp
+++ b/src/protocols/core/Compositor.cpp
@@ -113,8 +113,8 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : resource(reso
return;
}
- if (stateLocks <= 0)
- commitPendingState();
+ if (!syncobj)
+ 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}); });
@@ -428,29 +428,14 @@ CRegion CWLSurfaceResource::accumulateCurrentBufferDamage() {
return surfaceDamage.scale(current.scale).transform(wlTransformToHyprutils(invertTransform(current.transform)), trc.x, trc.y).add(current.bufferDamage);
}
-void CWLSurfaceResource::lockPendingState() {
- stateLocks++;
-}
-
-void CWLSurfaceResource::unlockPendingState() {
- stateLocks--;
- if (stateLocks <= 0)
- commitPendingState();
-}
-
-void CWLSurfaceResource::commitPendingState() {
- static auto PDROP = CConfigValue<Hyprlang::INT>("render:allow_early_buffer_release");
- current = pending;
- pending.damage.clear();
- pending.bufferDamage.clear();
- pending.newBuffer = false;
- if (!*PDROP)
- dropPendingBuffer(); // at this point current.buffer holds the same SP and we don't use pending anymore
-
- events.roleCommit.emit();
-
- if (syncobj && syncobj->current.releaseTimeline && syncobj->current.releaseTimeline->timeline && current.buffer && current.buffer->buffer)
- current.buffer->releaser = makeShared<CSyncReleaser>(syncobj->current.releaseTimeline->timeline, syncobj->current.releasePoint);
+void CWLSurfaceResource::commitPendingState(SSurfaceState& state) {
+ if (state.newBuffer) {
+ state.newBuffer = false;
+ current = state;
+ state.damage.clear();
+ state.bufferDamage.clear();
+ state.buffer.reset();
+ }
if (current.texture)
current.texture->m_eTransform = wlTransformToHyprutils(current.transform);
@@ -463,14 +448,6 @@ void CWLSurfaceResource::commitPendingState() {
// TODO: don't update the entire texture
if (role->role() == SURFACE_ROLE_CURSOR && !DAMAGE.empty())
updateCursorShm(DAMAGE);
-
- // release the buffer if it's synchronous as update() has done everything thats needed
- // so we can let the app know we're done.
- // Some clients aren't ready to receive a release this early. Should be fine to release it on the next commitPendingState.
- if (current.buffer->buffer->isSynchronous() && *PDROP) {
- dropCurrentBuffer();
- dropPendingBuffer(); // at this point current.buffer holds the same SP and we don't use pending anymore
- }
}
// TODO: we should _accumulate_ and not replace above if sync
@@ -494,11 +471,16 @@ void CWLSurfaceResource::commitPendingState() {
nullptr);
}
- lastBuffer = current.buffer ? current.buffer->buffer : WP<IHLBuffer>{};
+ // release the buffer if it's synchronous as update() has done everything thats needed
+ // so we can let the app know we're done.
+ // if (!syncobj && current.buffer && current.buffer->buffer && current.buffer->buffer->isSynchronous()) {
+ // dropCurrentBuffer(); // lets not drop it at all, it will get dropped on next commit if a new buffer arrives.
+ // solves flickering on nonsyncobj apps on explicit sync.
+ // }
}
void CWLSurfaceResource::updateCursorShm(CRegion damage) {
- auto buf = current.buffer ? current.buffer->buffer : lastBuffer;
+ auto buf = current.buffer ? current.buffer->buffer : WP<IHLBuffer>{};
if UNLIKELY (!buf)
return;
diff --git a/src/protocols/core/Compositor.hpp b/src/protocols/core/Compositor.hpp
index 39690017..f958528c 100644
--- a/src/protocols/core/Compositor.hpp
+++ b/src/protocols/core/Compositor.hpp
@@ -16,6 +16,7 @@
#include "../../helpers/math/Math.hpp"
#include "../types/Buffer.hpp"
#include "../types/SurfaceRole.hpp"
+#include "../types/SurfaceState.hpp"
class CWLOutputResource;
class CMonitor;
@@ -77,42 +78,15 @@ class CWLSurfaceResource {
Vector2D sourceSize();
struct {
- CSignal precommit; // before commit
- CSignal roleCommit; // commit for role objects, before regular commit
- CSignal commit; // after commit
+ CSignal precommit; // before commit
+ CSignal commit; // after commit
CSignal map;
CSignal unmap;
CSignal newSubsurface;
CSignal destroy;
} events;
- struct SState {
- CRegion opaque, input = CBox{{}, {INT32_MAX, INT32_MAX}}, damage, bufferDamage = CBox{{}, {INT32_MAX, INT32_MAX}} /* initial damage */;
- wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
- int scale = 1;
- SP<CHLBufferReference> buffer; // buffer ref will be released once the buffer is no longer locked. For checking if a buffer is attached to this state, check texture.
- SP<CTexture> texture;
- Vector2D offset;
- Vector2D size, bufferSize;
- struct {
- bool hasDestination = false;
- bool hasSource = false;
- Vector2D destination;
- CBox source;
- } viewport;
- bool rejected = false;
- bool newBuffer = false;
-
- //
- void reset() {
- damage.clear();
- bufferDamage.clear();
- transform = WL_OUTPUT_TRANSFORM_NORMAL;
- scale = 1;
- offset = {};
- size = {};
- }
- } current, pending;
+ SSurfaceState current, pending;
std::vector<SP<CWLCallbackResource>> callbacks;
WP<CWLSurfaceResource> self;
@@ -130,28 +104,20 @@ class CWLSurfaceResource {
SP<CWLSurfaceResource> findFirstPreorder(std::function<bool(SP<CWLSurfaceResource>)> fn);
CRegion accumulateCurrentBufferDamage();
void presentFeedback(timespec* when, PHLMONITOR pMonitor, bool discarded = false);
- void lockPendingState();
- void unlockPendingState();
+ void commitPendingState(SSurfaceState& state);
// returns a pair: found surface (null if not found) and surface local coords.
// localCoords param is relative to 0,0 of this surface
std::pair<SP<CWLSurfaceResource>, Vector2D> at(const Vector2D& localCoords, bool allowsInput = false);
private:
- SP<CWlSurface> resource;
- wl_client* pClient = nullptr;
-
- // this is for cursor dumb copy. Due to our (and wayland's...) architecture,
- // this stupid-ass hack is used
- WP<IHLBuffer> lastBuffer;
-
- int stateLocks = 0;
+ SP<CWlSurface> resource;
+ wl_client* pClient = nullptr;
void destroy();
void releaseBuffers(bool onlyCurrent = true);
void dropPendingBuffer();
void dropCurrentBuffer();
- void commitPendingState();
void bfHelper(std::vector<SP<CWLSurfaceResource>> const& nodes, std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data);
SP<CWLSurfaceResource> findFirstPreorderHelper(SP<CWLSurfaceResource> root, std::function<bool(SP<CWLSurfaceResource>)> fn);
void updateCursorShm(CRegion damage = CBox{0, 0, INT16_MAX, INT16_MAX});
diff --git a/src/protocols/core/Shm.cpp b/src/protocols/core/Shm.cpp
index e0e62560..37a48fd3 100644
--- a/src/protocols/core/Shm.cpp
+++ b/src/protocols/core/Shm.cpp
@@ -37,6 +37,11 @@ CWLSHMBuffer::CWLSHMBuffer(SP<CWLSHMPoolResource> pool_, uint32_t id, int32_t of
Debug::log(ERR, "Failed creating a shm texture: null texture id");
}
+CWLSHMBuffer::~CWLSHMBuffer() {
+ if (resource)
+ resource->sendRelease();
+}
+
Aquamarine::eBufferCapability CWLSHMBuffer::caps() {
return Aquamarine::eBufferCapability::BUFFER_CAPABILITY_DATAPTR;
}
diff --git a/src/protocols/core/Shm.hpp b/src/protocols/core/Shm.hpp
index fef821cb..fa5f29a4 100644
--- a/src/protocols/core/Shm.hpp
+++ b/src/protocols/core/Shm.hpp
@@ -33,7 +33,7 @@ class CSHMPool {
class CWLSHMBuffer : public IHLBuffer {
public:
CWLSHMBuffer(SP<CWLSHMPoolResource> pool, uint32_t id, int32_t offset, const Vector2D& size, int32_t stride, uint32_t fmt);
- virtual ~CWLSHMBuffer() = default;
+ virtual ~CWLSHMBuffer();
virtual Aquamarine::eBufferCapability caps();
virtual Aquamarine::eBufferType type();