Instead of PaletteImpl_Create.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
v3: Don't import palette.c anymore, use WINCODECS_CUSTOM_UNIXLIB define to guard custom encoders / decoders. Resending jxrlib integration later.
Supersedes: 198861-198864
dlls/windowscodecs/wincodecs_common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/wincodecs_common.c b/dlls/windowscodecs/wincodecs_common.c index 37ad7128f10..1b146908be9 100644 --- a/dlls/windowscodecs/wincodecs_common.c +++ b/dlls/windowscodecs/wincodecs_common.c @@ -121,9 +121,17 @@ HRESULT write_source(IWICBitmapFrameEncode *iface,
if (need_palette) { + IWICImagingFactory *factory; IWICPalette *palette;
- hr = PaletteImpl_Create(&palette); + hr = create_instance(&CLSID_WICImagingFactory, &IID_IWICImagingFactory, (void**)&factory); + + if (SUCCEEDED(hr)) + { + hr = IWICImagingFactory_CreatePalette(factory, &palette); + IWICImagingFactory_Release(factory); + } + if (SUCCEEDED(hr)) { hr = IWICBitmapSource_CopyPalette(converted_source, palette);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/windowscodecs/unix_lib.c | 2 ++ dlls/windowscodecs/wincodecs_private.h | 1 + 2 files changed, 3 insertions(+)
diff --git a/dlls/windowscodecs/unix_lib.c b/dlls/windowscodecs/unix_lib.c index 268a1cd9d16..9255b3ed243 100644 --- a/dlls/windowscodecs/unix_lib.c +++ b/dlls/windowscodecs/unix_lib.c @@ -67,6 +67,7 @@ HRESULT CDECL stream_write(IStream *stream, const void *buffer, ULONG write, ULO return win32_funcs->stream_write(stream, buffer, write, bytes_written); }
+#ifndef WINCODECS_CUSTOM_UNIXLIB HRESULT CDECL decoder_create(const CLSID *decoder_clsid, struct decoder_info *info, struct decoder **result) { if (IsEqualGUID(decoder_clsid, &CLSID_WICPngDecoder)) @@ -97,6 +98,7 @@ HRESULT CDECL encoder_create(const CLSID *encoder_clsid, struct encoder_info *in
return E_NOTIMPL; } +#endif /* WINCODECS_CUSTOM_UNIXLIB */
static const struct unix_funcs unix_funcs = { decoder_create, diff --git a/dlls/windowscodecs/wincodecs_private.h b/dlls/windowscodecs/wincodecs_private.h index 453bc58cca6..61c3b95a7dd 100644 --- a/dlls/windowscodecs/wincodecs_private.h +++ b/dlls/windowscodecs/wincodecs_private.h @@ -396,6 +396,7 @@ struct encoder_funcs void (CDECL *destroy)(struct encoder* This); };
+HRESULT CDECL encoder_create(const CLSID *encoder_clsid, struct encoder_info *info, struct encoder **result); HRESULT CDECL encoder_initialize(struct encoder* This, IStream *stream); HRESULT CDECL encoder_get_supported_format(struct encoder* This, GUID *pixel_format, DWORD *bpp, BOOL *indexed); HRESULT CDECL encoder_create_frame(struct encoder* This, const struct encoder_frame *frame);
Signed-off-by: Esme Povirk esme@codeweavers.com
Rémi Bernon rbernon@codeweavers.com writes:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/windowscodecs/unix_lib.c | 2 ++ dlls/windowscodecs/wincodecs_private.h | 1 + 2 files changed, 3 insertions(+)
diff --git a/dlls/windowscodecs/unix_lib.c b/dlls/windowscodecs/unix_lib.c index 268a1cd9d16..9255b3ed243 100644 --- a/dlls/windowscodecs/unix_lib.c +++ b/dlls/windowscodecs/unix_lib.c @@ -67,6 +67,7 @@ HRESULT CDECL stream_write(IStream *stream, const void *buffer, ULONG write, ULO return win32_funcs->stream_write(stream, buffer, write, bytes_written); }
+#ifndef WINCODECS_CUSTOM_UNIXLIB HRESULT CDECL decoder_create(const CLSID *decoder_clsid, struct decoder_info *info, struct decoder **result) { if (IsEqualGUID(decoder_clsid, &CLSID_WICPngDecoder)) @@ -97,6 +98,7 @@ HRESULT CDECL encoder_create(const CLSID *encoder_clsid, struct encoder_info *in
return E_NOTIMPL;
} +#endif /* WINCODECS_CUSTOM_UNIXLIB */
That doesn't seem like an improvement. I don't see what you gain by sharing this file across dlls.
On 2/1/21 10:49 AM, Alexandre Julliard wrote:
Rémi Bernon rbernon@codeweavers.com writes:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/windowscodecs/unix_lib.c | 2 ++ dlls/windowscodecs/wincodecs_private.h | 1 + 2 files changed, 3 insertions(+)
diff --git a/dlls/windowscodecs/unix_lib.c b/dlls/windowscodecs/unix_lib.c index 268a1cd9d16..9255b3ed243 100644 --- a/dlls/windowscodecs/unix_lib.c +++ b/dlls/windowscodecs/unix_lib.c @@ -67,6 +67,7 @@ HRESULT CDECL stream_write(IStream *stream, const void *buffer, ULONG write, ULO return win32_funcs->stream_write(stream, buffer, write, bytes_written); }
+#ifndef WINCODECS_CUSTOM_UNIXLIB HRESULT CDECL decoder_create(const CLSID *decoder_clsid, struct decoder_info *info, struct decoder **result) { if (IsEqualGUID(decoder_clsid, &CLSID_WICPngDecoder)) @@ -97,6 +98,7 @@ HRESULT CDECL encoder_create(const CLSID *encoder_clsid, struct encoder_info *in
return E_NOTIMPL;
} +#endif /* WINCODECS_CUSTOM_UNIXLIB */
That doesn't seem like an improvement. I don't see what you gain by sharing this file across dlls.
Well, it was initially duplicated and I changed it on request. I guess it factors the windowscodecs unixlib interface a bit more, helping the module maintenance? I personally don't have much preference here.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wmphoto/Makefile.in | 11 +++- dlls/wmphoto/jxrlib.c | 55 +++++++++++++++++ dlls/wmphoto/main.c | 128 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 183 insertions(+), 11 deletions(-) create mode 100644 dlls/wmphoto/jxrlib.c
diff --git a/dlls/wmphoto/Makefile.in b/dlls/wmphoto/Makefile.in index 24e1f49496a..36cef3fcfd4 100644 --- a/dlls/wmphoto/Makefile.in +++ b/dlls/wmphoto/Makefile.in @@ -1,7 +1,16 @@ MODULE = wmphoto.dll +IMPORTS = windowscodecs uuid ole32 oleaut32 propsys rpcrt4 shlwapi +PARENTSRC = ../windowscodecs
EXTRADLLFLAGS = -mno-cygwin +EXTRADEFS = -DWINCODECS_CUSTOM_UNIXLIB
-C_SRCS = main.c +C_SRCS = \ + decoder.c \ + jxrlib.c \ + main.c \ + unix_iface.c \ + unix_lib.c \ + wincodecs_common.c
IDL_SRCS = wmphoto.idl diff --git a/dlls/wmphoto/jxrlib.c b/dlls/wmphoto/jxrlib.c new file mode 100644 index 00000000000..891c905a9a6 --- /dev/null +++ b/dlls/wmphoto/jxrlib.c @@ -0,0 +1,55 @@ +/* + * unix_lib.c - This is the Unix side of the Unix interface. + * + * Copyright 2020 Esme Povirk + * Copyright 2020 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep unix +#endif + +#include "config.h" +#include "wine/port.h" + +#include <stdarg.h> + +#define NONAMELESSUNION + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winternl.h" +#include "winbase.h" +#include "objbase.h" + +#include "wincodecs_private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); + +HRESULT CDECL decoder_create(const CLSID *decoder_clsid, struct decoder_info *info, struct decoder **result) +{ + FIXME("decoder_clsid %s, info %p, result %p, stub!\n", debugstr_guid(decoder_clsid), info, result); + return E_NOTIMPL; +} + +HRESULT CDECL encoder_create(const CLSID *encoder_clsid, struct encoder_info *info, struct encoder **result) +{ + FIXME("encoder_clsid %s, info %p, result %p, stub!\n", debugstr_guid(encoder_clsid), info, result); + return E_NOTIMPL; +} diff --git a/dlls/wmphoto/main.c b/dlls/wmphoto/main.c index d3a926e7704..7659dcb2ca8 100644 --- a/dlls/wmphoto/main.c +++ b/dlls/wmphoto/main.c @@ -1,5 +1,6 @@ /* * Copyright 2017 Vincent Povirk for CodeWeavers + * Copyright 2020 Rémi Bernon for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,24 +19,121 @@
#include <stdarg.h>
+#define COBJMACROS + #include "windef.h" #include "winbase.h" #include "objbase.h" #include "rpcproxy.h"
+#include "wincodecs_private.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
-static HINSTANCE WMPHOTO_hInstance; +HRESULT create_instance(const CLSID *clsid, const IID *iid, void **ppv) +{ + return CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, ppv); +} + +HRESULT get_decoder_info(REFCLSID clsid, IWICBitmapDecoderInfo **info) +{ + IWICImagingFactory* factory; + IWICComponentInfo *compinfo; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICImagingFactory, (void **)&factory); + if (FAILED(hr)) + return hr; + + hr = IWICImagingFactory_CreateComponentInfo(factory, clsid, &compinfo); + if (FAILED(hr)) + { + IWICImagingFactory_Release(factory); + return hr; + } + + hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo, + (void **)info); + + IWICComponentInfo_Release(compinfo); + IWICImagingFactory_Release(factory); + return hr; +} + +struct class_factory +{ + IClassFactory IClassFactory_iface; +}; + +static HRESULT WINAPI wmp_class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory)) + { + *out = iface; + IClassFactory_AddRef(iface); + return S_OK; + } + + *out = NULL; + FIXME("%s not implemented.\n", debugstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI wmp_class_factory_AddRef(IClassFactory *iface) { return 2; }
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +static ULONG WINAPI wmp_class_factory_Release(IClassFactory *iface) { return 1; } + +static HRESULT WINAPI wmp_class_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **out) +{ + struct decoder_info decoder_info; + struct decoder *decoder; + HRESULT hr; + + TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out); + + *out = NULL; + if (outer) return CLASS_E_NOAGGREGATION; + + hr = get_unix_decoder(&CLSID_WICWmpDecoder, &decoder_info, &decoder); + + if (SUCCEEDED(hr)) + hr = CommonDecoder_CreateInstance(decoder, &decoder_info, iid, out); + + return hr; +} + +static HRESULT WINAPI wmp_class_factory_LockServer(IClassFactory *iface, BOOL lock) +{ + FIXME("iface %p, lock %d, stub!\n", iface, lock); + return S_OK; +} + +static const IClassFactoryVtbl wmp_class_factory_vtbl = +{ + wmp_class_factory_QueryInterface, + wmp_class_factory_AddRef, + wmp_class_factory_Release, + wmp_class_factory_CreateInstance, + wmp_class_factory_LockServer, +}; + +static struct class_factory wmp_class_factory = {{&wmp_class_factory_vtbl}}; + +HMODULE windowscodecs_module = 0; + +BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { - switch (fdwReason) + TRACE("instance %p, reason %d, reserved %p\n", instance, reason, reserved); + + switch (reason) { case DLL_PROCESS_ATTACH: - WMPHOTO_hInstance = hinstDLL; - DisableThreadLibraryCalls(hinstDLL); + windowscodecs_module = instance; + DisableThreadLibraryCalls(instance); break; case DLL_WINE_PREATTACH: return FALSE; /* prefer native version */ @@ -49,18 +147,28 @@ HRESULT WINAPI DllCanUnloadNow(void) return S_FALSE; }
-HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv) +HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *out) { - FIXME("wmphoto: stub\n"); - return E_NOTIMPL; + struct class_factory *factory; + + TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out); + + if (IsEqualGUID(clsid, &CLSID_WICWmpDecoder)) factory = &wmp_class_factory; + else + { + FIXME("%s not implemented.\n", debugstr_guid(clsid)); + return CLASS_E_CLASSNOTAVAILABLE; + } + + return IClassFactory_QueryInterface(&factory->IClassFactory_iface, iid, out); }
HRESULT WINAPI DllRegisterServer(void) { - return __wine_register_resources( WMPHOTO_hInstance ); + return __wine_register_resources( windowscodecs_module ); }
HRESULT WINAPI DllUnregisterServer(void) { - return __wine_unregister_resources( WMPHOTO_hInstance ); + return __wine_unregister_resources( windowscodecs_module ); }
Signed-off-by: Esme Povirk esme@codeweavers.com