[PATCH v2 2/2] d2d1/tests: Add tests for effect register.

Nikolay Sivov nsivov at codeweavers.com
Tue May 17 02:42:50 CDT 2022



On 5/17/22 08:00, Ziqing Hui wrote:
> @@ -25,10 +25,72 @@
>   #include "wincrypt.h"
>   #include "wine/test.h"
>   #include "initguid.h"
> +#include "d2d1effectauthor.h"
>   #include "dwrite.h"
>   #include "wincodec.h"
>   #include "wine/heap.h"
d2d1effectauthor.h should go to uuid, so you don't need to initguid it here.

> +#define EFFECT_XML(x) L###x
> +
> +static const WCHAR *effect_xml_a = EFFECT_XML
> +(
> +    <?xml version='1.0'?>
> +    <Effect>
> +        <Property name='DisplayName' type='string' value='TestEffect'/>
> +        <Property name='Author'      type='string' value='The Wine Project'/>
> +        <Property name='Category'    type='string' value='Test'/>
> +        <Property name='Description' type='string' value='Test effect.'/>
> +        <Inputs>
> +            <Input name='Source'/>
> +        </Inputs>
> +        <Property name='Integer' type='uint32'>
> +            <Property name='DisplayName' type='string' value='Integer'/>
> +            <Property name='Min'         type='uint32' value='0'/>
> +            <Property name='Max'         type='uint32' value='100'/>
> +            <Property name='Default'     type='uint32' value='10'/>
> +        </Property>
> +    </Effect>
> +);
I personally don't like macro tricks for this. It believe this should 
work with regular L"", and "\" and the end of the lines.

> +static HRESULT STDMETHODCALLTYPE effect_impl_QueryInterface(ID2D1EffectImpl *iface, REFIID iid, void **out)
> +{
> +    if (IsEqualGUID(iid, &IID_ID2D1EffectImpl)
> +            || IsEqualGUID(iid, &IID_IUnknown))
> +    {
> +        *out = iface;
> +        return S_OK;
> +    }
> +
> +    *out = NULL;
> +    return E_NOINTERFACE;
> +}
This is an allocated test effect, so it should addref here,

> +static ULONG STDMETHODCALLTYPE effect_impl_Release(ID2D1EffectImpl *iface)
> +{
> +    struct effect_impl *effect_impl = impl_from_ID2D1EffectImpl(iface);
> +    ULONG refcount = InterlockedDecrement(&effect_impl->refcount);
> +    return refcount;
> +}
...release here...

> +static HRESULT STDMETHODCALLTYPE effect_impl_Initialize(ID2D1EffectImpl *iface,
> +        ID2D1EffectContext *context,ID2D1TransformGraph *graph)
> +{
> +    struct effect_impl *effect_impl = impl_from_ID2D1EffectImpl(iface);
> +    effect_impl->effect_context = context;
> +    return S_OK;
> +}
...addref here..

> +static HRESULT STDMETHODCALLTYPE effect_impl_create(IUnknown **effect_impl)
> +{
> +    struct effect_impl *object;
> +
> +    if (!(object = heap_alloc(sizeof(*object))))
> +        return E_OUTOFMEMORY;
> +
> +    object->ID2D1EffectImpl_iface.lpVtbl = &effect_impl_vtbl;
> +    object->refcount = 1;
> +
> +    *effect_impl = (IUnknown *)&object->ID2D1EffectImpl_iface;
> +    return S_OK;
> +}
and fully initialize here.



More information about the wine-devel mailing list