d3dx9: Use wincodecs directly without initializing COM system.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-01-28 15:51:46 +03:00 committed by Alexandre Julliard
parent 3c87df0bc0
commit 77c3761ad4
21 changed files with 33 additions and 24 deletions

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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;
}

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \