vcl: refactor Polygon PixelToLogic() with MapMode to use wrappers
This commit refactors OutputDevice::PixelToLogic(Polygon, MapMode) to use the ViewSubPixelToLogicIntX/Y() overloads that accept custom mapping resolutions (ImplMapRes). Key changes: - Replaced manual coordinate scaling and sequential subtraction of mapping and logical offsets with encapsulated master wrappers. - Preserved the "Round-then-Shift" order of operations to ensure polygon vertices maintain legacy rounding symmetry and pass unit tests. - Modernized the loop by removing legacy pointer-based array access in favor of direct index assignment and Point construction. - Further reduced the footprint of coordinate mathematics within map.cxx. Change-Id: Ided023472c28d9bdd2e0c35c5f00705b58435bff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203676 Tested-by: Jenkins Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit is contained in:
committed by
Dan Williams
parent
580b99dbc2
commit
08874223db
@@ -881,28 +881,23 @@ tools::Rectangle OutputDevice::PixelToLogic( const tools::Rectangle& rDeviceRect
|
||||
tools::Polygon OutputDevice::PixelToLogic( const tools::Polygon& rDevicePoly,
|
||||
const MapMode& rMapMode ) const
|
||||
{
|
||||
|
||||
// calculate nothing if default-MapMode
|
||||
if ( rMapMode.IsDefault() )
|
||||
return rDevicePoly;
|
||||
|
||||
// calculate MapMode-resolution and convert
|
||||
ImplMapRes aMapRes;
|
||||
// calculate MapMode-resolution
|
||||
ImplMapRes aMapRes;
|
||||
aMapRes.CalcMapResolution(rMapMode, mpMapper->GetDPIX(), mpMapper->GetDPIY());
|
||||
|
||||
const sal_uInt16 nPoints = rDevicePoly.GetSize();
|
||||
tools::Polygon aPoly( rDevicePoly );
|
||||
|
||||
// get pointer to Point-array (copy data)
|
||||
const Point* pPointAry = aPoly.GetConstPointAry();
|
||||
|
||||
for (sal_uInt16 i = 0; i < nPoints; i++)
|
||||
for (sal_uInt16 i = 0; i < nPoints; ++i)
|
||||
{
|
||||
const Point* pPt = &(pPointAry[i]);
|
||||
Point aPt;
|
||||
aPt.setX(mpMapper->ViewToLogicDistanceX(pPt->X(), aMapRes.mfMapScX) - aMapRes.mnMapOfsX - mpMapper->GetLogicalXOffset());
|
||||
aPt.setY(mpMapper->ViewToLogicDistanceY(pPt->Y(), aMapRes.mfMapScY) - aMapRes.mnMapOfsY - mpMapper->GetLogicalYOffset());
|
||||
aPoly[i] = aPt;
|
||||
aPoly[i] = Point(
|
||||
mpMapper->ViewSubPixelToLogicIntX(aPoly[i].X(), aMapRes),
|
||||
mpMapper->ViewSubPixelToLogicIntY(aPoly[i].Y(), aMapRes)
|
||||
);
|
||||
}
|
||||
|
||||
return aPoly;
|
||||
|
||||
Reference in New Issue
Block a user