mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 18:05:59 +01:00
internal: migrate to damage_ring
This commit is contained in:
parent
569eaff04c
commit
24ace03780
3 changed files with 27 additions and 12 deletions
|
@ -8,6 +8,14 @@ int ratHandler(void* data) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
CMonitor::CMonitor() {
|
||||
wlr_damage_ring_init(&damage);
|
||||
}
|
||||
|
||||
CMonitor::~CMonitor() {
|
||||
wlr_damage_ring_finish(&damage);
|
||||
}
|
||||
|
||||
void CMonitor::onConnect(bool noRule) {
|
||||
hyprListener_monitorDestroy.removeCallback();
|
||||
hyprListener_monitorFrame.removeCallback();
|
||||
|
@ -114,13 +122,13 @@ void CMonitor::onConnect(bool noRule) {
|
|||
if (!noRule)
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
damage = wlr_output_damage_create(output);
|
||||
|
||||
// add a WLR workspace group
|
||||
if (!pWLRWorkspaceGroupHandle) {
|
||||
pWLRWorkspaceGroupHandle = wlr_ext_workspace_group_handle_v1_create(g_pCompositor->m_sWLREXTWorkspaceMgr);
|
||||
|
@ -253,8 +261,6 @@ void CMonitor::onDisconnect() {
|
|||
|
||||
activeWorkspace = -1;
|
||||
|
||||
wlr_output_damage_destroy(damage);
|
||||
|
||||
wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
|
||||
|
||||
wlr_output_enable(output, false);
|
||||
|
@ -284,11 +290,11 @@ void CMonitor::onDisconnect() {
|
|||
}
|
||||
|
||||
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) {
|
||||
wlr_output_damage_add_box(damage, box);
|
||||
wlr_damage_ring_add_box(&damage, box);
|
||||
}
|
||||
|
||||
bool CMonitor::isMirror() {
|
||||
|
|
|
@ -12,6 +12,9 @@ struct SMonitorRule;
|
|||
|
||||
class CMonitor {
|
||||
public:
|
||||
CMonitor();
|
||||
~CMonitor();
|
||||
|
||||
Vector2D vecPosition = Vector2D(-1, -1); // means unset
|
||||
Vector2D vecSize = Vector2D(0, 0);
|
||||
Vector2D vecPixelSize = Vector2D(0, 0);
|
||||
|
@ -29,9 +32,9 @@ class CMonitor {
|
|||
Vector2D vecReservedBottomRight = Vector2D(0, 0);
|
||||
|
||||
// WLR stuff
|
||||
wlr_damage_ring damage;
|
||||
wlr_output* output = nullptr;
|
||||
float refreshRate = 60;
|
||||
wlr_output_damage* damage = nullptr;
|
||||
int framesToSkip = 0;
|
||||
int forceFullFrames = 0;
|
||||
bool noFrameSchedule = false;
|
||||
|
|
|
@ -815,8 +815,8 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
|
||||
// check the damage
|
||||
pixman_region32_t damage;
|
||||
bool hasChanged;
|
||||
pixman_region32_init(&damage);
|
||||
bool hasChanged = pMonitor->output->needs_frame || !pixman_region32_not_empty(&pMonitor->damage.current);
|
||||
int bufferAge;
|
||||
|
||||
if (*PDAMAGETRACKINGMODE == -1) {
|
||||
Debug::log(CRIT, "Damage tracking mode -1 ????");
|
||||
|
@ -827,7 +827,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
if (UNLOCK_SC)
|
||||
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());
|
||||
|
||||
if (UNLOCK_SC)
|
||||
|
@ -836,6 +836,9 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
return;
|
||||
}
|
||||
|
||||
pixman_region32_init(&damage);
|
||||
wlr_damage_ring_get_buffer_damage(&pMonitor->damage, bufferAge, &damage);
|
||||
|
||||
pMonitor->renderingActive = true;
|
||||
|
||||
// we need to cleanup fading out when rendering the appropriate context
|
||||
|
@ -955,6 +958,8 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||
|
||||
pMonitor->renderingActive = false;
|
||||
|
||||
wlr_damage_ring_rotate(&pMonitor->damage);
|
||||
|
||||
if (!wlr_output_commit(pMonitor->output)) {
|
||||
pixman_region32_fini(&damage);
|
||||
|
||||
|
@ -1249,8 +1254,7 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
|
|||
}
|
||||
|
||||
// damage the monitor if can
|
||||
if (PMONITOR->damage)
|
||||
damageMonitor(PMONITOR);
|
||||
damageMonitor(PMONITOR);
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitor);
|
||||
|
||||
|
@ -1723,6 +1727,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
if (!pMonitor->isMirror())
|
||||
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
|
||||
arrangeLayersForMonitor(pMonitor->ID);
|
||||
|
||||
|
|
Loading…
Reference in a new issue