View Single Post
Old 29 March 2011, 14:40   #30
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Hi Peter,

I have a question about this part of your code...

Quote:
Originally Posted by PeterK View Post
Code:
.fakeAlphaChannel
                    MOVE.L        -(A0),D1                 ; color = black ?
                    BEQ.S          .settransparency
                    CMP.L          D2,D1                    ; color of 1. pixel ?
.settransparency
                    SNE.B          (A0)                     ; if not make visible
                    DBRA.S        D0,.fakeAlphaChannel
.hasAlphaChannel   .....
It looks to me like the pixel is already transparent (alpha=0) when the color is black (0/0/0/0) so there is no need to set transparency (alpha=0) with SNE. When the BEQ is taken to .settransparency, the SNE will never change the alpha byte from 0 because the CC zero flag is still set. If this is as you intended, then consider jumping to .settransparency+2 skipping the SNE and a wasted write. Consider this code...

Code:
                    MOVEA.L      $34(SP),A0        ; start of image
                    MOVE.L        D4,D0               ;reduces change/use stall
                    MOVE.L        (A0),D2             ; color of first pixel
                    LEA           (A0,D4*4),A0     ; image start + size*4
                    MOVE.L        A0,$38(SP)        ; = end of image
                    SUBQ.B        #mskHasAlpha,bmh_Masking(A4)
                    BEQ.S          .hasAlphaChannel
                    SUBQ.L        #1,D0
.fakeAlphaChannel
                    MOVE.L        -(A0),D1            ; color = black ?
                    BEQ.S          .keeptransparent
                    CMP.L          D2,D1                ; color of 1. pixel ?
                    SNE.B          (A0)                  ; if not make visible
.keeptransparent
                    DBRA.S        D0,.fakeAlphaChannel
This code does not write the pixel when it's black and transparent. Would it be better to make black with any value for it's alpha channel be transparent? I also made a few changes pre-loop that saves several cycles on the 68040+ and 2 bytes without compromising 68020/68030 performance. Notice that moving the MOVE.L D4,D0 to the 2nd line saves a cycle of change/use stall and using the LEA eliminates the need for the 2nd MOVE.L D4,D0.

Nice job on the PNG support and thanks for the updates.

Last edited by matthey; 30 March 2011 at 02:32. Reason: Re-thinking
matthey is offline  
 
Page generated in 0.05322 seconds with 9 queries