From e947af789491ace48fc59a4fffe19be4be234b1b Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 15 Aug 2024 22:34:45 +0200 Subject: [PATCH] drm/atomic: clip damage to pixel size ref https://github.com/hyprwm/Hyprland/issues/7356 --- src/backend/drm/impl/Atomic.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/drm/impl/Atomic.cpp b/src/backend/drm/impl/Atomic.cpp index 84efceb..7ca36e9 100644 --- a/src/backend/drm/impl/Atomic.cpp +++ b/src/backend/drm/impl/Atomic.cpp @@ -221,6 +221,7 @@ Aquamarine::CDRMAtomicImpl::CDRMAtomicImpl(Hyprutils::Memory::CSharedPointer connector, SDRMConnectorCommitData& data) { const auto& STATE = connector->output->state->state(); const bool enable = STATE.enabled; + const auto& MODE = STATE.mode ? STATE.mode : STATE.customMode; if (data.modeset) { if (!enable) @@ -262,11 +263,12 @@ bool Aquamarine::CDRMAtomicImpl::prepareConnector(Hyprutils::Memory::CSharedPoin } } - if (STATE.committed & COutputState::AQ_OUTPUT_STATE_DAMAGE && connector->crtc->primary->props.fb_damage_clips) { + if ((STATE.committed & COutputState::AQ_OUTPUT_STATE_DAMAGE) && connector->crtc->primary->props.fb_damage_clips && MODE) { if (STATE.damage.empty()) data.atomic.fbDamage = 0; else { - std::vector rects = STATE.damage.getRects(); + TRACE(connector->backend->backend->log(AQ_LOG_TRACE, std::format("atomic drm: clipping damage to pixel size {}", MODE->pixelSize))); + std::vector rects = STATE.damage.copy().intersect(CBox{{}, MODE->pixelSize}).getRects(); if (drmModeCreatePropertyBlob(connector->backend->gpu->fd, rects.data(), sizeof(pixman_box32_t) * rects.size(), &data.atomic.fbDamage)) { connector->backend->backend->log(AQ_LOG_ERROR, "atomic drm: failed to create a damage blob"); return false;