summaryrefslogtreecommitdiff
path: root/src/protocols/core/Compositor.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-11-14 20:15:51 +0000
committerGitHub <noreply@github.com>2024-11-14 20:15:51 +0000
commit20031cea92417a852410827a5cdb4adbcaee4342 (patch)
tree665917c3c02f5de7311c27110ec4e76eb5becd6c /src/protocols/core/Compositor.cpp
parent3fb47372b79265ebdabeeefdad10359d5b18377a (diff)
pointer: add drm dumb buffers for cursors (#8399)
--------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
Diffstat (limited to 'src/protocols/core/Compositor.cpp')
-rw-r--r--src/protocols/core/Compositor.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp
index 57f61f87..89f2a4cb 100644
--- a/src/protocols/core/Compositor.cpp
+++ b/src/protocols/core/Compositor.cpp
@@ -438,12 +438,13 @@ void CWLSurfaceResource::commitPendingState() {
current.texture->m_eTransform = wlTransformToHyprutils(current.transform);
if (current.buffer && current.buffer->buffer) {
- current.buffer->buffer->update(accumulateCurrentBufferDamage());
+ const auto DAMAGE = accumulateCurrentBufferDamage();
+ current.buffer->buffer->update(DAMAGE);
// if the surface is a cursor, update the shm buffer
// TODO: don't update the entire texture
- if (role->role() == SURFACE_ROLE_CURSOR)
- updateCursorShm();
+ 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.
@@ -486,13 +487,12 @@ void CWLSurfaceResource::commitPendingState() {
lastBuffer = current.buffer ? current.buffer->buffer : WP<IHLBuffer>{};
}
-void CWLSurfaceResource::updateCursorShm() {
+void CWLSurfaceResource::updateCursorShm(CRegion damage) {
auto buf = current.buffer ? current.buffer->buffer : lastBuffer;
if (!buf)
return;
- // TODO: actually use damage
auto& shmData = CCursorSurfaceRole::cursorPixelData(self.lock());
auto shmAttrs = buf->shm();
@@ -501,11 +501,25 @@ void CWLSurfaceResource::updateCursorShm() {
return;
}
+ damage.intersect(CBox{0, 0, buf->size.x, buf->size.y});
+
// no need to end, shm.
auto [pixelData, fmt, bufLen] = buf->beginDataPtr(0);
shmData.resize(bufLen);
- memcpy(shmData.data(), pixelData, bufLen);
+
+ if (const auto RECTS = damage.getRects(); RECTS.size() == 1 && RECTS.at(0).x2 == buf->size.x && RECTS.at(0).y2 == buf->size.y)
+ memcpy(shmData.data(), pixelData, bufLen);
+ else {
+ for (auto& box : damage.getRects()) {
+ for (auto y = box.y1; y < box.y2; ++y) {
+ // bpp is 32 INSALLAH
+ auto begin = 4 * box.y1 * (box.x2 - box.x1) + box.x1;
+ auto len = 4 * (box.x2 - box.x1);
+ memcpy((uint8_t*)shmData.data() + begin, (uint8_t*)pixelData + begin, len);
+ }
+ }
+ }
}
void CWLSurfaceResource::presentFeedback(timespec* when, PHLMONITOR pMonitor) {