[PATCH v3 2/5] d2d1: Implement d2d_effect_GetInputCount().
Ziqing Hui
zhui at codeweavers.com
Thu Aug 5 03:06:02 CDT 2021
Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
---
v3: Split the large implementation patch into 4 patches.
Use d2d_array_reserve().
Add a return value to d2d_effect_init().
Introduce d2d_effect_cleanup().
dlls/d2d1/d2d1_private.h | 5 ++++-
dlls/d2d1/device.c | 8 +++++++-
dlls/d2d1/effect.c | 29 +++++++++++++++++++++++++----
dlls/d2d1/tests/d2d1.c | 2 +-
4 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index ce99e7c3432..48d15dfcf22 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -572,9 +572,12 @@ struct d2d_effect
LONG refcount;
ID2D1Factory *factory;
+ ID2D1Image **inputs;
+ size_t inputs_size;
+ size_t input_count;
};
-void d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) DECLSPEC_HIDDEN;
+HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) DECLSPEC_HIDDEN;
static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
{
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c
index 0647bc57fc3..d8704f1b43b 100644
--- a/dlls/d2d1/device.c
+++ b/dlls/d2d1/device.c
@@ -1887,13 +1887,19 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceCont
{
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
struct d2d_effect *object;
+ HRESULT hr;
FIXME("iface %p, effect_id %s, effect %p stub!\n", iface, debugstr_guid(effect_id), effect);
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
- d2d_effect_init(object, context->factory);
+ if (FAILED(hr = d2d_effect_init(object, context->factory)))
+ {
+ WARN("Failed to initialize effect, hr %#x.\n", hr);
+ heap_free(object);
+ return hr;
+ }
TRACE("Created effect %p.\n", object);
*effect = &object->ID2D1Effect_iface;
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c
index 40dd2187953..fa616ebe6be 100644
--- a/dlls/d2d1/effect.c
+++ b/dlls/d2d1/effect.c
@@ -25,6 +25,12 @@ static inline struct d2d_effect *impl_from_ID2D1Effect(ID2D1Effect *iface)
return CONTAINING_RECORD(iface, struct d2d_effect, ID2D1Effect_iface);
}
+static void d2d_effect_cleanup(struct d2d_effect *effect)
+{
+ heap_free(effect->inputs);
+ ID2D1Factory_Release(effect->factory);
+}
+
static HRESULT STDMETHODCALLTYPE d2d_effect_QueryInterface(ID2D1Effect *iface, REFIID iid, void **out)
{
struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
@@ -72,7 +78,7 @@ static ULONG STDMETHODCALLTYPE d2d_effect_Release(ID2D1Effect *iface)
if (!refcount)
{
- ID2D1Factory_Release(effect->factory);
+ d2d_effect_cleanup(effect);
heap_free(effect);
}
@@ -183,9 +189,11 @@ static void STDMETHODCALLTYPE d2d_effect_GetInput(ID2D1Effect *iface, UINT32 ind
static UINT32 STDMETHODCALLTYPE d2d_effect_GetInputCount(ID2D1Effect *iface)
{
- FIXME("iface %p stub!\n", iface);
+ struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
- return 0;
+ TRACE("iface %p.\n", iface);
+
+ return effect->input_count;
}
static void STDMETHODCALLTYPE d2d_effect_GetOutput(ID2D1Effect *iface, ID2D1Image **output)
@@ -269,10 +277,23 @@ static const ID2D1ImageVtbl d2d_effect_image_vtbl =
d2d_effect_image_GetFactory,
};
-void d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory)
+HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory)
{
effect->ID2D1Effect_iface.lpVtbl = &d2d_effect_vtbl;
effect->ID2D1Image_iface.lpVtbl = &d2d_effect_image_vtbl;
effect->refcount = 1;
+
ID2D1Factory_AddRef(effect->factory = factory);
+
+ effect->input_count = 1;
+ if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
+ effect->input_count, sizeof(*effect->inputs)))
+ goto fail;
+ memset(effect->inputs, 0, sizeof(*effect->inputs) * effect->inputs_size);
+
+ return S_OK;
+
+fail:
+ d2d_effect_cleanup(effect);
+ return E_OUTOFMEMORY;
}
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 146952d7418..64d9765e866 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -9802,7 +9802,7 @@ static void test_effect(BOOL d3d11)
}
input_count = ID2D1Effect_GetInputCount(effect);
- todo_wine
+ todo_wine_if(test->default_input_count != 1)
ok (input_count == test->default_input_count, "Got unexpected input count %u, expected %u.\n",
input_count, test->default_input_count);
--
2.25.1
More information about the wine-devel
mailing list