https://git.reactos.org/?p=reactos.git;a=commitdiff;h=16bc86bfb1d9e128e1d3c…
commit 16bc86bfb1d9e128e1d3c3eae68cb4ab06b93e22
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Jan 4 01:48:04 2020 +0100
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Feb 26 18:19:18 2020 +0100
[WINESYNC]d3dx9: Use wincodecs directly without initializing COM system.
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 77c3761ad4e557f9fa311299e77746bf225a575a by Nikolay Sivov
<nsivov(a)codeweavers.com>
---
dll/directx/wine/d3dx9_36/d3dx9.cmake | 1 +
dll/directx/wine/d3dx9_36/surface.c | 37 ++++++++++++-----------------------
sdk/tools/winesync/d3dx9.cfg | 2 +-
3 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/dll/directx/wine/d3dx9_36/d3dx9.cmake
b/dll/directx/wine/d3dx9_36/d3dx9.cmake
index 5f206cf6377..77dd1cde119 100644
--- a/dll/directx/wine/d3dx9_36/d3dx9.cmake
+++ b/dll/directx/wine/d3dx9_36/d3dx9.cmake
@@ -36,6 +36,7 @@ function(add_d3dx9_target __version)
add_dependencies(${module} d3d_idl_headers)
target_link_libraries(${module} dxguid wine)
add_importlibs(${module} d3dcompiler_43 d3dxof user32 ole32 gdi32 msvcrt kernel32
ntdll)
+ add_delay_importlibs(${module} windowscodecs)
add_pch(${module} ../d3dx9_36/precomp.h SOURCE)
add_cd_file(TARGET ${module} DESTINATION reactos/system32 FOR all)
diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c
index cae80a8689b..cf8286ec758 100644
--- a/dll/directx/wine/d3dx9_36/surface.c
+++ b/dll/directx/wine/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/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index c2b8a4cc5f5..996f8297083 100644
--- a/sdk/tools/winesync/d3dx9.cfg
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -33,4 +33,4 @@ files:
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h
tags:
- wine: 699eb8cdba8fe236f038550e2bd68a4cd2cab055
+ wine: 77c3761ad4e557f9fa311299e77746bf225a575a