[PATCH v3 3/5] d2d1: Implement d2d_effect_SetInputCount().

Henri Verbeet hverbeet at gmail.com
Fri Aug 6 09:01:11 CDT 2021


On Thu, 5 Aug 2021 at 10:06, Ziqing Hui <zhui at codeweavers.com> wrote:
>  static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UINT32 count)
>  {
> -    FIXME("iface %p, count %u stub!\n", iface, count);
> +    struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
> +    unsigned int i;
>
> -    return E_NOTIMPL;
> +    TRACE("iface %p, count %u.\n", iface, count);
> +
> +    if (count < effect->min_inputs || count > effect->max_inputs)
> +        return E_INVALIDARG;
> +    if (count == effect->input_count)
> +        return S_OK;
> +
> +    if (count < effect->input_count)
> +    {
> +        for (i = count; i < effect->input_count; ++i)
> +        {
> +            if (effect->inputs[i])
> +                ID2D1Image_Release(effect->inputs[i]);
> +        }
> +    }

In this case we're in fact done after the for-loop and can return.

> +
> +    if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
> +                           count, sizeof(*effect->inputs)))
> +    {

We use double (i.e., 8 space) indentation for line continuations.

> +        ERR("Failed to resize inputs array.\n");
> +        return E_OUTOFMEMORY;
> +    }
> +
> +    if (count > effect->input_count)
> +        memset(effect->inputs + effect->input_count, 0,
> +               sizeof(*effect->inputs) * (count - effect->input_count));
> +
"effect->inputs + effect->input_count" ->
"&effect->inputs[effect->input_count]", by convention.

> @@ -286,6 +314,8 @@ HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory)
>      ID2D1Factory_AddRef(effect->factory = factory);
>
>      effect->input_count = 1;
> +    effect->min_inputs = 1;
> +    effect->max_inputs = 1;

It seems a little unfortunate to hardcode these to "1" here, since it
means we'll never actually grow the inputs array. At the same time,
this would seem like a great time to introduce the effect info array
containing the minimum, maximum, and initial input counts.



More information about the wine-devel mailing list