diff options
| author | vaxerski <vaxry@vaxry.net> | 2024-02-19 11:24:54 +0000 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2024-02-19 11:24:54 +0000 |
| commit | e4790e3f8e8f3693d924c3d8fc9012e3ab7bbf8f (patch) | |
| tree | 45d88aee67b0529d3d7c11e875bbb6f7653bb06d /src/helpers | |
| parent | 69a4f08dbee6dc08d1e2ce498ce80ab20844e4f3 (diff) | |
surface: fix invalid damage tracking in damageSurface
ref #4744
Diffstat (limited to 'src/helpers')
| -rw-r--r-- | src/helpers/Region.cpp | 5 | ||||
| -rw-r--r-- | src/helpers/Region.hpp | 3 | ||||
| -rw-r--r-- | src/helpers/WLSurface.cpp | 14 | ||||
| -rw-r--r-- | src/helpers/WLSurface.hpp | 2 |
4 files changed, 23 insertions, 1 deletions
diff --git a/src/helpers/Region.cpp b/src/helpers/Region.cpp index 8f180416..502bc198 100644 --- a/src/helpers/Region.cpp +++ b/src/helpers/Region.cpp @@ -112,6 +112,11 @@ CRegion& CRegion::scale(float scale) { return *this; } +CRegion& CRegion::scale(const Vector2D& scale) { + wlr_region_scale_xy(&m_rRegion, &m_rRegion, scale.x, scale.y); + return *this; +} + std::vector<pixman_box32_t> CRegion::getRects() const { std::vector<pixman_box32_t> result; diff --git a/src/helpers/Region.hpp b/src/helpers/Region.hpp index 972a2ba7..0c3e21ad 100644 --- a/src/helpers/Region.hpp +++ b/src/helpers/Region.hpp @@ -49,6 +49,7 @@ class CRegion { CRegion& invert(pixman_box32_t* box); CRegion& invert(const CBox& box); CRegion& scale(float scale); + CRegion& scale(const Vector2D& scale); CBox getExtents(); bool containsPoint(const Vector2D& vec) const; bool empty() const; @@ -58,7 +59,7 @@ class CRegion { std::vector<pixman_box32_t> getRects() const; pixman_region32_t* pixman() { - return &m_rRegion; + return &m_rRegion; } private: diff --git a/src/helpers/WLSurface.cpp b/src/helpers/WLSurface.cpp index 3528a72d..99771d0d 100644 --- a/src/helpers/WLSurface.cpp +++ b/src/helpers/WLSurface.cpp @@ -52,6 +52,20 @@ Vector2D CWLSurface::getViewporterCorrectedSize() const { Vector2D{m_pWLRSurface->current.buffer_width, m_pWLRSurface->current.buffer_height}; } +CRegion CWLSurface::logicalDamage() const { + CRegion damage{&m_pWLRSurface->buffer_damage}; + damage.transform(m_pWLRSurface->current.transform, m_pWLRSurface->current.buffer_width, m_pWLRSurface->current.buffer_height); + damage.scale(1.0 / m_pWLRSurface->current.scale); + + const auto VPSIZE = getViewporterCorrectedSize() / m_pWLRSurface->current.scale; + const auto CORRECTVEC = correctSmallVec(); + + damage.scale({VPSIZE.x / m_pWLRSurface->current.width, VPSIZE.y / m_pWLRSurface->current.height}); + damage.translate(CORRECTVEC); + + return damage; +} + void CWLSurface::destroy() { if (!m_pWLRSurface) return; diff --git a/src/helpers/WLSurface.hpp b/src/helpers/WLSurface.hpp index 03714bbf..eab4ac48 100644 --- a/src/helpers/WLSurface.hpp +++ b/src/helpers/WLSurface.hpp @@ -1,6 +1,7 @@ #pragma once #include "../defines.hpp" +#include "Region.hpp" class CWindow; @@ -23,6 +24,7 @@ class CWLSurface { bool small() const; // means surface is smaller than the requested size Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces Vector2D getViewporterCorrectedSize() const; + CRegion logicalDamage() const; // allow stretching. Useful for plugins. bool m_bFillIgnoreSmall = false; |
