[Bug] Bug in BitBlt (rgbMul sets alpha to 0)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug] Bug in BitBlt (rgbMul sets alpha to 0)

Juan Vuletich-4
 
Hi Folks,

I found that rule 37 sets alpha to zero if the destination is 32 bit.
This affects my antialiased StrikeFonts. The following
f1 := Form extent: 8@8 depth: 32.
   f1 fillColor: (Color r: 1.0 g: 1.0 b: 0.7 alpha: 0.7).
   f2 := Form extent: 8@8 depth: 32.
   f2 fillColor: (Color r: 0.5 g: 1.0 b: 0.7 alpha: 0.9).
   bb :=(BitBlt toForm: f1) sourceForm: f2; combinationRule: 37; copyBits.
   (f1 colorAt: 2@2)
answers Color transparent when it should answer (TranslucentColor r:
0.501 g: 1.0 b: 0.494 alpha: 0.627).

This is related to the stuff I fixed in April, but it is a different bug
in a different method, that I didn't find that time:
#partitionedMul:with:nBits:nPartitions: ignores the last argument, and
acts as if it was always 3.

The fix I propose is as follows:

partitionedMul: word1 with: word2 nBits: nBits nPartitions: nParts
    "Multiply word1 with word2 as nParts partitions of nBits each.
    This is useful for packed pixels, or packed colors.
    Bug in loop version when non-white background"

    | sMask product result dMask |
    sMask := maskTable at: nBits.  "partition mask starts at the right"
    dMask := sMask << nBits.
    result := (((word1 bitAnd: sMask)+1) * ((word2 bitAnd: sMask)+1) - 1
                bitAnd: dMask) >> nBits.    "optimized first step"
    nParts = 1
        ifTrue: [ ^result ].
    product := (((word1>>nBits bitAnd: sMask)+1) * ((word2>>nBits
bitAnd: sMask)+1) - 1 bitAnd: dMask).
    result := result bitOr: (product bitAnd: dMask).
    nParts = 2
        ifTrue: [ ^result ].
    product := (((word1>>(2*nBits) bitAnd: sMask)+1) *
((word2>>(2*nBits) bitAnd: sMask)+1) - 1 bitAnd: dMask).
    result := result bitOr: (product bitAnd: dMask) << nBits.
    nParts = 3
        ifTrue: [ ^result ].
    product := (((word1>>(3*nBits) bitAnd: sMask)+1) *
((word2>>(3*nBits) bitAnd: sMask)+1) - 1 bitAnd: dMask).
    result := result bitOr: (product bitAnd: dMask) << (2*nBits).
    ^ result

If you agree, I'll add an issue to Mantis with the proposed fix.

Cheers,
Juan Vuletich
Reply | Threaded
Open this post in threaded view
|

Re: [Bug] Bug in BitBlt (rgbMul sets alpha to 0)

Juan Vuletich-4
 
Hi Folks,

I added issue #7376 to Mantis, with the proposed fix attached. Please
check it to see if it looks ok to yoy. With this fix, the second bitblt
pass for aa strike fonts will not be needed anymore if text is black,
meaning a small performance improvement, aside from correct bitblt behavior.

David, please add it to the repository. Thanks!

Cheers,
Juan Vuletich

Juan Vuletich wrote:

>
> Hi Folks,
>
> I found that rule 37 sets alpha to zero if the destination is 32 bit.
> This affects my antialiased StrikeFonts. The following
> f1 := Form extent: 8@8 depth: 32.
>   f1 fillColor: (Color r: 1.0 g: 1.0 b: 0.7 alpha: 0.7).
>   f2 := Form extent: 8@8 depth: 32.
>   f2 fillColor: (Color r: 0.5 g: 1.0 b: 0.7 alpha: 0.9).
>   bb :=(BitBlt toForm: f1) sourceForm: f2; combinationRule: 37; copyBits.
>   (f1 colorAt: 2@2)
> answers Color transparent when it should answer (TranslucentColor r:
> 0.501 g: 1.0 b: 0.494 alpha: 0.627).
>
> This is related to the stuff I fixed in April, but it is a different
> bug in a different method, that I didn't find that time:
> #partitionedMul:with:nBits:nPartitions: ignores the last argument, and
> acts as if it was always 3.
>
> The fix I propose is as follows:
>
> partitionedMul: word1 with: word2 nBits: nBits nPartitions: nParts
>    "Multiply word1 with word2 as nParts partitions of nBits each.
>    This is useful for packed pixels, or packed colors.
>    Bug in loop version when non-white background"
>
>    | sMask product result dMask |
>    sMask := maskTable at: nBits.  "partition mask starts at the right"
>    dMask := sMask << nBits.
>    result := (((word1 bitAnd: sMask)+1) * ((word2 bitAnd: sMask)+1) - 1
>                bitAnd: dMask) >> nBits.    "optimized first step"
>    nParts = 1
>        ifTrue: [ ^result ].
>    product := (((word1>>nBits bitAnd: sMask)+1) * ((word2>>nBits
> bitAnd: sMask)+1) - 1 bitAnd: dMask).
>    result := result bitOr: (product bitAnd: dMask).
>    nParts = 2
>        ifTrue: [ ^result ].
>    product := (((word1>>(2*nBits) bitAnd: sMask)+1) *
> ((word2>>(2*nBits) bitAnd: sMask)+1) - 1 bitAnd: dMask).
>    result := result bitOr: (product bitAnd: dMask) << nBits.
>    nParts = 3
>        ifTrue: [ ^result ].
>    product := (((word1>>(3*nBits) bitAnd: sMask)+1) *
> ((word2>>(3*nBits) bitAnd: sMask)+1) - 1 bitAnd: dMask).
>    result := result bitOr: (product bitAnd: dMask) << (2*nBits).
>    ^ result
>
> If you agree, I'll add an issue to Mantis with the proposed fix.
>
> Cheers,
> Juan Vuletich
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.392 / Virus Database: 270.13.44/2282 - Release Date: 08/04/09 18:01:00
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: [Bug] Bug in BitBlt (rgbMul sets alpha to 0)

David T. Lewis
 
On Mon, Aug 10, 2009 at 10:08:44AM -0300, Juan Vuletich wrote:
>
> Hi Folks,
>
> I added issue #7376 to Mantis, with the proposed fix attached. Please
> check it to see if it looks ok to yoy. With this fix, the second bitblt
> pass for aa strike fonts will not be needed anymore if text is black,
> meaning a small performance improvement, aside from correct bitblt behavior.
>
> David, please add it to the repository. Thanks!

This patch is in VMMaker-dtl.131 on SqueakSource.

Dave

Reply | Threaded
Open this post in threaded view
|

Re: [Bug] Bug in BitBlt (rgbMul sets alpha to 0)

Juan Vuletich-4
 
David T. Lewis wrote:

>  
> On Mon, Aug 10, 2009 at 10:08:44AM -0300, Juan Vuletich wrote:
>  
>> Hi Folks,
>>
>> I added issue #7376 to Mantis, with the proposed fix attached. Please
>> check it to see if it looks ok to yoy. With this fix, the second bitblt
>> pass for aa strike fonts will not be needed anymore if text is black,
>> meaning a small performance improvement, aside from correct bitblt behavior.
>>
>> David, please add it to the repository. Thanks!
>>    
>
> This patch is in VMMaker-dtl.131 on SqueakSource.
>
> Dave
>  

Thanks Dave!

Cheers,
Juan Vuletich