mirror of
https://github.com/reactos/reactos.git
synced 2024-11-18 21:13:52 +00:00
[WINESYNC]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> wine commit id 77c3761ad4e557f9fa311299e77746bf225a575a by Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
296900e697
commit
16bc86bfb1
3 changed files with 15 additions and 25 deletions
|
@ -36,6 +36,7 @@ function(add_d3dx9_target __version)
|
||||||
add_dependencies(${module} d3d_idl_headers)
|
add_dependencies(${module} d3d_idl_headers)
|
||||||
target_link_libraries(${module} dxguid wine)
|
target_link_libraries(${module} dxguid wine)
|
||||||
add_importlibs(${module} d3dcompiler_43 d3dxof user32 ole32 gdi32 msvcrt kernel32 ntdll)
|
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_pch(${module} ../d3dx9_36/precomp.h SOURCE)
|
||||||
add_cd_file(TARGET ${module} DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET ${module} DESTINATION reactos/system32 FOR all)
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
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,
|
||||||
/* 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,
|
||||||
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,
|
||||||
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,
|
||||||
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:
|
||||||
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
|
||||||
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
|
||||||
{
|
{
|
||||||
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
|
||||||
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:
|
||||||
|
|
||||||
if (encoder) IWICBitmapEncoder_Release(encoder);
|
if (encoder) IWICBitmapEncoder_Release(encoder);
|
||||||
|
|
||||||
if (SUCCEEDED(initresult)) CoUninitialize();
|
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,4 +33,4 @@ files:
|
||||||
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h
|
include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h
|
||||||
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h
|
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h
|
||||||
tags:
|
tags:
|
||||||
wine: 699eb8cdba8fe236f038550e2bd68a4cd2cab055
|
wine: 77c3761ad4e557f9fa311299e77746bf225a575a
|
||||||
|
|
Loading…
Reference in a new issue