d2d1: Properly check if a face is real in d2d_path_geometry_add_face().

In particular, the existing test may fail if the convex hull has only three
vertices.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2015-10-08 20:07:43 +02:00 committed by Alexandre Julliard
parent a3c3409796
commit c575f04b68
2 changed files with 41 additions and 2 deletions

View File

@ -1234,8 +1234,7 @@ static BOOL d2d_path_geometry_add_face(struct d2d_geometry *geometry, const stru
probe.x += cdt->vertices[d2d_cdt_edge_origin(cdt, &tmp)].x * 0.50f; probe.x += cdt->vertices[d2d_cdt_edge_origin(cdt, &tmp)].x * 0.50f;
probe.y += cdt->vertices[d2d_cdt_edge_origin(cdt, &tmp)].y * 0.50f; probe.y += cdt->vertices[d2d_cdt_edge_origin(cdt, &tmp)].y * 0.50f;
d2d_cdt_edge_next_left(cdt, &tmp, &tmp); if (d2d_cdt_leftof(cdt, face->v[2], base_edge) && d2d_path_geometry_point_inside(geometry, &probe))
if (tmp.idx == base_edge->idx && d2d_path_geometry_point_inside(geometry, &probe))
++geometry->face_count; ++geometry->face_count;
return TRUE; return TRUE;

View File

@ -1630,6 +1630,46 @@ static void test_path_geometry(void)
ID2D1TransformedGeometry_Release(transformed_geometry); ID2D1TransformedGeometry_Release(transformed_geometry);
ID2D1PathGeometry_Release(geometry); 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, 40.0f, 20.0f);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
set_point(&point, 75.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 5.0f, 300.0f);
ID2D1GeometrySink_AddLine(sink, point);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
set_point(&point, 40.0f, 290.0f);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
set_point(&point, 55.0f, 160.0f);
ID2D1GeometrySink_AddLine(sink, point);
set_point(&point, 25.0f, 160.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 == 2, "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 == 6, "Got unexpected segment count %u.\n", count);
ID2D1GeometrySink_Release(sink);
ID2D1RenderTarget_BeginDraw(rt);
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);
match = compare_surface(surface, "a875e68e0cb9c055927b1b50b879f90b24e38470");
ok(match, "Surface does not match.\n");
ID2D1PathGeometry_Release(geometry);
ID2D1SolidColorBrush_Release(brush); ID2D1SolidColorBrush_Release(brush);
ID2D1RenderTarget_Release(rt); ID2D1RenderTarget_Release(rt);
refcount = ID2D1Factory_Release(factory); refcount = ID2D1Factory_Release(factory);