Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d2d1/tests/d2d1.c | 357 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 357 insertions(+)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 7c0ee91099..a3fe5f10a8 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -2494,6 +2494,45 @@ static void fill_geometry_sink_bezier(ID2D1GeometrySink *sink, unsigned int holl ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED); }
+static void fill_geometry_sink_cubic_bezier(ID2D1GeometrySink *sink, unsigned int hollow_count) +{ + D2D1_FIGURE_BEGIN begin; + unsigned int idx = 0; + D2D1_POINT_2F point; + + set_point(&point, 25.0f, 220.0f); + begin = idx++ < hollow_count ? D2D1_FIGURE_BEGIN_HOLLOW : D2D1_FIGURE_BEGIN_FILLED; + ID2D1GeometrySink_BeginFigure(sink, point, begin); + cubic_to(sink, 37.5f, 170.0f, 12.5f, 120.0f, 25.0f, 70.0f); + cubic_to(sink, 37.5f, 120.0f, 50.0f, 20.0f, 62.5f, 70.0f); + cubic_to(sink, 50.0f, 120.0f, 75.0f, 170.0f, 62.5f, 220.0f); + cubic_to(sink, 50.0f, 170.0f, 37.5f, 270.0f, 25.0f, 220.0f); + ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED); + + set_point(&point, 20.0f, 145.0f); + begin = idx++ < hollow_count ? D2D1_FIGURE_BEGIN_HOLLOW : D2D1_FIGURE_BEGIN_FILLED; + ID2D1GeometrySink_BeginFigure(sink, point, begin); + cubic_to(sink, 55.0f, 0.0f, 35.0f, 0.0f, 70.0f, 145.0f); + cubic_to(sink, 35.0f, 290.0f, 55.0f, 290.0f, 20.0f, 145.0f); + ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED); + + set_point(&point, 25.0f, 672.0f); + begin = idx++ < hollow_count ? D2D1_FIGURE_BEGIN_HOLLOW : D2D1_FIGURE_BEGIN_FILLED; + ID2D1GeometrySink_BeginFigure(sink, point, begin); + cubic_to(sink, 37.5f, 622.0f, 12.5f, 572.0f, 25.0f, 522.0f); + cubic_to(sink, 37.5f, 572.0f, 50.0f, 472.0f, 62.5f, 522.0f); + cubic_to(sink, 50.0f, 572.0f, 75.0f, 622.0f, 62.5f, 672.0f); + cubic_to(sink, 50.0f, 622.0f, 37.5f, 722.0f, 25.0f, 672.0f); + ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED); + + set_point(&point, 20.0f, 597.0f); + begin = idx++ < hollow_count ? D2D1_FIGURE_BEGIN_HOLLOW : D2D1_FIGURE_BEGIN_FILLED; + ID2D1GeometrySink_BeginFigure(sink, point, begin); + cubic_to(sink, 55.0f, 452.0f, 35.0f, 452.0f, 70.0f, 597.0f); + cubic_to(sink, 35.0f, 742.0f, 55.0f, 742.0f, 20.0f, 597.0f); + ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED); +} + static void test_path_geometry(void) { ID2D1TransformedGeometry *transformed_geometry; @@ -2786,6 +2825,154 @@ static void test_path_geometry(void) /* Figure 28. */ {SEGMENT_LINE, {{{ 75.0f, 300.0f}}}}, {SEGMENT_LINE, {{{ 5.0f, 300.0f}}}}, + /* Figure 29. */ + {SEGMENT_BEZIER, {{{3.75000000e+01f, 1.70000000e+02f}, + {1.25000000e+01f, 1.20000000e+02f}, + {2.50000000e+01f, 7.00000000e+01f}}}}, + {SEGMENT_BEZIER, {{{3.75000000e+01f, 1.20000000e+02f}, + {5.00000000e+01f, 2.00000000e+01f}, + {6.25000000e+01f, 7.00000000e+01f}}}}, + {SEGMENT_BEZIER, {{{5.00000000e+01f, 1.20000000e+02f}, + {7.50000000e+01f, 1.70000000e+02f}, + {6.25000000e+01f, 2.20000000e+02f}}}}, + {SEGMENT_BEZIER, {{{5.00000000e+01f, 1.70000000e+02f}, + {3.75000000e+01f, 2.70000000e+02f}, + {2.50000000e+01f, 2.20000000e+02f}}}}, + /* Figure 30. */ + {SEGMENT_BEZIER, {{{5.50000000e+01f, 0.00000000e+00f}, + {3.50000000e+01f, 0.00000000e+00f}, + {7.00000000e+01f, 1.45000000e+02f}}}}, + {SEGMENT_BEZIER, {{{3.50000000e+01f, 2.90000000e+02f}, + {5.50000000e+01f, 2.90000000e+02f}, + {2.00000000e+01f, 1.45000000e+02f}}}}, + /* Figure 31. */ + {SEGMENT_BEZIER, {{{3.75000000e+01f, 6.22000000e+02f}, + {1.25000000e+01f, 5.72000000e+02f}, + {2.50000000e+01f, 5.22000000e+02f}}}}, + {SEGMENT_BEZIER, {{{3.75000000e+01f, 5.72000000e+02f}, + {5.00000000e+01f, 4.72000000e+02f}, + {6.25000000e+01f, 5.22000000e+02f}}}}, + {SEGMENT_BEZIER, {{{5.00000000e+01f, 5.72000000e+02f}, + {7.50000000e+01f, 6.22000000e+02f}, + {6.25000000e+01f, 6.72000000e+02f}}}}, + {SEGMENT_BEZIER, {{{5.00000000e+01f, 6.22000000e+02f}, + {3.75000000e+01f, 7.22000000e+02f}, + {2.50000000e+01f, 6.72000000e+02f}}}}, + /* Figure 32. */ + {SEGMENT_BEZIER, {{{5.50000000e+01f, 4.52000000e+02f}, + {3.50000000e+01f, 4.52000000e+02f}, + {7.00000000e+01f, 5.97000000e+02f}}}}, + {SEGMENT_BEZIER, {{{3.50000000e+01f, 7.42000000e+02f}, + {5.50000000e+01f, 7.42000000e+02f}, + {2.00000000e+01f, 5.97000000e+02f}}}}, + /* Figure 33. */ + {SEGMENT_LINE, {{{2.50000000e+01f, 7.00000000e+01f}}}}, + {SEGMENT_LINE, {{{4.37500000e+01f, 7.00000000e+01f}}}}, + {SEGMENT_LINE, {{{6.25000000e+01f, 7.00000000e+01f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{6.25000000e+01f, 2.20000000e+02f}}}}, + {SEGMENT_LINE, {{{4.37500000e+01f, 2.20000000e+02f}}}}, + {SEGMENT_LINE, {{{2.50000000e+01f, 2.20000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + /* Figure 34. */ + {SEGMENT_LINE, {{{4.50000000e+01f, 3.62500000e+01f}}}}, + {SEGMENT_LINE, {{{7.00000000e+01f, 1.45000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{4.50000000e+01f, 2.53750000e+02f}}}}, + {SEGMENT_LINE, {{{2.00000000e+01f, 1.45000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + /* Figure 35. */ + {SEGMENT_LINE, {{{2.50000000e+01f, 5.22000000e+02f}}}}, + {SEGMENT_LINE, {{{4.37500000e+01f, 5.22000000e+02f}}}}, + {SEGMENT_LINE, {{{6.25000000e+01f, 5.22000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{6.25000000e+01f, 6.72000000e+02f}}}}, + {SEGMENT_LINE, {{{4.37500000e+01f, 6.72000000e+02f}}}}, + {SEGMENT_LINE, {{{2.50000000e+01f, 6.72000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + /* Figure 36. */ + {SEGMENT_LINE, {{{4.50000000e+01f, 4.88250000e+02f}}}}, + {SEGMENT_LINE, {{{7.00000000e+01f, 5.97000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{4.50000000e+01f, 7.05750000e+02f}}}}, + {SEGMENT_LINE, {{{2.00000000e+01f, 5.97000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + /* Figure 37. */ + {SEGMENT_LINE, {{{2.50000000e+01f, 1.45000000e+02f}}}}, + {SEGMENT_LINE, {{{2.50000000e+01f, 7.00000000e+01f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{3.43750000e+01f, 8.40625000e+01f}}}}, + {SEGMENT_LINE, {{{4.37500000e+01f, 7.00000000e+01f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{5.31250000e+01f, 5.59375000e+01f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{6.25000000e+01f, 7.00000000e+01f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{6.25000000e+01f, 1.45000000e+02f}}}}, + {SEGMENT_LINE, {{{6.25000000e+01f, 2.20000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{5.31250000e+01f, 2.05937500e+02f}}}}, + {SEGMENT_LINE, {{{4.37500000e+01f, 2.20000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{3.43750000e+01f, 2.34062500e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{2.50000000e+01f, 2.20000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + /* Figure 38. */ + {SEGMENT_LINE, {{{3.76562500e+01f, 6.34375000e+01f}}}}, + {SEGMENT_LINE, {{{4.50000000e+01f, 3.62500000e+01f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{5.23437500e+01f, 6.34375000e+01f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{7.00000000e+01f, 1.45000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{5.23437500e+01f, 2.26562500e+02f}}}}, + {SEGMENT_LINE, {{{4.50000000e+01f, 2.53750000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{3.76562500e+01f, 2.26562500e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{2.00000000e+01f, 1.45000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + /* Figure 39. */ + {SEGMENT_LINE, {{{2.50000000e+01f, 5.97000000e+02f}}}}, + {SEGMENT_LINE, {{{2.50000000e+01f, 5.22000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{3.43750000e+01f, 5.36062500e+02f}}}}, + {SEGMENT_LINE, {{{4.37500000e+01f, 5.22000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{5.31250000e+01f, 5.07937500e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{6.25000000e+01f, 5.22000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{6.25000000e+01f, 5.97000000e+02f}}}}, + {SEGMENT_LINE, {{{6.25000000e+01f, 6.72000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{5.31250000e+01f, 6.57937500e+02f}}}}, + {SEGMENT_LINE, {{{4.37500000e+01f, 6.72000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{3.43750000e+01f, 6.86062500e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{2.50000000e+01f, 6.72000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + /* Figure 40. */ + {SEGMENT_LINE, {{{3.76562500e+01f, 5.15437500e+02f}}}}, + {SEGMENT_LINE, {{{4.50000000e+01f, 4.88250000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{5.23437500e+01f, 5.15437500e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{7.00000000e+01f, 5.97000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{5.23437500e+01f, 6.78562500e+02f}}}}, + {SEGMENT_LINE, {{{4.50000000e+01f, 7.05750000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{3.76562500e+01f, 6.78562500e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + {SEGMENT_LINE, {{{2.00000000e+01f, 5.97000000e+02f}}}, D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN}, + /* Figure 41. */ + {SEGMENT_BEZIER, {{{1.96464462e+02f, 1.60274170e+02f}, + {1.87625626e+02f, 5.42081528e+01f}, + {2.05303299e+02f, 5.42081528e+01f}}}}, + {SEGMENT_BEZIER, {{{2.05303299e+02f, 1.24918823e+02f}, + {2.31819809e+02f, 8.95634918e+01f}, + {2.31819809e+02f, 1.60274170e+02f}}}}, + {SEGMENT_BEZIER, {{{2.14142136e+02f, 1.60274170e+02f}, + {2.22980972e+02f, 2.66340179e+02f}, + {2.05303299e+02f, 2.66340179e+02f}}}}, + {SEGMENT_BEZIER, {{{2.05303299e+02f, 1.95629517e+02f}, + {1.78786804e+02f, 2.30984833e+02f}, + {1.78786804e+02f, 1.60274170e+02f}}}}, + /* Figure 42. */ + {SEGMENT_BEZIER, {{{2.38890869e+02f, 8.95634918e+01f}, + {2.24748734e+02f, 3.29949493e+01f}, + {2.23864853e+02f, 2.34520386e+02f}}}}, + {SEGMENT_BEZIER, {{{1.73483490e+02f, 2.38055908e+02f}, + {1.87625641e+02f, 2.94624451e+02f}, + {1.88509521e+02f, 9.30990295e+01f}}}}, + /* Figure 43. */ + {SEGMENT_BEZIER, {{{1.16561401e+02f, 4.79886414e+02f}, + {1.07722572e+02f, 3.73820404e+02f}, + {1.25400238e+02f, 3.73820435e+02f}}}}, + {SEGMENT_BEZIER, {{{1.25400238e+02f, 4.44531067e+02f}, + {1.51916748e+02f, 4.09175751e+02f}, + {1.51916733e+02f, 4.79886414e+02f}}}}, + {SEGMENT_BEZIER, {{{1.34239075e+02f, 4.79886414e+02f}, + {1.43077911e+02f, 5.85952454e+02f}, + {1.25400238e+02f, 5.85952454e+02f}}}}, + {SEGMENT_BEZIER, {{{1.25400238e+02f, 5.15241760e+02f}, + {9.88837280e+01f, 5.50597107e+02f}, + {9.88837280e+01f, 4.79886414e+02f}}}}, + /* Figure 44. */ + {SEGMENT_BEZIER, {{{1.58987808e+02f, 4.09175781e+02f}, + {1.44845673e+02f, 3.52607239e+02f}, + {1.43961792e+02f, 5.54132629e+02f}}}}, + {SEGMENT_BEZIER, {{{9.35804291e+01f, 5.57668152e+02f}, + {1.07722565e+02f, 6.14236694e+02f}, + {1.08606453e+02f, 4.12711273e+02f}}}}, }; static const struct expected_geometry_figure expected_figures[] = { @@ -2829,6 +3016,30 @@ static void test_path_geometry(void) {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 20.0f, 612.0f}, 8, &expected_segments[164]}, /* 28 */ {D2D1_FIGURE_BEGIN_HOLLOW, D2D1_FIGURE_END_OPEN, { 40.0f, 20.0f}, 2, &expected_segments[172]}, + /* 29 */ + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 25.0f, 220.0f}, 4, &expected_segments[174]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 20.0f, 145.0f}, 2, &expected_segments[178]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 25.0f, 672.0f}, 4, &expected_segments[180]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 20.0f, 597.0f}, 2, &expected_segments[184]}, + /* 33 */ + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 25.0f, 220.0f}, 6, &expected_segments[186]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 20.0f, 145.0f}, 4, &expected_segments[192]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 25.0f, 672.0f}, 6, &expected_segments[196]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 20.0f, 597.0f}, 4, &expected_segments[202]}, + /* 37 */ + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 25.0f, 220.0f}, 12, &expected_segments[206]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 20.0f, 145.0f}, 8, &expected_segments[218]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 25.0f, 672.0f}, 12, &expected_segments[226]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, { 20.0f, 597.0f}, 8, &expected_segments[238]}, + /* 41 */ + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, + {1.78786804e+02f, 1.60274170e+02f}, 4, &expected_segments[246]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, + {1.88509521e+02f, 9.30990295e+01f}, 2, &expected_segments[250]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, + {9.88837280e+01f, 4.79886414e+02f}, 4, &expected_segments[252]}, + {D2D1_FIGURE_BEGIN_FILLED, D2D1_FIGURE_END_CLOSED, + {1.08606453e+02f, 4.12711273e+02f}, 2, &expected_segments[256]}, };
if (!(device = create_device())) @@ -3070,6 +3281,8 @@ static void test_path_geometry(void)
ID2D1PathGeometry_Release(geometry);
+ + /* GetBounds() with bezier segments. */ hr = ID2D1Factory_CreatePathGeometry(factory, &geometry); ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr); @@ -3087,6 +3300,12 @@ static void test_path_geometry(void) ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n", rect.left, rect.top, rect.right, rect.bottom);
+ ID2D1RenderTarget_BeginDraw(rt); + set_color(&color, 0.396f, 0.180f, 0.537f, 1.0f); + ID2D1RenderTarget_Clear(rt, &color); + ID2D1RenderTarget_FillGeometry(rt, (ID2D1Geometry *)geometry, (ID2D1Brush *)brush, NULL); + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + set_matrix_identity(&matrix); translate_matrix(&matrix, 80.0f, 640.0f); scale_matrix(&matrix, 2.0f, 0.5f); @@ -3556,7 +3775,145 @@ static void test_path_geometry(void) ok(SUCCEEDED(hr), "Failed to simplify geometry, hr %#x.\n", hr); geometry_sink_check(&simplify_sink, D2D1_FILL_MODE_ALTERNATE, 1, &expected_figures[28], 1); geometry_sink_cleanup(&simplify_sink); + ID2D1PathGeometry_Release(geometry); + + /* GetBounds() with cubic bezier segments. */ + hr = ID2D1Factory_CreatePathGeometry(factory, &geometry); + ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr); + hr = ID2D1PathGeometry_Open(geometry, &sink); + ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr); + fill_geometry_sink_cubic_bezier(sink, 0); + hr = ID2D1GeometrySink_Close(sink); + ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr); + ID2D1GeometrySink_Release(sink); + + set_rect(&rect, 0.0f, 0.0f, 0.0f, 0.0f); + hr = ID2D1PathGeometry_GetBounds(geometry, NULL, &rect); + ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr); + match = compare_rect(&rect, 20.0f, 36.25f, 70.0f, 705.75f, 0); + ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n", + rect.left, rect.top, rect.right, rect.bottom); + + set_matrix_identity(&matrix); + translate_matrix(&matrix, 80.0f, 640.0f); + scale_matrix(&matrix, 2.0f, 0.5f); + set_rect(&rect, 0.0f, 0.0f, 0.0f, 0.0f); + hr = ID2D1PathGeometry_GetBounds(geometry, &matrix, &rect); + ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr); + match = compare_rect(&rect, 120.0f, 658.125f, 220.0f, 992.875f, 0); + ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n", + rect.left, rect.top, rect.right, rect.bottom); + + ID2D1PathGeometry_Release(geometry); + + /* GetBounds() with cubic bezier segments and some hollow components. */ + hr = ID2D1Factory_CreatePathGeometry(factory, &geometry); + ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr); + hr = ID2D1PathGeometry_Open(geometry, &sink); + ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr); + fill_geometry_sink_cubic_bezier(sink, 2); + hr = ID2D1GeometrySink_Close(sink); + ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr); + ID2D1GeometrySink_Release(sink); + + set_rect(&rect, 0.0f, 0.0f, 0.0f, 0.0f); + hr = ID2D1PathGeometry_GetBounds(geometry, NULL, &rect); + ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr); + match = compare_rect(&rect, 20.0f, 488.25f, 70.0f, 705.75f, 0); + ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n", + rect.left, rect.top, rect.right, rect.bottom); + + set_matrix_identity(&matrix); + translate_matrix(&matrix, 80.0f, 640.0f); + scale_matrix(&matrix, 2.0f, 0.5f); + set_rect(&rect, 0.0f, 0.0f, 0.0f, 0.0f); + hr = ID2D1PathGeometry_GetBounds(geometry, &matrix, &rect); + ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr); + match = compare_rect(&rect, 120.0f, 884.125f, 220.0f, 992.875f, 0); + ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n", + rect.left, rect.top, rect.right, rect.bottom); + + ID2D1PathGeometry_Release(geometry); + + /* GetBounds() with bezier segments and all hollow components. */ + hr = ID2D1Factory_CreatePathGeometry(factory, &geometry); + ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr); + hr = ID2D1PathGeometry_Open(geometry, &sink); + ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr); + fill_geometry_sink_cubic_bezier(sink, 4); + hr = ID2D1GeometrySink_Close(sink); + ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr); + ID2D1GeometrySink_Release(sink); + + set_rect(&rect, 0.0f, 0.0f, 0.0f, 0.0f); + hr = ID2D1PathGeometry_GetBounds(geometry, NULL, &rect); + ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr); + match = compare_rect(&rect, INFINITY, INFINITY, FLT_MAX, FLT_MAX, 0); + ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n", + rect.left, rect.top, rect.right, rect.bottom); + + set_matrix_identity(&matrix); + translate_matrix(&matrix, 80.0f, 640.0f); + scale_matrix(&matrix, 2.0f, 0.5f); + set_rect(&rect, 0.0f, 0.0f, 0.0f, 0.0f); + hr = ID2D1PathGeometry_GetBounds(geometry, &matrix, &rect); + ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr); + match = compare_rect(&rect, INFINITY, INFINITY, FLT_MAX, FLT_MAX, 0); + ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n", + rect.left, rect.top, rect.right, rect.bottom); + + ID2D1PathGeometry_Release(geometry); + + /* Cubic bezier simplify tests. */ + hr = ID2D1Factory_CreatePathGeometry(factory, &geometry); + ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr); + hr = ID2D1PathGeometry_Open(geometry, &sink); + ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr); + fill_geometry_sink_cubic_bezier(sink, 0); + hr = ID2D1GeometrySink_Close(sink); + ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr); + hr = ID2D1PathGeometry_GetFigureCount(geometry, &count); + ok(SUCCEEDED(hr), "Failed to get figure count, hr %#x.\n", hr); + ok(count == 4, "Got unexpected figure count %u.\n", count); + hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count); + ok(SUCCEEDED(hr), "Failed to get segment count, hr %#x.\n", hr); + ok(count == 16, "Got unexpected segment count %u.\n", count); + ID2D1GeometrySink_Release(sink); + + geometry_sink_init(&simplify_sink); + hr = ID2D1PathGeometry_Simplify(geometry, D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES, + NULL, 0.0f, &simplify_sink.ID2D1SimplifiedGeometrySink_iface); + ok(SUCCEEDED(hr), "Failed to simplify geometry, hr %#x.\n", hr); + geometry_sink_check(&simplify_sink, D2D1_FILL_MODE_ALTERNATE, 4, &expected_figures[29], 1); + geometry_sink_cleanup(&simplify_sink); + geometry_sink_init(&simplify_sink); + hr = ID2D1PathGeometry_Simplify(geometry, D2D1_GEOMETRY_SIMPLIFICATION_OPTION_LINES, + NULL, 100.0f, &simplify_sink.ID2D1SimplifiedGeometrySink_iface); + ok(SUCCEEDED(hr), "Failed to simplify geometry, hr %#x.\n", hr); + geometry_sink_check(&simplify_sink, D2D1_FILL_MODE_ALTERNATE, 4, &expected_figures[33], 1); + geometry_sink_cleanup(&simplify_sink); + geometry_sink_init(&simplify_sink); + hr = ID2D1PathGeometry_Simplify(geometry, D2D1_GEOMETRY_SIMPLIFICATION_OPTION_LINES, + NULL, 10.0f, &simplify_sink.ID2D1SimplifiedGeometrySink_iface); + ok(SUCCEEDED(hr), "Failed to simplify geometry, hr %#x.\n", hr); + geometry_sink_check(&simplify_sink, D2D1_FILL_MODE_ALTERNATE, 4, &expected_figures[37], 1); + geometry_sink_cleanup(&simplify_sink);
+ set_matrix_identity(&matrix); + scale_matrix(&matrix, 0.5f, 2.0f); + translate_matrix(&matrix, 400.0f, -33.0f); + rotate_matrix(&matrix, M_PI / 4.0f); + scale_matrix(&matrix, 2.0f, 0.5f); + hr = ID2D1Factory_CreateTransformedGeometry(factory, (ID2D1Geometry *)geometry, &matrix, &transformed_geometry); + ok(SUCCEEDED(hr), "Failed to create transformed geometry, hr %#x.\n", hr); + + geometry_sink_init(&simplify_sink); + hr = ID2D1TransformedGeometry_Simplify(transformed_geometry, D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES, + NULL, 0.0f, &simplify_sink.ID2D1SimplifiedGeometrySink_iface); + ok(SUCCEEDED(hr), "Failed to simplify geometry, hr %#x.\n", hr); + geometry_sink_check(&simplify_sink, D2D1_FILL_MODE_ALTERNATE, 4, &expected_figures[41], 4); + geometry_sink_cleanup(&simplify_sink); + ID2D1TransformedGeometry_Release(transformed_geometry); ID2D1PathGeometry_Release(geometry);
ID2D1SolidColorBrush_Release(brush);