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

commits at source.squeak.org commits at source.squeak.org
Sun Nov 13 12:55:14 UTC 2016


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

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

Name: VMMaker.oscog-nice.1989
Author: nice
Time: 13 November 2016, 1:53:23.184058 pm
UUID: 7e63fa13-3564-4b1b-8c0b-31378a87bc74
Ancestors: VMMaker.oscog-nice.1988

Fix prototype of various SurfaceFn again to match those of platforms/Corss/plugins/SurfacePlugin/SurfacePlugin.h

These should be matching the prototypes:
fn_getSurfaceFormat
fn_lockSurface
fn_unlockSurface
fn_showSurface

=============== Diff against VMMaker.oscog-nice.1988 ===============

Item was changed:
  ----- Method: BitBltSimulation>>lockSurfaces (in category 'surface support') -----
  lockSurfaces
  	"Get a pointer to the bits of any OS surfaces."
  	"Notes: 
  	* For equal source/dest handles only one locking operation is performed.
  	This is to prevent locking of overlapping areas which does not work with
  	certain APIs (as an example, DirectDraw prevents locking of overlapping areas). 
  	A special case for non-overlapping but equal source/dest handle would 
  	be possible but we would have to transfer this information over to 
  	unlockSurfaces somehow (currently, only one unlock operation is 
  	performed for equal source and dest handles). Also, this would require
  	a change in the notion of ioLockSurface() which is right now interpreted
  	as a hint and not as a requirement to lock only the specific portion of
  	the surface.
  
  	* The arguments in ioLockSurface() provide the implementation with
  	an explicit hint what area is affected. It can be very useful to
  	know the max. affected area beforehand if getting the bits requires expensive
  	copy operations (e.g., like a roundtrip to the X server or a glReadPixel op).
  	However, the returned pointer *MUST* point to the virtual origin of the surface
  	and not to the beginning of the rectangle. The promise made by BitBlt
  	is to never access data outside the given rectangle (aligned to 4byte boundaries!!)
  	so it is okay to return a pointer to the virtual origin that is actually outside
  	the valid memory area.
  
  	* The area provided in ioLockSurface() is already clipped (e.g., it will always
  	be inside the source and dest boundingBox) but it is not aligned to word boundaries
  	yet. It is up to the support code to compute accurate alignment if necessary.
  
  	* Warping always requires the entire source surface to be locked because
  	there is no beforehand knowledge about what area will actually be traversed.
  
  	"
  	| sourceHandle destHandle l r t b fn |
  	<inline: true>
+ 	<var: #fn declareC:'sqIntptr_t (*fn)(sqIntptr_t, int*, int, int, int, int)'>
- 	<var: #fn declareC:'sqInt (*fn)(sqInt, sqInt*, sqInt, sqInt, sqInt, sqInt)'>
  	hasSurfaceLock := false.
  	destBits = 0 ifTrue:["Blitting *to* OS surface"
  		lockSurfaceFn = 0 ifTrue:[self loadSurfacePlugin ifFalse:[^nil]].
+ 		fn := self cCoerce: lockSurfaceFn to: 'sqIntptr_t (*)(sqIntptr_t, int*, int, int, int, int)'.
- 		fn := self cCoerce: lockSurfaceFn to: 'sqInt (*)(sqInt, sqInt*, sqInt, sqInt, sqInt, sqInt)'.
  		destHandle := interpreterProxy fetchInteger: FormBitsIndex ofObject: destForm.
  		(sourceBits = 0 and:[noSource not]) ifTrue:[
  			sourceHandle := interpreterProxy fetchInteger: FormBitsIndex ofObject: sourceForm.
  			"Handle the special case of equal source and dest handles"
  			(sourceHandle = destHandle) ifTrue:[
  				"If we have overlapping source/dest we lock the entire area
  				so that there is only one area transmitted"
  				isWarping ifFalse:[
  					"When warping we always need the entire surface for the source"
  					sourceBits := self cCode:'fn(sourceHandle, &sourcePitch, 0,0, sourceWidth, sourceHeight)'.
  				] ifTrue:[
  					"Otherwise use overlapping area"
  					l := sx min: dx. r := (sx max: dx) + bbW.
  					t := sy min: dy. b := (sy max: dy) + bbH.
  					sourceBits := self cCode:'fn(sourceHandle, &sourcePitch, l, t, r-l, b-t)'.
  				].
  				destBits := sourceBits.
  				destPitch := sourcePitch.
  				hasSurfaceLock := true.
  				^destBits ~~ 0
  			].
  			"Fall through - if not equal it'll be handled below"
  		].
  		destBits := self cCode:'fn(destHandle, &destPitch, dx, dy, bbW, bbH)'.
  		hasSurfaceLock := true.
  	].
  	(sourceBits == 0 and:[noSource not]) ifTrue:["Blitting *from* OS surface"
  		sourceHandle := interpreterProxy fetchInteger: FormBitsIndex ofObject: sourceForm.
  		interpreterProxy failed ifTrue:[^nil]. "fetch sourceHandle could fail"
  		lockSurfaceFn = 0 ifTrue:[self loadSurfacePlugin ifFalse:[^nil]].
+ 		fn := self cCoerce: lockSurfaceFn to: 'sqIntptr_t (*)(sqIntptr_t, int*, int, int, int, int)'.
- 		fn := self cCoerce: lockSurfaceFn to: 'sqInt (*)(sqInt, sqInt*, sqInt, sqInt, sqInt, sqInt)'.
  		"Warping requiring the entire surface"
  		isWarping ifTrue:[
  			sourceBits := self cCode:'fn(sourceHandle, &sourcePitch, 0, 0, sourceWidth, sourceHeight)'.
  		] ifFalse:[
  			sourceBits := self cCode:'fn(sourceHandle, &sourcePitch, sx, sy, bbW, bbH)'.
  		].
  		hasSurfaceLock := true.
  	].
  	^destBits ~~ 0 and:[sourceBits ~~ 0 or:[noSource]].!

Item was changed:
  ----- Method: BitBltSimulation>>queryDestSurface: (in category 'surface support') -----
  queryDestSurface: handle
  	"Query the dimension of an OS surface.
  	This method is provided so that in case the inst vars of the
  	source form are broken, *actual* values of the OS surface
  	can be obtained. This might, for instance, happen if the user
  	resizes the main window.
  	Note: Moved to a separate function for better inlining of the caller."
  	querySurfaceFn = 0 ifTrue:[self loadSurfacePlugin ifFalse:[^false]].
+ 	^(self cCode:' ((int (*) (sqIntptr_t, int*, int*, int*, int*))querySurfaceFn)
- 	^(self cCode:' ((sqInt (*) (sqInt, sqInt*, sqInt*, sqInt*, sqInt*))querySurfaceFn)
  		(handle, &destWidth, &destHeight, &destDepth, &destMSB)'
  			 inSmalltalk:[false])!

Item was changed:
  ----- Method: BitBltSimulation>>querySourceSurface: (in category 'surface support') -----
  querySourceSurface: handle
  	"Query the dimension of an OS surface.
  	This method is provided so that in case the inst vars of the
  	source form are broken, *actual* values of the OS surface
  	can be obtained. This might, for instance, happen if the user
  	resizes the main window.
  	Note: Moved to a separate function for better inlining of the caller."
  	querySurfaceFn = 0 ifTrue:[self loadSurfacePlugin ifFalse:[^false]].
+ 	^(self cCode:' ((int (*) (sqIntptr_t, int*, int*, int*, int*))querySurfaceFn)
- 	^(self cCode:' ((sqInt (*) (sqInt, sqInt*, sqInt*, sqInt*, sqInt*))querySurfaceFn)
  		(handle, &sourceWidth, &sourceHeight, &sourceDepth, &sourceMSB)'
  			inSmalltalk:[false])!

Item was changed:
  ----- Method: BitBltSimulation>>unlockSurfaces (in category 'surface support') -----
  unlockSurfaces
  	"Unlock the bits of any OS surfaces."
  	"See the comment in lockSurfaces. Similar rules apply. That is, the area provided in ioUnlockSurface can be used to determine the dirty region after drawing. If a source is unlocked, then the area will be (0,0,0,0) to indicate that no portion is dirty."
  	| sourceHandle destHandle destLocked fn |
+ 	<var: #fn declareC:'int (*fn)(sqIntptr_t, int, int, int, int)'>
- 	<var: #fn declareC:'int (*fn)(int, int, int, int, int)'>
  	hasSurfaceLock ifTrue:[
  		unlockSurfaceFn = 0 ifTrue:[self loadSurfacePlugin ifFalse:[^nil]].
+ 		fn := self cCoerce: unlockSurfaceFn to: 'int (*)(sqIntptr_t, int, int, int, int)'.
- 		fn := self cCoerce: unlockSurfaceFn to: 'int (*)(int, int, int, int, int)'.
  		destLocked := false.
  		destHandle := interpreterProxy fetchPointer: FormBitsIndex ofObject: destForm.
  		(interpreterProxy isIntegerObject: destHandle) ifTrue:[
  			destHandle := interpreterProxy integerValueOf: destHandle.
  			"The destBits are always assumed to be dirty"
  			self cCode:'fn(destHandle, affectedL, affectedT, affectedR-affectedL, affectedB-affectedT)'.
  			destBits := destPitch := 0.
  			destLocked := true.
  		].
  		noSource ifFalse:[
  			sourceHandle := interpreterProxy fetchPointer: FormBitsIndex ofObject: sourceForm.
  			(interpreterProxy isIntegerObject: sourceHandle) ifTrue:[
  				sourceHandle := interpreterProxy integerValueOf: sourceHandle.
  				"Only unlock sourceHandle if different from destHandle"
  				(destLocked and:[sourceHandle = destHandle]) 
  					ifFalse:[self cCode: 'fn(sourceHandle, 0, 0, 0, 0)'].
  				sourceBits := sourcePitch := 0.
  			].
  		].
  		hasSurfaceLock := false.
  		self cCode: [] inSmalltalk:
  			[self touch: fn.
  			 interpreterProxy displayObject = destForm ifTrue:
  				[interpreterProxy getDeferDisplayUpdates "for some reason this is true..."
  					ifTrue:
  						[interpreterProxy fullDisplayUpdate]
  					ifFalse:
  						[interpreterProxy fullDisplayUpdate]]].
  	].!

Item was changed:
  ----- Method: Interpreter>>displayBitsOf:Left:Top:Right:Bottom: (in category 'I/O primitives') -----
  displayBitsOf: aForm Left: l Top: t Right: r Bottom: b
  	"Repaint the portion of the Smalltalk screen bounded by the affected rectangle. Used to synchronize the screen after a Bitblt to the Smalltalk Display object."
  
  	| displayObj dispBits w h dispBitsIndex d left right top bottom surfaceHandle |
  	displayObj := self splObj: TheDisplay.
  	aForm = displayObj ifFalse: [^ nil].
  	self success: ((self isPointers: displayObj) and: [(self lengthOf: displayObj) >= 4]).
  	successFlag ifTrue: [
  		dispBits := self fetchPointer: 0 ofObject: displayObj.
  		w := self fetchInteger: 1 ofObject: displayObj.
  		h := self fetchInteger: 2 ofObject: displayObj.
  		d := self fetchInteger: 3 ofObject: displayObj.
  	].
  	l < 0 ifTrue:[left := 0] ifFalse: [left := l].
  	r > w ifTrue: [right := w] ifFalse: [right := r].
  	t < 0 ifTrue: [top := 0] ifFalse: [top := t].
  	b > h ifTrue: [bottom := h] ifFalse: [bottom := b].
  	((left <= right) and: [top <= bottom]) ifFalse: [^nil].
  	successFlag ifTrue: [
  		(self isIntegerObject: dispBits) ifTrue: [
  			surfaceHandle := self integerValueOf: dispBits.
  			showSurfaceFn = 0 ifTrue: [
  				showSurfaceFn := self ioLoadFunction: 'ioShowSurface' From: 'SurfacePlugin'.
  				showSurfaceFn = 0 ifTrue: [^self success: false]].
+ 			self cCode:'((int (*)(sqIntptr_t, int, int, int, int))showSurfaceFn)(surfaceHandle, left, top, right-left, bottom-top)'.
- 			self cCode:'((sqInt (*)(sqInt, sqInt, sqInt, sqInt, sqInt))showSurfaceFn)(surfaceHandle, left, top, right-left, bottom-top)'.
  		] ifFalse: [
  			dispBitsIndex := dispBits + self baseHeaderSize.  "index in memory byte array"
  			self cCode: 'ioShowDisplay(dispBitsIndex, w, h, d, left, right, top, bottom)'
  				inSmalltalk: [self showDisplayBits: dispBitsIndex 
  								w: w h: h d: d
  								left: left right: right top: top bottom: bottom]
  		].
  	].!

Item was changed:
  ----- Method: StackInterpreter>>displayBitsOf:Left:Top:Right:Bottom: (in category 'I/O primitives') -----
  displayBitsOf: aForm Left: l Top: t Right: r Bottom: b
  	"Repaint the portion of the Smalltalk screen bounded by the affected rectangle. Used to synchronize the screen after a Bitblt to the Smalltalk Display object."
  
  	| displayObj dispBits w h dispBitsIndex d left right top bottom surfaceHandle |
  	displayObj := objectMemory splObj: TheDisplay.
  	aForm = displayObj ifFalse: [^ nil].
  	self success: ((objectMemory isPointers: displayObj) and: [(objectMemory lengthOf: displayObj) >= 4]).
  	self successful ifTrue: [
  		dispBits := objectMemory fetchPointer: 0 ofObject: displayObj.
  		w := self fetchInteger: 1 ofObject: displayObj.
  		h := self fetchInteger: 2 ofObject: displayObj.
  		d := self fetchInteger: 3 ofObject: displayObj.
  	].
  	l < 0 ifTrue:[left := 0] ifFalse: [left := l].
  	r > w ifTrue: [right := w] ifFalse: [right := r].
  	t < 0 ifTrue: [top := 0] ifFalse: [top := t].
  	b > h ifTrue: [bottom := h] ifFalse: [bottom := b].
  	((left <= right) and: [top <= bottom]) ifFalse: [^nil].
  	self successful ifTrue: [
  		(objectMemory isIntegerObject: dispBits) ifTrue: [
  			surfaceHandle := objectMemory integerValueOf: dispBits.
  			showSurfaceFn = 0 ifTrue: [
  				showSurfaceFn := self ioLoadFunction: 'ioShowSurface' From: 'SurfacePlugin'.
  				showSurfaceFn = 0 ifTrue: [^self success: false]].
+ 			self cCode:'((int (*)(sqIntptr_t, int, int, int, int))showSurfaceFn)(surfaceHandle, left, top, right-left, bottom-top)'.
- 			self cCode:'((sqInt (*)(sqInt, sqInt, sqInt, sqInt, sqInt))showSurfaceFn)(surfaceHandle, left, top, right-left, bottom-top)'.
  		] ifFalse: [
  			self assert: (objectMemory isNonImmediate: dispBits).
  			dispBitsIndex := dispBits + objectMemory baseHeaderSize.  "index in memory byte array"
  			self cCode: 'ioShowDisplay(dispBitsIndex, w, h, d, left, right, top, bottom)'
  				inSmalltalk: [self showDisplayBits: dispBitsIndex 
  								w: w h: h d: d
  								left: left right: right top: top bottom: bottom]
  		].
  	]!



More information about the Vm-dev mailing list