d2d1: Add a properties list for builtin effects.
[wine.git] / dlls / d2d1 / effect.c
blobc884c3b8d4f9ae7d5e2a215a01ee1ec65615066a
1 /*
2 * Copyright 2018 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "d2d1_private.h"
21 WINE_DEFAULT_DEBUG_CHANNEL(d2d);
23 struct d2d_effect_info
25 const CLSID *clsid;
26 UINT32 default_input_count;
29 static const struct d2d_effect_info builtin_effects[] =
31 {&CLSID_D2D12DAffineTransform, 1},
32 {&CLSID_D2D13DPerspectiveTransform, 1},
33 {&CLSID_D2D1Composite, 2}
36 static inline struct d2d_effect *impl_from_ID2D1Effect(ID2D1Effect *iface)
38 return CONTAINING_RECORD(iface, struct d2d_effect, ID2D1Effect_iface);
41 static void d2d_effect_cleanup(struct d2d_effect *effect)
43 heap_free(effect->inputs);
44 ID2D1Factory_Release(effect->factory);
47 static HRESULT STDMETHODCALLTYPE d2d_effect_QueryInterface(ID2D1Effect *iface, REFIID iid, void **out)
49 struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
50 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
52 if (IsEqualGUID(iid, &IID_ID2D1Effect)
53 || IsEqualGUID(iid, &IID_ID2D1Properties)
54 || IsEqualGUID(iid, &IID_IUnknown))
56 ID2D1Effect_AddRef(iface);
57 *out = iface;
58 return S_OK;
61 if (IsEqualGUID(iid, &IID_ID2D1Image)
62 || IsEqualGUID(iid, &IID_ID2D1Resource))
64 ID2D1Image_AddRef(&effect->ID2D1Image_iface);
65 *out = &effect->ID2D1Image_iface;
66 return S_OK;
69 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
71 *out = NULL;
72 return E_NOINTERFACE;
75 static ULONG STDMETHODCALLTYPE d2d_effect_AddRef(ID2D1Effect *iface)
77 struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
78 ULONG refcount = InterlockedIncrement(&effect->refcount);
80 TRACE("%p increasing refcount to %u.\n", iface, refcount);
82 return refcount;
85 static ULONG STDMETHODCALLTYPE d2d_effect_Release(ID2D1Effect *iface)
87 struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
88 ULONG refcount = InterlockedDecrement(&effect->refcount);
90 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
92 if (!refcount)
94 d2d_effect_cleanup(effect);
95 heap_free(effect);
98 return refcount;
101 static UINT32 STDMETHODCALLTYPE d2d_effect_GetPropertyCount(ID2D1Effect *iface)
103 FIXME("iface %p stub!\n", iface);
105 return 0;
108 static HRESULT STDMETHODCALLTYPE d2d_effect_GetPropertyName(ID2D1Effect *iface, UINT32 index,
109 WCHAR *name, UINT32 name_count)
111 FIXME("iface %p, index %u, name %p, name_count %u stub!\n", iface, index, name, name_count);
113 return E_NOTIMPL;
116 static UINT32 STDMETHODCALLTYPE d2d_effect_GetPropertyNameLength(ID2D1Effect *iface, UINT32 index)
118 FIXME("iface %p, index %u stub!\n", iface, index);
120 return 0;
123 static D2D1_PROPERTY_TYPE STDMETHODCALLTYPE d2d_effect_GetType(ID2D1Effect *iface, UINT32 index)
125 FIXME("iface %p, index %u stub!\n", iface, index);
127 return 0;
130 static UINT32 STDMETHODCALLTYPE d2d_effect_GetPropertyIndex(ID2D1Effect *iface, const WCHAR *name)
132 FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
134 return 0;
137 static HRESULT STDMETHODCALLTYPE d2d_effect_SetValueByName(ID2D1Effect *iface, const WCHAR *name,
138 D2D1_PROPERTY_TYPE type, const BYTE *value, UINT32 value_size)
140 FIXME("iface %p, name %s, type %#x, value %p, value_size %u stub!\n", iface, debugstr_w(name),
141 type, value, value_size);
143 return E_NOTIMPL;
146 static HRESULT STDMETHODCALLTYPE d2d_effect_SetValue(ID2D1Effect *iface, UINT32 index, D2D1_PROPERTY_TYPE type,
147 const BYTE *value, UINT32 value_size)
149 FIXME("iface %p, index %u, type %#x, value %p, value_size %u stub!\n", iface, index, type, value, value_size);
151 return S_OK;
154 static HRESULT STDMETHODCALLTYPE d2d_effect_GetValueByName(ID2D1Effect *iface, const WCHAR *name,
155 D2D1_PROPERTY_TYPE type, BYTE *value, UINT32 value_size)
157 FIXME("iface %p, name %s, type %#x, value %p, value_size %u stub!\n", iface, debugstr_w(name), type,
158 value, value_size);
160 return E_NOTIMPL;
163 static HRESULT STDMETHODCALLTYPE d2d_effect_GetValue(ID2D1Effect *iface, UINT32 index, D2D1_PROPERTY_TYPE type,
164 BYTE *value, UINT32 value_size)
166 FIXME("iface %p, index %u, type %#x, value %p, value_size %u stub!\n", iface, index, type,
167 value, value_size);
169 return E_NOTIMPL;
172 static UINT32 STDMETHODCALLTYPE d2d_effect_GetValueSize(ID2D1Effect *iface, UINT32 index)
174 FIXME("iface %p, index %u stub!\n", iface, index);
176 return 0;
179 static HRESULT STDMETHODCALLTYPE d2d_effect_GetSubProperties(ID2D1Effect *iface, UINT32 index, ID2D1Properties **props)
181 FIXME("iface %p, index %u, props %p stub!\n", iface, index, props);
183 return E_NOTIMPL;
186 static void STDMETHODCALLTYPE d2d_effect_SetInput(ID2D1Effect *iface, UINT32 index, ID2D1Image *input, BOOL invalidate)
188 FIXME("iface %p, index %u, input %p, invalidate %d stub!\n", iface, index, input, invalidate);
191 static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UINT32 count)
193 FIXME("iface %p, count %u stub!\n", iface, count);
195 return E_NOTIMPL;
198 static void STDMETHODCALLTYPE d2d_effect_GetInput(ID2D1Effect *iface, UINT32 index, ID2D1Image **input)
200 FIXME("iface %p, index %u, input %p stub!\n", iface, index, input);
203 static UINT32 STDMETHODCALLTYPE d2d_effect_GetInputCount(ID2D1Effect *iface)
205 struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
207 TRACE("iface %p.\n", iface);
209 return effect->input_count;
212 static void STDMETHODCALLTYPE d2d_effect_GetOutput(ID2D1Effect *iface, ID2D1Image **output)
214 struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
216 TRACE("iface %p, output %p.\n", iface, output);
218 ID2D1Image_AddRef(*output = &effect->ID2D1Image_iface);
221 static const ID2D1EffectVtbl d2d_effect_vtbl =
223 d2d_effect_QueryInterface,
224 d2d_effect_AddRef,
225 d2d_effect_Release,
226 d2d_effect_GetPropertyCount,
227 d2d_effect_GetPropertyName,
228 d2d_effect_GetPropertyNameLength,
229 d2d_effect_GetType,
230 d2d_effect_GetPropertyIndex,
231 d2d_effect_SetValueByName,
232 d2d_effect_SetValue,
233 d2d_effect_GetValueByName,
234 d2d_effect_GetValue,
235 d2d_effect_GetValueSize,
236 d2d_effect_GetSubProperties,
237 d2d_effect_SetInput,
238 d2d_effect_SetInputCount,
239 d2d_effect_GetInput,
240 d2d_effect_GetInputCount,
241 d2d_effect_GetOutput,
244 static inline struct d2d_effect *impl_from_ID2D1Image(ID2D1Image *iface)
246 return CONTAINING_RECORD(iface, struct d2d_effect, ID2D1Image_iface);
249 static HRESULT STDMETHODCALLTYPE d2d_effect_image_QueryInterface(ID2D1Image *iface, REFIID iid, void **out)
251 struct d2d_effect *effect = impl_from_ID2D1Image(iface);
253 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
255 return d2d_effect_QueryInterface(&effect->ID2D1Effect_iface, iid, out);
258 static ULONG STDMETHODCALLTYPE d2d_effect_image_AddRef(ID2D1Image *iface)
260 struct d2d_effect *effect = impl_from_ID2D1Image(iface);
262 TRACE("iface %p.\n", iface);
264 return d2d_effect_AddRef(&effect->ID2D1Effect_iface);
267 static ULONG STDMETHODCALLTYPE d2d_effect_image_Release(ID2D1Image *iface)
269 struct d2d_effect *effect = impl_from_ID2D1Image(iface);
271 TRACE("iface %p.\n", iface);
273 return d2d_effect_Release(&effect->ID2D1Effect_iface);
276 static void STDMETHODCALLTYPE d2d_effect_image_GetFactory(ID2D1Image *iface, ID2D1Factory **factory)
278 struct d2d_effect *effect = impl_from_ID2D1Image(iface);
280 TRACE("iface %p, factory %p.\n", iface, factory);
282 ID2D1Factory_AddRef(*factory = effect->factory);
285 static const ID2D1ImageVtbl d2d_effect_image_vtbl =
287 d2d_effect_image_QueryInterface,
288 d2d_effect_image_AddRef,
289 d2d_effect_image_Release,
290 d2d_effect_image_GetFactory,
293 HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory, const CLSID *effect_id)
295 unsigned int i;
297 effect->ID2D1Effect_iface.lpVtbl = &d2d_effect_vtbl;
298 effect->ID2D1Image_iface.lpVtbl = &d2d_effect_image_vtbl;
299 effect->refcount = 1;
301 for (i = 0; i < ARRAY_SIZE(builtin_effects); ++i)
303 if (IsEqualGUID(effect_id, builtin_effects[i].clsid))
305 effect->input_count = builtin_effects[i].default_input_count;
307 if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
308 effect->input_count, sizeof(*effect->inputs)))
309 return E_OUTOFMEMORY;
310 memset(effect->inputs, 0, sizeof(*effect->inputs) * effect->input_count);
312 ID2D1Factory_AddRef(effect->factory = factory);
314 return S_OK;
318 WARN("Unsupported effect clsid %s.\n", debugstr_guid(effect_id));
319 return E_FAIL;