Module: wine Branch: master Commit: 722469254daec2093f3dc8bacb6474a20dc10dfa URL: https://source.winehq.org/git/wine.git/?a=commit;h=722469254daec2093f3dc8bac...
Author: Giovanni Mascellani gio@debian.org Date: Thu Jan 30 17:54:42 2020 +0330
d2d1: Ensure that hollow figures do not impact geometry bounds.
Signed-off-by: Giovanni Mascellani gio@debian.org Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d2d1/geometry.c | 25 ++++++++++++++++++++++++- dlls/d2d1/tests/d2d1.c | 8 ++++---- 2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/dlls/d2d1/geometry.c b/dlls/d2d1/geometry.c index 6e1c648707..e7bb809359 100644 --- a/dlls/d2d1/geometry.c +++ b/dlls/d2d1/geometry.c @@ -3097,10 +3097,22 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetBounds(ID2D1PathGeometry *
if (!transform) { - if (geometry->u.path.bounds.left > geometry->u.path.bounds.right) + if (geometry->u.path.bounds.left > geometry->u.path.bounds.right + && !isinf(geometry->u.path.bounds.left)) { 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 = INFINITY; + geometry->u.path.bounds.right = FLT_MAX; + geometry->u.path.bounds.top = INFINITY; + geometry->u.path.bounds.bottom = FLT_MAX; + } }
*bounds = geometry->u.path.bounds; @@ -3115,6 +3127,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) { @@ -3181,6 +3196,14 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetBounds(ID2D1PathGeometry * } }
+ if (bounds->left > bounds->right) + { + bounds->left = INFINITY; + bounds->right = FLT_MAX; + bounds->top = INFINITY; + bounds->bottom = FLT_MAX; + } + return S_OK; }
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 65233c26df..319246a0bc 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -3114,7 +3114,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); @@ -3124,7 +3124,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); @@ -3143,7 +3143,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, INFINITY, INFINITY, 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); @@ -3153,7 +3153,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, INFINITY, INFINITY, 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);