[PATCH] d3dx9: Use wincodecs directly without initializing COM system.
Nikolay Sivov
nsivov at codeweavers.com
Mon Jan 28 06:51:46 CST 2019
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d3dx9_24/Makefile.in | 1 +
dlls/d3dx9_25/Makefile.in | 1 +
dlls/d3dx9_26/Makefile.in | 1 +
dlls/d3dx9_27/Makefile.in | 1 +
dlls/d3dx9_28/Makefile.in | 1 +
dlls/d3dx9_29/Makefile.in | 1 +
dlls/d3dx9_30/Makefile.in | 1 +
dlls/d3dx9_31/Makefile.in | 1 +
dlls/d3dx9_32/Makefile.in | 1 +
dlls/d3dx9_33/Makefile.in | 1 +
dlls/d3dx9_34/Makefile.in | 1 +
dlls/d3dx9_35/Makefile.in | 1 +
dlls/d3dx9_36/Makefile.in | 1 +
dlls/d3dx9_36/surface.c | 37 +++++++++++++------------------------
dlls/d3dx9_37/Makefile.in | 1 +
dlls/d3dx9_38/Makefile.in | 1 +
dlls/d3dx9_39/Makefile.in | 1 +
dlls/d3dx9_40/Makefile.in | 1 +
dlls/d3dx9_41/Makefile.in | 1 +
dlls/d3dx9_42/Makefile.in | 1 +
dlls/d3dx9_43/Makefile.in | 1 +
21 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/dlls/d3dx9_24/Makefile.in b/dlls/d3dx9_24/Makefile.in
index 482c92d64e..02e64d3a89 100644
--- a/dlls/d3dx9_24/Makefile.in
+++ b/dlls/d3dx9_24/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=24
MODULE = d3dx9_24.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_25/Makefile.in b/dlls/d3dx9_25/Makefile.in
index be4c76980e..57ed1da74a 100644
--- a/dlls/d3dx9_25/Makefile.in
+++ b/dlls/d3dx9_25/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=25
MODULE = d3dx9_25.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_26/Makefile.in b/dlls/d3dx9_26/Makefile.in
index c5e9e85bfb..04d9ba4df4 100644
--- a/dlls/d3dx9_26/Makefile.in
+++ b/dlls/d3dx9_26/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=26
MODULE = d3dx9_26.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_27/Makefile.in b/dlls/d3dx9_27/Makefile.in
index ee7f0e2449..faec9b20dd 100644
--- a/dlls/d3dx9_27/Makefile.in
+++ b/dlls/d3dx9_27/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=27
MODULE = d3dx9_27.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_28/Makefile.in b/dlls/d3dx9_28/Makefile.in
index 094420013d..b8aad93aa7 100644
--- a/dlls/d3dx9_28/Makefile.in
+++ b/dlls/d3dx9_28/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=28
MODULE = d3dx9_28.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_29/Makefile.in b/dlls/d3dx9_29/Makefile.in
index 88cb110ff5..29c76c4a74 100644
--- a/dlls/d3dx9_29/Makefile.in
+++ b/dlls/d3dx9_29/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=29
MODULE = d3dx9_29.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_30/Makefile.in b/dlls/d3dx9_30/Makefile.in
index 6ab2ff2451..810edc9a20 100644
--- a/dlls/d3dx9_30/Makefile.in
+++ b/dlls/d3dx9_30/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=30
MODULE = d3dx9_30.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_31/Makefile.in b/dlls/d3dx9_31/Makefile.in
index 3d44da147d..fce2b53e1e 100644
--- a/dlls/d3dx9_31/Makefile.in
+++ b/dlls/d3dx9_31/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=31
MODULE = d3dx9_31.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_32/Makefile.in b/dlls/d3dx9_32/Makefile.in
index 37cc2797af..ad53b260d0 100644
--- a/dlls/d3dx9_32/Makefile.in
+++ b/dlls/d3dx9_32/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=32
MODULE = d3dx9_32.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_33/Makefile.in b/dlls/d3dx9_33/Makefile.in
index 5b03ec134d..318ddce1ac 100644
--- a/dlls/d3dx9_33/Makefile.in
+++ b/dlls/d3dx9_33/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=33
MODULE = d3dx9_33.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_34/Makefile.in b/dlls/d3dx9_34/Makefile.in
index b7f9c46d5e..451a371bad 100644
--- a/dlls/d3dx9_34/Makefile.in
+++ b/dlls/d3dx9_34/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=34
MODULE = d3dx9_34.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_35/Makefile.in b/dlls/d3dx9_35/Makefile.in
index 9c196ea038..978d0b0bfa 100644
--- a/dlls/d3dx9_35/Makefile.in
+++ b/dlls/d3dx9_35/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=35
MODULE = d3dx9_35.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in
index da8098dd8d..847edece53 100644
--- a/dlls/d3dx9_36/Makefile.in
+++ b/dlls/d3dx9_36/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=36
MODULE = d3dx9_36.dll
IMPORTLIB = d3dx9
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index cae80a8689..cf8286ec75 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -29,6 +29,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
+HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory**);
/* Wine-specific WIC GUIDs */
DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22);
@@ -861,7 +862,6 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
IWICBitmapDecoder *decoder = NULL;
IWICStream *stream;
HRESULT hr;
- HRESULT initresult;
BOOL dib;
TRACE("(%p, %d, %p)\n", data, datasize, info);
@@ -880,9 +880,7 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
/* In case of DIB file, convert it to BMP */
dib = convert_dib_to_bmp((void**)&data, &datasize);
- initresult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
-
- hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory);
+ hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
if (SUCCEEDED(hr)) {
IWICImagingFactory_CreateStream(factory, &stream);
@@ -968,9 +966,6 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
if (decoder)
IWICBitmapDecoder_Release(decoder);
- if (SUCCEEDED(initresult))
- CoUninitialize();
-
if (dib)
HeapFree(GetProcessHeap(), 0, (void*)data);
@@ -1108,7 +1103,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo)
{
D3DXIMAGE_INFO imginfo;
- HRESULT hr, com_init;
+ HRESULT hr;
IWICImagingFactory *factory = NULL;
IWICBitmapDecoder *decoder;
@@ -1161,9 +1156,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
if (imginfo.ImageFileFormat == D3DXIFF_DIB)
convert_dib_to_bmp((void**)&pSrcData, &SrcDataSize);
- com_init = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
-
- if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory)))
+ if (FAILED(WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory)))
goto cleanup_err;
if (FAILED(IWICImagingFactory_CreateStream(factory, &stream)))
@@ -1264,9 +1257,6 @@ cleanup_err:
if (factory)
IWICImagingFactory_Release(factory);
- if (SUCCEEDED(com_init))
- CoUninitialize();
-
if (imginfo.ImageFileFormat == D3DXIFF_DIB)
HeapFree(GetProcessHeap(), 0, (void*)pSrcData);
@@ -2087,10 +2077,10 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
IPropertyBag2 *encoder_options = NULL;
IStream *stream = NULL;
HRESULT hr;
- HRESULT initresult;
- const CLSID *encoder_clsid;
+ const GUID *container_format;
const GUID *pixel_format_guid;
WICPixelFormatGUID wic_pixel_format;
+ IWICImagingFactory *factory;
D3DFORMAT d3d_pixel_format;
D3DSURFACE_DESC src_surface_desc;
IDirect3DSurface9 *temp_surface;
@@ -2116,13 +2106,13 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
{
case D3DXIFF_BMP:
case D3DXIFF_DIB:
- encoder_clsid = &CLSID_WICBmpEncoder;
+ container_format = &GUID_ContainerFormatBmp;
break;
case D3DXIFF_PNG:
- encoder_clsid = &CLSID_WICPngEncoder;
+ container_format = &GUID_ContainerFormatPng;
break;
case D3DXIFF_JPG:
- encoder_clsid = &CLSID_WICJpegEncoder;
+ container_format = &GUID_ContainerFormatJpeg;
break;
case D3DXIFF_DDS:
return save_dds_surface_to_memory(dst_buffer, src_surface, src_rect);
@@ -2160,10 +2150,11 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
height = src_surface_desc.Height;
}
- initresult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
+ if (FAILED(hr)) goto cleanup_err;
- hr = CoCreateInstance(encoder_clsid, NULL, CLSCTX_INPROC_SERVER,
- &IID_IWICBitmapEncoder, (void **)&encoder);
+ hr = IWICImagingFactory_CreateEncoder(factory, container_format, NULL, &encoder);
+ IWICImagingFactory_Release(factory);
if (FAILED(hr)) goto cleanup_err;
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
@@ -2294,7 +2285,5 @@ cleanup:
if (encoder) IWICBitmapEncoder_Release(encoder);
- if (SUCCEEDED(initresult)) CoUninitialize();
-
return hr;
}
diff --git a/dlls/d3dx9_37/Makefile.in b/dlls/d3dx9_37/Makefile.in
index ab790a4d5c..a05068c2bf 100644
--- a/dlls/d3dx9_37/Makefile.in
+++ b/dlls/d3dx9_37/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=37
MODULE = d3dx9_37.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_38/Makefile.in b/dlls/d3dx9_38/Makefile.in
index 6125c2da67..b092e6267f 100644
--- a/dlls/d3dx9_38/Makefile.in
+++ b/dlls/d3dx9_38/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=38
MODULE = d3dx9_38.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_39/Makefile.in b/dlls/d3dx9_39/Makefile.in
index d97a787c67..4d17120e0b 100644
--- a/dlls/d3dx9_39/Makefile.in
+++ b/dlls/d3dx9_39/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=39
MODULE = d3dx9_39.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_40/Makefile.in b/dlls/d3dx9_40/Makefile.in
index 36c5a210cd..59f6f3d592 100644
--- a/dlls/d3dx9_40/Makefile.in
+++ b/dlls/d3dx9_40/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=40
MODULE = d3dx9_40.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_41/Makefile.in b/dlls/d3dx9_41/Makefile.in
index d4552cf608..f18443a51e 100644
--- a/dlls/d3dx9_41/Makefile.in
+++ b/dlls/d3dx9_41/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=41
MODULE = d3dx9_41.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_42/Makefile.in b/dlls/d3dx9_42/Makefile.in
index 5806fce66c..cb142b7ac2 100644
--- a/dlls/d3dx9_42/Makefile.in
+++ b/dlls/d3dx9_42/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=42
MODULE = d3dx9_42.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_43/Makefile.in b/dlls/d3dx9_43/Makefile.in
index 72ba8b4c1e..3e6111a13d 100644
--- a/dlls/d3dx9_43/Makefile.in
+++ b/dlls/d3dx9_43/Makefile.in
@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=43
MODULE = d3dx9_43.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36
+DELAYIMPORTS = windowscodecs
C_SRCS = \
animation.c \
--
2.20.1
More information about the wine-devel
mailing list