From a96037cd57042beeda59095776627056a135f1c8 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Sun, 1 Nov 2020 16:38:14 +0100 Subject: [PATCH] sw_engine shape: change of the rectangle fast tracking algorithm The algorithm erroneously treated some shapes (like isosceles trapezoids and specifically arranged zero width parallelograms) as rectangles, which causes the whole bbox to be filled. --- src/lib/sw_engine/tvgSwShape.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/sw_engine/tvgSwShape.cpp b/src/lib/sw_engine/tvgSwShape.cpp index a0cbce15..44066f33 100644 --- a/src/lib/sw_engine/tvgSwShape.cpp +++ b/src/lib/sw_engine/tvgSwShape.cpp @@ -430,13 +430,14 @@ bool _fastTrack(const SwOutline* outline) auto pt3 = outline->pts + 2; auto pt4 = outline->pts + 3; - auto min1 = pt1->y < pt3->y ? pt1 : pt3; - auto min2 = pt2->y < pt4->y ? pt2 : pt4; - if (min1->y != min2->y) return false; + SwPoint a; + SwPoint b; + a.x = pt1->x; + a.y = pt3->y; + b.x = pt3->x; + b.y = pt1->y; - SwCoord len1 = pow(pt1->x - pt3->x, 2) + pow(pt1->y - pt3->y, 2); - SwCoord len2 = pow(pt2->x - pt4->x, 2) + pow(pt2->y - pt4->y, 2); - if (len1 == len2) return true; + if ((*pt2 == a && *pt4 == b) || (*pt2 == b && *pt4 == a)) return true; return false; }