[PATCH 6/6] d2d1: Ensure that hollow figures do not impact geometry bounds.
Giovanni Mascellani
gio at debian.org
Wed Jan 29 06:04:59 CST 2020
Signed-off-by: Giovanni Mascellani <gio at debian.org>
---
dlls/d2d1/geometry.c | 21 ++++++++++++++++++++-
dlls/d2d1/tests/d2d1.c | 8 ++++----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/dlls/d2d1/geometry.c b/dlls/d2d1/geometry.c
index afdfa9190f..3662291160 100644
--- a/dlls/d2d1/geometry.c
+++ b/dlls/d2d1/geometry.c
@@ -3097,8 +3097,17 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetBounds(ID2D1PathGeometry *
{
if (geometry->u.path.bounds.left > geometry->u.path.bounds.right)
{
- for (i = 0; i < geometry->u.path.figure_count; ++i)
+ for (i = 0; i < geometry->u.path.figure_count; ++i) {
+ if (geometry->u.path.figures[i].flags & D2D_FIGURE_FLAG_HOLLOW)
+ continue;
d2d_rect_union(&geometry->u.path.bounds, &geometry->u.path.figures[i].bounds);
+ }
+ if (geometry->u.path.bounds.left > geometry->u.path.bounds.right) {
+ geometry->u.path.bounds.left = 1.0f / 0.0f;
+ geometry->u.path.bounds.right = FLT_MAX;
+ geometry->u.path.bounds.top = 1.0f / 0.0f;
+ geometry->u.path.bounds.bottom = FLT_MAX;
+ }
}
*bounds = geometry->u.path.bounds;
@@ -3113,6 +3122,9 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetBounds(ID2D1PathGeometry *
D2D1_POINT_2F p, p1, p2;
size_t j, bezier_idx;
+ if (figure->flags & D2D_FIGURE_FLAG_HOLLOW)
+ continue;
+
/* Single vertex figures are reduced by CloseFigure(). */
if (figure->vertex_count == 0)
{
@@ -3179,6 +3191,13 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetBounds(ID2D1PathGeometry *
}
}
+ if (bounds->left > bounds->right) {
+ bounds->left = 1.0f / 0.0f;
+ bounds->right = FLT_MAX;
+ bounds->top = 1.0f / 0.0f;
+ bounds->bottom = FLT_MAX;
+ }
+
return S_OK;
}
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index b4de61bfe3..52089c4cbc 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -3112,7 +3112,7 @@ static void test_path_geometry(void)
hr = ID2D1PathGeometry_GetBounds(geometry, NULL, &rect);
ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr);
match = compare_rect(&rect, 5.0f, 472.0f, 75.0f, 752.0f, 0);
- todo_wine ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n",
+ ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n",
rect.left, rect.top, rect.right, rect.bottom);
set_matrix_identity(&matrix);
@@ -3122,7 +3122,7 @@ static void test_path_geometry(void)
hr = ID2D1PathGeometry_GetBounds(geometry, &matrix, &rect);
ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr);
match = compare_rect(&rect, 90.0f, 876.0f, 230.0f, 1016.0f, 0);
- todo_wine ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n",
+ ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n",
rect.left, rect.top, rect.right, rect.bottom);
ID2D1PathGeometry_Release(geometry);
@@ -3141,7 +3141,7 @@ static void test_path_geometry(void)
hr = ID2D1PathGeometry_GetBounds(geometry, NULL, &rect);
ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr);
match = compare_rect(&rect, 1.0f / 0.0f, 1.0f / 0.0f, FLT_MAX, FLT_MAX, 0);
- todo_wine ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n",
+ ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n",
rect.left, rect.top, rect.right, rect.bottom);
set_matrix_identity(&matrix);
@@ -3151,7 +3151,7 @@ static void test_path_geometry(void)
hr = ID2D1PathGeometry_GetBounds(geometry, &matrix, &rect);
ok(SUCCEEDED(hr), "Failed to get geometry bounds, hr %#x.\n", hr);
match = compare_rect(&rect, 1.0f / 0.0f, 1.0f / 0.0f, FLT_MAX, FLT_MAX, 0);
- todo_wine ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n",
+ ok(match, "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.\n",
rect.left, rect.top, rect.right, rect.bottom);
ID2D1PathGeometry_Release(geometry);
--
2.25.0
More information about the wine-devel
mailing list