summaryrefslogtreecommitdiff
path: root/src/helpers/WLSurface.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2023-10-25 22:05:04 +0100
committerVaxry <vaxry@vaxry.net>2023-10-25 22:05:04 +0100
commit8991be671fb231ebe268352fe9cc883911b066c2 (patch)
treed6b60255760431ea66357e260ca9766e55f96b76 /src/helpers/WLSurface.cpp
parent6650e4ba85568a687b1de79eb7375cabfa68e848 (diff)
renderer: respect viewporter dest on base surfaces
Diffstat (limited to 'src/helpers/WLSurface.cpp')
-rw-r--r--src/helpers/WLSurface.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/helpers/WLSurface.cpp b/src/helpers/WLSurface.cpp
index a34c77a1..3d3800cb 100644
--- a/src/helpers/WLSurface.cpp
+++ b/src/helpers/WLSurface.cpp
@@ -38,11 +38,20 @@ Vector2D CWLSurface::correctSmallVec() const {
if (!m_pOwner || !exists() || !small() || m_bFillIgnoreSmall)
return {};
- return Vector2D{(m_pOwner->m_vReportedSize.x - m_pWLRSurface->current.buffer_width) / 2, (m_pOwner->m_vReportedSize.y - m_pWLRSurface->current.buffer_height) / 2}.clamp(
- {}, {INFINITY, INFINITY}) *
+ const auto SIZE = getViewporterCorrectedSize();
+
+ return Vector2D{(m_pOwner->m_vReportedSize.x - SIZE.x) / 2, (m_pOwner->m_vReportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) *
(m_pOwner->m_vRealSize.vec() / m_pOwner->m_vReportedSize);
}
+Vector2D CWLSurface::getViewporterCorrectedSize() const {
+ if (!exists())
+ return {};
+
+ return m_pWLRSurface->current.viewport.has_dst ? Vector2D{m_pWLRSurface->current.viewport.dst_width, m_pWLRSurface->current.viewport.dst_height} :
+ Vector2D{m_pWLRSurface->current.buffer_width, m_pWLRSurface->current.buffer_height};
+}
+
void CWLSurface::destroy() {
if (!m_pWLRSurface)
return;