Chip Davis : d3d8/tests: Introduce compare_uint().
Module: wine Branch: master Commit: 67af6800a285058bb436eafc31d231a97490bb78 URL: https://source.winehq.org/git/wine.git/?a=commit;h=67af6800a285058bb436eafc3... Author: Chip Davis <cdavis(a)codeweavers.com> Date: Mon Mar 30 20:48:08 2020 +0430 d3d8/tests: Introduce compare_uint(). Signed-off-by: Chip Davis <cdavis(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3d8/tests/visual.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index ab194b9ced..fc8a05a3c4 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -51,16 +51,19 @@ static HWND create_window(void) 0, 0, rect.right - rect.left, rect.bottom - rect.top, 0, 0, 0, 0); } +static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff) +{ + unsigned int diff = x > y ? x - y : y - x; + + return diff <= max_diff; +} + static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff) { - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; - return TRUE; + return compare_uint(c1 & 0xff, c2 & 0xff, max_diff) + && compare_uint((c1 >> 8) & 0xff, (c2 >> 8) & 0xff, max_diff) + && compare_uint((c1 >> 16) & 0xff, (c2 >> 16) & 0xff, max_diff) + && compare_uint((c1 >> 24) & 0xff, (c2 >> 24) & 0xff, max_diff); } static BOOL compare_float(float f, float g, unsigned int ulps)
participants (1)
-
Alexandre Julliard