From a9e34cba9302d498ae2251ad2399d13f36f753bc Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 23 Aug 2022 16:07:47 +0200 Subject: [PATCH] move monitor damage to separate funcs --- src/helpers/Monitor.cpp | 8 ++++++++ src/helpers/Monitor.hpp | 2 ++ src/render/Renderer.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 80dc1d50c..7359e6b73 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -232,3 +232,11 @@ void CMonitor::onDisconnect() { g_pCompositor->m_vMonitors.erase(std::remove_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](std::shared_ptr& el) { return el.get() == this; })); } + +void CMonitor::addDamage(pixman_region32_t* rg) { + wlr_output_damage_add(damage, rg); +} + +void CMonitor::addDamage(wlr_box* box) { + wlr_output_damage_add_box(damage, box); +} diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 5b8b02d41..c3f521083 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -55,6 +55,8 @@ public: // methods void onConnect(bool noRule); void onDisconnect(); + void addDamage(pixman_region32_t* rg); + void addDamage(wlr_box* box); std::shared_ptr* m_pThisWrap = nullptr; bool m_bEnabled = false; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index a618a580f..b7032f9fc 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -712,7 +712,7 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) { wlr_region_scale(&damageBoxForEach, &damageBoxForEach, m->scale); pixman_region32_translate(&damageBoxForEach, lx + m->vecPosition.x, ly + m->vecPosition.y); - wlr_output_damage_add(m->damage, &damageBoxForEach); + m->addDamage(&damageBoxForEach); } pixman_region32_fini(&damageBoxForEach); @@ -733,7 +733,7 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) { for (auto& m : g_pCompositor->m_vMonitors) { wlr_box fixedDamageBox = {damageBox.x - m->vecPosition.x, damageBox.y - m->vecPosition.y, damageBox.width, damageBox.height}; scaleBox(&fixedDamageBox, m->scale); - wlr_output_damage_add_box(m->damage, &fixedDamageBox); + m->addDamage(&fixedDamageBox); } static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; @@ -747,7 +747,7 @@ void CHyprRenderer::damageMonitor(CMonitor* pMonitor) { return; wlr_box damageBox = {0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y}; - wlr_output_damage_add_box(pMonitor->damage, &damageBox); + pMonitor->addDamage(&damageBox); static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; @@ -762,7 +762,7 @@ void CHyprRenderer::damageBox(wlr_box* pBox) { for (auto& m : g_pCompositor->m_vMonitors) { wlr_box damageBox = {pBox->x - m->vecPosition.x, pBox->y - m->vecPosition.y, pBox->width, pBox->height}; scaleBox(&damageBox, m->scale); - wlr_output_damage_add_box(m->damage, &damageBox); + m->addDamage(&damageBox); } static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;