[Vm-dev] BitBlt looking for rule blitting an alpha mask + constant color

Igor Stasenko siguctua at gmail.com
Sat Jun 20 03:12:41 UTC 2009


Alain, maybe you can help resolving the confusion?
I'm trying calling

copyBitsColor: argbColorSmallInteger alpha: argbAlphaSmallInteger
gammaTable: gammaByteArray ungammaTable: ungammaByteArray
	"This entry point to BitBlt supplies an extra argument to specify the
fore color
	argb value for operation 41. This is split into an alpha value and an
rgb value,
	so that both can be passed as smallIntegers to the primitive.
	rgbColorInteger must be a smallInteger between 0 and 16rFFFFFF.
	alpha must be a smallInteger between 0 and 16rFF."
	<primitive: 'primitiveCopyBits' module: 'BitBltPlugin'>


And plugin sources, which i have, indeed taking care of arguments and
setting the componentAlphaModeColor :

------------------
copyBitsLockedAndClipped
	"Perform the actual copyBits operation.
	Assume: Surfaces have been locked and clipping was performed."
	| done gammaLookupTableOop ungammaLookupTableOop |
	self inline: true.
	combinationRule = 41
		ifTrue:["fetch the forecolor into componentAlphaModeColor."
			componentAlphaModeAlpha := 255.
			componentAlphaModeColor := 16777215.
			gammaLookupTable := nil.
			ungammaLookupTable := nil.
			interpreterProxy methodArgumentCount >= 2
				ifTrue:[
					componentAlphaModeAlpha := interpreterProxy stackIntegerValue:
(interpreterProxy methodArgumentCount - 2).
					(interpreterProxy failed not)
						ifFalse: [^ interpreterProxy primitiveFail].
					componentAlphaModeColor := interpreterProxy stackIntegerValue:
(interpreterProxy methodArgumentCount - 1).
					(interpreterProxy failed not)
						ifFalse: [^ interpreterProxy primitiveFail].
					interpreterProxy methodArgumentCount = 4
						ifTrue:[
							gammaLookupTableOop := interpreterProxy stackObjectValue: 1.
							(interpreterProxy isBytes: gammaLookupTableOop)
								ifTrue:[gammaLookupTable := interpreterProxy
firstIndexableField: gammaLookupTableOop.].
							ungammaLookupTableOop := interpreterProxy stackObjectValue: 0.
							(interpreterProxy isBytes: ungammaLookupTableOop)
								ifTrue:[ungammaLookupTable := interpreterProxy
firstIndexableField: ungammaLookupTableOop]]]
				ifFalse:[
					interpreterProxy methodArgumentCount = 1
						ifTrue: [
							componentAlphaModeColor := interpreterProxy stackIntegerValue: 0.
							(interpreterProxy failed not)
								ifFalse: [^ interpreterProxy primitiveFail]]
						ifFalse:[^ interpreterProxy primitiveFail]]].
	"Try a shortcut for stuff that should be run as quickly as possible"
 	done := self tryCopyingBitsQuickly.
	done ifTrue:[^nil].

	(combinationRule = 30) | (combinationRule = 31) ifTrue:
		["Check and fetch source alpha parameter for alpha blend"
		interpreterProxy methodArgumentCount = 1
			ifTrue: [sourceAlpha := interpreterProxy stackIntegerValue: 0.
					(interpreterProxy failed not and: [(sourceAlpha >= 0) &
(sourceAlpha <= 255)])
						ifFalse: [^ interpreterProxy primitiveFail]]
			ifFalse: [^ interpreterProxy primitiveFail]].

	bitCount := 0.
	"Choose and perform the actual copy loop."
	self performCopyLoop.

	(combinationRule = 22) | (combinationRule = 32) ifTrue:
		["zero width and height; return the count"
		affectedL := affectedR := affectedT := affectedB := 0].
	hDir > 0
		ifTrue: [affectedL := dx.
				affectedR := dx + bbW]
		ifFalse: [affectedL := dx - bbW + 1.
				affectedR := dx + 1].
	vDir > 0
		ifTrue: [affectedT := dy.
				affectedB := dy + bbH]
		ifFalse: [affectedT := dy - bbH + 1.
				affectedB := dy + 1]

-----------
blitting works, but color argument are totally ignored (yellow color
used instead, always!), while alpha - not.

It seems that either this stuff broken, or my VM sources are too outdated.

2009/6/20 Andreas Raab <andreas.raab at gmx.de>:
>
> Igor Stasenko wrote:
>>
>> 2009/6/20 Andreas Raab <andreas.raab at gmx.de>:
>>>
>>> Easy. Make a color map that is set up such that
>>>
>>> cmap := Bitmap new: 256.
>>> 0 to: 255 do:[:i|
>>>  cmap at: i+1 put: (constColor alpha: i/255.0) pixelValue32.
>>> ].
>>
>> That is possible, but the price is generating a color map each time
>> the color changes :(
>> Much less price than converting/using 32 bpp, but still is not perfect :)
>
> It's utterly trivial to cache it. If you're using this for font display
> you'll only have a few colors to deal with so the cache won't be big.
>
>> Any advice, how to force rule 41 work correctly? Or it is impossible? :)
>>
>> Btw, i don't sure that my VM (windoze) having latest & fixed rule 41.
>> I remember there were problems with it.
>
> I'm not sure what rule 41 does. The Windows VM contains whatever is in
> VMMaker.
>
> Cheers,
>  - Andreas
>



-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list