Commit 77c3761a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3dx9: Use wincodecs directly without initializing COM system.

parent 3c87df0b
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=24 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=24
MODULE = d3dx9_24.dll MODULE = d3dx9_24.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=25 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=25
MODULE = d3dx9_25.dll MODULE = d3dx9_25.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=26 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=26
MODULE = d3dx9_26.dll MODULE = d3dx9_26.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=27 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=27
MODULE = d3dx9_27.dll MODULE = d3dx9_27.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=28 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=28
MODULE = d3dx9_28.dll MODULE = d3dx9_28.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=29 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=29
MODULE = d3dx9_29.dll MODULE = d3dx9_29.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=30 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=30
MODULE = d3dx9_30.dll MODULE = d3dx9_30.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=31 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=31
MODULE = d3dx9_31.dll MODULE = d3dx9_31.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=32 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=32
MODULE = d3dx9_32.dll MODULE = d3dx9_32.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=33 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=33
MODULE = d3dx9_33.dll MODULE = d3dx9_33.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=34 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=34
MODULE = d3dx9_34.dll MODULE = d3dx9_34.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=35 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=35
MODULE = d3dx9_35.dll MODULE = d3dx9_35.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=36 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=36
MODULE = d3dx9_36.dll MODULE = d3dx9_36.dll
IMPORTLIB = d3dx9 IMPORTLIB = d3dx9
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3dx); WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory**);
/* Wine-specific WIC GUIDs */ /* Wine-specific WIC GUIDs */
DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22); 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, ...@@ -861,7 +862,6 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
IWICBitmapDecoder *decoder = NULL; IWICBitmapDecoder *decoder = NULL;
IWICStream *stream; IWICStream *stream;
HRESULT hr; HRESULT hr;
HRESULT initresult;
BOOL dib; BOOL dib;
TRACE("(%p, %d, %p)\n", data, datasize, info); TRACE("(%p, %d, %p)\n", data, datasize, info);
...@@ -880,9 +880,7 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, ...@@ -880,9 +880,7 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
/* In case of DIB file, convert it to BMP */ /* In case of DIB file, convert it to BMP */
dib = convert_dib_to_bmp((void**)&data, &datasize); dib = convert_dib_to_bmp((void**)&data, &datasize);
initresult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
IWICImagingFactory_CreateStream(factory, &stream); IWICImagingFactory_CreateStream(factory, &stream);
...@@ -968,9 +966,6 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, ...@@ -968,9 +966,6 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
if (decoder) if (decoder)
IWICBitmapDecoder_Release(decoder); IWICBitmapDecoder_Release(decoder);
if (SUCCEEDED(initresult))
CoUninitialize();
if (dib) if (dib)
HeapFree(GetProcessHeap(), 0, (void*)data); HeapFree(GetProcessHeap(), 0, (void*)data);
...@@ -1108,7 +1103,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface, ...@@ -1108,7 +1103,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo) const RECT *pSrcRect, DWORD dwFilter, D3DCOLOR Colorkey, D3DXIMAGE_INFO *pSrcInfo)
{ {
D3DXIMAGE_INFO imginfo; D3DXIMAGE_INFO imginfo;
HRESULT hr, com_init; HRESULT hr;
IWICImagingFactory *factory = NULL; IWICImagingFactory *factory = NULL;
IWICBitmapDecoder *decoder; IWICBitmapDecoder *decoder;
...@@ -1161,9 +1156,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface, ...@@ -1161,9 +1156,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromFileInMemory(IDirect3DSurface9 *pDestSurface,
if (imginfo.ImageFileFormat == D3DXIFF_DIB) if (imginfo.ImageFileFormat == D3DXIFF_DIB)
convert_dib_to_bmp((void**)&pSrcData, &SrcDataSize); convert_dib_to_bmp((void**)&pSrcData, &SrcDataSize);
com_init = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (FAILED(WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory)))
if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&factory)))
goto cleanup_err; goto cleanup_err;
if (FAILED(IWICImagingFactory_CreateStream(factory, &stream))) if (FAILED(IWICImagingFactory_CreateStream(factory, &stream)))
...@@ -1264,9 +1257,6 @@ cleanup_err: ...@@ -1264,9 +1257,6 @@ cleanup_err:
if (factory) if (factory)
IWICImagingFactory_Release(factory); IWICImagingFactory_Release(factory);
if (SUCCEEDED(com_init))
CoUninitialize();
if (imginfo.ImageFileFormat == D3DXIFF_DIB) if (imginfo.ImageFileFormat == D3DXIFF_DIB)
HeapFree(GetProcessHeap(), 0, (void*)pSrcData); HeapFree(GetProcessHeap(), 0, (void*)pSrcData);
...@@ -2087,10 +2077,10 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE ...@@ -2087,10 +2077,10 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
IPropertyBag2 *encoder_options = NULL; IPropertyBag2 *encoder_options = NULL;
IStream *stream = NULL; IStream *stream = NULL;
HRESULT hr; HRESULT hr;
HRESULT initresult; const GUID *container_format;
const CLSID *encoder_clsid;
const GUID *pixel_format_guid; const GUID *pixel_format_guid;
WICPixelFormatGUID wic_pixel_format; WICPixelFormatGUID wic_pixel_format;
IWICImagingFactory *factory;
D3DFORMAT d3d_pixel_format; D3DFORMAT d3d_pixel_format;
D3DSURFACE_DESC src_surface_desc; D3DSURFACE_DESC src_surface_desc;
IDirect3DSurface9 *temp_surface; IDirect3DSurface9 *temp_surface;
...@@ -2116,13 +2106,13 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE ...@@ -2116,13 +2106,13 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
{ {
case D3DXIFF_BMP: case D3DXIFF_BMP:
case D3DXIFF_DIB: case D3DXIFF_DIB:
encoder_clsid = &CLSID_WICBmpEncoder; container_format = &GUID_ContainerFormatBmp;
break; break;
case D3DXIFF_PNG: case D3DXIFF_PNG:
encoder_clsid = &CLSID_WICPngEncoder; container_format = &GUID_ContainerFormatPng;
break; break;
case D3DXIFF_JPG: case D3DXIFF_JPG:
encoder_clsid = &CLSID_WICJpegEncoder; container_format = &GUID_ContainerFormatJpeg;
break; break;
case D3DXIFF_DDS: case D3DXIFF_DDS:
return save_dds_surface_to_memory(dst_buffer, src_surface, src_rect); return save_dds_surface_to_memory(dst_buffer, src_surface, src_rect);
...@@ -2160,10 +2150,11 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE ...@@ -2160,10 +2150,11 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE
height = src_surface_desc.Height; 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, hr = IWICImagingFactory_CreateEncoder(factory, container_format, NULL, &encoder);
&IID_IWICBitmapEncoder, (void **)&encoder); IWICImagingFactory_Release(factory);
if (FAILED(hr)) goto cleanup_err; if (FAILED(hr)) goto cleanup_err;
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
...@@ -2294,7 +2285,5 @@ cleanup: ...@@ -2294,7 +2285,5 @@ cleanup:
if (encoder) IWICBitmapEncoder_Release(encoder); if (encoder) IWICBitmapEncoder_Release(encoder);
if (SUCCEEDED(initresult)) CoUninitialize();
return hr; return hr;
} }
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=37 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=37
MODULE = d3dx9_37.dll MODULE = d3dx9_37.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=38 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=38
MODULE = d3dx9_38.dll MODULE = d3dx9_38.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=39 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=39
MODULE = d3dx9_39.dll MODULE = d3dx9_39.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=40 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=40
MODULE = d3dx9_40.dll MODULE = d3dx9_40.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=41 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=41
MODULE = d3dx9_41.dll MODULE = d3dx9_41.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=42 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=42
MODULE = d3dx9_42.dll MODULE = d3dx9_42.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=43 ...@@ -2,6 +2,7 @@ EXTRADEFS = -DD3DX_SDK_VERSION=43
MODULE = d3dx9_43.dll MODULE = d3dx9_43.dll
IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32 IMPORTS = d3d9 d3dcompiler dxguid d3dxof ole32 gdi32 user32
PARENTSRC = ../d3dx9_36 PARENTSRC = ../d3dx9_36
DELAYIMPORTS = windowscodecs
C_SRCS = \ C_SRCS = \
animation.c \ animation.c \
......
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