internal: migrate to damage_ring

This commit is contained in:
vaxerski 2023-04-07 12:18:40 +01:00
parent 569eaff04c
commit 24ace03780
3 changed files with 27 additions and 12 deletions

View file

@ -8,6 +8,14 @@ int ratHandler(void* data) {
return 1; return 1;
} }
CMonitor::CMonitor() {
wlr_damage_ring_init(&damage);
}
CMonitor::~CMonitor() {
wlr_damage_ring_finish(&damage);
}
void CMonitor::onConnect(bool noRule) { void CMonitor::onConnect(bool noRule) {
hyprListener_monitorDestroy.removeCallback(); hyprListener_monitorDestroy.removeCallback();
hyprListener_monitorFrame.removeCallback(); hyprListener_monitorFrame.removeCallback();
@ -114,13 +122,13 @@ void CMonitor::onConnect(bool noRule) {
if (!noRule) if (!noRule)
g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true); g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true);
wlr_damage_ring_set_bounds(&damage, vecTransformedSize.x, vecTransformedSize.y);
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale); wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %x", output->name, (int)vecPosition.x, (int)vecPosition.y, (int)vecPixelSize.x, Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %x", output->name, (int)vecPosition.x, (int)vecPosition.y, (int)vecPixelSize.x,
(int)vecPixelSize.y, output); (int)vecPixelSize.y, output);
damage = wlr_output_damage_create(output);
// add a WLR workspace group // add a WLR workspace group
if (!pWLRWorkspaceGroupHandle) { if (!pWLRWorkspaceGroupHandle) {
pWLRWorkspaceGroupHandle = wlr_ext_workspace_group_handle_v1_create(g_pCompositor->m_sWLREXTWorkspaceMgr); pWLRWorkspaceGroupHandle = wlr_ext_workspace_group_handle_v1_create(g_pCompositor->m_sWLREXTWorkspaceMgr);
@ -253,8 +261,6 @@ void CMonitor::onDisconnect() {
activeWorkspace = -1; activeWorkspace = -1;
wlr_output_damage_destroy(damage);
wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output); wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
wlr_output_enable(output, false); wlr_output_enable(output, false);
@ -284,11 +290,11 @@ void CMonitor::onDisconnect() {
} }
void CMonitor::addDamage(pixman_region32_t* rg) { void CMonitor::addDamage(pixman_region32_t* rg) {
wlr_output_damage_add(damage, rg); wlr_damage_ring_add(&damage, rg);
} }
void CMonitor::addDamage(wlr_box* box) { void CMonitor::addDamage(wlr_box* box) {
wlr_output_damage_add_box(damage, box); wlr_damage_ring_add_box(&damage, box);
} }
bool CMonitor::isMirror() { bool CMonitor::isMirror() {

View file

@ -12,6 +12,9 @@ struct SMonitorRule;
class CMonitor { class CMonitor {
public: public:
CMonitor();
~CMonitor();
Vector2D vecPosition = Vector2D(-1, -1); // means unset Vector2D vecPosition = Vector2D(-1, -1); // means unset
Vector2D vecSize = Vector2D(0, 0); Vector2D vecSize = Vector2D(0, 0);
Vector2D vecPixelSize = Vector2D(0, 0); Vector2D vecPixelSize = Vector2D(0, 0);
@ -29,9 +32,9 @@ class CMonitor {
Vector2D vecReservedBottomRight = Vector2D(0, 0); Vector2D vecReservedBottomRight = Vector2D(0, 0);
// WLR stuff // WLR stuff
wlr_damage_ring damage;
wlr_output* output = nullptr; wlr_output* output = nullptr;
float refreshRate = 60; float refreshRate = 60;
wlr_output_damage* damage = nullptr;
int framesToSkip = 0; int framesToSkip = 0;
int forceFullFrames = 0; int forceFullFrames = 0;
bool noFrameSchedule = false; bool noFrameSchedule = false;

View file

@ -815,8 +815,8 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
// check the damage // check the damage
pixman_region32_t damage; pixman_region32_t damage;
bool hasChanged; bool hasChanged = pMonitor->output->needs_frame || !pixman_region32_not_empty(&pMonitor->damage.current);
pixman_region32_init(&damage); int bufferAge;
if (*PDAMAGETRACKINGMODE == -1) { if (*PDAMAGETRACKINGMODE == -1) {
Debug::log(CRIT, "Damage tracking mode -1 ????"); Debug::log(CRIT, "Damage tracking mode -1 ????");
@ -827,7 +827,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
if (UNLOCK_SC) if (UNLOCK_SC)
wlr_output_lock_software_cursors(pMonitor->output, true); wlr_output_lock_software_cursors(pMonitor->output, true);
if (!wlr_output_damage_attach_render(pMonitor->damage, &hasChanged, &damage)) { if (!wlr_output_attach_render(pMonitor->output, &bufferAge)) {
Debug::log(ERR, "Couldn't attach render to display %s ???", pMonitor->szName.c_str()); Debug::log(ERR, "Couldn't attach render to display %s ???", pMonitor->szName.c_str());
if (UNLOCK_SC) if (UNLOCK_SC)
@ -836,6 +836,9 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
return; return;
} }
pixman_region32_init(&damage);
wlr_damage_ring_get_buffer_damage(&pMonitor->damage, bufferAge, &damage);
pMonitor->renderingActive = true; pMonitor->renderingActive = true;
// we need to cleanup fading out when rendering the appropriate context // we need to cleanup fading out when rendering the appropriate context
@ -955,6 +958,8 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
pMonitor->renderingActive = false; pMonitor->renderingActive = false;
wlr_damage_ring_rotate(&pMonitor->damage);
if (!wlr_output_commit(pMonitor->output)) { if (!wlr_output_commit(pMonitor->output)) {
pixman_region32_fini(&damage); pixman_region32_fini(&damage);
@ -1249,7 +1254,6 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
} }
// damage the monitor if can // damage the monitor if can
if (PMONITOR->damage)
damageMonitor(PMONITOR); damageMonitor(PMONITOR);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitor); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitor);
@ -1723,6 +1727,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
if (!pMonitor->isMirror()) if (!pMonitor->isMirror())
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitor->vecPosition.x, (int)pMonitor->vecPosition.y); wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitor->vecPosition.x, (int)pMonitor->vecPosition.y);
wlr_damage_ring_set_bounds(&pMonitor->damage, pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y);
// updato us // updato us
arrangeLayersForMonitor(pMonitor->ID); arrangeLayersForMonitor(pMonitor->ID);