<div dir="ltr">Please take a look at v2 of this patch and v2 of patch 2/4. 1/4 and 4/4 are there as well but are way down the list so should I resend the whole patch set instead?<div><br></div><div>Cheers</div><div>Aaryaman</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 30, 2016 at 4:54 PM, Aaryaman Vasishta <span dir="ltr"><<a href="mailto:jem456.vasishta@gmail.com" target="_blank">jem456.vasishta@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Aaryaman Vasishta <<a href="mailto:jem456.vasishta@gmail.com" target="_blank">jem456.vasishta@gmail.com</a>><br>
---<br>
 dlls/d3drm/d3drm.c       | 37 ++++++++++++++++++++---------<br>
 dlls/d3drm/tests/d3drm.c | 61 ++++++++++++++++++++++++++++++++++++++++++++----<br>
 dlls/d3drm/texture.c     |  2 +-<br>
 3 files changed, 83 insertions(+), 17 deletions(-)<br>
<br>
diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c<br>
index 2b428ef..6c6007d 100644<br>
--- a/dlls/d3drm/d3drm.c<br>
+++ b/dlls/d3drm/d3drm.c<br>
@@ -195,17 +195,19 @@ static HRESULT WINAPI d3drm1_CreateAnimationSet(IDirect3DRM *iface, IDirect3DRMA<br>
 static HRESULT WINAPI d3drm1_CreateTexture(IDirect3DRM *iface,<br>
         D3DRMIMAGE *image, IDirect3DRMTexture **texture)<br>
 {<br>
-    struct d3drm_texture *object;<br>
+    struct d3drm *d3drm = impl_from_IDirect3DRM(iface);<br>
+    IDirect3DRMTexture3 *texture3;<br>
     HRESULT hr;<br>
<br>
-    FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);<br>
+    TRACE("iface %p, image %p, texture %p.\n", iface, image, texture);<br>
<br>
-    if (FAILED(hr = d3drm_texture_create(&object)))<br>
+    if (FAILED(hr = IDirect3DRM3_CreateTexture(&d3drm->IDirect3DRM3_iface, image, &texture3)))<br>
         return hr;<br>
<br>
-    *texture = &object->IDirect3DRMTexture_iface;<br>
+    hr = IDirect3DRMTexture3_QueryInterface(texture3, &IID_IDirect3DRMTexture, (void **)texture);<br>
+    IDirect3DRMTexture3_Release(texture3);<br>
<br>
-    return D3DRM_OK;<br>
+    return hr;<br>
 }<br>
<br>
 static HRESULT WINAPI d3drm1_CreateLight(IDirect3DRM *iface,<br>
@@ -661,17 +663,19 @@ static HRESULT WINAPI d3drm2_CreateAnimationSet(IDirect3DRM2 *iface, IDirect3DRM<br>
 static HRESULT WINAPI d3drm2_CreateTexture(IDirect3DRM2 *iface,<br>
         D3DRMIMAGE *image, IDirect3DRMTexture2 **texture)<br>
 {<br>
-    struct d3drm_texture *object;<br>
+    struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);<br>
+    IDirect3DRMTexture3 *texture3;<br>
     HRESULT hr;<br>
<br>
-    FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);<br>
+    TRACE("iface %p, image %p, texture %p.\n", iface, image, texture);<br>
<br>
-    if (FAILED(hr = d3drm_texture_create(&object)))<br>
+    if (FAILED(hr = IDirect3DRM3_CreateTexture(&d3drm->IDirect3DRM3_iface, image, &texture3)))<br>
         return hr;<br>
<br>
-    *texture = &object->IDirect3DRMTexture2_iface;<br>
+    hr = IDirect3DRMTexture3_QueryInterface(texture3, &IID_IDirect3DRMTexture2, (void **)texture);<br>
+    IDirect3DRMTexture3_Release(texture3);<br>
<br>
-    return D3DRM_OK;<br>
+    return hr;<br>
 }<br>
<br>
 static HRESULT WINAPI d3drm2_CreateLight(IDirect3DRM2 *iface,<br>
@@ -1152,13 +1156,24 @@ static HRESULT WINAPI d3drm3_CreateAnimationSet(IDirect3DRM3 *iface, IDirect3DRM<br>
 static HRESULT WINAPI d3drm3_CreateTexture(IDirect3DRM3 *iface,<br>
         D3DRMIMAGE *image, IDirect3DRMTexture3 **texture)<br>
 {<br>
+    struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);<br>
     struct d3drm_texture *object;<br>
     HRESULT hr;<br>
<br>
-    FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);<br>
+    TRACE("iface %p, image %p, texture %p.\n", iface, image, texture);<br>
+<br>
+    if (!d3drm_validate_image(image))<br>
+        return D3DRMERR_BADVALUE;<br>
<br>
     if (FAILED(hr = d3drm_texture_create(&object)))<br>
         return hr;<br>
+    object->d3drm = &d3drm->IDirect3DRM_iface;<br>
+<br>
+    if (FAILED(hr = IDirect3DRMTexture3_InitFromImage(&object->IDirect3DRMTexture3_iface, image)))<br>
+    {<br>
+        d3drm_texture_destroy(object);<br>
+        return hr;<br>
+    }<br>
<br>
     *texture = &object->IDirect3DRMTexture3_iface;<br>
<br>
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c<br>
index 2a70ca4..3a32e6d 100644<br>
--- a/dlls/d3drm/tests/d3drm.c<br>
+++ b/dlls/d3drm/tests/d3drm.c<br>
@@ -1725,11 +1725,62 @@ static void test_Texture(void)<br>
     hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);<br>
     ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);<br>
<br>
+    /* Tests for validation of D3DRMIMAGE struct */<br>
+    hr = IDirect3DRM_CreateTexture(d3drm1, &testimg, &texture1);<br>
+    ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %x)\n", hr);<br>
+    hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg, &texture2);<br>
+    ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %x)\n", hr);<br>
+    hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3);<br>
+    ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %x)\n", hr);<br>
+    IDirect3DRMTexture_Release(texture1);<br>
+    IDirect3DRMTexture2_Release(texture2);<br>
+    IDirect3DRMTexture3_Release(texture3);<br>
+<br>
+    initimg.rgb = 0;<br>
+    hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    initimg.rgb = 1;<br>
+    initimg.red_mask = 0;<br>
+    hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    initimg.red_mask = 0x000000ff;<br>
+    initimg.green_mask = 0;<br>
+    hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    initimg.green_mask = 0x0000ff00;<br>
+    initimg.blue_mask = 0;<br>
+    hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    initimg.blue_mask = 0x00ff0000;<br>
+    initimg.buffer1 = NULL;<br>
+    hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+    hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);<br>
+    ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);<br>
+<br>
     initimg.buffer1 = &pixel;<br>
     hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);<br>
     ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %x)\n", hr);<br>
     ref2 = get_refcount((IUnknown *)d3drm1);<br>
-    todo_wine ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);<br>
+    ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);<br>
     ref3 = get_refcount((IUnknown *)d3drm2);<br>
     ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);<br>
     ref4 = get_refcount((IUnknown *)d3drm3);<br>
@@ -1737,7 +1788,7 @@ static void test_Texture(void)<br>
     hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);<br>
     ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %x)\n", hr);<br>
     ref2 = get_refcount((IUnknown *)d3drm1);<br>
-    todo_wine ok(ref2 > ref1 + 1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);<br>
+    ok(ref2 > ref1 + 1, "expected ref2 > (ref1 + 1), got ref1 = %u , ref2 = %u.\n", ref1, ref2);<br>
     ref3 = get_refcount((IUnknown *)d3drm2);<br>
     ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);<br>
     ref4 = get_refcount((IUnknown *)d3drm3);<br>
@@ -1745,7 +1796,7 @@ static void test_Texture(void)<br>
     hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);<br>
     ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %x)\n", hr);<br>
     ref2 = get_refcount((IUnknown *)d3drm1);<br>
-    todo_wine ok(ref2 > ref1 + 2, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);<br>
+    ok(ref2 > ref1 + 2, "expected ref2 > (ref1 + 2), got ref1 = %u , ref2 = %u.\n", ref1, ref2);<br>
     ref3 = get_refcount((IUnknown *)d3drm2);<br>
     ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);<br>
     ref4 = get_refcount((IUnknown *)d3drm3);<br>
@@ -1803,7 +1854,7 @@ static void test_Texture(void)<br>
<br>
     IDirect3DRMTexture_Release(texture1);<br>
     ref2 = get_refcount((IUnknown *)d3drm1);<br>
-    todo_wine ok(ref2 - 2 == ref1, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);<br>
+    ok(ref2 - 2 == ref1, "expected (ref2 - 2) == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);<br>
     ref3 = get_refcount((IUnknown *)d3drm2);<br>
     ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1, ref3);<br>
     ref4 = get_refcount((IUnknown *)d3drm3);<br>
@@ -1827,7 +1878,7 @@ static void test_Texture(void)<br>
<br>
     IDirect3DRMTexture2_Release(texture2);<br>
     ref2 = get_refcount((IUnknown *)d3drm1);<br>
-    todo_wine ok(ref2 - 1 == ref1, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);<br>
+    ok(ref2 - 1 == ref1, "expected (ref2 - 1) == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);<br>
     ref3 = get_refcount((IUnknown *)d3drm2);<br>
     ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1, ref3);<br>
     ref4 = get_refcount((IUnknown *)d3drm3);<br>
diff --git a/dlls/d3drm/texture.c b/dlls/d3drm/texture.c<br>
index 7db3ecd..883be82 100644<br>
--- a/dlls/d3drm/texture.c<br>
+++ b/dlls/d3drm/texture.c<br>
@@ -46,7 +46,7 @@ static inline struct d3drm_texture *impl_from_IDirect3DRMTexture3(IDirect3DRMTex<br>
<br>
 void d3drm_texture_destroy(struct d3drm_texture *texture)<br>
 {<br>
-    if (texture->d3drm && texture->initialized)<br>
+    if (texture->initialized)<br>
         IDirect3DRM_Release(texture->d3drm);<br>
     HeapFree(GetProcessHeap(), 0, texture);<br>
 }<br>
<span><font color="#888888">--<br>
2.3.2 (Apple Git-55)<br>
<br>
</font></span></blockquote></div><br></div></div>