From adf3a4e560652b139b66e2f4e66f4f9659b91c3b Mon Sep 17 00:00:00 2001 From: Christopher Sherlock Date: Tue, 14 Apr 2026 20:46:47 +1000 Subject: [PATCH] vcl: utilize CoordinateMapper wrappers to simplify map.cxx This commit replaces manual coordinate arithmetic in map.cxx with the newly introduced CoordinateMapper pipeline stages and master wrappers, improving encapsulation and fixing a subtle offset bug. Key changes: - OutputDevice::LogicToDeviceSubPixel: Replaced nested pipeline calls and manual device origin additions with the LogicToDeviceSubPixel master wrapper. This completely hides the math from map.cxx and ensures the absolute logical offset (mnOutOffLogic) is correctly applied before any DPI/MapMode scaling occurs. - OutputDevice::ImplPixelToDevicePixel: Fixed an early-exit bug. The legacy code only checked if the screen origin (mnOutOff) was zero before returning early, completely ignoring whether the window had an internal VCL pixel offset (mnOutOffOrig). By piping `0` through ViewToWindowUnits and WindowToDeviceUnits, we now calculate the exact combined spatial delta to check for the early exit and move the region safely. Change-Id: I697a0a7aa2bc4c03e55654305432b0805cee9c66 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203667 Tested-by: Jenkins Reviewed-by: Dan Williams --- vcl/source/outdev/map.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 588ec741db6c..a4ca062215cd 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -257,11 +257,14 @@ tools::Rectangle OutputDevice::ImplDevicePixelToLogic( const tools::Rectangle& r vcl::Region OutputDevice::ImplPixelToDevicePixel( const vcl::Region& rRegion ) const { - if ( !mpMapper->GetDeviceOriginX() && !mpMapper->GetDeviceOriginY() ) + tools::Long nDeltaX = mpMapper->WindowToDeviceUnitsX(mpMapper->ViewToWindowUnitsX(0)); + tools::Long nDeltaY = mpMapper->WindowToDeviceUnitsY(mpMapper->ViewToWindowUnitsY(0)); + + if (nDeltaX == 0 && nDeltaY == 0) return rRegion; vcl::Region aRegion( rRegion ); - aRegion.Move( mpMapper->GetDeviceOriginX()+mpMapper->GetPixelXOffset(), mpMapper->GetDeviceOriginY()+mpMapper->GetPixelYOffset() ); + aRegion.Move(nDeltaX, nDeltaY); return aRegion; }