makefiles: Explicitly create destination dirs when installing symlinks.
[wine/zf.git] / dlls / windowscodecs / unix_iface.c
blobe376ea458417bb1fae50a1ef99eb1cc01bc8aa73
1 /*
2 * unix_iface.c - This is the Win32 side of the Unix interface.
4 * Copyright 2020 Esme Povirk
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdarg.h>
26 #define NONAMELESSUNION
27 #define COBJMACROS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "objbase.h"
32 #include "winternl.h"
34 #include "wincodecs_private.h"
36 #include "wine/debug.h"
38 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
40 static const struct unix_funcs *unix_funcs;
42 static const struct win32_funcs win32_funcs = {
43 stream_read,
44 stream_seek
47 static BOOL WINAPI load_unixlib( INIT_ONCE *once, void *param, void **context )
49 __wine_init_unix_lib( windowscodecs_module, DLL_PROCESS_ATTACH, &win32_funcs, &unix_funcs );
50 return TRUE;
53 static void init_unixlib(void)
55 InitOnceExecuteOnce( &init_once, load_unixlib, NULL, NULL );
58 struct decoder_wrapper
60 struct decoder win32_decoder;
61 struct decoder *unix_decoder;
64 static inline struct decoder_wrapper *impl_from_decoder(struct decoder* iface)
66 return CONTAINING_RECORD(iface, struct decoder_wrapper, win32_decoder);
69 HRESULT CDECL decoder_wrapper_initialize(struct decoder* iface, IStream* stream, struct decoder_stat *st)
71 struct decoder_wrapper* This = impl_from_decoder(iface);
72 return unix_funcs->decoder_initialize(This->unix_decoder, stream, st);
75 HRESULT CDECL decoder_wrapper_get_frame_info(struct decoder* iface, UINT frame, struct decoder_frame *info)
77 struct decoder_wrapper* This = impl_from_decoder(iface);
78 return unix_funcs->decoder_get_frame_info(This->unix_decoder, frame, info);
81 HRESULT CDECL decoder_wrapper_copy_pixels(struct decoder* iface, UINT frame,
82 const WICRect *prc, UINT stride, UINT buffersize, BYTE *buffer)
84 struct decoder_wrapper* This = impl_from_decoder(iface);
85 return unix_funcs->decoder_copy_pixels(This->unix_decoder, frame, prc, stride, buffersize, buffer);
88 HRESULT CDECL decoder_wrapper_get_metadata_blocks(struct decoder* iface,
89 UINT frame, UINT *count, struct decoder_block **blocks)
91 struct decoder_wrapper* This = impl_from_decoder(iface);
92 return unix_funcs->decoder_get_metadata_blocks(This->unix_decoder, frame, count, blocks);
95 HRESULT CDECL decoder_wrapper_get_color_context(struct decoder* iface,
96 UINT frame, UINT num, BYTE **data, DWORD *datasize)
98 struct decoder_wrapper* This = impl_from_decoder(iface);
99 return unix_funcs->decoder_get_color_context(This->unix_decoder, frame, num, data, datasize);
102 void CDECL decoder_wrapper_destroy(struct decoder* iface)
104 struct decoder_wrapper* This = impl_from_decoder(iface);
105 unix_funcs->decoder_destroy(This->unix_decoder);
106 HeapFree(GetProcessHeap(), 0, This);
109 static const struct decoder_funcs decoder_wrapper_vtable = {
110 decoder_wrapper_initialize,
111 decoder_wrapper_get_frame_info,
112 decoder_wrapper_copy_pixels,
113 decoder_wrapper_get_metadata_blocks,
114 decoder_wrapper_get_color_context,
115 decoder_wrapper_destroy
118 HRESULT get_unix_decoder(const CLSID *decoder_clsid, struct decoder_info *info, struct decoder **result)
120 HRESULT hr;
121 struct decoder_wrapper *wrapper;
122 struct decoder *unix_decoder;
124 init_unixlib();
126 hr = unix_funcs->decoder_create(decoder_clsid, info, &unix_decoder);
128 if (SUCCEEDED(hr))
130 wrapper = HeapAlloc(GetProcessHeap(), 0, sizeof(*wrapper));
132 if (!wrapper)
134 unix_funcs->decoder_destroy(unix_decoder);
135 return E_OUTOFMEMORY;
138 wrapper->win32_decoder.vtable = &decoder_wrapper_vtable;
139 wrapper->unix_decoder = unix_decoder;
140 *result = &wrapper->win32_decoder;
143 return hr;