On 20.10.2009 15:56, David T. Lewis wrote:
Could this be the cause of issue for which Juan was asking help?
Subject line "[Vm-dev] Bug in BitBlt. Need Help." http://lists.squeakfoundation.org/pipermail/vm-dev/2009-September/003160.htm...
Yes, that's exactly it, sorry I had not seen it. Attached is a proof-of-concept fix (for partitionedAdd: only), valid as long as nParts > 1 ( I suggest one wouldn't use partitionedAdd anyways if it were :) ) If anyone has a better idea, it'd be appreciated!
Correctness test: | sourceForm destForm blt correctAlphas | correctAlphas := 0. 0 to: 255 do: [:sourceAlpha | sourceForm := Form extent: 1 @ 1 depth: 32. sourceForm bits at: 1 put: sourceAlpha << 24 + (33 << 16) + (25 << 8) + 27. 0 to: 255 do: [:destAlpha | destForm := Form extent: 1 @ 1 depth: 32. destForm bits at: 1 put: destAlpha << 24 + (255 << 16) + (255 << 8) + 255. blt := BitBlt new. blt sourceForm: sourceForm. blt sourceOrigin: 0 @ 0. blt setDestForm: destForm. blt destOrigin: 0 @ 0. blt combinationRule: 20. blt copyBits. correctAlphas := correctAlphas + (((blt destForm bits at: 1) digitAt: 4) = (destAlpha + sourceAlpha min: 255) ifTrue: [1] ifFalse: [0]) ]]. self assert: 65536 equals: correctAlphas
Performance is not impacted to a significant degree as far as I can tell, the from runtimes of the test: [|sourceForm destForm blt| destForm := Form extent: 99@99 depth: 32. 1 to: destForm bits size do: [:ix | destForm bits at: ix put: ((192 << 24) + (255 << 16) + (255 << 8) + 255).]. sourceForm := Form extent: 99@99 depth: 32. 1 to: sourceForm bits size do: [:ix | sourceForm bits at: ix put: ((192 << 24) + (33 << 16) + (25 << 8) + 27).]. blt := BitBlt new. blt sourceForm: sourceForm. blt sourceOrigin: 0@0. blt setDestForm: destForm. blt destOrigin: 0@0. blt combinationRule: 20. 5000 timesRepeat: [ blt copyBits.]] timeToRun
Cheers, Henry