From: Ziqing Hui zhui@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/d2d1_private.h | 7 +++ dlls/d2d1/effect.c | 95 +++++++++++++++++++++++++++++++++++++++- dlls/d2d1/tests/d2d1.c | 14 +++--- 3 files changed, 105 insertions(+), 11 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 98f99744746..6dc89ce51db 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -658,6 +658,13 @@ struct d2d_effect_registration * d2d_factory_get_registered_effect(ID2D1Factory void d2d_factory_register_effect(struct d2d_factory *factory, struct d2d_effect_registration *effect) DECLSPEC_HIDDEN;
+struct d2d_offset_transform +{ + ID2D1OffsetTransform ID2D1OffsetTransform_iface; + LONG refcount; + D2D1_POINT_2L offset; +}; + struct d2d_transform_graph { ID2D1TransformGraph ID2D1TransformGraph_iface; diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 7b086e20b9b..9437a700fb6 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -20,6 +20,87 @@
WINE_DEFAULT_DEBUG_CHANNEL(d2d);
+static inline struct d2d_offset_transform *impl_from_ID2D1OffsetTransform(ID2D1OffsetTransform *iface) +{ + return CONTAINING_RECORD(iface, struct d2d_offset_transform, ID2D1OffsetTransform_iface); +} + +static HRESULT STDMETHODCALLTYPE d2d_offset_transform_QueryInterface(ID2D1OffsetTransform *iface, REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_ID2D1OffsetTransform) + || IsEqualGUID(iid, &IID_ID2D1TransformNode) + || IsEqualGUID(iid, &IID_IUnknown)) + { + ID2D1OffsetTransform_AddRef(iface); + *out = iface; + return S_OK; + } + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d2d_offset_transform_AddRef(ID2D1OffsetTransform *iface) +{ + struct d2d_offset_transform *transform = impl_from_ID2D1OffsetTransform(iface); + ULONG refcount = InterlockedIncrement(&transform->refcount); + + TRACE("%p increasing refcount to %lu.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d2d_offset_transform_Release(ID2D1OffsetTransform *iface) +{ + struct d2d_offset_transform *transform = impl_from_ID2D1OffsetTransform(iface); + ULONG refcount = InterlockedDecrement(&transform->refcount); + + TRACE("%p decreasing refcount to %lu.\n", iface, refcount); + + if (!refcount) + free(transform); + + return refcount; +} + +static UINT32 STDMETHODCALLTYPE d2d_offset_transform_GetInputCount(ID2D1OffsetTransform *iface) +{ + TRACE("iface %p.\n", iface); + + return 1; +} + +static void STDMETHODCALLTYPE d2d_offset_transform_SetOffset(ID2D1OffsetTransform *iface, D2D1_POINT_2L offset) +{ + struct d2d_offset_transform *transform = impl_from_ID2D1OffsetTransform(iface); + + TRACE("iface %p, offset %s.\n", iface, debug_d2d_point_2l(&offset)); + + transform->offset = offset; +} + +static D2D1_POINT_2L *STDMETHODCALLTYPE d2d_offset_transform_GetOffset(ID2D1OffsetTransform *iface, D2D1_POINT_2L *ret) +{ + struct d2d_offset_transform *transform = impl_from_ID2D1OffsetTransform(iface); + + TRACE("iface %p, ret %p.\n", iface, ret); + + *ret = transform->offset; + return ret; +} + +static const ID2D1OffsetTransformVtbl d2d_offset_transform_vtbl = +{ + d2d_offset_transform_QueryInterface, + d2d_offset_transform_AddRef, + d2d_offset_transform_Release, + d2d_offset_transform_GetInputCount, + d2d_offset_transform_SetOffset, + d2d_offset_transform_GetOffset, +}; + static inline struct d2d_transform_graph *impl_from_ID2D1TransformGraph(ID2D1TransformGraph *iface) { return CONTAINING_RECORD(iface, struct d2d_transform_graph, ID2D1TransformGraph_iface); @@ -754,9 +835,19 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_CreateBorderTransform(ID2D1E static HRESULT STDMETHODCALLTYPE d2d_effect_context_CreateOffsetTransform(ID2D1EffectContext *iface, D2D1_POINT_2L offset, ID2D1OffsetTransform **transform) { - FIXME("iface %p, offset %s, transform %p stub!\n", iface, debug_d2d_point_2l(&offset), transform); + struct d2d_offset_transform *object;
- return E_NOTIMPL; + TRACE("iface %p, offset %s, transform %p.\n", iface, debug_d2d_point_2l(&offset), transform); + + if (!(object = calloc(1, sizeof(*object)))) + return E_OUTOFMEMORY; + + object->ID2D1OffsetTransform_iface.lpVtbl = &d2d_offset_transform_vtbl; + object->refcount = 1; + object->offset = offset; + *transform = &object->ID2D1OffsetTransform_iface; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d2d_effect_context_CreateBoundsAdjustmentTransform(ID2D1EffectContext *iface, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 7678c697c5e..6f12b91bdf6 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -12064,10 +12064,10 @@ static void test_transform_graph(BOOL d3d11)
/* Create transforms */ hr = ID2D1EffectContext_CreateOffsetTransform(effect_context, point, &offset_transform); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); hr = ID2D1EffectContext_CreateBlendTransform(effect_context, 2, &blend_desc, &blend_transform); todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (!offset_transform || !blend_transform) + if (!blend_transform) goto done;
/* Add nodes */ @@ -12139,8 +12139,8 @@ done:
static void test_offset_transform(BOOL d3d11) { - ID2D1OffsetTransform *transform = NULL; ID2D1EffectContext *effect_context; + ID2D1OffsetTransform *transform; D2D1_PROPERTY_BINDING binding; struct d2d1_test_context ctx; ID2D1Factory1 *factory; @@ -12178,9 +12178,7 @@ static void test_offset_transform(BOOL d3d11) offset.x = 1; offset.y = 2; hr = ID2D1EffectContext_CreateOffsetTransform(effect_context, offset, &transform); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (hr != S_OK) - goto done; + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); offset = ID2D1OffsetTransform_GetOffset(transform); ok(offset.x == 1 && offset.y == 2, "Got unexpected offset {%ld, %ld}.\n", offset.x, offset.y);
@@ -12195,9 +12193,7 @@ static void test_offset_transform(BOOL d3d11) offset = ID2D1OffsetTransform_GetOffset(transform); ok(offset.x == -10 && offset.y == 20, "Got unexpected offset {%ld, %ld}.\n", offset.x, offset.y);
-done: - if (transform) - ID2D1OffsetTransform_Release(transform); + ID2D1OffsetTransform_Release(transform); ID2D1Effect_Release(effect); hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);