[Vm-dev] VM Maker: VMMaker-tpr.313.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Mar 25 23:57:13 UTC 2013


tim Rowledge uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker-tpr.313.mcz

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

Name: VMMaker-tpr.313
Author: tpr
Time: 25 March 2013, 4:54:55.792 pm
UUID: af8edbb1-fc10-4392-b80e-18938380a554
Ancestors: VMMaker-dtl.312

Move BitBltSimulation (ie BitBltPlugin) to be a subclass of SmartSyntaxInterpreterPlugin and copy the PixelValuePeekPlugin primitivePixelValueAtX:y: code into it.

Also updated the class comment a little to include newly added combination rules. Well, new about ten years ago.

A resulting VM runs the tests in BitBltTests ok.

=============== Diff against VMMaker-dtl.312 ===============

Item was changed:
+ SmartSyntaxInterpreterPlugin subclass: #BitBltSimulation
- InterpreterPlugin subclass: #BitBltSimulation
  	instanceVariableNames: 'destForm sourceForm halftoneForm combinationRule destX destY width height sourceX sourceY clipX clipY clipWidth clipHeight sourceWidth sourceHeight sourceDepth sourcePitch sourceBits sourcePPW sourceMSB destWidth destHeight destDepth destPitch destBits destPPW destMSB bitCount skew mask1 mask2 preload nWords destMask hDir vDir sourceIndex sourceDelta destIndex destDelta sx sy dx dy bbW bbH halftoneHeight noSource noHalftone halftoneBase sourceAlpha srcBitShift dstBitShift bitBltOop affectedL affectedR affectedT affectedB opTable maskTable ditherMatrix4x4 ditherThresholds16 ditherValues16 hasSurfaceLock warpSrcShift warpSrcMask warpAlignShift warpAlignMask warpBitShiftTable querySurfaceFn lockSurfaceFn unlockSurfaceFn isWarping cmFlags cmMask cmShiftTable cmMaskTable cmLookupTable cmBitsPerColor dither8Lookup componentAlphaModeColor componentAlphaModeAlpha ungammaLookupTable gammaLookupTable'
  	classVariableNames: 'AllOnes AlphaIndex BBClipHeightIndex BBClipWidthIndex BBClipXIndex BBClipYIndex BBColorMapIndex BBDestFormIndex BBDestXIndex BBDestYIndex BBHalftoneFormIndex BBHeightIndex BBLastIndex BBRuleIndex BBSourceFormIndex BBSourceXIndex BBSourceYIndex BBWarpBase BBWidthIndex BBXTableIndex BinaryPoint BlueIndex ColorMapFixedPart ColorMapIndexedPart ColorMapNewStyle ColorMapPresent CrossedX EndOfRun FixedPt1 FormBitsIndex FormDepthIndex FormHeightIndex FormWidthIndex GreenIndex JitBltHookSize OpTable OpTableSize RedIndex'
  	poolDictionaries: ''
  	category: 'VMMaker-Interpreter'!
  
+ !BitBltSimulation commentStamp: 'tpr 3/25/2013 16:50' prior: 0!
- !BitBltSimulation commentStamp: '<historical>' prior: 0!
  This class implements BitBlt, much as specified in the Blue Book spec.
  
  Performance has been enhanced through the use of pointer variables such as sourceIndex and destIndex, and by separating several special cases of the inner loop.
  
  Operation has been extended to color, with support for 1, 2, 4, 8, 16, and 32-bit pixel sizes.  Conversion between different pixel sizes is facilitated by accepting an optional color map.
  
  In addition to the original 16 combination rules, this BitBlt supports
  	16	fail (for old paint mode)
  	17	fail (for old mask mode)
  	18	sourceWord + destinationWord
  	19	sourceWord - destinationWord
  	20	rgbAdd: sourceWord with: destinationWord
  	21	rgbSub: sourceWord with: destinationWord
  	22	OLDrgbDiff: sourceWord with: destinationWord
  	23	OLDtallyIntoMap: destinationWord -- old vers doesn't clip to bit boundary
  	24	alphaBlend: sourceWord with: destinationWord
  	25	pixPaint: sourceWord with: destinationWord
  	26	pixMask: sourceWord with: destinationWord
  	27	rgbMax: sourceWord with: destinationWord
  	28	rgbMin: sourceWord with: destinationWord
  	29	rgbMin: sourceWord bitInvert32 with: destinationWord
  	30	alphaBlendConst: sourceWord with: destinationWord -- alpha passed as an arg
  	31	alphaPaintConst: sourceWord with: destinationWord -- alpha passed as an arg
  	32	rgbDiff: sourceWord with: destinationWord
  	33	tallyIntoMap: destinationWord
  	34	alphaBlendScaled: sourceWord with: destinationWord
+ 	35 alphaBlendScaled: sourceWord with:	"unused here - only used by FXBlt"
+ 	36 alphaBlendScaled: sourceWord with:	"unused here - only used by FXBlt"
+ 	37 rgbMul: sourceWord with: destinationWord
+ 	38 pixSwap: sourceWord with: destinationWord
+ 	39 pixClear: sourceWord with: destinationWord
+ 	40 fixAlpha: sourceWord with: destinationWord
+ 	41 rgbComponentAlpha: sourceWord with: destinationWord
  
  This implementation has also been fitted with an experimental "warp drive" that allows abritrary scaling and rotation (and even limited affine deformations) with all BitBlt storage modes supported.
  
  To add a new rule to BitBlt...
  	1.  add the new rule method or methods in the category 'combination rules' of BBSim
  	2.  describe it in the class comment  of BBSim and in the class comment for BitBlt
  	3.  add refs to initializeRuleTable in proper positions
  	4.  add refs to initBBOpTable, following the pattern
  !

Item was added:
+ ----- Method: BitBltSimulation>>primitivePixelValueAtX:y: (in category 'primitives') -----
+ primitivePixelValueAtX: xVal y: yVal
+ 	"returns the single pixel at x at y.
+ 	It does not handle LSB bitmaps right now.
+ 	If x or y are < 0, return 0 to indicate transparent (cf BitBlt>bitPeekerFromForm: usage).
+ 	Likewise if x>width or y>depth.
+ 	Fail if the rcvr doesn't seem to be a Form, or x|y seem wrong"
+ 	| rcvr bitmap depth ppW stride word mask shift pixel |
+ 	rcvr := self primitive: 'primitivePixelValueAt' parameters: #(SmallInteger SmallInteger) receiver: #Oop.
+ 	
+ 	"possible quick exit if x or y is -ve"
+ 	(xVal < 0 or: [ yVal < 0 ] ) ifTrue:[^interpreterProxy integerObjectOf: 0].
+ 	"check that rcvr is plausibly a Form or subclass"	
+ 	rcvr := interpreterProxy stackValue: interpreterProxy methodArgumentCount.
+ 	((interpreterProxy isPointers: rcvr) and: [(interpreterProxy slotSizeOf: rcvr) >= 4])
+ 		ifFalse: [^interpreterProxy primitiveFail].
+ 
+ 	"get the bits oop and width/height/depth"
+ 	bitmap := interpreterProxy fetchPointer: FormBitsIndex ofObject: rcvr.
+ 	width := interpreterProxy fetchInteger: FormWidthIndex ofObject: rcvr.
+ 	height := interpreterProxy fetchInteger: FormHeightIndex ofObject: rcvr.
+ 	depth := interpreterProxy fetchInteger: FormDepthIndex ofObject: rcvr.
+ 	"if width/height/depth are not integer, fail"
+ 	interpreterProxy failed ifTrue:[^nil].
+ 
+ 	"possible quick exit if x or y is >= extent of form. This also catches cases where the width/height are < 0"
+ 	(xVal >= width or: [ yVal >= height ] ) ifTrue:[^interpreterProxy integerObjectOf: 0].
+ 
+ 	"we don't handle LSB Forms yet"
+ 	depth < 0 ifTrue:[^interpreterProxy primitiveFail].
+ 	
+ 	"OK so now we know we have a plausible Form, the width/height/depth/x/y are all reasonable and it's time to plunder the bitmap"
+ 	ppW := 32//depth. "pixels in each word"
+ 	stride := (width + (ppW  -1)) // ppW. "how many words per rox of pixels"
+ 	word := interpreterProxy fetchLong32:(yVal * stride) + (xVal//ppW) ofObject: bitmap. "load the word that contains our target"
+ 	mask := 16rFFFFFFFF >> (32 - depth). "make a mask to isolate the pixel within that word"
+ 	shift := 32 - (((xVal bitAnd: ppW-1) + 1) * depth). "this is the tricky MSB part - we mask the xVal to find how far into the word we need, then add 1 for the pixel we're looking for, then * depth to get the bit shift"
+ 	pixel := (word >> shift) bitAnd: mask. "shift, mask and dim the lights"
+ 	^ pixel asPositiveIntegerObj "pop the incoming and push our answer"
+ !



More information about the Vm-dev mailing list