Henri Verbeet : d3dx9/tests: Introduce compare_uint().
Alexandre Julliard
julliard at winehq.org
Mon Mar 30 16:24:28 CDT 2020
Module: wine
Branch: master
Commit: 9bcb1f5195d1e65e0e7afb288d36fee716fe3a60
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9bcb1f5195d1e65e0e7afb288d36fee716fe3a60
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Mon Mar 30 20:48:15 2020 +0430
d3dx9/tests: Introduce compare_uint().
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3dx9_36/tests/texture.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index 2688559c2c..bec7ba4827 100644
--- a/dlls/d3dx9_36/tests/texture.c
+++ b/dlls/d3dx9_36/tests/texture.c
@@ -146,20 +146,19 @@ static inline void expect_vec4_(unsigned int line, const D3DXVECTOR4 *expected,
got->x, got->y, got->z, got->w);
}
+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 compare_color(DWORD c1, DWORD 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 is_autogenmipmap_supported(IDirect3DDevice9 *device, D3DRESOURCETYPE resource_type)
More information about the wine-cvs
mailing list