[PATCH 9/9] d2d1/effect: Move effect instance creation to the device context.
Nikolay Sivov
wine at gitlab.winehq.org
Sun Jun 19 13:43:42 CDT 2022
From: Nikolay Sivov <nsivov at codeweavers.com>
Creating new effects from effect context does not reuse calling context.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d2d1/device.c | 23 ++++++++++++++++++++---
dlls/d2d1/effect.c | 18 ++----------------
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c
index 62eb98a94a1..be7b8f9f8e2 100644
--- a/dlls/d2d1/device.c
+++ b/dlls/d2d1/device.c
@@ -1947,18 +1947,35 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceCont
{
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
struct d2d_effect_context *effect_context;
+ struct d2d_effect *object;
HRESULT hr;
- FIXME("iface %p, effect_id %s, effect %p stub!\n", iface, debugstr_guid(effect_id), effect);
+ 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);
- hr = ID2D1EffectContext_CreateEffect(&effect_context->ID2D1EffectContext_iface, effect_id, effect);
+ 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);
- return hr;
+ 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;
}
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateGradientStopCollection(
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c
index 78db9489be9..f5d5494c67a 100644
--- a/dlls/d2d1/effect.c
+++ b/dlls/d2d1/effect.c
@@ -123,25 +123,11 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_CreateEffect(ID2D1EffectCont
REFCLSID clsid, ID2D1Effect **effect)
{
struct d2d_effect_context *effect_context = impl_from_ID2D1EffectContext(iface);
- struct d2d_effect *object;
- HRESULT hr;
TRACE("iface %p, clsid %s, effect %p.\n", iface, debugstr_guid(clsid), effect);
- if (!(object = calloc(1, sizeof(*object))))
- return E_OUTOFMEMORY;
-
- if (FAILED(hr = d2d_effect_init(object, effect_context, clsid)))
- {
- WARN("Failed to initialise effect, hr %#lx.\n", hr);
- free(object);
- return hr;
- }
-
- TRACE("Created effect %p.\n", object);
- *effect = &object->ID2D1Effect_iface;
-
- return S_OK;
+ return ID2D1DeviceContext1_CreateEffect(&effect_context->device_context->ID2D1DeviceContext1_iface,
+ clsid, effect);
}
static HRESULT STDMETHODCALLTYPE d2d_effect_context_GetMaximumSupportedFeatureLevel(ID2D1EffectContext *iface,
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/278
More information about the wine-devel
mailing list