bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: blit.m in module back


From: Fred Kiefer
Subject: Re: blit.m in module back
Date: Sat, 13 Mar 2010 13:35:32 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.8) Gecko/20100228 SUSE/3.0.3-1.1.1 Thunderbird/3.0.3

Am 13.03.2010 01:25, schrieb Anibal Rindisbacher:
> Hi, me again. I try to understand the code in back/Source/art/blit.m, I
> focus in warnings now, the line in MPRE(run_opaque) of that file:
> 
> unsigned int v;
> unsigned short *dst = (unsigned short *)ri->dst;
> 
> COPY_ASSEMBLE_PIXEL(v, ri->r, ri->g, ri->b)
> v = v + (v << 16);
> *if (((int)dst&2) && num)*
> {
>       *dst++ = v;
>       num--;
> }
> .....
> 
> in the if statement, verify that the bit 31st was 1, do you sure you want to
> do that?.

The code you are pointing to is really hard to understand. It comes from
Alexander Malmberg and we only rarely find bugs in his code.

As far as I get this it is an optimisation for the case when the pointer
dst is not a multiple of four. In that case four byte operations would
be slow or impossible on some machines. So what the code does is a
special handling for the first two bytes and then the rest should be
neatly aligned. And the copy operations copy over two copies of the
target value at once. A bit of comment might have helped here, but in
itself the code is rather clear :-)

There still could be a problem with that code, I just don't see it.

Fred




reply via email to

[Prev in Thread] Current Thread [Next in Thread]