Christian Costa : d3dxof: Add support for case sensitive legacy type indexColor.
Alexandre Julliard
julliard at winehq.org
Mon Jun 24 16:23:47 CDT 2013
Module: wine
Branch: master
Commit: c6106428f6c83175006a99b9a2dbdb57408a4a9e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c6106428f6c83175006a99b9a2dbdb57408a4a9e
Author: Christian Costa <titan.costa at gmail.com>
Date: Sun Jun 23 21:56:39 2013 +0200
d3dxof: Add support for case sensitive legacy type indexColor.
---
dlls/d3dx9_36/tests/xfile.c | 2 +-
dlls/d3dxof/d3dxof.c | 18 ++++++++++++++++--
dlls/d3dxof/parsing.c | 24 ++++++++++++++++--------
dlls/d3dxof/tests/d3dxof.c | 2 +-
4 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/dlls/d3dx9_36/tests/xfile.c b/dlls/d3dx9_36/tests/xfile.c
index c47cffb..d105aee 100644
--- a/dlls/d3dx9_36/tests/xfile.c
+++ b/dlls/d3dx9_36/tests/xfile.c
@@ -237,7 +237,7 @@ static void test_type_index_color(void)
/* Test that 'indexColor' can be used (same as IndexedColor in standard templates) and is case sensitive */
ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, template_using_index_color_lower, sizeof(template_using_index_color_lower) - 1);
- todo_wine ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);
+ ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);
ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, template_using_index_color_upper, sizeof(template_using_index_color_upper) - 1);
ok(ret == D3DXFERR_PARSEERROR, "RegisterTemplates returned %#x instead of %#x\n", ret, D3DXFERR_PARSEERROR);
diff --git a/dlls/d3dxof/d3dxof.c b/dlls/d3dxof/d3dxof.c
index c0bea3c..f726170 100644
--- a/dlls/d3dxof/d3dxof.c
+++ b/dlls/d3dxof/d3dxof.c
@@ -46,6 +46,9 @@ static HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImp
static HRESULT IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl** ppObj);
static HRESULT IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj);
+#define TOKEN_DWORD 41
+#define TOKEN_FLOAT 42
+
HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj)
{
IDirectXFileImpl* object;
@@ -62,6 +65,17 @@ HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj)
object->IDirectXFile_iface.lpVtbl = &IDirectXFile_Vtbl;
object->ref = 1;
+ /* Reserve first template to handle the case sensitive legacy type indexColor */
+ object->nb_xtemplates = 1;
+ strcpy(object->xtemplates[0].name, "indexColor");
+ object->xtemplates[0].nb_members = 2;
+ object->xtemplates[0].members[0].type = TOKEN_DWORD;
+ object->xtemplates[0].members[0].nb_dims = 0;
+ object->xtemplates[0].members[1].type = TOKEN_FLOAT;
+ object->xtemplates[0].members[1].nb_dims = 1;
+ object->xtemplates[0].members[1].dim_fixed[0] = TRUE;
+ object->xtemplates[0].members[1].dim_value[0] = 4;
+
*ppObj = &object->IDirectXFile_iface;
return S_OK;
@@ -252,7 +266,7 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
{
ULONG i;
TRACE("Registered templates (%d):\n", This->nb_xtemplates);
- for (i = 0; i < This->nb_xtemplates; i++)
+ for (i = 1; i < This->nb_xtemplates; i++)
DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id));
}
@@ -330,7 +344,7 @@ static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LP
{
ULONG i;
TRACE("Registered templates (%d):\n", This->nb_xtemplates);
- for (i = 0; i < This->nb_xtemplates; i++)
+ for (i = 1; i < This->nb_xtemplates; i++)
DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id));
}
diff --git a/dlls/d3dxof/parsing.c b/dlls/d3dxof/parsing.c
index fc7250c..fa992ce 100644
--- a/dlls/d3dxof/parsing.c
+++ b/dlls/d3dxof/parsing.c
@@ -961,17 +961,25 @@ static BOOL parse_template_members_list(parse_buffer * buf)
if (check_TOKEN(buf) == TOKEN_NAME)
{
cur_member->type = get_TOKEN(buf);
- cur_member->idx_template = 0;
- while (cur_member->idx_template < buf->pdxf->nb_xtemplates)
+ if (!strcmp((char*)buf->value, "indexColor"))
{
- if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[cur_member->idx_template].name))
- break;
- cur_member->idx_template++;
+ /* Case sensitive legacy type indexColor is described in the first template */
+ cur_member->idx_template = 0;
}
- if (cur_member->idx_template == buf->pdxf->nb_xtemplates)
+ else
{
- ERR("Reference to a nonexistent template '%s'\n", (char*)buf->value);
- return FALSE;
+ cur_member->idx_template = 1;
+ while (cur_member->idx_template < buf->pdxf->nb_xtemplates)
+ {
+ if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[cur_member->idx_template].name))
+ break;
+ cur_member->idx_template++;
+ }
+ if (cur_member->idx_template == buf->pdxf->nb_xtemplates)
+ {
+ WARN("Reference to a nonexistent template '%s'\n", (char*)buf->value);
+ return FALSE;
+ }
}
}
else if (is_primitive_type(check_TOKEN(buf)))
diff --git a/dlls/d3dxof/tests/d3dxof.c b/dlls/d3dxof/tests/d3dxof.c
index d0f110d..f115eb3 100644
--- a/dlls/d3dxof/tests/d3dxof.c
+++ b/dlls/d3dxof/tests/d3dxof.c
@@ -1103,7 +1103,7 @@ static void test_type_index_color(void)
/* Test that 'indexColor' can be used (same as IndexedColor in standard templates) and is case sensitive */
ret = IDirectXFile_RegisterTemplates(dxfile, template_using_index_color_lower, sizeof(template_using_index_color_lower) - 1);
- todo_wine ok(ret == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates failed with %#x\n", ret);
+ ok(ret == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates failed with %#x\n", ret);
ret = IDirectXFile_RegisterTemplates(dxfile, template_using_index_color_upper, sizeof(template_using_index_color_upper) - 1);
ok(ret == DXFILEERR_PARSEERROR, "IDirectXFileImpl_RegisterTemplates returned %#x instead of %#x\n", ret, DXFILEERR_PARSEERROR);
More information about the wine-cvs
mailing list