diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 0691cd37..301370bd 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -10,10 +10,12 @@ int ratHandler(void* data) { CMonitor::CMonitor() { wlr_damage_ring_init(&damage); + pixman_region32_init(&lastFrameDamage); } CMonitor::~CMonitor() { wlr_damage_ring_finish(&damage); + pixman_region32_fini(&lastFrameDamage); } void CMonitor::onConnect(bool noRule) { diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 610fa656..08fe5f2b 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -61,6 +61,8 @@ class CMonitor { CMonitor* pMirrorOf = nullptr; std::vector mirrors; + pixman_region32_t lastFrameDamage; // stores last frame damage + // for the special workspace. 0 means not open. int specialWorkspaceID = 0; diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index d79a3473..07a591e7 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -407,10 +407,11 @@ void CScreencopyProtocolManager::sendFrameDamage(SScreencopyFrame* frame) { if (!frame->withDamage) return; - PIXMAN_DAMAGE_FOREACH(&g_pHyprOpenGL->m_rOriginalDamageRegion) { + PIXMAN_DAMAGE_FOREACH(&frame->pMonitor->lastFrameDamage) { const auto RECT = &RECTSARR[i]; zwlr_screencopy_frame_v1_send_damage(frame->resource, std::clamp(RECT->x1, 0, frame->buffer->width), std::clamp(RECT->y1, 0, frame->buffer->height), - std::clamp(RECT->x2 - RECT->x1, 0, frame->buffer->width - RECT->x1), std::clamp(RECT->y2 - RECT->y1, 0, frame->buffer->height - RECT->y1)); + std::clamp(RECT->x2 - RECT->x1, 0, frame->buffer->width - RECT->x1), + std::clamp(RECT->y2 - RECT->y1, 0, frame->buffer->height - RECT->y1)); } } diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 6091aacf..9810a6fb 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -28,8 +28,6 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() { g_pHookSystem->hookDynamic("preRender", [&](void* self, std::any data) { preRender(std::any_cast(data)); }); - pixman_region32_init(&m_rOriginalDamageRegion); - RASSERT(eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT), "Couldn't unset current EGL!"); m_tGlobalTimer.reset(); @@ -149,7 +147,7 @@ void CHyprOpenGLImpl::end() { // end the render, copy the data to the WLR framebuffer if (!m_bFakeFrame) { - pixman_region32_copy(m_RenderData.pDamage, &m_rOriginalDamageRegion); + pixman_region32_copy(m_RenderData.pDamage, &m_RenderData.pMonitor->lastFrameDamage); if (!m_RenderData.pMonitor->mirrors.empty()) g_pHyprOpenGL->saveBufferForMirror(); // save with original damage region diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 36aa612c..b696c8cb 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -141,8 +141,6 @@ class CHyprOpenGLImpl { CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window - pixman_region32_t m_rOriginalDamageRegion; // used for storing the pre-expanded region - std::unordered_map m_mWindowFramebuffers; std::unordered_map m_mLayerFramebuffers; std::unordered_map m_mMonitorRenderResources; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 500af191..da47142c 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -934,7 +934,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) { pMonitor->isMirror() /* why??? */) { pixman_region32_union_rect(&damage, &damage, 0, 0, (int)pMonitor->vecTransformedSize.x * 10, (int)pMonitor->vecTransformedSize.y * 10); // wot? - pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); + pixman_region32_copy(&pMonitor->lastFrameDamage, &damage); } else { static auto* const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; @@ -949,11 +949,11 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) { // now, prep the damage, get the extended damage region wlr_region_expand(&damage, &damage, BLURRADIUS); // expand for proper blurring - pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); + pixman_region32_copy(&pMonitor->lastFrameDamage, &damage); wlr_region_expand(&damage, &damage, BLURRADIUS); // expand for proper blurring 2 } else { - pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); + pixman_region32_copy(&pMonitor->lastFrameDamage, &damage); } } @@ -1035,7 +1035,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) { pixman_region32_init(&frameDamage); const auto TRANSFORM = wlr_output_transform_invert(pMonitor->output->transform); - wlr_region_transform(&frameDamage, &g_pHyprOpenGL->m_rOriginalDamageRegion, TRANSFORM, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y); + wlr_region_transform(&frameDamage, &pMonitor->lastFrameDamage, TRANSFORM, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y); if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR) pixman_region32_union_rect(&frameDamage, &frameDamage, 0, 0, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y);