render: move lastFrameDamage to CMonitor

This commit is contained in:
vaxerski 2023-07-10 13:21:00 +02:00
parent fe54dcb4eb
commit 515a363ecd
6 changed files with 12 additions and 11 deletions

View file

@ -10,10 +10,12 @@ int ratHandler(void* data) {
CMonitor::CMonitor() { CMonitor::CMonitor() {
wlr_damage_ring_init(&damage); wlr_damage_ring_init(&damage);
pixman_region32_init(&lastFrameDamage);
} }
CMonitor::~CMonitor() { CMonitor::~CMonitor() {
wlr_damage_ring_finish(&damage); wlr_damage_ring_finish(&damage);
pixman_region32_fini(&lastFrameDamage);
} }
void CMonitor::onConnect(bool noRule) { void CMonitor::onConnect(bool noRule) {

View file

@ -61,6 +61,8 @@ class CMonitor {
CMonitor* pMirrorOf = nullptr; CMonitor* pMirrorOf = nullptr;
std::vector<CMonitor*> mirrors; std::vector<CMonitor*> mirrors;
pixman_region32_t lastFrameDamage; // stores last frame damage
// for the special workspace. 0 means not open. // for the special workspace. 0 means not open.
int specialWorkspaceID = 0; int specialWorkspaceID = 0;

View file

@ -407,10 +407,11 @@ void CScreencopyProtocolManager::sendFrameDamage(SScreencopyFrame* frame) {
if (!frame->withDamage) if (!frame->withDamage)
return; return;
PIXMAN_DAMAGE_FOREACH(&g_pHyprOpenGL->m_rOriginalDamageRegion) { PIXMAN_DAMAGE_FOREACH(&frame->pMonitor->lastFrameDamage) {
const auto RECT = &RECTSARR[i]; 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), 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));
} }
} }

View file

@ -28,8 +28,6 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
g_pHookSystem->hookDynamic("preRender", [&](void* self, std::any data) { preRender(std::any_cast<CMonitor*>(data)); }); g_pHookSystem->hookDynamic("preRender", [&](void* self, std::any data) { preRender(std::any_cast<CMonitor*>(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!"); 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(); m_tGlobalTimer.reset();
@ -149,7 +147,7 @@ void CHyprOpenGLImpl::end() {
// end the render, copy the data to the WLR framebuffer // end the render, copy the data to the WLR framebuffer
if (!m_bFakeFrame) { 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()) if (!m_RenderData.pMonitor->mirrors.empty())
g_pHyprOpenGL->saveBufferForMirror(); // save with original damage region g_pHyprOpenGL->saveBufferForMirror(); // save with original damage region

View file

@ -141,8 +141,6 @@ class CHyprOpenGLImpl {
CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window 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<CWindow*, CFramebuffer> m_mWindowFramebuffers; std::unordered_map<CWindow*, CFramebuffer> m_mWindowFramebuffers;
std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers; std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources; std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;

View file

@ -934,7 +934,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
pMonitor->isMirror() /* why??? */) { pMonitor->isMirror() /* why??? */) {
pixman_region32_union_rect(&damage, &damage, 0, 0, (int)pMonitor->vecTransformedSize.x * 10, (int)pMonitor->vecTransformedSize.y * 10); // wot? 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 { } else {
static auto* const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; 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 // now, prep the damage, get the extended damage region
wlr_region_expand(&damage, &damage, BLURRADIUS); // expand for proper blurring 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 wlr_region_expand(&damage, &damage, BLURRADIUS); // expand for proper blurring 2
} else { } 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); pixman_region32_init(&frameDamage);
const auto TRANSFORM = wlr_output_transform_invert(pMonitor->output->transform); 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) 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); pixman_region32_union_rect(&frameDamage, &frameDamage, 0, 0, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y);