[PATCH 5/5] d2d1: Implement initial support for quadratic bezier outlines.
Jochen Theodorou
blackdrag at gmx.org
Mon May 22 11:13:49 CDT 2017
On 21.05.2017 18:56, Henri Verbeet wrote:
> On 21 May 2017 at 18:23, Dmitry Timoshkov <dmitry at baikal.ru> wrote:
>> Henri Verbeet <hverbeet at codeweavers.com> wrote:
>>
>>> +static void d2d_point_lerp(D2D1_POINT_2F *out,
>>> + const D2D1_POINT_2F *a, const D2D1_POINT_2F *b, float t)
>>> +{
>>> + out->x = a->x * (1.0f - t) + b->x * t;
>>> + out->y = a->y * (1.0f - t) + b->y * t;
>>> +}
>>
>> According to my investigation of a better bilinear blending (lerp)
>> implementation the above formula is better to explicitely simplify
>> to
>>
>> out->x = a->x + (b->x - a->x) * t;
>> out->y = a->y + (b->y - a->y) * t;
>>
> For performance, quite possibly. This isn't particularly performance
> sensitive code though, and I'd be surprised if that variant had better
> accuracy.
If you go by the simple rule of addition and subtraction are bad,
because small values get swallowed,
for t being almost 1.0f a->x * (1.0f - t) + b->x * t; will produce
roughly b->x. In a->x + (b->x - a->x) * t what matters more is the
result of (b->x - a->x), which might almost zero, leading to a->x to win
the result. Remember, for this a->x and b->x must be almost equal.
for t being almost 0, both are dominated by a->x
for b->x being almost 0, and letsĀ“s say t=1 we get in the first case
b->x and in the second case 0, since a->x is assumed big enough to
dominate b->x - a->x with -a->x.
for a->x being almost 0 and lets say t=0 the both case still give a->x
For me that means the weak points for case one are t being almost 1 and
for case 2 b->x >> a->x.
bye Jochen
More information about the wine-devel
mailing list