[Vm-dev] VM Maker: VMMaker.oscog-nice.3169.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 24 00:54:54 UTC 2022


Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.3169.mcz

==================== Summary ====================

Name: VMMaker.oscog-nice.3169
Author: nice
Time: 24 February 2022, 1:53:42.760293 am
UUID: e2ca1296-dc0c-418e-b1ac-7def7ff9a33d
Ancestors: VMMaker.oscog-eem.3168

Fix alphaBlendUnscaled

some bits were leaking in the neighbour color.

=============== Diff against VMMaker.oscog-eem.3168 ===============

Item was changed:
  ----- Method: BitBltSimulation>>alphaBlendUnscaled:with: (in category 'combination rules') -----
  alphaBlendUnscaled: sourceWord with: destinationWord
  	"Blend sourceWord with destinationWord using the alpha value from both sourceWord and destinationWord.
  	Alpha is encoded as 0 meaning 0.0, and 255 meaning 1.0.
  	The alpha channel and color produced are
  
  		srcAlpha + (destAlpha*(1-srcAlpha))
  		(srcAlpha*srcColor + (destAlpha*(1-srcAlpha)*dstColor)) / (srcAlpha + (destAlpha*(1-srcAlpha)))
  
  	In contrast to alphaBlend:with: the method does not assume that destination form is opaque.
  	In contrast to alphaBlendScaled:with: the method does not assume that colors have been pre-scaled (muliplied) by alpha channel."
  	| alpha blendA result blendRB blendG |
  	<inline: false>
  	<returnTypeC: 'unsigned int'>
  	<var: 'sourceWord' type: #'unsigned int'>
  	<var: 'destinationWord' type: #'unsigned int'>
  	<var: 'blendRB' type: #'unsigned int'>
  	<var: 'blendG' type: #'unsigned int'>
  	<var: 'result' type: #'unsigned int'>
  	<var: 'alpha' type: #'unsigned int'>
  	<var: 'blendA' type: #'unsigned int'>
  	alpha := sourceWord >> 24.  "High 8 bits of source pixel, assuming ARGB encoding"
  	alpha = 0 ifTrue: [ ^ destinationWord ].
  	alpha = 255 ifTrue: [ ^ sourceWord ].
  	
  	blendA := 16rFF * alpha + (16rFF - alpha * (destinationWord >> 24)) + 16rFF. "blend alpha channels"
  	blendA := blendA + (blendA - 1 >> 8 bitAnd: 16rFF) >> 8 bitAnd: 16rFF. "divide by 255"
  
  	blendRB := ((sourceWord bitAnd: 16rFF00FF) * alpha) +
  				((destinationWord bitAnd: 16rFF00FF) * (blendA-alpha))
+ 				/ blendA bitAnd: 16rFF00FF.	"blend red and blue"
- 				/ blendA.	"blend red and blue"
  
  	blendG := ((sourceWord bitAnd: 16r00FF00) * alpha) +
  				((destinationWord bitAnd: 16r00FF00) * (blendA-alpha))
+ 				/ blendA bitAnd: 16r00FF00.	"blend green"
- 				/ blendA.	"blend green"
  	result := (blendRB bitOr: blendG) bitOr: blendA << 24.
  	^ result
  !



More information about the Vm-dev mailing list