mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-08 20:05:59 +01:00
render: move lastFrameDamage to CMonitor
This commit is contained in:
parent
fe54dcb4eb
commit
515a363ecd
6 changed files with 12 additions and 11 deletions
|
@ -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) {
|
||||
|
|
|
@ -61,6 +61,8 @@ class CMonitor {
|
|||
CMonitor* pMirrorOf = nullptr;
|
||||
std::vector<CMonitor*> mirrors;
|
||||
|
||||
pixman_region32_t lastFrameDamage; // stores last frame damage
|
||||
|
||||
// for the special workspace. 0 means not open.
|
||||
int specialWorkspaceID = 0;
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
|
|||
|
||||
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!");
|
||||
|
||||
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
|
||||
|
|
|
@ -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<CWindow*, CFramebuffer> m_mWindowFramebuffers;
|
||||
std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;
|
||||
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue