How many levels of opacity/alpha does GapiDraw use?
If one is satisfied with 64 levels one can reduce the number of multiplications from 3 to 2 per pixel (if you operate on one pixel).
If you operate on 2 pixels you could do the same and reduce the number of multiplications from 1.5 to 1 per pixel but then you have to use only 32 levels.
Is that enough? How does GapiDraw do it?
After doing some more thinking I realized that I probably was wrong.
I don't see how it is possible to use reduce it to only one multiplication, I think that the way I came up with would lead to overflow.
If you really wanted to do it in one multiply, you could probably mask+shift the green bits into the the high bytes of an unsigned 32-bit variable/register, so it looks like this:
00000ggg ggg00000 rrrrr000 000bbbbb
This can be safely multiplied by 0-32 without overflow.
But you need to do this shifting and masking to both the source and dest pixel, if you're using this blending equation:
output = destpixel + ((srcpixel - destpixel) * alpha5bits ) >> 5
And the overhead of the shifting and masking probably outweighs the advantages of eliminating one multiply, as multiplies are fairly fast on ARM-based CPUs
I've settled with the 2-multiplies-per-pixel method (with 6 bit alpha values on PocketPC, but only 4 bit on Series60 Symbian - the size of the 'hole' left by separating out the green channel), as it's mostly used in my front end and font rendering, which isn't too performance-critical. But I may rewrite it in ARM ASM for a little speed boost
Yes I had already figured that out, after StephC' reply. So I guess my original question is still valid.
http://www.gapidraw.com/features-technical.asp (check the bottom of the document)
One multiplication per pixel of course... I'll see to it so that the performance documentation in CGapiSurface is updated...
only 4 bit on Series60 Symbian
Just FYI: Newer Series 60 devices use 565 displays (such as the Nokia6600). GapiDraw uses a template-based adapter scheme that supports all 16-bit displays (444, 555, 565) that adapts the alpha bit size depending on the display for optimum quality with no performance loss.
So GapiDraw uses only 32 levels of opacity on 565 systems and 16 on 444 systems?
Pejo Software - Per wrote:So GapiDraw uses only 32 levels of opacity on 565 systems and 16 on 444 systems?
I was talking about my own blitting code, which doesn't use GD.
But on a system that only has 16 possible values for each colour component, I don't think you'd see any advantage from more precision in the blending than 16 levels
