[PATCH 4/4] d3drm: Implement IDirect3DRM*::LoadTexture. (v10)
Aaryaman Vasishta
jem456.vasishta at gmail.com
Fri Oct 19 22:59:26 CDT 2018
v10: Remove todo_wine(s) on corresponding tests in previous patch in this series.
v9: Split patch.
v8: Rebased on top of master as of this patch date.
---
dlls/d3drm/d3drm.c | 40 ++++++++++++++++++++++-----
dlls/d3drm/tests/d3drm.c | 58 +++++++++++++++++-----------------------
2 files changed, 58 insertions(+), 40 deletions(-)
diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c
index 3ea16327bf..d0f20235a8 100644
--- a/dlls/d3drm/d3drm.c
+++ b/dlls/d3drm/d3drm.c
@@ -638,12 +638,24 @@ static HRESULT WINAPI d3drm1_LoadTexture(IDirect3DRM *iface,
struct d3drm_texture *object;
HRESULT hr;
- FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
+ TRACE("iface %p, filename %s, texture %p.\n", iface, debugstr_a(filename), texture);
+
+ if (!texture)
+ return D3DRMERR_BADVALUE;
if (FAILED(hr = d3drm_texture_create(&object, iface)))
return hr;
*texture = &object->IDirect3DRMTexture_iface;
+ if (FAILED(hr = IDirect3DRMTexture_InitFromFile(*texture, filename)))
+ {
+ IDirect3DRMTexture_Release(*texture);
+ *texture = NULL;
+ if (!filename)
+ return D3DRMERR_BADVALUE;
+
+ return hr == D3DRMERR_BADOBJECT ? D3DRMERR_FILENOTFOUND : hr;
+ }
return D3DRM_OK;
}
@@ -1143,15 +1155,22 @@ static HRESULT WINAPI d3drm2_LoadTexture(IDirect3DRM2 *iface,
const char *filename, IDirect3DRMTexture2 **texture)
{
struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
- struct d3drm_texture *object;
+ IDirect3DRMTexture3 *texture3;
HRESULT hr;
- FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
+ TRACE("iface %p, filename %s, texture %p.\n", iface, debugstr_a(filename), texture);
- if (FAILED(hr = d3drm_texture_create(&object, &d3drm->IDirect3DRM_iface)))
+ if (!texture)
+ return D3DRMERR_BADVALUE;
+
+ if (FAILED(hr = IDirect3DRM3_LoadTexture(&d3drm->IDirect3DRM3_iface, filename, &texture3)))
+ {
+ *texture = NULL;
return hr;
+ }
- *texture = &object->IDirect3DRMTexture2_iface;
+ hr = IDirect3DRMTexture3_QueryInterface(texture3, &IID_IDirect3DRMTexture2, (void **)texture);
+ IDirect3DRMTexture3_Release(texture3);
return hr;
}
@@ -1818,12 +1837,21 @@ static HRESULT WINAPI d3drm3_LoadTexture(IDirect3DRM3 *iface,
struct d3drm_texture *object;
HRESULT hr;
- FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
+ TRACE("iface %p, filename %s, texture %p.\n", iface, debugstr_a(filename), texture);
+
+ if (!texture)
+ return D3DRMERR_BADVALUE;
if (FAILED(hr = d3drm_texture_create(&object, &d3drm->IDirect3DRM_iface)))
return hr;
*texture = &object->IDirect3DRMTexture3_iface;
+ if (FAILED(hr = IDirect3DRMTexture3_InitFromFile(*texture, filename)))
+ {
+ IDirect3DRMTexture3_Release(*texture);
+ *texture = NULL;
+ return hr == D3DRMERR_BADOBJECT ? D3DRMERR_FILENOTFOUND : hr;
+ }
return D3DRM_OK;
}
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index c5e7478b06..9630187ed9 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -5601,46 +5601,36 @@ static void test_load_texture(void)
/* Test all failures together */
texture1 = (IDirect3DRMTexture *)0xdeadbeef;
hr = IDirect3DRM_LoadTexture(d3drm1, NULL, &texture1);
- todo_wine ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
- todo_wine ok(!texture1, "Expected texture returned == NULL, got %p.\n", texture1);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
+ ok(!texture1, "Expected texture returned == NULL, got %p.\n", texture1);
texture1 = (IDirect3DRMTexture *)0xdeadbeef;
hr = IDirect3DRM_LoadTexture(d3drm1, "", &texture1);
- todo_wine ok(!texture1, "Expected texture returned == NULL, got %p.\n", texture1);
- todo_wine ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
- if (hr == D3DRMERR_FILENOTFOUND)
- {
- hr = IDirect3DRM_LoadTexture(d3drm1, NULL, NULL);
- ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
- }
-
+ ok(!texture1, "Expected texture returned == NULL, got %p.\n", texture1);
+ ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
+ hr = IDirect3DRM_LoadTexture(d3drm1, NULL, NULL);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
hr = IDirect3DRM2_LoadTexture(d3drm2, NULL, &texture2);
- todo_wine ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
- todo_wine ok(!texture2, "Expected texture returned == NULL, got %p.\n", texture2);
+ ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
+ ok(!texture2, "Expected texture returned == NULL, got %p.\n", texture2);
texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
hr = IDirect3DRM2_LoadTexture(d3drm2, "", &texture2);
- todo_wine ok(!texture2, "Expected texture returned == NULL, got %p.\n", texture2);
- todo_wine ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
- if (hr == D3DRMERR_FILENOTFOUND)
- {
- hr = IDirect3DRM2_LoadTexture(d3drm2, NULL, NULL);
- ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
- }
+ ok(!texture2, "Expected texture returned == NULL, got %p.\n", texture2);
+ ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
+ hr = IDirect3DRM2_LoadTexture(d3drm2, NULL, NULL);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
hr = IDirect3DRM3_LoadTexture(d3drm3, NULL, &texture3);
- todo_wine ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
- todo_wine ok(!texture3, "Expected texture returned == NULL, got %p.\n", texture3);
+ ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
+ ok(!texture3, "Expected texture returned == NULL, got %p.\n", texture3);
texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
hr = IDirect3DRM_LoadTexture(d3drm3, "", &texture3);
- todo_wine ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
- todo_wine ok(!texture3, "Expected texture returned == NULL, got %p.\n", texture3);
- if (hr == D3DRMERR_FILENOTFOUND)
- {
- hr = IDirect3DRM3_LoadTexture(d3drm3, NULL, NULL);
- ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
- }
+ ok(hr == D3DRMERR_FILENOTFOUND, "Expected hr == D3DRMERR_FILENOTFOUND, got %#x.\n", hr);
+ ok(!texture3, "Expected texture returned == NULL, got %p.\n", texture3);
+ hr = IDirect3DRM3_LoadTexture(d3drm3, NULL, NULL);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
@@ -5649,10 +5639,10 @@ static void test_load_texture(void)
hr = IDirect3DRM_LoadTexture(d3drm1, filename, &texture1);
ok(SUCCEEDED(hr), "Test %u: Failed to load texture, hr %#x.\n", i, hr);
ref2 = get_refcount((IUnknown *)d3drm1);
- todo_wine ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
+ ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
hr = IDirect3DRMTexture_InitFromFile(texture1, filename);
- todo_wine ok(hr == D3DRMERR_BADOBJECT, "Test %u: Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", i, hr);
+ ok(hr == D3DRMERR_BADOBJECT, "Test %u: Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", i, hr);
/* InitFromFile seems to AddRef IDirect3DRM even if it fails. */
if (FAILED(hr))
IDirect3DRM_Release(d3drm1);
@@ -5679,10 +5669,10 @@ static void test_load_texture(void)
hr = IDirect3DRM2_LoadTexture(d3drm2, filename, &texture2);
ok(SUCCEEDED(hr), "Test %u: Failed to load texture, hr %#x.\n", i, hr);
ref2 = get_refcount((IUnknown *)d3drm1);
- todo_wine ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
+ ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
hr = IDirect3DRMTexture2_InitFromFile(texture2, filename);
- todo_wine ok(hr == D3DRMERR_BADOBJECT, "Test %u: Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", i, hr);
+ ok(hr == D3DRMERR_BADOBJECT, "Test %u: Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", i, hr);
if (FAILED(hr))
IDirect3DRM_Release(d3drm1);
d3drm_img = IDirect3DRMTexture2_GetImage(texture2);
@@ -5708,10 +5698,10 @@ static void test_load_texture(void)
hr = IDirect3DRM3_LoadTexture(d3drm3, filename, &texture3);
ok(SUCCEEDED(hr), "Test %u: Failed to load texture, hr %#x.\n", i, hr);
ref2 = get_refcount((IUnknown *)d3drm1);
- todo_wine ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
+ ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
hr = IDirect3DRMTexture3_InitFromFile(texture3, filename);
- todo_wine ok(hr == D3DRMERR_BADOBJECT, "Test %u: Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", i, hr);
+ ok(hr == D3DRMERR_BADOBJECT, "Test %u: Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", i, hr);
if (FAILED(hr))
IDirect3DRM_Release(d3drm1);
d3drm_img = IDirect3DRMTexture3_GetImage(texture3);
--
2.17.1
More information about the wine-devel
mailing list