With this PR, the GdipFlattenPath and GdiAddPath*Curve are drawing the same way as the native gdiplus
-- v3: gdiplus: Fix GdipFlattenPath return path precision gdiplus/test: Add GdipFlattenPath tests with default flatness 0.25
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/tests/graphicspath.c | 52 +++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 89a7dd786de..54b701c0356 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -75,7 +75,7 @@ typedef struct int todo; } path_test_t;
-#define ok_path(a,b,c,d) _ok_path_fudge(a,b,c,d,1.0,__LINE__) +#define ok_path(a,b,c,d) _ok_path_fudge(a,b,c,d,0.4,__LINE__) #define ok_path_fudge(a,b,c,d,e) _ok_path_fudge(a,b,c,d,e,__LINE__) static void _ok_path_fudge(GpPath* path, const path_test_t *expected, INT expected_size, BOOL todo_size, REAL fudge, int line) @@ -910,13 +910,13 @@ static void test_lastpoint(void) static path_test_t addcurve_path[] = { {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/ {3.3, 3.3, PathPointTypeBezier, 0, 0}, /*1*/ - {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*2*/ + {6.7, 3.3, PathPointTypeBezier, 0, 1}, /*2*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/ - {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*4*/ - {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*5*/ + {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*4*/ + {3.3, 20.0, PathPointTypeBezier, 0, 1}, /*5*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*6*/ - {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*7*/ - {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*8*/ + {16.7, 20.0, PathPointTypeBezier, 0, 1}, /*7*/ + {23.3, 13.3, PathPointTypeBezier, 0, 1}, /*8*/ {30.0, 10.0, PathPointTypeBezier, 0, 0} /*9*/ }; static path_test_t addcurve_path_default_tension[] = { @@ -936,34 +936,34 @@ static path_test_t addcurve_path2[] = { {123.0,10.0, PathPointTypeLine, 0, 0}, /*1*/ {0.0, 0.0, PathPointTypeLine, 0, 0}, /*2*/ {3.3, 3.3, PathPointTypeBezier, 0, 0}, /*3*/ - {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*4*/ + {6.7, 3.3, PathPointTypeBezier, 0, 1}, /*4*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*5*/ - {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*6*/ - {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*7*/ + {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*6*/ + {3.3, 20.0, PathPointTypeBezier, 0, 1}, /*7*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*8*/ - {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*9*/ - {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*10*/ + {16.7, 20.0, PathPointTypeBezier, 0, 1}, /*9*/ + {23.3, 13.3, PathPointTypeBezier, 0, 1}, /*10*/ {30.0, 10.0, PathPointTypeBezier, 0, 0} /*11*/ }; static path_test_t addcurve_path3[] = { {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/ - {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*1*/ - {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*2*/ + {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*1*/ + {3.3, 20.0, PathPointTypeBezier, 0, 1}, /*2*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*3*/ - {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*4*/ - {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*5*/ + {16.7, 20.0, PathPointTypeBezier, 0, 1}, /*4*/ + {23.3, 13.3, PathPointTypeBezier, 0, 1}, /*5*/ {30.0, 10.0, PathPointTypeBezier, 0, 0} /*6*/ }; static path_test_t addcurve_path4[] = { {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/ {3.33, 3.33, PathPointTypeBezier, 0, 0}, /*1*/ - {6.66, 3.33, PathPointTypeBezier, 0, 0}, /*2*/ + {6.66, 3.33, PathPointTypeBezier, 0, 1}, /*2*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/ }; static path_test_t addcurve_path5[] = { {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/ - {13.3, 16.6, PathPointTypeBezier, 0, 0}, /*1*/ - {3.33, 20.0, PathPointTypeBezier, 0, 0}, /*2*/ + {13.3, 16.6, PathPointTypeBezier, 0, 1}, /*1*/ + {3.33, 20.0, PathPointTypeBezier, 0, 1}, /*2*/ {10.0, 20.0, PathPointTypeBezier, 0, 0} /*3*/ };
@@ -1063,17 +1063,17 @@ static void test_addcurve(void)
static path_test_t addclosedcurve_path[] = { {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/ - {-6.7, 0.0, PathPointTypeBezier, 0, 0}, /*1*/ - {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*2*/ + {-6.7, 0.0, PathPointTypeBezier, 0, 1}, /*1*/ + {6.7, 3.3, PathPointTypeBezier, 0, 1}, /*2*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/ - {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*4*/ - {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*5*/ + {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*4*/ + {3.3, 20.0, PathPointTypeBezier, 0, 1}, /*5*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*6*/ - {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*7*/ - {33.3, 16.7, PathPointTypeBezier, 0, 0}, /*8*/ + {16.7, 20.0, PathPointTypeBezier, 0, 1}, /*7*/ + {33.3, 16.7, PathPointTypeBezier, 0, 1}, /*8*/ {30.0, 10.0, PathPointTypeBezier, 0, 0}, /*9*/ - {26.7, 3.3, PathPointTypeBezier, 0, 0}, /*10*/ - {6.7, 0.0, PathPointTypeBezier, 0, 0}, /*11*/ + {26.7, 3.3, PathPointTypeBezier, 0, 1}, /*10*/ + {6.7, 0.0, PathPointTypeBezier, 0, 1}, /*11*/ {0.0, 0.0, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*12*/ }; static path_test_t addclosedcurve_path_default_tension[] = {
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/gdiplus_private.h | 2 +- dlls/gdiplus/tests/graphicspath.c | 50 +++++++++++++++---------------- 2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 040d0ef4e8d..8316a1334d1 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -42,7 +42,7 @@ #define VERSION_MAGIC 0xdbc01001 #define VERSION_MAGIC2 0xdbc01002 #define VALID_MAGIC(x) (((x) & 0xfffff000) == 0xdbc01000) -#define TENSION_CONST (0.3) +#define TENSION_CONST (0.333333333f)
#define GIF_DISPOSE_UNSPECIFIED 0 #define GIF_DISPOSE_DO_NOT_DISPOSE 1 diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 54b701c0356..a0fcbde4a0a 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -910,13 +910,13 @@ static void test_lastpoint(void) static path_test_t addcurve_path[] = { {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/ {3.3, 3.3, PathPointTypeBezier, 0, 0}, /*1*/ - {6.7, 3.3, PathPointTypeBezier, 0, 1}, /*2*/ + {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*2*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/ - {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*4*/ - {3.3, 20.0, PathPointTypeBezier, 0, 1}, /*5*/ + {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*4*/ + {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*5*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*6*/ - {16.7, 20.0, PathPointTypeBezier, 0, 1}, /*7*/ - {23.3, 13.3, PathPointTypeBezier, 0, 1}, /*8*/ + {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*7*/ + {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*8*/ {30.0, 10.0, PathPointTypeBezier, 0, 0} /*9*/ }; static path_test_t addcurve_path_default_tension[] = { @@ -936,34 +936,34 @@ static path_test_t addcurve_path2[] = { {123.0,10.0, PathPointTypeLine, 0, 0}, /*1*/ {0.0, 0.0, PathPointTypeLine, 0, 0}, /*2*/ {3.3, 3.3, PathPointTypeBezier, 0, 0}, /*3*/ - {6.7, 3.3, PathPointTypeBezier, 0, 1}, /*4*/ + {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*4*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*5*/ - {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*6*/ - {3.3, 20.0, PathPointTypeBezier, 0, 1}, /*7*/ + {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*6*/ + {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*7*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*8*/ - {16.7, 20.0, PathPointTypeBezier, 0, 1}, /*9*/ - {23.3, 13.3, PathPointTypeBezier, 0, 1}, /*10*/ + {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*9*/ + {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*10*/ {30.0, 10.0, PathPointTypeBezier, 0, 0} /*11*/ }; static path_test_t addcurve_path3[] = { {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/ - {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*1*/ - {3.3, 20.0, PathPointTypeBezier, 0, 1}, /*2*/ + {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*1*/ + {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*2*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*3*/ - {16.7, 20.0, PathPointTypeBezier, 0, 1}, /*4*/ - {23.3, 13.3, PathPointTypeBezier, 0, 1}, /*5*/ + {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*4*/ + {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*5*/ {30.0, 10.0, PathPointTypeBezier, 0, 0} /*6*/ }; static path_test_t addcurve_path4[] = { {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/ {3.33, 3.33, PathPointTypeBezier, 0, 0}, /*1*/ - {6.66, 3.33, PathPointTypeBezier, 0, 1}, /*2*/ + {6.66, 3.33, PathPointTypeBezier, 0, 0}, /*2*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/ }; static path_test_t addcurve_path5[] = { {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/ - {13.3, 16.6, PathPointTypeBezier, 0, 1}, /*1*/ - {3.33, 20.0, PathPointTypeBezier, 0, 1}, /*2*/ + {13.3, 16.6, PathPointTypeBezier, 0, 0}, /*1*/ + {3.33, 20.0, PathPointTypeBezier, 0, 0}, /*2*/ {10.0, 20.0, PathPointTypeBezier, 0, 0} /*3*/ };
@@ -1063,17 +1063,17 @@ static void test_addcurve(void)
static path_test_t addclosedcurve_path[] = { {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/ - {-6.7, 0.0, PathPointTypeBezier, 0, 1}, /*1*/ - {6.7, 3.3, PathPointTypeBezier, 0, 1}, /*2*/ + {-6.7, 0.0, PathPointTypeBezier, 0, 0}, /*1*/ + {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*2*/ {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/ - {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*4*/ - {3.3, 20.0, PathPointTypeBezier, 0, 1}, /*5*/ + {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*4*/ + {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*5*/ {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*6*/ - {16.7, 20.0, PathPointTypeBezier, 0, 1}, /*7*/ - {33.3, 16.7, PathPointTypeBezier, 0, 1}, /*8*/ + {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*7*/ + {33.3, 16.7, PathPointTypeBezier, 0, 0}, /*8*/ {30.0, 10.0, PathPointTypeBezier, 0, 0}, /*9*/ - {26.7, 3.3, PathPointTypeBezier, 0, 1}, /*10*/ - {6.7, 0.0, PathPointTypeBezier, 0, 1}, /*11*/ + {26.7, 3.3, PathPointTypeBezier, 0, 0}, /*10*/ + {6.7, 0.0, PathPointTypeBezier, 0, 0}, /*11*/ {0.0, 0.0, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*12*/ }; static path_test_t addclosedcurve_path_default_tension[] = {
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/tests/graphicspath.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index a0fcbde4a0a..28db22227b5 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1253,7 +1253,14 @@ static path_test_t flattenline_path[] = { {50.0, 100.0, PathPointTypeLine, 0, 0} /*1*/ };
-static path_test_t flattenarc_path[] = { +static path_test_t arc_path3[] = { + {100.0, 25.0, PathPointTypeStart, 0, 0}, /*0*/ + {100.0, 38.8, PathPointTypeBezier, 0, 0}, /*1*/ + {77.6, 50.0, PathPointTypeBezier, 0, 0}, /*2*/ + {50.0, 50.0, PathPointTypeBezier, 0, 0} /*3*/ + }; + +static path_test_t flattenarc_path3[] = { {100.0, 25.0,PathPointTypeStart, 0, 0}, /*0*/ {99.0, 30.0, PathPointTypeLine, 0, 0}, /*1*/ {96.0, 34.8, PathPointTypeLine, 0, 0}, /*2*/ @@ -1318,9 +1325,11 @@ static void test_flatten(void) expect(Ok, status); status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 50.0, 0.0, 90.0); expect(Ok, status); + ok_path(path, arc_path3, ARRAY_SIZE(arc_path3), FALSE); + status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); - ok_path(path, flattenarc_path, ARRAY_SIZE(flattenarc_path), TRUE); + ok_path(path, flattenarc_path3, ARRAY_SIZE(flattenarc_path3), TRUE);
/* easy case - quater of a full circle */ status = GdipResetPath(path);
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/tests/graphicspath.c | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 28db22227b5..d2e0f875d89 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1270,6 +1270,21 @@ static path_test_t flattenarc_path3[] = { {50.0, 50.0, PathPointTypeLine, 0, 1} /*6*/ };
+static path_test_t flattenarc_path4[] = { + {100.0,25.0, PathPointTypeStart, 0, 0}, /*0*/ + {99.8, 27.6, PathPointTypeLine, 0, 0}, /*1*/ + {99.0, 30.1, PathPointTypeLine, 0, 0}, /*2*/ + {97.8, 32.4, PathPointTypeLine, 0, 0}, /*3*/ + {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*/ + }; + static path_test_t flattenquater_path[] = { {100.0, 50.0,PathPointTypeStart, 0, 0}, /*0*/ {99.0, 60.0, PathPointTypeLine, 0, 0}, /*1*/ @@ -1321,6 +1336,16 @@ static void test_flatten(void) expect(Ok, status); ok_path(path, flattenline_path, ARRAY_SIZE(flattenline_path), FALSE);
+ // Flatten line with FlatnessDefault (0.25f) + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 100.0); + expect(Ok, status); + status = GdipFlattenPath(path, NULL, FlatnessDefault); + expect(Ok, status); + ok_path(path, flattenline_path, ARRAY_SIZE(flattenline_path), FALSE); + + /* Flatten arc path with Flatness = 1.0) */ status = GdipResetPath(path); expect(Ok, status); status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 50.0, 0.0, 90.0); @@ -1331,6 +1356,16 @@ static void test_flatten(void) expect(Ok, status); ok_path(path, flattenarc_path3, ARRAY_SIZE(flattenarc_path3), TRUE);
+ /* Flatten arc path with FlatnessDefault (0.25f) */ + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 50.0, 0.0, 90.0); + expect(Ok, status); + + status = GdipFlattenPath(path, NULL, FlatnessDefault); + expect(Ok, status); + ok_path(path, flattenarc_path4, ARRAY_SIZE(flattenarc_path4), TRUE); + /* easy case - quater of a full circle */ status = GdipResetPath(path); expect(Ok, status);
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);
Esme Povirk (@madewokherd) commented about dlls/gdiplus/graphicspath.c:
struct list jobs; struct flatten_bezier_job *current, *next;
- flatness = 0.62f * flatness;
How did you arrive at this number?
On Sun Mar 16 02:35:07 2025 +0000, Esme Povirk wrote:
How did you arrive at this number?
Both numbers are aligned experimentally. It seems TENSION_CONST number is just division by 3.
Flatness variable is changing the number of point per curve. I don't know what 0.62 means (previously it was 0.5), as he 0.666 value is too big. It is taken by changing constant and comparing the output path with native.
I covered these changes with tests. It will prevent from regression.
This merge request was approved by Esme Povirk.