[PATCH 3/4] d2d1: Add ID2D1Image interface for d2d effect.

Henri Verbeet hverbeet at gmail.com
Wed Jul 7 10:59:59 CDT 2021


On Wed, 7 Jul 2021 at 06:50, Ziqing Hui <zhui at codeweavers.com> wrote:
> static HRESULT STDMETHODCALLTYPE d2d_effect_QueryInterface(ID2D1Effect *iface, REFIID iid, void **out)
> {
> +    struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
>     TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
>
>     if (IsEqualGUID(iid, &IID_ID2D1Effect)
>             || IsEqualGUID(iid, &IID_ID2D1Properties)
>             || IsEqualGUID(iid, &IID_IUnknown))
>     {
> -        ID2D1Effect_AddRef(iface);
>         *out = iface;
> -        return S_OK;
> +    }
> +    else if (IsEqualGUID(iid, &IID_ID2D1Image)
> +            || IsEqualGUID(iid, &IID_ID2D1Resource))
> +    {
> +        *out = &effect->ID2D1Image_iface;
> +    }
> +    else
> +    {
> +        WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
> +        *out = NULL;
> +        return E_NOINTERFACE;
>     }
>
> -    WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
> -
> -    *out = NULL;
> -    return E_NOINTERFACE;
> +    IUnknown_AddRef((IUnknown*)*out);
> +    return S_OK;
>  }
That seems like somewhat of a gratuitous change, and I don't think
it's an improvement. Any reason for not simply adding the extra block
for the ID2D1Image and ID2D1Resource interfaces?

> +static void STDMETHODCALLTYPE  d2d_effect_image_GetFactory(ID2D1Image *iface, ID2D1Factory **factory)
There's a stray space there.

> +void d2d_effect_init(struct d2d_device_context *context, struct d2d_effect *effect)
> {
>     effect->ID2D1Effect_iface.lpVtbl = &d2d_effect_vtbl;
> +    effect->ID2D1Image_iface.lpVtbl = &d2d_effect_image_vtbl;
>     effect->refcount = 1;
> +    effect->factory = context->factory;
> }
If all we're using from "context" is the factory, we may as well just
pass the factory as argument, like we do for most other d2d objects.

By convention, the object the function operates on (i.e., "effect" in
this case) would be the first parameter to the function.



More information about the wine-devel mailing list