Commit a8f45dff authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d2d1: Implement d2d_geometry_sink_AddLines().

parent b92a05c8
......@@ -215,6 +215,7 @@ struct d2d_geometry
size_t vertex_count;
struct d2d_face *faces;
size_t faces_size;
size_t face_count;
union
......@@ -223,8 +224,12 @@ struct d2d_geometry
{
ID2D1GeometrySink ID2D1GeometrySink_iface;
struct d2d_figure *figures;
size_t figures_size;
size_t figure_count;
enum d2d_geometry_state state;
UINT32 figure_count, segment_count;
UINT32 segment_count;
} path;
struct
{
......
......@@ -877,12 +877,14 @@ static void test_path_geometry(void)
{
ID2D1GeometrySink *sink, *tmp_sink;
D2D1_POINT_2F point = {0.0f, 0.0f};
ID2D1SolidColorBrush *brush;
ID2D1PathGeometry *geometry;
IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt;
ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Factory *factory;
D2D1_COLOR_F color;
ULONG refcount;
UINT32 count;
HWND window;
......@@ -1054,6 +1056,139 @@ static void test_path_geometry(void)
ok(count == 1, "Got unexpected segment count %u.\n", count);
ID2D1PathGeometry_Release(geometry);
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);
set_point(&point, 15.0f, 20.0f);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
set_point(&point, 55.0f, 20.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 55.0f, 220.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 25.0f, 220.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 25.0f, 100.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 75.0f, 100.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 75.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 5.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 5.0f, 60.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 45.0f, 60.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 45.0f, 180.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 35.0f, 180.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 35.0f, 140.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 65.0f, 140.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 65.0f, 260.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 15.0f, 260.0f);
ID2D1GeometrySink_AddLine(sink, point);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
set_point(&point, 155.0f, 300.0f);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
set_point(&point, 155.0f, 160.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 85.0f, 160.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 85.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 120.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 120.0f, 20.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 155.0f, 20.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 155.0f, 160.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 85.0f, 160.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 85.0f, 20.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 120.0f, 20.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 120.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
set_point(&point, 165.0f, 20.0f);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
set_point(&point, 165.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 235.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 235.0f, 20.0f);
ID2D1GeometrySink_AddLine(sink, point);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
set_point(&point, 225.0f, 60.0f);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
set_point(&point, 225.0f, 260.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 175.0f, 260.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 175.0f, 60.0f);
ID2D1GeometrySink_AddLine(sink, point);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
set_point(&point, 215.0f, 220.0f);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
set_point(&point, 185.0f, 220.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 185.0f, 100.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 215.0f, 100.0f);
ID2D1GeometrySink_AddLine(sink, point);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
set_point(&point, 195.0f, 180.0f);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
set_point(&point, 205.0f, 180.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 205.0f, 140.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 195.0f, 140.0f);
ID2D1GeometrySink_AddLine(sink, point);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
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 == 6, "Got unexpected figure count %u.\n", count);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get segment count, hr %#x.\n", hr);
/* Intersections don't create extra segments. */
ok(count == 44, "Got unexpected segment count %u.\n", count);
ID2D1GeometrySink_Release(sink);
ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f);
ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED);
set_color(&color, 0.890f, 0.851f, 0.600f, 1.0f);
hr = ID2D1RenderTarget_CreateSolidColorBrush(rt, &color, NULL, &brush);
ok(SUCCEEDED(hr), "Failed to create brush, hr %#x.\n", hr);
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);
ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr);
ok(compare_surface(surface, "736d9bf019bcf0be264571c1bd954f07752330ab"), "Surface does not match.\n");
ID2D1PathGeometry_Release(geometry);
ID2D1SolidColorBrush_Release(brush);
ID2D1RenderTarget_Release(rt);
refcount = ID2D1Factory_Release(factory);
ok(!refcount, "Factory has %u references left.\n", refcount);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment