Henri Verbeet : d3drm/tests: Introduce compare_uint().
Alexandre Julliard
julliard at winehq.org
Mon Mar 30 16:24:28 CDT 2020
Module: wine
Branch: master
Commit: 83666361c9b83f739558533ae9a02a7834682f1c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=83666361c9b83f739558533ae9a02a7834682f1c
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Mon Mar 30 20:48:14 2020 +0430
d3drm/tests: Introduce compare_uint().
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3drm/tests/d3drm.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index 6821bca50f..25e9b4e0ac 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -103,6 +103,21 @@ static void vector_eq_(unsigned int line, const D3DVECTOR *left, const D3DVECTOR
expect_vector_(line, left, U1(*right).x, U2(*right).y, U3(*right).z, 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 compare_color(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 D3DRMMATRIX4D identity = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
@@ -6714,18 +6729,6 @@ static IDirect3DDevice2 *create_device2_without_ds(IDirectDraw2 *ddraw, HWND win
return device;
}
-static BOOL compare_color(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
-{
- if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
- c1 >>= 8; c2 >>= 8;
- if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
- c1 >>= 8; c2 >>= 8;
- if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
- c1 >>= 8; c2 >>= 8;
- if ((c1 & 0xff) - (c2 & 0xff) > max_diff) return FALSE;
- return TRUE;
-}
-
static void clear_depth_surface(IDirectDrawSurface *surface, DWORD value)
{
HRESULT hr;
More information about the wine-cvs
mailing list