Re: [PATCH 6/6] d3drm: Partially implement IDirect3DRM*::LoadTexture. (v4)
See patch 5/6 for the v4 changes. Cheers, Aaryaman On Sun, May 8, 2016 at 4:01 PM, Aaryaman Vasishta <jem456.vasishta(a)gmail.com
wrote:
v4: Removed various leaks, avoided redundant usage of HEAP_ZERO_MEMORY.
Signed-off-by: Aaryaman Vasishta <jem456.vasishta(a)gmail.com> --- dlls/d3drm/d3drm.c | 32 +++++++++++++++++++++++++------- dlls/d3drm/tests/d3drm.c | 33 +++++++++++++-------------------- 2 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c index 6c6007d..c74d5d8 100644 --- a/dlls/d3drm/d3drm.c +++ b/dlls/d3drm/d3drm.c @@ -418,11 +418,18 @@ 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 (FAILED(hr = d3drm_texture_create(&object))) return hr;
+ object->d3drm = iface; + if (FAILED(hr = IDirect3DRMTexture_InitFromFile(&object->IDirect3DRMTexture_iface, filename))) + { + d3drm_texture_destroy(object); + return hr; + } + *texture = &object->IDirect3DRMTexture_iface;
return D3DRM_OK; @@ -861,17 +868,19 @@ static HRESULT WINAPI d3drm2_CreateUserVisual(IDirect3DRM2 *iface, static HRESULT WINAPI d3drm2_LoadTexture(IDirect3DRM2 *iface, const char *filename, IDirect3DRMTexture2 **texture) { - struct d3drm_texture *object; + struct d3drm *d3drm = impl_from_IDirect3DRM2(iface); + 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))) + if (FAILED(hr = IDirect3DRM3_LoadTexture(&d3drm->IDirect3DRM3_iface, filename, &texture3))) return hr;
- *texture = &object->IDirect3DRMTexture2_iface; + hr = IDirect3DRMTexture3_QueryInterface(texture3, &IID_IDirect3DRMTexture2, (void **)texture); + IDirect3DRMTexture3_Release(texture3);
- return D3DRM_OK; + return hr; }
static HRESULT WINAPI d3drm2_LoadTextureFromResource(IDirect3DRM2 *iface, HMODULE module, @@ -1413,14 +1422,23 @@ static HRESULT WINAPI d3drm3_CreateUserVisual(IDirect3DRM3 *iface, static HRESULT WINAPI d3drm3_LoadTexture(IDirect3DRM3 *iface, const char *filename, IDirect3DRMTexture3 **texture) { + struct d3drm *d3drm = impl_from_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 (FAILED(hr = d3drm_texture_create(&object))) return hr;
+ object->d3drm = &d3drm->IDirect3DRM_iface; + if (FAILED(hr = IDirect3DRMTexture3_InitFromFile(&object->IDirect3DRMTexture3_iface, filename))) + { + d3drm_texture_destroy(object); + return hr; + } + + object->d3drm = &d3drm->IDirect3DRM_iface; *texture = &object->IDirect3DRMTexture3_iface;
return D3DRM_OK; diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index e6311d8..4cf3ba7 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -4510,18 +4510,16 @@ 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); + IDirect3DRM_Release(d3drm1);
d3drm_img = IDirect3DRMTexture_GetImage(texture1); ok(!!d3drm_img, "Test %u: Failed to get image.\n", i); - if (d3drm_img) - test_bitmap_data(i * 7, d3drm_img, FALSE, tests[i].w, tests[i].h, tests[i].palettized); + test_bitmap_data(i * 7, d3drm_img, FALSE, tests[i].w, tests[i].h, tests[i].palettized); IDirect3DRMTexture_Release(texture1); ref2 = get_refcount((IUnknown *)d3drm1); ok(ref1 == ref2, "Test %u: expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2); @@ -4537,17 +4535,15 @@ 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); - if (FAILED(hr)) - IDirect3DRM_Release(d3drm1); + ok(hr == D3DRMERR_BADOBJECT, "Test %u: Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", i, hr); + IDirect3DRM_Release(d3drm1);
d3drm_img = IDirect3DRMTexture2_GetImage(texture2); ok(!!d3drm_img, "Test %u: Failed to get image.\n", i); - if (d3drm_img) - test_bitmap_data(i * 7 + 2, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized); + test_bitmap_data(i * 7 + 2, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized); IDirect3DRMTexture2_Release(texture2); ref2 = get_refcount((IUnknown *)d3drm1); ok(ref1 == ref2, "Test %u: expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2); @@ -4563,25 +4559,22 @@ 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); - if (FAILED(hr)) - IDirect3DRM_Release(d3drm1); + ok(hr == D3DRMERR_BADOBJECT, "Test %u: Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", i, hr); + IDirect3DRM_Release(d3drm1);
d3drm_img = IDirect3DRMTexture3_GetImage(texture3); ok(!!d3drm_img, "Test %u: Failed to get image.\n", i); - if (d3drm_img) - test_bitmap_data(i * 7 + 4, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized); + test_bitmap_data(i * 7 + 4, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized); /* Test whether querying a version 1 texture from version 3 causes a * change in the loading behavior. */ hr = IDirect3DRMTexture3_QueryInterface(texture3, &IID_IDirect3DRMTexture, (void **)&texture1); ok(SUCCEEDED(hr), "Failed to get IDirect3DRMTexture interface, hr %#x.\n", hr); d3drm_img = IDirect3DRMTexture_GetImage(texture1); ok(!!d3drm_img, "Test %u: Failed to get image.\n", i); - if (d3drm_img) - test_bitmap_data(i * 7 + 5, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized); + test_bitmap_data(i * 7 + 5, d3drm_img, TRUE, tests[i].w, tests[i].h, tests[i].palettized); IDirect3DRMTexture_Release(texture1); IDirect3DRMTexture3_Release(texture3); ref2 = get_refcount((IUnknown *)d3drm1); -- 2.3.2 (Apple Git-55)
participants (1)
-
Aaryaman Vasishta