[Vm-dev] a question about sqInt displayObject(void)

John M McIntosh johnmci at smalltalkconsulting.com
Wed Feb 10 19:28:46 UTC 2010

Ok, I'm working on an iPhone project where I have to consider what is going on with the Squeak Drawing cycle. 
The original logic takes the 	

		ioShowDisplay(dispBitsIndex, w, h, d, left, right, top, bottom);

and builds CGImageRefs from the dispBitsIndex data. This is an immutable object and actually uses Copy On Write Virtual Paging logic
to ensure what the bits were when ioShowDisplay was called are what they will be when it's drawn. 

Usually ioShowDisplay is followed by a ForceDisplayUpdate which would then trigger the VM to take the queue of CGImageRefs (zero or more)  and draw them to the screen. This entails invalidating the combined rectangle(s), and waiting for the video sync logic to catch up and render the CGImageRef(s) to the drawing surface. 

There is a case where if you use warpblt then showDisplayBitsLeftTopRightBottom is uses and doesn't do the  ioForceDisplayUpdate. This is triggered by 
the primitive 231 code.  However on both the Macintosh and iPhone I have a dead man's timer and fire the primitiveForceDisplayUpdate if a draw is pending and 
oh say about 20 millisecond passes. This ensure the queue doesn't go to infinity (I've a production example of that...)

This works fine on os-x because we write to  a window backing store but only flush the data to the window server for drawing based on the forceupdate. 

But on the iPhone it's different. 
We draw the CGImageRefs, BUT at some point the graphic layer can flush the content or part of the content and expect you to redraw eveything. However I don't have any of that information, or I didn't think I did, so I get black chunks of nothingness.... 

I've moved from something rather complex, tricky and broken on the iPhone to something more simple which makes a copy of all the drawing. But it's painfully slow. 

Last night I got to thinking, where *does* the data come from.   So it appears and people can help confirm this, that Squeak *always* draws the data to the pointer in specialObjectsOops ->TheDisplay, found via sqInt displayObject(void).

I recall that Tim had a hook for the ARM code to make the memory pointer not point to an area in Squeak OOps space, but to point it to video memory? 

Anyway I'm thinking here I should be able to at ForceDisplayUpdate time take the recorded rectangle data from ioShowDisplay and pull the bits directly from 
specialObjectsOops ->TheDisplay

So anyone think this is not feasible?   I'd also look at doing this on OS-X since it avoids building the intern  CGImageRefs.


			Platform usage, not used on mac.

			Primitive 127
				Via DisplayScreen>>primShowRectLeft:right:top:bottom:		
				Via DisplayScreen>>primRetryShowRectLeft:right:top:bottom:		
			debugging code used by DoAssertionChecks

			**** only user of deferDisplayUpdates
			various places from BitBlt Plugin

			Primitive 231

sqInt displayObject(void) {
	return longAt((foo->specialObjectsOop + BaseHeaderSize) + (TheDisplay << ShiftForWord));

John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com

More information about the Vm-dev mailing list