sw_engine shape: change of the rectangle fast tracking algorithm
authorMira Grudzinska <m.grudzinska@samsung.com>
Sun, 1 Nov 2020 15:38:14 +0000 (16:38 +0100)
committerHermet Park <chuneon.park@samsung.com>
Tue, 3 Nov 2020 03:18:05 +0000 (12:18 +0900)
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.

Change-Id: If5aa87c53cf174367841323ac813b28ead4871b4

src/lib/sw_engine/tvgSwShape.cpp

index a0cbce1..44066f3 100644 (file)
@@ -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;
-
-    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;
+    SwPoint a;
+    SwPoint b;
+    a.x = pt1->x;
+    a.y = pt3->y;
+    b.x = pt3->x;
+    b.y = pt1->y;
+
+    if ((*pt2 == a && *pt4 == b) || (*pt2 == b && *pt4 == a)) return true;
 
     return false;
 }