Commit 53b1b034 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

evr/tests: Simplify d3d9 device creation helper.

parent 895bb6f2
......@@ -49,10 +49,14 @@ static HWND create_window(void)
0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
}
static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window)
static IDirect3DDevice9 *create_device(HWND focus_window)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
IDirect3DDevice9 *device = NULL;
IDirect3D9 *d3d9;
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d9, "Failed to create a D3D object.\n");
present_parameters.BackBufferWidth = 640;
present_parameters.BackBufferHeight = 480;
......@@ -66,6 +70,8 @@ static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window)
IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, focus_window,
D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
IDirect3D9_Release(d3d9);
return device;
}
......@@ -719,16 +725,13 @@ static void test_surface_sample(void)
DWORD flags, count, length;
IDirect3DDevice9 *device;
IMFSample *sample;
IDirect3D9 *d3d;
IUnknown *unk;
HWND window;
HRESULT hr;
BYTE *data;
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window)))
if (!(device = create_device(window)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
......@@ -930,7 +933,6 @@ static void test_surface_sample(void)
done:
if (backbuffer)
IDirect3DSurface9_Release(backbuffer);
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
......@@ -945,7 +947,6 @@ static void test_default_mixer_type_negotiation(void)
IMFTransform *transform;
DWORD index, count;
GUID guid, *guids;
IDirect3D9 *d3d;
IUnknown *unk;
HWND window;
HRESULT hr;
......@@ -981,9 +982,7 @@ static void test_default_mixer_type_negotiation(void)
/* Now try with device manager. */
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window)))
if (!(device = create_device(window)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
......@@ -1118,7 +1117,6 @@ todo_wine
done:
IMFTransform_Release(transform);
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
......@@ -1341,7 +1339,6 @@ static void test_MFCreateVideoSampleAllocator(void)
LONG refcount, count;
unsigned int token;
IMFGetService *gs;
IDirect3D9 *d3d;
IUnknown *unk;
HWND window;
HRESULT hr;
......@@ -1456,9 +1453,7 @@ static void test_MFCreateVideoSampleAllocator(void)
/* Using device manager */
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window)))
if (!(device = create_device(window)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
......@@ -1507,7 +1502,6 @@ static void test_MFCreateVideoSampleAllocator(void)
IDirect3DDeviceManager9_Release(manager);
IDirect3DDevice9_Release(device);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
......@@ -2102,7 +2096,6 @@ static void test_presenter_media_type(void)
IDirect3DDeviceManager9 *manager;
HRESULT hr;
IMFTransform *mixer;
IDirect3D9 *d3d;
IDirect3DDevice9 *device;
unsigned int token;
SIZE frame_size;
......@@ -2112,9 +2105,7 @@ static void test_presenter_media_type(void)
RECT dst;
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window)))
if (!(device = create_device(window)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
......@@ -2196,7 +2187,6 @@ todo_wine {
IMFTransform_Release(mixer);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
......@@ -2439,16 +2429,13 @@ static void test_mixer_samples(void)
DWORD count, flags, color, status;
IMFTransform *mixer;
IMFSample *sample, *sample2;
IDirect3D9 *d3d;
HWND window;
UINT token;
HRESULT hr;
LONGLONG pts, duration;
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window)))
if (!(device = create_device(window)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
......@@ -2678,7 +2665,6 @@ static void test_mixer_samples(void)
IDirect3DDeviceManager9_Release(manager);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment