Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/d3d9/tests/d3d9ex.c | 21 +++++++++++---------- dlls/d3d9/tests/visual.c | 19 +++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c index 17dd3c5c12e..5b24f6b05eb 100644 --- a/dlls/d3d9/tests/d3d9ex.c +++ b/dlls/d3d9/tests/d3d9ex.c @@ -48,18 +48,19 @@ static BOOL adapter_is_warp(const D3DADAPTER_IDENTIFIER9 *identifier) return !strcmp(identifier->Driver, "d3d10warp.dll"); }
-static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff) +static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff) { - unsigned int i; + unsigned int diff = x > y ? x - y : y - x;
- for (i = 0; i < 4; ++i) - { - if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) - return FALSE; - c1 >>= 8; - c2 >>= 8; - } - return TRUE; + return diff <= max_diff; +} + +static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff) +{ + 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 DWORD get_pixel_color(IDirect3DDevice9Ex *device, unsigned int x, unsigned int y) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 9ceb758c605..92116b3eb83 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -63,16 +63,19 @@ static HWND create_window(void) return hwnd; }
+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((int)(c1 & 0xff) - (int)(c2 & 0xff)) > max_diff) return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((int)(c1 & 0xff) - (int)(c2 & 0xff)) > max_diff) return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((int)(c1 & 0xff) - (int)(c2 & 0xff)) > max_diff) return FALSE; - c1 >>= 8; c2 >>= 8; - if (abs((int)(c1 & 0xff) - (int)(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)