From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/graphicspath.c | 5 +-- dlls/gdiplus/tests/graphicspath.c | 60 +++++++++++++++---------------- 2 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index b1e417842f8..f9b5798a085 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -202,6 +202,7 @@ static BOOL flatten_bezier(path_list_node_t *start, REAL x2, REAL y2, REAL x3, R struct list jobs; struct flatten_bezier_job *current, *next;
+ flatness = 0.62f * flatness; list_init( &jobs ); flatten_bezier_add(&jobs, start, x2, y2, x3, y3, end); LIST_FOR_EACH_ENTRY( current, &jobs, struct flatten_bezier_job, entry ) @@ -238,7 +239,7 @@ static BOOL flatten_bezier(path_list_node_t *start, REAL x2, REAL y2, REAL x3, R * Also avoids limited-precision errors in flatness check */ if((fabs(pt.X - mp[2].X) + fabs(pt.Y - mp[2].Y) + - fabs(pt_st.X - mp[2].X) + fabs(pt_st.Y - mp[2].Y) ) <= flatness * 0.5) + fabs(pt_st.X - mp[2].X) + fabs(pt_st.Y - mp[2].Y) ) <= flatness) continue;
/* check flatness as a half of distance between middle point and a linearized path @@ -250,7 +251,7 @@ static BOOL flatten_bezier(path_list_node_t *start, REAL x2, REAL y2, REAL x3, R */ area_triangle = (pt.Y - pt_st.Y)*mp[2].X + (pt_st.X - pt.X)*mp[2].Y + (pt_st.Y*pt.X - pt_st.X*pt.Y); distance_start_end = hypotf(pt.Y - pt_st.Y, pt_st.X - pt.X); - if(fabs(area_triangle) <= (0.5 * flatness * distance_start_end)){ + if(fabs(area_triangle) <= flatness * distance_start_end){ continue; } else diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index d2e0f875d89..86c3c6ed989 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1226,26 +1226,26 @@ static path_test_t flattenellipse_path[] = { {96.0, 34.8, PathPointTypeLine, 0, 0}, /*2*/ {91.5, 39.0, PathPointTypeLine, 0, 0}, /*3*/ {85.5, 42.8, PathPointTypeLine, 0, 0}, /*4*/ - {69.5, 48.0, PathPointTypeLine, 0, 1}, /*5*/ - {50.0, 50.0, PathPointTypeLine, 0, 1}, /*6*/ - {30.5, 48.0, PathPointTypeLine, 0, 1}, /*7*/ - {14.8, 42.8, PathPointTypeLine, 0, 1}, /*8*/ - {8.5, 39.0, PathPointTypeLine, 0, 1}, /*9*/ - {4.0, 34.8, PathPointTypeLine, 0, 1}, /*10*/ - {1.0, 30.0, PathPointTypeLine, 0, 1}, /*11*/ - {0.0, 25.0, PathPointTypeLine, 0, 1}, /*12*/ - {1.0, 20.0, PathPointTypeLine, 0, 1}, /*13*/ - {4.0, 15.3, PathPointTypeLine, 0, 1}, /*14*/ - {8.5, 11.0, PathPointTypeLine, 0, 1}, /*15*/ - {14.8, 7.3, PathPointTypeLine, 0, 1}, /*16*/ - {30.5, 2.0, PathPointTypeLine, 0, 1}, /*17*/ - {50.0, 0.0, PathPointTypeLine, 0, 1}, /*18*/ - {69.5, 2.0, PathPointTypeLine, 0, 1}, /*19*/ - {85.5, 7.3, PathPointTypeLine, 0, 1}, /*20*/ - {91.5, 11.0, PathPointTypeLine, 0, 1}, /*21*/ - {96.0, 15.3, PathPointTypeLine, 0, 1}, /*22*/ - {99.0, 20.0, PathPointTypeLine, 0, 1}, /*23*/ - {100.0,25.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 1} /*24*/ + {69.5, 48.0, PathPointTypeLine, 0, 0}, /*5*/ + {50.0, 50.0, PathPointTypeLine, 0, 0}, /*6*/ + {30.5, 48.0, PathPointTypeLine, 0, 0}, /*7*/ + {14.8, 42.8, PathPointTypeLine, 0, 0}, /*8*/ + {8.5, 39.0, PathPointTypeLine, 0, 0}, /*9*/ + {4.0, 34.8, PathPointTypeLine, 0, 0}, /*10*/ + {1.0, 30.0, PathPointTypeLine, 0, 0}, /*11*/ + {0.0, 25.0, PathPointTypeLine, 0, 0}, /*12*/ + {1.0, 20.0, PathPointTypeLine, 0, 0}, /*13*/ + {4.0, 15.3, PathPointTypeLine, 0, 0}, /*14*/ + {8.5, 11.0, PathPointTypeLine, 0, 0}, /*15*/ + {14.8, 7.3, PathPointTypeLine, 0, 0}, /*16*/ + {30.5, 2.0, PathPointTypeLine, 0, 0}, /*17*/ + {50.0, 0.0, PathPointTypeLine, 0, 0}, /*18*/ + {69.5, 2.0, PathPointTypeLine, 0, 0}, /*19*/ + {85.5, 7.3, PathPointTypeLine, 0, 0}, /*20*/ + {91.5, 11.0, PathPointTypeLine, 0, 0}, /*21*/ + {96.0, 15.3, PathPointTypeLine, 0, 0}, /*22*/ + {99.0, 20.0, PathPointTypeLine, 0, 0}, /*23*/ + {100.0,25.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0} /*24*/ };
static path_test_t flattenline_path[] = { @@ -1266,8 +1266,8 @@ static path_test_t flattenarc_path3[] = { {96.0, 34.8, PathPointTypeLine, 0, 0}, /*2*/ {91.5, 39.0, PathPointTypeLine, 0, 0}, /*3*/ {85.5, 42.8, PathPointTypeLine, 0, 0}, /*4*/ - {69.5, 48.0, PathPointTypeLine, 0, 1}, /*5*/ - {50.0, 50.0, PathPointTypeLine, 0, 1} /*6*/ + {69.5, 48.0, PathPointTypeLine, 0, 0}, /*5*/ + {50.0, 50.0, PathPointTypeLine, 0, 0} /*6*/ };
static path_test_t flattenarc_path4[] = { @@ -1278,11 +1278,11 @@ static path_test_t flattenarc_path4[] = { {96.0, 34.8, PathPointTypeLine, 0, 0}, /*4*/ {93.9, 36.9, PathPointTypeLine, 0, 0}, /*5*/ {91.4, 39.0, PathPointTypeLine, 0, 0}, /*6*/ - {85.4, 42.7, PathPointTypeLine, 0, 1}, /*7*/ - {77.9, 45.8, PathPointTypeLine, 0, 1}, /*8*/ - {69.5, 48.0, PathPointTypeLine, 0, 1}, /*9*/ - {60.0, 49.5, PathPointTypeLine, 0, 1}, /*10*/ - {50.0, 50.0, PathPointTypeLine, 0, 1} /*11*/ + {85.4, 42.7, PathPointTypeLine, 0, 0}, /*7*/ + {77.9, 45.8, PathPointTypeLine, 0, 0}, /*8*/ + {69.5, 48.0, PathPointTypeLine, 0, 0}, /*9*/ + {60.0, 49.5, PathPointTypeLine, 0, 0}, /*10*/ + {50.0, 50.0, PathPointTypeLine, 0, 0} /*11*/ };
static path_test_t flattenquater_path[] = { @@ -1326,7 +1326,7 @@ static void test_flatten(void)
status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); - ok_path(path, flattenellipse_path, ARRAY_SIZE(flattenellipse_path), TRUE); + ok_path(path, flattenellipse_path, ARRAY_SIZE(flattenellipse_path), FALSE);
status = GdipResetPath(path); expect(Ok, status); @@ -1354,7 +1354,7 @@ static void test_flatten(void)
status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); - ok_path(path, flattenarc_path3, ARRAY_SIZE(flattenarc_path3), TRUE); + ok_path(path, flattenarc_path3, ARRAY_SIZE(flattenarc_path3), FALSE);
/* Flatten arc path with FlatnessDefault (0.25f) */ status = GdipResetPath(path); @@ -1364,7 +1364,7 @@ static void test_flatten(void)
status = GdipFlattenPath(path, NULL, FlatnessDefault); expect(Ok, status); - ok_path(path, flattenarc_path4, ARRAY_SIZE(flattenarc_path4), TRUE); + ok_path(path, flattenarc_path4, ARRAY_SIZE(flattenarc_path4), FALSE);
/* easy case - quater of a full circle */ status = GdipResetPath(path);