Commit 6bae0a00 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3dx9: Implement D3DXFrameFind().

parent 63e3179c
......@@ -132,7 +132,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -132,7 +132,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -135,7 +135,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -135,7 +135,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -135,7 +135,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -135,7 +135,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -135,7 +135,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -7555,3 +7555,83 @@ HRESULT WINAPI D3DXConvertMeshSubsetToSingleStrip(struct ID3DXBaseMesh *mesh_in,
return E_NOTIMPL;
}
struct frame_node
{
struct list entry;
D3DXFRAME *frame;
};
static BOOL queue_frame_node(struct list *queue, D3DXFRAME *frame)
{
struct frame_node *node;
if (!frame->pFrameFirstChild)
return TRUE;
node = HeapAlloc(GetProcessHeap(), 0, sizeof(*node));
if (!node)
return FALSE;
node->frame = frame;
list_add_tail(queue, &node->entry);
return TRUE;
}
static void empty_frame_queue(struct list *queue)
{
struct frame_node *cur, *cur2;
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, queue, struct frame_node, entry)
{
list_remove(&cur->entry);
HeapFree(GetProcessHeap(), 0, cur);
}
}
D3DXFRAME * WINAPI D3DXFrameFind(const D3DXFRAME *root, const char *name)
{
D3DXFRAME *found = NULL, *frame;
struct list queue;
TRACE("root frame %p, name %s.\n", root, debugstr_a(name));
if (!root)
return NULL;
list_init(&queue);
frame = (D3DXFRAME *)root;
for (;;)
{
struct frame_node *node;
while (frame)
{
if ((name && frame->Name && !strcmp(frame->Name, name)) || (!name && !frame->Name))
{
found = frame;
goto cleanup;
}
if (!queue_frame_node(&queue, frame))
goto cleanup;
frame = frame->pFrameSibling;
}
if (list_empty(&queue))
break;
node = LIST_ENTRY(list_head(&queue), struct frame_node, entry);
list_remove(&node->entry);
frame = node->frame->pFrameFirstChild;
HeapFree(GetProcessHeap(), 0, node);
}
cleanup:
empty_frame_queue(&queue);
return found;
}
......@@ -11188,6 +11188,81 @@ static void D3DXCreateAnimationControllerTest(void)
animation->lpVtbl->Release(animation);
}
static void test_D3DXFrameFind(void)
{
static char n1[] = "name1";
static char n2[] = "name2";
static char n3[] = "name3";
static char n4[] = "name4";
static char n5[] = "name5";
static char n6[] = "name6";
static char N1[] = "Name1";
D3DXFRAME root, sibling, sibling2, child, *ret;
D3DXFRAME child2, child3;
ret = D3DXFrameFind(NULL, NULL);
ok(ret == NULL, "Unexpected frame, %p.\n", ret);
ret = D3DXFrameFind(NULL, "test");
ok(ret == NULL, "Unexpected frame, %p.\n", ret);
memset(&root, 0, sizeof(root));
ret = D3DXFrameFind(&root, NULL);
ok(ret == &root, "Unexpected frame, %p.\n", ret);
root.Name = n1;
ret = D3DXFrameFind(&root, NULL);
ok(ret == NULL, "Unexpected frame, %p.\n", ret);
ret = D3DXFrameFind(&root, n1);
ok(ret == &root, "Unexpected frame, %p.\n", ret);
ret = D3DXFrameFind(&root, N1);
ok(ret == NULL, "Unexpected frame, %p.\n", ret);
/* Test siblings order traversal. */
memset(&sibling, 0, sizeof(sibling));
sibling.Name = n2;
root.pFrameSibling = &sibling;
ret = D3DXFrameFind(&root, n2);
ok(ret == &sibling, "Unexpected frame, %p.\n", ret);
memset(&sibling2, 0, sizeof(sibling2));
sibling2.Name = n2;
sibling.pFrameSibling = &sibling2;
ret = D3DXFrameFind(&root, n2);
ok(ret == &sibling, "Unexpected frame, %p.\n", ret);
sibling2.Name = n3;
ret = D3DXFrameFind(&root, n3);
ok(ret == &sibling2, "Unexpected frame, %p.\n", ret);
/* Siblings first. */
memset(&child, 0, sizeof(child));
child.Name = n2;
root.pFrameFirstChild = &child;
ret = D3DXFrameFind(&root, n2);
ok(ret == &sibling, "Unexpected frame, %p.\n", ret);
child.Name = n4;
ret = D3DXFrameFind(&root, n4);
ok(ret == &child, "Unexpected frame, %p.\n", ret);
/* Link a grandchild and another one for sibling. */
memset(&child2, 0, sizeof(child2));
memset(&child3, 0, sizeof(child3));
child2.Name = child3.Name = n5;
sibling.pFrameFirstChild = &child2;
child.pFrameFirstChild = &child3;
ret = D3DXFrameFind(&root, n5);
ok(ret == &child2, "Unexpected frame, %p.\n", ret);
child3.Name = n6;
ret = D3DXFrameFind(&root, n6);
ok(ret == &child3, "Unexpected frame, %p.\n", ret);
}
START_TEST(mesh)
{
D3DXBoundProbeTest();
......@@ -11218,4 +11293,5 @@ START_TEST(mesh)
test_valid_mesh();
test_optimize_faces();
test_compute_normals();
test_D3DXFrameFind();
}
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -136,7 +136,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -134,7 +134,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
......@@ -134,7 +134,7 @@
@ stub D3DXFrameAppendChild(ptr ptr)
@ stub D3DXFrameCalculateBoundingSphere(ptr ptr ptr)
@ stdcall D3DXFrameDestroy(ptr ptr)
@ stub D3DXFrameFind(ptr str)
@ stdcall D3DXFrameFind(ptr str)
@ stub D3DXFrameNumNamedMatrices(ptr)
@ stub D3DXFrameRegisterNamedMatrices(ptr ptr)
@ stdcall D3DXFresnelTerm(float float)
......
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