Nikolay Sivov : d2d1: Move effect object creation to effect.c.
Alexandre Julliard
julliard at winehq.org
Mon Jun 27 16:12:51 CDT 2022
Module: wine
Branch: master
Commit: c172b89588abef7c2fc4b26a5af843e817acbf0e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c172b89588abef7c2fc4b26a5af843e817acbf0e
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun Jun 26 14:13:02 2022 +0300
d2d1: Move effect object creation to effect.c.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d2d1/d2d1_private.h | 4 ++--
dlls/d2d1/device.c | 28 +---------------------------
dlls/d2d1/effect.c | 43 ++++++++++++++++++++++++++++++++-----------
3 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 9be553c72d8..82c0b91e06d 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -624,8 +624,8 @@ struct d2d_effect
size_t input_count;
};
-HRESULT d2d_effect_init(struct d2d_effect *effect,
- struct d2d_effect_context *effect_context, const CLSID *effect_id) DECLSPEC_HIDDEN;
+HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effect_id,
+ ID2D1Effect **effect) 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 04a31992ba2..dc29f3b7cb6 100644
--- a/dlls/d2d1/device.c
+++ b/dlls/d2d1/device.c
@@ -1946,36 +1946,10 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceCont
REFCLSID effect_id, ID2D1Effect **effect)
{
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
- struct d2d_effect_context *effect_context;
- struct d2d_effect *object;
- HRESULT hr;
TRACE("iface %p, effect_id %s, effect %p.\n", iface, debugstr_guid(effect_id), effect);
- if (!(effect_context = calloc(1, sizeof(*effect_context))))
- return E_OUTOFMEMORY;
- d2d_effect_context_init(effect_context, context);
-
- if (!(object = calloc(1, sizeof(*object))))
- {
- ID2D1EffectContext_Release(&effect_context->ID2D1EffectContext_iface);
- return E_OUTOFMEMORY;
- }
-
- hr = d2d_effect_init(object, effect_context, effect_id);
- ID2D1EffectContext_Release(&effect_context->ID2D1EffectContext_iface);
- if (FAILED(hr))
- {
- WARN("Failed to initialise effect, hr %#lx.\n", hr);
- free(object);
- return hr;
- }
-
- *effect = &object->ID2D1Effect_iface;
-
- TRACE("Created effect %p.\n", *effect);
-
- return S_OK;
+ return d2d_effect_create(context, effect_id, effect);
}
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateGradientStopCollection(
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c
index f1b877821c8..688f1055791 100644
--- a/dlls/d2d1/effect.c
+++ b/dlls/d2d1/effect.c
@@ -753,26 +753,47 @@ static const ID2D1ImageVtbl d2d_effect_image_vtbl =
d2d_effect_image_GetFactory,
};
-HRESULT d2d_effect_init(struct d2d_effect *effect, struct d2d_effect_context *effect_context, const CLSID *effect_id)
+HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effect_id,
+ ID2D1Effect **effect)
{
+ struct d2d_effect_context *effect_context;
+ struct d2d_effect *object;
unsigned int i;
- effect->ID2D1Effect_iface.lpVtbl = &d2d_effect_vtbl;
- effect->ID2D1Image_iface.lpVtbl = &d2d_effect_image_vtbl;
- effect->refcount = 1;
+ if (!(effect_context = calloc(1, sizeof(*effect_context))))
+ return E_OUTOFMEMORY;
+ d2d_effect_context_init(effect_context, context);
+
+ if (!(object = calloc(1, sizeof(*object))))
+ {
+ ID2D1EffectContext_Release(&effect_context->ID2D1EffectContext_iface);
+ return E_OUTOFMEMORY;
+ }
+
+ object->ID2D1Effect_iface.lpVtbl = &d2d_effect_vtbl;
+ object->ID2D1Image_iface.lpVtbl = &d2d_effect_image_vtbl;
+ object->refcount = 1;
+ object->effect_context = effect_context;
for (i = 0; i < ARRAY_SIZE(builtin_effects); ++i)
{
if (IsEqualGUID(effect_id, builtin_effects[i].clsid))
{
- effect->info = &builtin_effects[i];
- d2d_effect_SetInputCount(&effect->ID2D1Effect_iface, effect->info->default_input_count);
- effect->effect_context = effect_context;
- ID2D1EffectContext_AddRef(&effect_context->ID2D1EffectContext_iface);
- return S_OK;
+ object->info = &builtin_effects[i];
+ d2d_effect_SetInputCount(&object->ID2D1Effect_iface, object->info->default_input_count);
+ break;
}
}
- WARN("Unsupported effect clsid %s.\n", debugstr_guid(effect_id));
- return E_FAIL;
+ if (i == ARRAY_SIZE(builtin_effects))
+ {
+ ID2D1Effect_Release(&object->ID2D1Effect_iface);
+ return E_FAIL;
+ }
+
+ *effect = &object->ID2D1Effect_iface;
+
+ TRACE("Created effect %p.\n", *effect);
+
+ return S_OK;
}
More information about the wine-cvs
mailing list