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