From: Aaryaman Vasishta Subject: [PATCH 3/4] d3drm: Implement IDirect3DRM*_CreateTexture. Message-Id: <1461871028-61881-3-git-send-email-jem456.vasishta@gmail.com> Date: Fri, 29 Apr 2016 00:47:07 +0530 In-Reply-To: <1461871028-61881-1-git-send-email-jem456.vasishta@gmail.com> References: <1461871028-61881-1-git-send-email-jem456.vasishta@gmail.com> Signed-off-by: Aaryaman Vasishta --- dlls/d3drm/d3drm.c | 45 ++++++++++++++++++++++++++++++++--- dlls/d3drm/tests/d3drm.c | 61 ++++++++++++++++++++++++++++++++++++++++++++---- dlls/d3drm/texture.c | 2 +- 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c index 2b428ef..254c06a 100644 --- a/dlls/d3drm/d3drm.c +++ b/dlls/d3drm/d3drm.c @@ -198,13 +198,24 @@ static HRESULT WINAPI d3drm1_CreateTexture(IDirect3DRM *iface, struct d3drm_texture *object; HRESULT hr; - FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture); + TRACE("iface %p, image %p, texture %p.\n", iface, image, texture); + + if (!d3drm_validate_image(image)) + return D3DRMERR_BADVALUE; if (FAILED(hr = d3drm_texture_create(&object))) + { + d3drm_texture_destroy(object); return hr; + } + object->d3drm = iface; + object->initialized = TRUE; + object->image = image; *texture = &object->IDirect3DRMTexture_iface; + IDirect3DRM_AddRef(iface); + return D3DRM_OK; } @@ -661,13 +672,27 @@ static HRESULT WINAPI d3drm2_CreateAnimationSet(IDirect3DRM2 *iface, IDirect3DRM static HRESULT WINAPI d3drm2_CreateTexture(IDirect3DRM2 *iface, D3DRMIMAGE *image, IDirect3DRMTexture2 **texture) { + struct d3drm *d3drm = impl_from_IDirect3DRM2(iface); struct d3drm_texture *object; HRESULT hr; - FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture); + TRACE("iface %p, image %p, texture %p.\n", iface, image, texture); + + if (!d3drm_validate_image(image)) + return D3DRMERR_BADVALUE; if (FAILED(hr = d3drm_texture_create(&object))) + { + d3drm_texture_destroy(object); return hr; + } + object->d3drm = &d3drm->IDirect3DRM_iface; + + if (FAILED(hr = IDirect3DRMTexture2_InitFromImage(&object->IDirect3DRMTexture2_iface, image))) + { + d3drm_texture_destroy(object); + return hr; + } *texture = &object->IDirect3DRMTexture2_iface; @@ -1152,13 +1177,27 @@ static HRESULT WINAPI d3drm3_CreateAnimationSet(IDirect3DRM3 *iface, IDirect3DRM static HRESULT WINAPI d3drm3_CreateTexture(IDirect3DRM3 *iface, D3DRMIMAGE *image, IDirect3DRMTexture3 **texture) { + struct d3drm *d3drm = impl_from_IDirect3DRM3(iface); struct d3drm_texture *object; HRESULT hr; - FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture); + TRACE("iface %p, image %p, texture %p.\n", iface, image, texture); + + if (!d3drm_validate_image(image)) + return D3DRMERR_BADVALUE; if (FAILED(hr = d3drm_texture_create(&object))) + { + d3drm_texture_destroy(object); return hr; + } + object->d3drm = &d3drm->IDirect3DRM_iface; + + if (FAILED(hr = IDirect3DRMTexture3_InitFromImage(&object->IDirect3DRMTexture3_iface, image))) + { + d3drm_texture_destroy(object); + return hr; + } *texture = &object->IDirect3DRMTexture3_iface; diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index f202b95..efecd37 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1725,11 +1725,62 @@ static void test_Texture(void) hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3); ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr); + /* Tests for validation of D3DRMIMAGE struct */ + hr = IDirect3DRM_CreateTexture(d3drm1, &testimg, &texture1); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %x)\n", hr); + hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg, &texture2); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %x)\n", hr); + hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %x)\n", hr); + IDirect3DRMTexture_Release(texture1); + IDirect3DRMTexture2_Release(texture2); + IDirect3DRMTexture3_Release(texture3); + + initimg.rgb = 0; + hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + initimg.rgb = 1; + initimg.red_mask = 0; + hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + initimg.red_mask = 0x000000ff; + initimg.green_mask = 0; + hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + initimg.green_mask = 0x0000ff00; + initimg.blue_mask = 0; + hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + initimg.blue_mask = 0x00ff0000; + initimg.buffer1 = NULL; + hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); + initimg.buffer1 = &pixel; hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %x)\n", hr); ref2 = get_refcount((IUnknown *)d3drm1); - todo_wine ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2); + ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2); ref3 = get_refcount((IUnknown *)d3drm2); ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3); ref4 = get_refcount((IUnknown *)d3drm3); @@ -1737,7 +1788,7 @@ static void test_Texture(void) hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %x)\n", hr); ref2 = get_refcount((IUnknown *)d3drm1); - todo_wine ok(ref2 > ref1 + 1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2); + ok(ref2 > ref1 + 1, "expected ref2 > (ref1 + 1), got ref1 = %u , ref2 = %u.\n", ref1, ref2); ref3 = get_refcount((IUnknown *)d3drm2); ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3); ref4 = get_refcount((IUnknown *)d3drm3); @@ -1745,7 +1796,7 @@ static void test_Texture(void) hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3); ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %x)\n", hr); ref2 = get_refcount((IUnknown *)d3drm1); - todo_wine ok(ref2 > ref1 + 2, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2); + ok(ref2 > ref1 + 2, "expected ref2 > (ref1 + 2), got ref1 = %u , ref2 = %u.\n", ref1, ref2); ref3 = get_refcount((IUnknown *)d3drm2); ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3); ref4 = get_refcount((IUnknown *)d3drm3); @@ -1803,7 +1854,7 @@ static void test_Texture(void) IDirect3DRMTexture_Release(texture1); ref2 = get_refcount((IUnknown *)d3drm1); - todo_wine ok(ref2 - 2 == ref1, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2); + ok(ref2 - 2 == ref1, "expected (ref2 - 2) == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2); ref3 = get_refcount((IUnknown *)d3drm2); ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1, ref3); ref4 = get_refcount((IUnknown *)d3drm3); @@ -1827,7 +1878,7 @@ static void test_Texture(void) IDirect3DRMTexture2_Release(texture2); ref2 = get_refcount((IUnknown *)d3drm1); - todo_wine ok(ref2 - 1 == ref1, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2); + ok(ref2 - 1 == ref1, "expected (ref2 - 1) == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2); ref3 = get_refcount((IUnknown *)d3drm2); ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1, ref3); ref4 = get_refcount((IUnknown *)d3drm3); diff --git a/dlls/d3drm/texture.c b/dlls/d3drm/texture.c index 8df58cc..3e0383a 100644 --- a/dlls/d3drm/texture.c +++ b/dlls/d3drm/texture.c @@ -46,7 +46,7 @@ static inline struct d3drm_texture *impl_from_IDirect3DRMTexture3(IDirect3DRMTex void d3drm_texture_destroy(struct d3drm_texture *texture) { - if (texture->d3drm && texture->initialized) + if (texture->initialized) IDirect3DRM_Release(texture->d3drm); HeapFree(GetProcessHeap(), 0, texture); } -- 2.3.2 (Apple Git-55)