From be0cbc356a15f118c45189f865d82953619f0a38 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 24 Mar 2025 19:12:03 +0900 Subject: [PATCH] sw_engine: hotfix a out of bound image access. this simply revert logic from the previous change: https://github.com/thorvg/thorvg/pull/2552 issue: https://github.com/thorvg/thorvg/issues/3327 --- src/renderer/sw_engine/tvgSwMath.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/renderer/sw_engine/tvgSwMath.cpp b/src/renderer/sw_engine/tvgSwMath.cpp index 5b84c43a..31a2c3eb 100644 --- a/src/renderer/sw_engine/tvgSwMath.cpp +++ b/src/renderer/sw_engine/tvgSwMath.cpp @@ -309,10 +309,17 @@ bool mathUpdateOutlineBBox(const SwOutline* outline, const SwBBox& clipRegion, S if (yMax < pt->y) yMax = pt->y; } - renderRegion.min.x = xMin >> 6; - renderRegion.max.x = (xMax + 63) >> 6; - renderRegion.min.y = yMin >> 6; - renderRegion.max.y = (yMax + 63) >> 6; + if (fastTrack) { + renderRegion.min.x = static_cast(round(xMin / 64.0f)); + renderRegion.max.x = static_cast(round(xMax / 64.0f)); + renderRegion.min.y = static_cast(round(yMin / 64.0f)); + renderRegion.max.y = static_cast(round(yMax / 64.0f)); + } else { + renderRegion.min.x = xMin >> 6; + renderRegion.max.x = (xMax + 63) >> 6; + renderRegion.min.y = yMin >> 6; + renderRegion.max.y = (yMax + 63) >> 6; + } return mathClipBBox(clipRegion, renderRegion); }