From 9c864f3e990048f5623f96e49590a4fb70bf1e82 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Sat, 1 Feb 2025 01:21:21 +0100 Subject: [PATCH] common: more accurate clipped viewport rounding Replaced ceil and direct casts with nearbyint to improve viewport size calculation. This ensures consistent approach with the fastTrack case in sw_engine. @Issue: https://github.com/thorvg/thorvg/issues/3148 --- src/renderer/tvgPaint.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderer/tvgPaint.cpp b/src/renderer/tvgPaint.cpp index 63db2043..4101a3fd 100644 --- a/src/renderer/tvgPaint.cpp +++ b/src/renderer/tvgPaint.cpp @@ -119,10 +119,10 @@ static Result _compFastTrack(RenderMethod* renderer, Paint* cmpTarget, const Mat if (v1.x > v2.x) std::swap(v1.x, v2.x); if (v1.y > v2.y) std::swap(v1.y, v2.y); - after.x = static_cast(v1.x); - after.y = static_cast(v1.y); - after.w = static_cast(ceil(v2.x - after.x)); - after.h = static_cast(ceil(v2.y - after.y)); + after.x = static_cast(nearbyint(v1.x)); + after.y = static_cast(nearbyint(v1.y)); + after.w = static_cast(nearbyint(v2.x)) - after.x; + after.h = static_cast(nearbyint(v2.y)) - after.y; if (after.w < 0) after.w = 0; if (after.h < 0) after.h = 0;