Commit 94bab100 authored by Aaryaman Vasishta's avatar Aaryaman Vasishta Committed by Alexandre Julliard

d3drm: Use a table in d3drm3_CreateObject() to create objects in a generic manner.

parent 275eb8ab
......@@ -51,6 +51,19 @@ static const char* get_IID_string(const GUID* guid)
return "?";
}
static HRESULT d3drm_create_texture_object(void **object, IDirect3DRM *d3drm)
{
struct d3drm_texture *texture;
HRESULT hr;
if (FAILED(hr = d3drm_texture_create(&texture, d3drm)))
return hr;
*object = &texture->IDirect3DRMTexture_iface;
return hr;
}
struct d3drm
{
IDirect3DRM IDirect3DRM_iface;
......@@ -1106,8 +1119,19 @@ static HRESULT WINAPI d3drm3_CreateObject(IDirect3DRM3 *iface,
{
struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
IUnknown *object;
unsigned int i;
HRESULT hr;
static const struct
{
const CLSID *clsid;
HRESULT (*create_object)(void **object, IDirect3DRM *d3drm);
}
object_table[] =
{
{&CLSID_CDirect3DRMTexture, d3drm_create_texture_object},
};
TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
iface, debugstr_guid(clsid), outer, debugstr_guid(iid), out);
......@@ -1127,17 +1151,19 @@ static HRESULT WINAPI d3drm3_CreateObject(IDirect3DRM3 *iface,
return E_NOTIMPL;
}
if (IsEqualGUID(clsid, &CLSID_CDirect3DRMTexture))
for (i = 0; i < ARRAY_SIZE(object_table); ++i)
{
struct d3drm_texture *texture;
if (FAILED(hr = d3drm_texture_create(&texture, &d3drm->IDirect3DRM_iface)))
if (IsEqualGUID(clsid, object_table[i].clsid))
{
*out = NULL;
return hr;
if (FAILED(hr = object_table[i].create_object((void **)&object, &d3drm->IDirect3DRM_iface)))
{
*out = NULL;
return hr;
}
break;
}
object = (IUnknown *)&texture->IDirect3DRMTexture3_iface;
}
else
if (i == ARRAY_SIZE(object_table))
{
FIXME("%s not implemented. Returning CLASSFACTORY_E_FIRST.\n", debugstr_guid(clsid));
*out = NULL;
......
......@@ -26,6 +26,10 @@
#include "wine/list.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
#endif
struct d3drm_device;
struct d3drm_object
{
......
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