Possible GraphicsContext::drawBevel bug?


Today I noticed my TextEditors no longer have shadows in them.
Obviously I accused myself, but after some minutes of self beating and investigation I have exonerated myself.

Looking in GraphicsContext::drawBevel() I have found this line:

const float op = useGradient ? (sharpEdgeOnOutside ? bevelThickness - i : i) / bevelThickness : 1.0f;

This line is responsible for the opacity of each line in the bevel.
In my case, useGradient and sharpEdgeOnOutside are both true, meaning the opacity is denoted by:

Now, this calculation is an all-int calculation, meaning it’s 1 when i = 0 and 0 for every other i.
I had modified the line to cast it to float:

const float op = useGradient ? (sharpEdgeOnOutside ? (float)bevelThickness - i : i) / bevelThickness : 1.0f;

And now it is working.
Is it a bug or am I doing something wrong here?

Note that when looking at an older commit, the line is:

const float op = useGradient ? ramp * (sharpEdgeOnOutside ? bevelThickness - i : i) : oldOpacity;

where ramp is:

const float oldOpacity = 1.0f;//xxx state->colour.getFloatAlpha(); const float ramp = oldOpacity / bevelThickness;

Meaning the calculation results in a float in the older commit.

Yes… you’re right, thanks! That was a bit clumsy of me, sorry!