Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2022
- 68 participants
- 3274 messages
[PATCH 5/6] d3dx10: Add D3DX10CreateAsyncTextureInfoProcessor implementation.
by Piotr Caban
From: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/d3dx10_43/async.c | 61 ++++++++++++++++++++++++++++++++++++--
dlls/d3dx10_43/dxhelpers.h | 2 ++
dlls/d3dx10_43/texture.c | 27 ++++++++++-------
3 files changed, 77 insertions(+), 13 deletions(-)
diff --git a/dlls/d3dx10_43/async.c b/dlls/d3dx10_43/async.c
index 33abd11eed6..0d75a64ff9e 100644
--- a/dlls/d3dx10_43/async.c
+++ b/dlls/d3dx10_43/async.c
@@ -19,6 +19,7 @@
#include "d3d10_1.h"
#include "d3dx10.h"
#include "d3dcompiler.h"
+#include "dxhelpers.h"
#include "wine/debug.h"
@@ -272,6 +273,48 @@ static const ID3DX10DataLoaderVtbl resourcedataloadervtbl =
resourcedataloader_Destroy
};
+struct texture_info_processor
+{
+ ID3DX10DataProcessor ID3DX10DataProcessor_iface;
+ D3DX10_IMAGE_INFO *info;
+};
+
+static inline struct texture_info_processor *impl_from_ID3DX10DataProcessor(ID3DX10DataProcessor *iface)
+{
+ return CONTAINING_RECORD(iface, struct texture_info_processor, ID3DX10DataProcessor_iface);
+}
+
+static HRESULT WINAPI texture_info_processor_Process(ID3DX10DataProcessor *iface, void *data, SIZE_T size)
+{
+ struct texture_info_processor *processor = impl_from_ID3DX10DataProcessor(iface);
+
+ TRACE("iface %p, data %p, size %Iu.\n", iface, data, size);
+ return get_image_info(data, size, processor->info);
+}
+
+static HRESULT WINAPI texture_info_processor_CreateDeviceObject(ID3DX10DataProcessor *iface, void **object)
+{
+ TRACE("iface %p, object %p.\n", iface, object);
+ return S_OK;
+}
+
+static HRESULT WINAPI texture_info_processor_Destroy(ID3DX10DataProcessor *iface)
+{
+ struct texture_info_processor *processor = impl_from_ID3DX10DataProcessor(iface);
+
+ TRACE("iface %p.\n", iface);
+
+ free(processor);
+ return S_OK;
+}
+
+static ID3DX10DataProcessorVtbl texture_info_processor_vtbl =
+{
+ texture_info_processor_Process,
+ texture_info_processor_CreateDeviceObject,
+ texture_info_processor_Destroy
+};
+
HRESULT WINAPI D3DX10CompileFromMemory(const char *data, SIZE_T data_size, const char *filename,
const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *entry_point,
const char *target, UINT sflags, UINT eflags, ID3DX10ThreadPump *pump, ID3D10Blob **shader,
@@ -453,8 +496,22 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
HRESULT WINAPI D3DX10CreateAsyncTextureInfoProcessor(D3DX10_IMAGE_INFO *info, ID3DX10DataProcessor **processor)
{
- FIXME("info %p, processor %p stub!\n", info, processor);
- return E_NOTIMPL;
+ struct texture_info_processor *object;
+
+ TRACE("info %p, processor %p.\n", info, processor);
+
+ if (!processor)
+ return E_INVALIDARG;
+
+ object = malloc(sizeof(*object));
+ if (!object)
+ return E_OUTOFMEMORY;
+
+ object->ID3DX10DataProcessor_iface.lpVtbl = &texture_info_processor_vtbl;
+ object->info = info;
+
+ *processor = &object->ID3DX10DataProcessor_iface;
+ return S_OK;
}
HRESULT WINAPI D3DX10PreprocessShaderFromMemory(const char *data, SIZE_T data_size, const char *filename,
diff --git a/dlls/d3dx10_43/dxhelpers.h b/dlls/d3dx10_43/dxhelpers.h
index d85e5878a18..82fe639c2ea 100644
--- a/dlls/d3dx10_43/dxhelpers.h
+++ b/dlls/d3dx10_43/dxhelpers.h
@@ -21,3 +21,5 @@ extern HRESULT load_resourceA(HMODULE module, const char *resource,
void **data, DWORD *size) DECLSPEC_HIDDEN;
extern HRESULT load_resourceW(HMODULE module, const WCHAR *resource,
void **data, DWORD *size) DECLSPEC_HIDDEN;
+
+extern HRESULT get_image_info(const void *data, SIZE_T size, D3DX10_IMAGE_INFO *img_info) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c
index 722784fc117..3930df3677f 100644
--- a/dlls/d3dx10_43/texture.c
+++ b/dlls/d3dx10_43/texture.c
@@ -382,8 +382,7 @@ HRESULT WINAPI D3DX10GetImageInfoFromResourceW(HMODULE module, const WCHAR *reso
return D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result);
}
-HRESULT WINAPI D3DX10GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX10ThreadPump *pump,
- D3DX10_IMAGE_INFO *img_info, HRESULT *hresult)
+HRESULT get_image_info(const void *data, SIZE_T size, D3DX10_IMAGE_INFO *img_info)
{
IWICBitmapFrameDecode *frame = NULL;
IWICImagingFactory *factory = NULL;
@@ -395,17 +394,9 @@ HRESULT WINAPI D3DX10GetImageInfoFromMemory(const void *src_data, SIZE_T src_dat
GUID container_format;
HRESULT hr;
- TRACE("src_data %p, src_data_size %Iu, pump %p, img_info %p, hresult %p.\n",
- src_data, src_data_size, pump, img_info, hresult);
-
- if (!src_data || !src_data_size || !img_info)
- return E_FAIL;
- if (pump)
- FIXME("Thread pump is not supported yet.\n");
-
WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
IWICImagingFactory_CreateStream(factory, &stream);
- hr = IWICStream_InitializeFromMemory(stream, (BYTE *)src_data, src_data_size);
+ hr = IWICStream_InitializeFromMemory(stream, (BYTE *)data, size);
if (FAILED(hr))
{
WARN("Failed to initialize stream.\n");
@@ -486,6 +477,20 @@ end:
return S_OK;
}
+HRESULT WINAPI D3DX10GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX10ThreadPump *pump,
+ D3DX10_IMAGE_INFO *img_info, HRESULT *result)
+{
+ TRACE("src_data %p, src_data_size %Iu, pump %p, img_info %p, hresult %p.\n",
+ src_data, src_data_size, pump, img_info, result);
+
+ if (!src_data)
+ return E_FAIL;
+ if (pump)
+ FIXME("Thread pump is not supported yet.\n");
+
+ return get_image_info(src_data, src_data_size, img_info);
+}
+
HRESULT WINAPI D3DX10CreateTextureFromFileA(ID3D10Device *device, const char *src_file,
D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
{
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/173
June 2, 2022
[PATCH 4/6] d3dx10: Share code for resource data loading.
by Piotr Caban
From: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/d3dx10_43/async.c | 89 ++++++++++++++++++++++++++++----------
dlls/d3dx10_43/compiler.c | 34 +++------------
dlls/d3dx10_43/dxhelpers.h | 4 ++
dlls/d3dx10_43/texture.c | 70 +++++-------------------------
4 files changed, 85 insertions(+), 112 deletions(-)
diff --git a/dlls/d3dx10_43/async.c b/dlls/d3dx10_43/async.c
index 21fa437ac73..33abd11eed6 100644
--- a/dlls/d3dx10_43/async.c
+++ b/dlls/d3dx10_43/async.c
@@ -41,7 +41,7 @@ struct asyncdataloader
} resource;
} u;
void *data;
- SIZE_T size;
+ DWORD size;
};
static inline struct asyncdataloader *impl_from_ID3DX10DataLoader(ID3DX10DataLoader *iface)
@@ -169,27 +169,74 @@ static const ID3DX10DataLoaderVtbl filedataloadervtbl =
filedataloader_Destroy
};
+static HRESULT load_resource_initA(HMODULE module, const char *resource, HRSRC *rsrc)
+{
+ if (!(*rsrc = FindResourceA(module, resource, (const char *)RT_RCDATA)))
+ *rsrc = FindResourceA(module, resource, (const char *)RT_BITMAP);
+ if (!*rsrc)
+ {
+ WARN("Failed to find resource.\n");
+ return D3DX10_ERR_INVALID_DATA;
+ }
+ return S_OK;
+}
+
+static HRESULT load_resource_initW(HMODULE module, const WCHAR *resource, HRSRC *rsrc)
+{
+ if (!(*rsrc = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
+ *rsrc = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP);
+ if (!*rsrc)
+ {
+ WARN("Failed to find resource.\n");
+ return D3DX10_ERR_INVALID_DATA;
+ }
+ return S_OK;
+}
+
+static HRESULT load_resource(HMODULE module, HRSRC rsrc, void **data, DWORD *size)
+{
+ HGLOBAL hglobal;
+
+ if (!(*size = SizeofResource(module, rsrc)))
+ return D3DX10_ERR_INVALID_DATA;
+ if (!(hglobal = LoadResource(module, rsrc)))
+ return D3DX10_ERR_INVALID_DATA;
+ if (!(*data = LockResource(hglobal)))
+ return D3DX10_ERR_INVALID_DATA;
+ return S_OK;
+}
+
+HRESULT load_resourceA(HMODULE module, const char *resource, void **data, DWORD *size)
+{
+ HRESULT hr;
+ HRSRC rsrc;
+
+ if (FAILED((hr = load_resource_initA(module, resource, &rsrc))))
+ return hr;
+ return load_resource(module, rsrc, data, size);
+}
+
+HRESULT load_resourceW(HMODULE module, const WCHAR *resource, void **data, DWORD *size)
+{
+ HRESULT hr;
+ HRSRC rsrc;
+
+ if ((FAILED(hr = load_resource_initW(module, resource, &rsrc))))
+ return hr;
+ return load_resource(module, rsrc, data, size);
+}
+
static HRESULT WINAPI resourcedataloader_Load(ID3DX10DataLoader *iface)
{
struct asyncdataloader *loader = impl_from_ID3DX10DataLoader(iface);
- HGLOBAL hglobal;
TRACE("iface %p.\n", iface);
if (loader->data)
return S_OK;
- hglobal = LoadResource(loader->u.resource.module, loader->u.resource.rsrc);
- if (!hglobal)
- {
- WARN("Failed to load resource.\n");
- return E_FAIL;
- }
-
- loader->data = LockResource(hglobal);
- loader->size = SizeofResource(loader->u.resource.module, loader->u.resource.rsrc);
-
- return S_OK;
+ return load_resource(loader->u.resource.module, loader->u.resource.rsrc,
+ &loader->data, &loader->size);
}
static HRESULT WINAPI resourcedataloader_Decompress(ID3DX10DataLoader *iface, void **data, SIZE_T *size)
@@ -344,6 +391,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE module, const char *reso
{
struct asyncdataloader *object;
HRSRC rsrc;
+ HRESULT hr;
TRACE("module %p, resource %s, loader %p.\n", module, debugstr_a(resource), loader);
@@ -354,13 +402,10 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE module, const char *reso
if (!object)
return E_OUTOFMEMORY;
- if (!(rsrc = FindResourceA(module, resource, (const char *)RT_RCDATA)))
- rsrc = FindResourceA(module, resource, (const char *)RT_BITMAP);
- if (!rsrc)
+ if (FAILED((hr = load_resource_initA(module, resource, &rsrc))))
{
- WARN("Failed to find resource.\n");
free(object);
- return D3DX10_ERR_INVALID_DATA;
+ return hr;
}
object->ID3DX10DataLoader_iface.lpVtbl = &resourcedataloadervtbl;
@@ -378,6 +423,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
{
struct asyncdataloader *object;
HRSRC rsrc;
+ HRESULT hr;
TRACE("module %p, resource %s, loader %p.\n", module, debugstr_w(resource), loader);
@@ -388,13 +434,10 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
if (!object)
return E_OUTOFMEMORY;
- if (!(rsrc = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
- rsrc = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP);
- if (!rsrc)
+ if (FAILED((hr = load_resource_initW(module, resource, &rsrc))))
{
- WARN("Failed to find resource.\n");
free(object);
- return D3DX10_ERR_INVALID_DATA;
+ return hr;
}
object->ID3DX10DataLoader_iface.lpVtbl = &resourcedataloadervtbl;
diff --git a/dlls/d3dx10_43/compiler.c b/dlls/d3dx10_43/compiler.c
index 9ae3fe93f85..c66eb679a8f 100644
--- a/dlls/d3dx10_43/compiler.c
+++ b/dlls/d3dx10_43/compiler.c
@@ -24,6 +24,7 @@
#include "d3d10_1.h"
#include "d3dx10.h"
#include "d3dcompiler.h"
+#include "dxhelpers.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
@@ -123,32 +124,12 @@ HRESULT WINAPI D3DX10CreateEffectFromFileA(const char *filename, const D3D10_SHA
return hr;
}
-static HRESULT get_resource_data(HMODULE module, HRSRC resinfo, void **buffer, DWORD *length)
-{
- HGLOBAL resource;
-
- *length = SizeofResource(module, resinfo);
- if (!*length)
- return D3DX10_ERR_INVALID_DATA;
-
- resource = LoadResource(module, resinfo);
- if (!resource)
- return D3DX10_ERR_INVALID_DATA;
-
- *buffer = LockResource(resource);
- if (!*buffer)
- return D3DX10_ERR_INVALID_DATA;
-
- return S_OK;
-}
-
HRESULT WINAPI D3DX10CreateEffectFromResourceA(HMODULE module, const char *resource_name,
const char *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include,
const char *profile, UINT shader_flags, UINT effect_flags, ID3D10Device *device,
ID3D10EffectPool *effect_pool, ID3DX10ThreadPump *pump, ID3D10Effect **effect,
ID3D10Blob **errors, HRESULT *hresult)
{
- HRSRC resinfo;
void *data;
DWORD size;
HRESULT hr;
@@ -159,10 +140,8 @@ HRESULT WINAPI D3DX10CreateEffectFromResourceA(HMODULE module, const char *resou
defines, include, debugstr_a(profile), shader_flags, effect_flags,
device, effect_pool, pump, effect, errors, hresult);
- if (!(resinfo = FindResourceA(module, resource_name, (const char *)RT_RCDATA)))
- return D3DX10_ERR_INVALID_DATA;
-
- if (FAILED(hr = get_resource_data(module, resinfo, &data, &size)))
+ hr = load_resourceA(module, resource_name, &data, &size);
+ if (FAILED(hr))
return hr;
return D3DX10CreateEffectFromMemory(data, size, filename, defines, include, profile,
@@ -176,7 +155,6 @@ HRESULT WINAPI D3DX10CreateEffectFromResourceW(HMODULE module, const WCHAR *reso
ID3D10Blob **errors, HRESULT *hresult)
{
char *filename = NULL;
- HRSRC resinfo;
void *data;
DWORD size;
HRESULT hr;
@@ -188,10 +166,8 @@ HRESULT WINAPI D3DX10CreateEffectFromResourceW(HMODULE module, const WCHAR *reso
defines, include, debugstr_a(profile), shader_flags, effect_flags,
device, effect_pool, pump, effect, errors, hresult);
- if (!(resinfo = FindResourceW(module, resource_name, (const WCHAR *)RT_RCDATA)))
- return D3DX10_ERR_INVALID_DATA;
-
- if (FAILED(hr = get_resource_data(module, resinfo, &data, &size)))
+ hr = load_resourceW(module, resource_name, &data, &size);
+ if (FAILED(hr))
return hr;
if (filenameW)
diff --git a/dlls/d3dx10_43/dxhelpers.h b/dlls/d3dx10_43/dxhelpers.h
index 9afc9bd901a..d85e5878a18 100644
--- a/dlls/d3dx10_43/dxhelpers.h
+++ b/dlls/d3dx10_43/dxhelpers.h
@@ -17,3 +17,7 @@
*/
extern HRESULT load_file(const WCHAR *path, void **data, DWORD *size) DECLSPEC_HIDDEN;
+extern HRESULT load_resourceA(HMODULE module, const char *resource,
+ void **data, DWORD *size) DECLSPEC_HIDDEN;
+extern HRESULT load_resourceW(HMODULE module, const WCHAR *resource,
+ void **data, DWORD *size) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c
index 56258fdd60d..722784fc117 100644
--- a/dlls/d3dx10_43/texture.c
+++ b/dlls/d3dx10_43/texture.c
@@ -292,22 +292,6 @@ static DXGI_FORMAT get_d3dx10_dds_format(DXGI_FORMAT format)
return format;
}
-static HRESULT load_resource(HMODULE module, HRSRC res_info, void **buffer, DWORD *size)
-{
- HGLOBAL resource;
-
- if (!(*size = SizeofResource(module, res_info)))
- return HRESULT_FROM_WIN32(GetLastError());
-
- if (!(resource = LoadResource(module, res_info)))
- return HRESULT_FROM_WIN32(GetLastError());
-
- if (!(*buffer = LockResource(resource)))
- return HRESULT_FROM_WIN32(GetLastError());
-
- return S_OK;
-}
-
HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info,
HRESULT *result)
{
@@ -361,7 +345,6 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadP
HRESULT WINAPI D3DX10GetImageInfoFromResourceA(HMODULE module, const char *resource, ID3DX10ThreadPump *pump,
D3DX10_IMAGE_INFO *info, HRESULT *result)
{
- HRSRC res_info;
void *buffer;
HRESULT hr;
DWORD size;
@@ -372,18 +355,9 @@ HRESULT WINAPI D3DX10GetImageInfoFromResourceA(HMODULE module, const char *resou
if (!resource || !info)
return D3DX10_ERR_INVALID_DATA;
- res_info = FindResourceA(module, resource, (const char *)RT_RCDATA);
- if (!res_info)
- {
- /* Try loading the resource as bitmap data */
- res_info = FindResourceA(module, resource, (const char *)RT_BITMAP);
- if (!res_info)
- return D3DX10_ERR_INVALID_DATA;
- }
-
- hr = load_resource(module, res_info, &buffer, &size);
+ hr = load_resourceA(module, resource, &buffer, &size);
if (FAILED(hr))
- return D3DX10_ERR_INVALID_DATA;
+ return hr;
return D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result);
}
@@ -391,7 +365,6 @@ HRESULT WINAPI D3DX10GetImageInfoFromResourceA(HMODULE module, const char *resou
HRESULT WINAPI D3DX10GetImageInfoFromResourceW(HMODULE module, const WCHAR *resource, ID3DX10ThreadPump *pump,
D3DX10_IMAGE_INFO *info, HRESULT *result)
{
- HRSRC res_info;
void *buffer;
HRESULT hr;
DWORD size;
@@ -402,18 +375,9 @@ HRESULT WINAPI D3DX10GetImageInfoFromResourceW(HMODULE module, const WCHAR *reso
if (!resource || !info)
return D3DX10_ERR_INVALID_DATA;
- res_info = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA);
- if (!res_info)
- {
- /* Try loading the resource as bitmap data */
- res_info = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP);
- if (!res_info)
- return D3DX10_ERR_INVALID_DATA;
- }
-
- hr = load_resource(module, res_info, &buffer, &size);
+ hr = load_resourceW(module, resource, &buffer, &size);
if (FAILED(hr))
- return D3DX10_ERR_INVALID_DATA;
+ return hr;
return D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result);
}
@@ -575,7 +539,6 @@ HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *s
HRESULT WINAPI D3DX10CreateTextureFromResourceA(ID3D10Device *device, HMODULE module, const char *resource,
D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
{
- HRSRC res_info;
void *buffer;
DWORD size;
HRESULT hr;
@@ -586,15 +549,9 @@ HRESULT WINAPI D3DX10CreateTextureFromResourceA(ID3D10Device *device, HMODULE mo
if (!resource || !texture)
return D3DX10_ERR_INVALID_DATA;
- if (!(res_info = FindResourceA(module, resource, (const char *)RT_RCDATA)))
- {
- /* Try loading the resource as bitmap data */
- if (!(res_info = FindResourceA(module, resource, (const char *)RT_BITMAP)))
- return D3DX10_ERR_INVALID_DATA;
- }
-
- if (FAILED(hr = load_resource(module, res_info, &buffer, &size)))
- return D3DX10_ERR_INVALID_DATA;
+ hr = load_resourceA(module, resource, &buffer, &size);
+ if (FAILED(hr))
+ return hr;
return D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
}
@@ -602,7 +559,6 @@ HRESULT WINAPI D3DX10CreateTextureFromResourceA(ID3D10Device *device, HMODULE mo
HRESULT WINAPI D3DX10CreateTextureFromResourceW(ID3D10Device *device, HMODULE module, const WCHAR *resource,
D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
{
- HRSRC res_info;
void *buffer;
DWORD size;
HRESULT hr;
@@ -613,15 +569,9 @@ HRESULT WINAPI D3DX10CreateTextureFromResourceW(ID3D10Device *device, HMODULE mo
if (!resource || !texture)
return D3DX10_ERR_INVALID_DATA;
- if (!(res_info = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
- {
- /* Try loading the resource as bitmap data */
- if (!(res_info = FindResourceW(module, resource, (const WCHAR *)RT_BITMAP)))
- return D3DX10_ERR_INVALID_DATA;
- }
-
- if (FAILED(hr = load_resource(module, res_info, &buffer, &size)))
- return D3DX10_ERR_INVALID_DATA;
+ hr = load_resourceW(module, resource, &buffer, &size);
+ if (FAILED(hr))
+ return hr;
return D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/173
June 2, 2022
[PATCH 3/6] d3dx10: Share code for file data loading.
by Piotr Caban
From: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/d3dx10_43/async.c | 38 +++++++++++++++---------
dlls/d3dx10_43/dxhelpers.h | 19 ++++++++++++
dlls/d3dx10_43/texture.c | 60 ++++----------------------------------
3 files changed, 48 insertions(+), 69 deletions(-)
create mode 100644 dlls/d3dx10_43/dxhelpers.h
diff --git a/dlls/d3dx10_43/async.c b/dlls/d3dx10_43/async.c
index 5a8ba77db87..21fa437ac73 100644
--- a/dlls/d3dx10_43/async.c
+++ b/dlls/d3dx10_43/async.c
@@ -84,38 +84,48 @@ static const ID3DX10DataLoaderVtbl memorydataloadervtbl =
memorydataloader_Destroy
};
-static HRESULT WINAPI filedataloader_Load(ID3DX10DataLoader *iface)
+HRESULT load_file(const WCHAR *path, void **data, DWORD *size)
{
- struct asyncdataloader *loader = impl_from_ID3DX10DataLoader(iface);
- DWORD size, read_len;
+ DWORD read_len;
HANDLE file;
- void *data;
BOOL ret;
- TRACE("iface %p.\n", iface);
-
- /* Always buffer file contents, even if Load() was already called. */
- file = CreateFileW(loader->u.file.path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ file = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (file == INVALID_HANDLE_VALUE)
return D3D10_ERROR_FILE_NOT_FOUND;
- size = GetFileSize(file, NULL);
- data = malloc(size);
- if (!data)
+ *size = GetFileSize(file, NULL);
+ *data = malloc(*size);
+ if (!*data)
{
CloseHandle(file);
return E_OUTOFMEMORY;
}
- ret = ReadFile(file, data, size, &read_len, NULL);
+ ret = ReadFile(file, *data, *size, &read_len, NULL);
CloseHandle(file);
- if (!ret)
+ if (!ret || read_len != *size)
{
WARN("Failed to read file contents.\n");
- free(data);
+ free(*data);
return E_FAIL;
}
+ return S_OK;
+}
+
+static HRESULT WINAPI filedataloader_Load(ID3DX10DataLoader *iface)
+{
+ struct asyncdataloader *loader = impl_from_ID3DX10DataLoader(iface);
+ void *data;
+ DWORD size;
+ HRESULT hr;
+
+ TRACE("iface %p.\n", iface);
+
+ /* Always buffer file contents, even if Load() was already called. */
+ if (FAILED((hr = load_file(loader->u.file.path, &data, &size))))
+ return hr;
free(loader->data);
loader->data = data;
diff --git a/dlls/d3dx10_43/dxhelpers.h b/dlls/d3dx10_43/dxhelpers.h
new file mode 100644
index 00000000000..9afc9bd901a
--- /dev/null
+++ b/dlls/d3dx10_43/dxhelpers.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2022 Piotr Caban
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+extern HRESULT load_file(const WCHAR *path, void **data, DWORD *size) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c
index 41f9723de6b..56258fdd60d 100644
--- a/dlls/d3dx10_43/texture.c
+++ b/dlls/d3dx10_43/texture.c
@@ -23,6 +23,7 @@
#include "d3d10_1.h"
#include "d3dx10.h"
#include "wincodec.h"
+#include "dxhelpers.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
@@ -291,57 +292,6 @@ static DXGI_FORMAT get_d3dx10_dds_format(DXGI_FORMAT format)
return format;
}
-static HRESULT load_file(const WCHAR *filename, void **buffer, DWORD *size)
-{
- HRESULT hr = S_OK;
- DWORD bytes_read;
- HANDLE file;
- BOOL ret;
-
- file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
- if (file == INVALID_HANDLE_VALUE)
- {
- hr = HRESULT_FROM_WIN32(GetLastError());
- goto done;
- }
-
- *size = GetFileSize(file, NULL);
- if (*size == INVALID_FILE_SIZE)
- {
- hr = HRESULT_FROM_WIN32(GetLastError());
- goto done;
- }
-
- *buffer = malloc(*size);
- if (!*buffer)
- {
- hr = E_OUTOFMEMORY;
- goto done;
- }
-
- ret = ReadFile(file, *buffer, *size, &bytes_read, NULL);
- if (!ret)
- {
- hr = HRESULT_FROM_WIN32(GetLastError());
- goto done;
- }
- if (bytes_read != *size)
- {
- hr = E_FAIL;
- goto done;
- }
-
-done:
- if (FAILED(hr))
- {
- free(*buffer);
- *buffer = NULL;
- }
- if (file != INVALID_HANDLE_VALUE)
- CloseHandle(file);
- return hr;
-}
-
static HRESULT load_resource(HMODULE module, HRSRC res_info, void **buffer, DWORD *size)
{
HGLOBAL resource;
@@ -398,8 +348,8 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadP
if (!src_file || !info)
return E_FAIL;
- if (FAILED(load_file(src_file, &buffer, &size)))
- return D3D10_ERROR_FILE_NOT_FOUND;
+ if (FAILED((hr = load_file(src_file, &buffer, &size))))
+ return hr;
hr = D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result);
@@ -612,8 +562,8 @@ HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *s
if (!src_file || !texture)
return E_FAIL;
- if (FAILED(load_file(src_file, &buffer, &size)))
- return D3D10_ERROR_FILE_NOT_FOUND;
+ if (FAILED((hr = load_file(src_file, &buffer, &size))))
+ return hr;
hr = D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/173
June 2, 2022
[PATCH 2/6] d3dx11: Use CRT memory allocators.
by Piotr Caban
From: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/d3dx11_43/async.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/dlls/d3dx11_43/async.c b/dlls/d3dx11_43/async.c
index 8d947742b9d..074a8529e4e 100644
--- a/dlls/d3dx11_43/async.c
+++ b/dlls/d3dx11_43/async.c
@@ -72,7 +72,7 @@ static HRESULT WINAPI memorydataloader_Destroy(ID3DX11DataLoader *iface)
TRACE("iface %p.\n", iface);
- HeapFree(GetProcessHeap(), 0, loader);
+ free(loader);
return S_OK;
}
@@ -100,7 +100,7 @@ static HRESULT WINAPI filedataloader_Load(ID3DX11DataLoader *iface)
return D3D11_ERROR_FILE_NOT_FOUND;
size = GetFileSize(file, NULL);
- data = HeapAlloc(GetProcessHeap(), 0, size);
+ data = malloc(size);
if (!data)
{
CloseHandle(file);
@@ -112,11 +112,11 @@ static HRESULT WINAPI filedataloader_Load(ID3DX11DataLoader *iface)
if (!ret)
{
ERR("Failed to read file contents.\n");
- HeapFree(GetProcessHeap(), 0, data);
+ free(data);
return E_FAIL;
}
- HeapFree(GetProcessHeap(), 0, loader->data);
+ free(loader->data);
loader->data = data;
loader->size = size;
@@ -144,9 +144,9 @@ static HRESULT WINAPI filedataloader_Destroy(ID3DX11DataLoader *iface)
TRACE("iface %p.\n", iface);
- HeapFree(GetProcessHeap(), 0, loader->u.file.path);
- HeapFree(GetProcessHeap(), 0, loader->data);
- HeapFree(GetProcessHeap(), 0, loader);
+ free(loader->u.file.path);
+ free(loader->data);
+ free(loader);
return S_OK;
}
@@ -202,7 +202,7 @@ static HRESULT WINAPI resourcedataloader_Destroy(ID3DX11DataLoader *iface)
TRACE("iface %p.\n", iface);
- HeapFree(GetProcessHeap(), 0, loader);
+ free(loader);
return S_OK;
}
@@ -282,7 +282,7 @@ HRESULT WINAPI D3DX11CreateAsyncMemoryLoader(const void *data, SIZE_T data_size,
if (!data || !loader)
return E_FAIL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@@ -307,12 +307,12 @@ HRESULT WINAPI D3DX11CreateAsyncFileLoaderA(const char *filename, ID3DX11DataLoa
return E_FAIL;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
- filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*filename_w));
+ filename_w = malloc(len * sizeof(*filename_w));
MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
hr = D3DX11CreateAsyncFileLoaderW(filename_w, loader);
- HeapFree(GetProcessHeap(), 0, filename_w);
+ free(filename_w);
return hr;
}
@@ -326,15 +326,15 @@ HRESULT WINAPI D3DX11CreateAsyncFileLoaderW(const WCHAR *filename, ID3DX11DataLo
if (!filename || !loader)
return E_FAIL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
object->ID3DX11DataLoader_iface.lpVtbl = &filedataloadervtbl;
- object->u.file.path = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR));
+ object->u.file.path = malloc((lstrlenW(filename) + 1) * sizeof(WCHAR));
if (!object->u.file.path)
{
- HeapFree(GetProcessHeap(), 0, object);
+ free(object);
return E_OUTOFMEMORY;
}
lstrcpyW(object->u.file.path, filename);
@@ -356,14 +356,14 @@ HRESULT WINAPI D3DX11CreateAsyncResourceLoaderA(HMODULE module, const char *reso
if (!loader)
return E_FAIL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
if (!(rsrc = FindResourceA(module, resource, (const char *)RT_RCDATA)))
{
WARN("Failed to find resource.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ free(object);
return D3DX11_ERR_INVALID_DATA;
}
@@ -388,14 +388,14 @@ HRESULT WINAPI D3DX11CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
if (!loader)
return E_FAIL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
if (!(rsrc = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
{
WARN("Failed to find resource.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ free(object);
return D3DX11_ERR_INVALID_DATA;
}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/173
June 2, 2022
[PATCH 1/6] d3dx10: Use CRT memory allocators.
by Piotr Caban
From: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/d3dx10_43/async.c | 36 ++++++++++++++++++------------------
dlls/d3dx10_43/compiler.c | 9 ++++-----
dlls/d3dx10_43/font.c | 31 +++++++++++++++----------------
dlls/d3dx10_43/mesh.c | 5 ++---
dlls/d3dx10_43/sprite.c | 5 ++---
dlls/d3dx10_43/texture.c | 21 ++++++++++-----------
6 files changed, 51 insertions(+), 56 deletions(-)
diff --git a/dlls/d3dx10_43/async.c b/dlls/d3dx10_43/async.c
index 716eb7f44fb..5a8ba77db87 100644
--- a/dlls/d3dx10_43/async.c
+++ b/dlls/d3dx10_43/async.c
@@ -73,7 +73,7 @@ static HRESULT WINAPI memorydataloader_Destroy(ID3DX10DataLoader *iface)
TRACE("iface %p.\n", iface);
- HeapFree(GetProcessHeap(), 0, loader);
+ free(loader);
return S_OK;
}
@@ -101,7 +101,7 @@ static HRESULT WINAPI filedataloader_Load(ID3DX10DataLoader *iface)
return D3D10_ERROR_FILE_NOT_FOUND;
size = GetFileSize(file, NULL);
- data = HeapAlloc(GetProcessHeap(), 0, size);
+ data = malloc(size);
if (!data)
{
CloseHandle(file);
@@ -113,11 +113,11 @@ static HRESULT WINAPI filedataloader_Load(ID3DX10DataLoader *iface)
if (!ret)
{
WARN("Failed to read file contents.\n");
- HeapFree(GetProcessHeap(), 0, data);
+ free(data);
return E_FAIL;
}
- HeapFree(GetProcessHeap(), 0, loader->data);
+ free(loader->data);
loader->data = data;
loader->size = size;
@@ -145,9 +145,9 @@ static HRESULT WINAPI filedataloader_Destroy(ID3DX10DataLoader *iface)
TRACE("iface %p.\n", iface);
- HeapFree(GetProcessHeap(), 0, loader->u.file.path);
- HeapFree(GetProcessHeap(), 0, loader->data);
- HeapFree(GetProcessHeap(), 0, loader);
+ free(loader->u.file.path);
+ free(loader->data);
+ free(loader);
return S_OK;
}
@@ -203,7 +203,7 @@ static HRESULT WINAPI resourcedataloader_Destroy(ID3DX10DataLoader *iface)
TRACE("iface %p.\n", iface);
- HeapFree(GetProcessHeap(), 0, loader);
+ free(loader);
return S_OK;
}
@@ -266,7 +266,7 @@ HRESULT WINAPI D3DX10CreateAsyncMemoryLoader(const void *data, SIZE_T data_size,
if (!data || !loader)
return E_FAIL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@@ -291,12 +291,12 @@ HRESULT WINAPI D3DX10CreateAsyncFileLoaderA(const char *filename, ID3DX10DataLoa
return E_FAIL;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
- filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*filename_w));
+ filename_w = malloc(len * sizeof(*filename_w));
MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
hr = D3DX10CreateAsyncFileLoaderW(filename_w, loader);
- HeapFree(GetProcessHeap(), 0, filename_w);
+ free(filename_w);
return hr;
}
@@ -310,15 +310,15 @@ HRESULT WINAPI D3DX10CreateAsyncFileLoaderW(const WCHAR *filename, ID3DX10DataLo
if (!filename || !loader)
return E_FAIL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
object->ID3DX10DataLoader_iface.lpVtbl = &filedataloadervtbl;
- object->u.file.path = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR));
+ object->u.file.path = malloc((lstrlenW(filename) + 1) * sizeof(WCHAR));
if (!object->u.file.path)
{
- HeapFree(GetProcessHeap(), 0, object);
+ free(object);
return E_OUTOFMEMORY;
}
lstrcpyW(object->u.file.path, filename);
@@ -340,7 +340,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE module, const char *reso
if (!loader)
return E_FAIL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@@ -349,7 +349,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE module, const char *reso
if (!rsrc)
{
WARN("Failed to find resource.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ free(object);
return D3DX10_ERR_INVALID_DATA;
}
@@ -374,7 +374,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
if (!loader)
return E_FAIL;
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
@@ -383,7 +383,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
if (!rsrc)
{
WARN("Failed to find resource.\n");
- HeapFree(GetProcessHeap(), 0, object);
+ free(object);
return D3DX10_ERR_INVALID_DATA;
}
diff --git a/dlls/d3dx10_43/compiler.c b/dlls/d3dx10_43/compiler.c
index 91a99110d0b..9ae3fe93f85 100644
--- a/dlls/d3dx10_43/compiler.c
+++ b/dlls/d3dx10_43/compiler.c
@@ -18,7 +18,6 @@
*/
#include "wine/debug.h"
-#include "wine/heap.h"
#define COBJMACROS
@@ -113,13 +112,13 @@ HRESULT WINAPI D3DX10CreateEffectFromFileA(const char *filename, const D3D10_SHA
return E_INVALIDARG;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
- if (!(filenameW = heap_alloc(len * sizeof(*filenameW))))
+ if (!(filenameW = malloc(len * sizeof(*filenameW))))
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, len);
hr = D3DX10CreateEffectFromFileW(filenameW, defines, include, profile, shader_flags,
effect_flags, device, effect_pool, pump, effect, errors, hresult);
- heap_free(filenameW);
+ free(filenameW);
return hr;
}
@@ -198,13 +197,13 @@ HRESULT WINAPI D3DX10CreateEffectFromResourceW(HMODULE module, const WCHAR *reso
if (filenameW)
{
len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
- if (!(filename = heap_alloc(len)))
+ if (!(filename = malloc(len)))
return E_OUTOFMEMORY;
WideCharToMultiByte(CP_ACP, 0, filenameW, -1, filename, len, NULL, NULL);
}
hr = D3DX10CreateEffectFromMemory(data, size, filename, defines, include, profile,
shader_flags, effect_flags, device, effect_pool, pump, effect, errors, hresult);
- heap_free(filename);
+ free(filename);
return hr;
}
diff --git a/dlls/d3dx10_43/font.c b/dlls/d3dx10_43/font.c
index 1589c3a0eef..09560363312 100644
--- a/dlls/d3dx10_43/font.c
+++ b/dlls/d3dx10_43/font.c
@@ -21,7 +21,6 @@
#include "d3dx10.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
@@ -82,7 +81,7 @@ static ULONG WINAPI d3dx_font_Release(ID3DX10Font *iface)
DeleteObject(font->hfont);
DeleteDC(font->hdc);
ID3D10Device_Release(font->device);
- heap_free(font);
+ free(font);
}
return refcount;
}
@@ -179,14 +178,14 @@ static HRESULT WINAPI d3dx_font_PreloadCharacters(ID3DX10Font *iface, UINT first
return S_OK;
count = last - first + 1;
- indices = heap_alloc(count * sizeof(*indices));
+ indices = malloc(count * sizeof(*indices));
if (!indices)
return E_OUTOFMEMORY;
- chars = heap_alloc(count * sizeof(*chars));
+ chars = malloc(count * sizeof(*chars));
if (!chars)
{
- heap_free(indices);
+ free(indices);
return E_OUTOFMEMORY;
}
@@ -208,8 +207,8 @@ static HRESULT WINAPI d3dx_font_PreloadCharacters(ID3DX10Font *iface, UINT first
}
ID3DX10Font_PreloadGlyphs(iface, start, end);
- heap_free(chars);
- heap_free(indices);
+ free(chars);
+ free(indices);
return S_OK;
}
@@ -237,14 +236,14 @@ static HRESULT WINAPI d3dx_font_PreloadTextA(ID3DX10Font *iface, const char *str
countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0);
- if (!(wstr = heap_alloc(countW * sizeof(*wstr))))
+ if (!(wstr = malloc(countW * sizeof(*wstr))))
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
hr = ID3DX10Font_PreloadTextW(iface, wstr, count < 0 ? countW - 1 : countW);
- heap_free(wstr);
+ free(wstr);
return hr;
}
@@ -266,7 +265,7 @@ static HRESULT WINAPI d3dx_font_PreloadTextW(ID3DX10Font *iface, const WCHAR *st
if (count < 0)
count = lstrlenW(string);
- indices = heap_alloc(count * sizeof(*indices));
+ indices = malloc(count * sizeof(*indices));
if (!indices)
return E_OUTOFMEMORY;
@@ -275,7 +274,7 @@ static HRESULT WINAPI d3dx_font_PreloadTextW(ID3DX10Font *iface, const WCHAR *st
for (i = 0; i < count; ++i)
ID3DX10Font_PreloadGlyphs(iface, indices[i], indices[i]);
- heap_free(indices);
+ free(indices);
return S_OK;
}
@@ -296,7 +295,7 @@ static INT WINAPI d3dx_font_DrawTextA(ID3DX10Font *iface, ID3DX10Sprite *sprite,
if (!(countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0)))
return 0;
- if (!(wstr = heap_alloc_zero(countW * sizeof(*wstr))))
+ if (!(wstr = calloc(countW, sizeof(*wstr))))
return 0;
MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
@@ -304,7 +303,7 @@ static INT WINAPI d3dx_font_DrawTextA(ID3DX10Font *iface, ID3DX10Sprite *sprite,
ret = ID3DX10Font_DrawTextW(iface, sprite, wstr, count < 0 ? countW - 1 : countW,
rect, format, color);
- heap_free(wstr);
+ free(wstr);
return ret;
}
@@ -430,13 +429,13 @@ HRESULT WINAPI D3DX10CreateFontIndirectW(ID3D10Device *device, const D3DX10_FONT
*font = NULL;
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->hdc = CreateCompatibleDC(NULL);
if (!object->hdc)
{
- heap_free(object);
+ free(object);
return E_FAIL;
}
@@ -445,7 +444,7 @@ HRESULT WINAPI D3DX10CreateFontIndirectW(ID3D10Device *device, const D3DX10_FONT
if (!object->hfont)
{
DeleteDC(object->hdc);
- heap_free(object);
+ free(object);
return E_FAIL;
}
SelectObject(object->hdc, object->hfont);
diff --git a/dlls/d3dx10_43/mesh.c b/dlls/d3dx10_43/mesh.c
index 7b8b0c80956..5966661573d 100644
--- a/dlls/d3dx10_43/mesh.c
+++ b/dlls/d3dx10_43/mesh.c
@@ -21,7 +21,6 @@
#include "d3dx10.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
@@ -72,7 +71,7 @@ static ULONG STDMETHODCALLTYPE d3dx10_mesh_Release(ID3DX10Mesh *iface)
TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
if (!refcount)
- heap_free(mesh);
+ free(mesh);
return refcount;
}
@@ -366,7 +365,7 @@ HRESULT WINAPI D3DX10CreateMesh(ID3D10Device *device, const D3D10_INPUT_ELEMENT_
*mesh = NULL;
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->ID3DX10Mesh_iface.lpVtbl = &d3dx10_mesh_vtbl;
diff --git a/dlls/d3dx10_43/sprite.c b/dlls/d3dx10_43/sprite.c
index 307bb575d7a..6feae868a44 100644
--- a/dlls/d3dx10_43/sprite.c
+++ b/dlls/d3dx10_43/sprite.c
@@ -21,7 +21,6 @@
#include "d3dx10.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
@@ -79,7 +78,7 @@ static ULONG WINAPI d3dx10_sprite_Release(ID3DX10Sprite *iface)
if (!refcount)
{
ID3D10Device_Release(sprite->device);
- heap_free(sprite);
+ free(sprite);
}
return refcount;
@@ -209,7 +208,7 @@ HRESULT WINAPI D3DX10CreateSprite(ID3D10Device *device, UINT size, ID3DX10Sprite
*sprite = NULL;
- if (!(object = heap_alloc_zero(sizeof(*object))))
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->ID3DX10Sprite_iface.lpVtbl = &d3dx10_sprite_vtbl;
diff --git a/dlls/d3dx10_43/texture.c b/dlls/d3dx10_43/texture.c
index dd3ad1497d5..41f9723de6b 100644
--- a/dlls/d3dx10_43/texture.c
+++ b/dlls/d3dx10_43/texture.c
@@ -17,7 +17,6 @@
*/
#include "wine/debug.h"
-#include "wine/heap.h"
#define COBJMACROS
@@ -313,7 +312,7 @@ static HRESULT load_file(const WCHAR *filename, void **buffer, DWORD *size)
goto done;
}
- *buffer = heap_alloc(*size);
+ *buffer = malloc(*size);
if (!*buffer)
{
hr = E_OUTOFMEMORY;
@@ -335,7 +334,7 @@ static HRESULT load_file(const WCHAR *filename, void **buffer, DWORD *size)
done:
if (FAILED(hr))
{
- heap_free(*buffer);
+ free(*buffer);
*buffer = NULL;
}
if (file != INVALID_HANDLE_VALUE)
@@ -375,14 +374,14 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPu
if (!str_len)
return HRESULT_FROM_WIN32(GetLastError());
- buffer = heap_alloc(str_len * sizeof(*buffer));
+ buffer = malloc(str_len * sizeof(*buffer));
if (!buffer)
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len);
hr = D3DX10GetImageInfoFromFileW(buffer, pump, info, result);
- heap_free(buffer);
+ free(buffer);
return hr;
}
@@ -404,7 +403,7 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadP
hr = D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result);
- heap_free(buffer);
+ free(buffer);
return hr;
}
@@ -589,13 +588,13 @@ HRESULT WINAPI D3DX10CreateTextureFromFileA(ID3D10Device *device, const char *sr
if (!(str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0)))
return HRESULT_FROM_WIN32(GetLastError());
- if (!(buffer = heap_alloc(str_len * sizeof(*buffer))))
+ if (!(buffer = malloc(str_len * sizeof(*buffer))))
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len);
hr = D3DX10CreateTextureFromFileW(device, buffer, load_info, pump, texture, hresult);
- heap_free(buffer);
+ free(buffer);
return hr;
}
@@ -618,7 +617,7 @@ HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *s
hr = D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
- heap_free(buffer);
+ free(buffer);
return hr;
}
@@ -740,7 +739,7 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s
stride = (width * get_bpp_from_format(img_info.Format) + 7) / 8;
frame_size = stride * height;
- if (!(buffer = heap_alloc(frame_size)))
+ if (!(buffer = malloc(frame_size)))
{
hr = E_FAIL;
goto end;
@@ -813,7 +812,7 @@ end:
IWICFormatConverter_Release(converter);
if (dds_frame)
IWICDdsFrameDecode_Release(dds_frame);
- heap_free(buffer);
+ free(buffer);
if (frame)
IWICBitmapFrameDecode_Release(frame);
if (decoder)
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/173
June 2, 2022
[PATCH 0/6] MR173: preparation for sharing code in d3dx10/d3dx11
by Piotr Caban (@piotr)
- use CRT allocators
- share data loading code
- implement D3DX10CreateAsyncTextureInfoProcessor
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/173
June 2, 2022
Re: [PATCH v2 2/2] d2d1/tests: Test unregistering effect which has existing instance.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=116018
Your paranoid android.
=== debian11 (64 bit WoW report) ===
d2d1:
d2d1.c:7178: Test failed: d2d1.c:10377: Test marked todo: Test 1: Got unexpected hr 0x88990029.
June 2, 2022
Re: [PATCH v2 1/2] d2d1/tests: Test custom effect properties.
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=116017
Your paranoid android.
=== build (build log) ===
WineRunBuild.pl:error: The build timed out
June 2, 2022
[PATCH v2 2/2] d2d1/tests: Test unregistering effect which has existing instance.
by Ziqing Hui
Signed-off-by: Ziqing Hui <zhui(a)codeweavers.com>
---
dlls/d2d1/tests/d2d1.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 397e460cbb2..bc662b4f8ae 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -10673,10 +10673,15 @@ static void test_effect_register(BOOL d3d11)
ok(hr == test->hr, "Got unexpected hr %#lx, expected %#lx.\n", hr, test->hr);
if (hr == S_OK)
{
+ effect = NULL;
+ hr = ID2D1DeviceContext_CreateEffect(device_context, &CLSID_TestEffect, &effect);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect);
todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect);
todo_wine ok(hr == D2DERR_EFFECT_IS_NOT_REGISTERED, "Got unexpected hr %#lx.\n", hr);
+ if (effect)
+ ID2D1Effect_Release(effect);
}
winetest_pop_context();
--
2.25.1
June 2, 2022
[PATCH v2 1/2] d2d1/tests: Test custom effect properties.
by Ziqing Hui
Signed-off-by: Ziqing Hui <zhui(a)codeweavers.com>
---
v2: Fix test failure on win8.
dlls/d2d1/tests/d2d1.c | 251 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 251 insertions(+)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index c73039504d3..397e460cbb2 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -10886,6 +10886,256 @@ done:
release_test_context(&ctx);
}
+static void test_effect_properties(BOOL d3d11)
+{
+ UINT32 i, min_inputs, max_inputs, integer, index;
+ ID2D1EffectContext *effect_context;
+ D2D1_BUFFER_PRECISION precision;
+ struct d2d1_test_context ctx;
+ ID2D1Factory1 *factory;
+ ID2D1Effect *effect;
+ WCHAR buffer[128];
+ CLSID clsid;
+ BOOL cached;
+ HRESULT hr;
+
+ static const WCHAR *effect_author = L"The Wine Project";
+ static const WCHAR *effect_category = L"Test";
+ static const WCHAR *effect_description = L"Test effect.";
+
+ const D2D1_PROPERTY_BINDING binding[] =
+ {
+ {L"Integer", effect_impl_set_integer, effect_impl_get_integer},
+ {L"Context", NULL, effect_impl_get_context},
+ };
+
+ const struct system_property_test
+ {
+ const WCHAR *xml;
+ const WCHAR *display_name;
+ const WCHAR *author;
+ const WCHAR *category;
+ const WCHAR *description;
+ UINT32 min_inputs;
+ UINT32 max_inputs;
+ }
+ system_property_tests[] =
+ {
+ {effect_xml_a, L"TestEffectA", effect_author, effect_category, effect_description, 1, 1},
+ {effect_xml_b, L"TestEffectB", effect_author, effect_category, effect_description, 1, 1},
+ {effect_xml_c, L"TestEffectC", effect_author, effect_category, effect_description, 1, 1},
+ {effect_xml_minimum, L"", L"" ,L"", L"", 0, 0},
+ };
+
+ if (!init_test_context(&ctx, d3d11))
+ return;
+
+ factory = ctx.factory1;
+ if (!factory)
+ {
+ win_skip("ID2D1Factory1 is not supported.\n");
+ release_test_context(&ctx);
+ return;
+ }
+
+ /* Test system properties */
+
+ for (i = 0; i < ARRAY_SIZE(system_property_tests); ++i)
+ {
+ const struct system_property_test *test = &system_property_tests[i];
+ winetest_push_context("Test %u", i);
+
+ hr = ID2D1Factory1_RegisterEffectFromString(factory, &CLSID_TestEffect, test->xml, NULL, 0, effect_impl_create);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ effect = NULL;
+ hr = ID2D1DeviceContext_CreateEffect(ctx.context, &CLSID_TestEffect, &effect);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ if (hr != S_OK)
+ goto next;
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_CLSID,
+ D2D1_PROPERTY_TYPE_CLSID, (BYTE *)&clsid, sizeof(clsid));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(IsEqualGUID(&clsid, &CLSID_TestEffect), "Got unexpected clsid %s, expected %s.\n",
+ debugstr_guid(&clsid), debugstr_guid(&CLSID_TestEffect));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_DISPLAYNAME,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(!wcscmp(buffer, test->display_name), "Got unexpected display name %s, expected %s.\n",
+ debugstr_w(buffer), debugstr_w(test->display_name));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_AUTHOR,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(!wcscmp(buffer, test->author), "Got unexpected author %s, expected %s.\n",
+ debugstr_w(buffer), debugstr_w(test->author));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_CATEGORY,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(!wcscmp(buffer, test->category), "Got unexpected category %s, expected %s.\n",
+ debugstr_w(buffer), debugstr_w(test->category));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_DESCRIPTION,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(!wcscmp(buffer, test->description), "Got unexpected description %s, expected %s.\n",
+ debugstr_w(buffer), debugstr_w(test->description));
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_CACHED,
+ D2D1_PROPERTY_TYPE_BOOL, (BYTE *)&cached, sizeof(cached));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(cached == FALSE, "Got unexpected cached %d.\n", cached);
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_PRECISION,
+ D2D1_PROPERTY_TYPE_ENUM, (BYTE *)&precision, sizeof(precision));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(precision == D2D1_BUFFER_PRECISION_UNKNOWN, "Got unexpected precision %#x.\n", precision);
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_MIN_INPUTS,
+ D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&min_inputs, sizeof(min_inputs));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(min_inputs == test->min_inputs, "Got unexpected min inputs %u, expected %u.\n",
+ min_inputs, test->min_inputs);
+
+ hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_MAX_INPUTS,
+ D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&max_inputs, sizeof(max_inputs));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(max_inputs == test->max_inputs, "Got unexpected max inputs %u, expected %u.\n",
+ max_inputs, test->max_inputs);
+
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_CLSID,
+ D2D1_PROPERTY_TYPE_CLSID, (BYTE *)&clsid, sizeof(clsid));
+ ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_DISPLAYNAME,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_AUTHOR,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_CATEGORY,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_DISPLAYNAME,
+ D2D1_PROPERTY_TYPE_STRING, (BYTE *)buffer, sizeof(buffer));
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_CACHED,
+ D2D1_PROPERTY_TYPE_BOOL, (BYTE *)&cached, sizeof(cached));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_PRECISION,
+ D2D1_PROPERTY_TYPE_ENUM, (BYTE *)&precision, sizeof(precision));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_MIN_INPUTS,
+ D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&min_inputs, sizeof(min_inputs));
+ ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, D2D1_PROPERTY_MAX_INPUTS,
+ D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&max_inputs, sizeof(max_inputs));
+ ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Got unexpected hr %#lx.\n", hr);
+
+ next:
+ if (effect)
+ ID2D1Effect_Release(effect);
+ hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ winetest_pop_context();
+ }
+
+ /* Test custom properties */
+
+ hr = ID2D1Factory1_RegisterEffectFromString(factory, &CLSID_TestEffect,
+ effect_xml_c, binding, 2, effect_impl_create);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ effect = NULL;
+ hr = ID2D1DeviceContext_CreateEffect(ctx.context, &CLSID_TestEffect, &effect);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ if (hr != S_OK)
+ goto done;
+
+ index = ID2D1Effect_GetPropertyIndex(effect, L"Context");
+ ok(index == 0, "Got unexpected index %u.\n", index);
+ index = ID2D1Effect_GetPropertyIndex(effect, L"Integer");
+ ok(index == 1, "Got unexpected index %u.\n", index);
+
+ effect_context = (ID2D1EffectContext *)0xdeadbeef;
+ hr = ID2D1Effect_GetValueByName(effect,
+ L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef,
+ "Got unexpected effect context %p.\n", effect_context);
+
+ effect_context = (ID2D1EffectContext *)0xdeadbeef;
+ hr = ID2D1Effect_GetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef,
+ "Got unexpected effect context %p.\n", effect_context);
+
+ hr = ID2D1Effect_SetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+
+ integer = 0xdeadbeef;
+ hr = ID2D1Effect_GetValueByName(effect, L"Integer", D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(integer == 10, "Got unexpected integer %u.", integer);
+
+ integer = 0xdeadbeef;
+ hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(integer == 10, "Got unexpected integer %u.", integer);
+
+ integer = 20;
+ hr = ID2D1Effect_SetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ integer = 0xdeadbeef;
+ hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(integer == 20, "Got unexpected integer %u.", integer);
+
+ ID2D1Effect_Release(effect);
+ hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ /* Test custom properties without binding */
+
+ hr = ID2D1Factory1_RegisterEffectFromString(factory, &CLSID_TestEffect, effect_xml_c, NULL, 0, effect_impl_create);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1DeviceContext_CreateEffect(ctx.context, &CLSID_TestEffect, &effect);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ index = ID2D1Effect_GetPropertyIndex(effect, L"Context");
+ ok(index == 0, "Got unexpected index %u.\n", index);
+ index = ID2D1Effect_GetPropertyIndex(effect, L"Integer");
+ ok(index == 1, "Got unexpected index %u.\n", index);
+
+ hr = ID2D1Effect_GetValueByName(effect, L"DeadBeef", D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
+ ok(hr == D2DERR_INVALID_PROPERTY, "Got unexpected hr %#lx.\n", hr);
+
+ effect_context = (ID2D1EffectContext *)0xdeadbeef;
+ hr = ID2D1Effect_GetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(effect_context == NULL, "Got unexpected effect context %p.\n", effect_context);
+
+ integer = 0xdeadbeef;
+ hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(integer == 0, "Got unexpected integer %u.", integer);
+
+ hr = ID2D1Effect_SetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+ hr = ID2D1Effect_SetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
+ ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Got unexpected hr %#lx.\n", hr);
+
+done:
+ if (effect)
+ ID2D1Effect_Release(effect);
+ hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ release_test_context(&ctx);
+}
+
static void test_effect_2d_affine(BOOL d3d11)
{
D2D1_MATRIX_3X2_F rotate, scale, skew;
@@ -12004,6 +12254,7 @@ START_TEST(d2d1)
queue_test(test_mt_factory);
queue_test(test_effect_register);
queue_test(test_effect_context);
+ queue_test(test_effect_properties);
queue_test(test_effect);
queue_test(test_effect_2d_affine);
queue_test(test_effect_crop);
--
2.25.1
June 2, 2022