Morphic redraws completely hidden objects.

Andreas Raab andreas.raab at gmx.de
Tue Aug 5 20:13:57 UTC 2003


> There is a Morph method called #areasRemainingToFill: that should be 
> overridden by subclasses that have known-opaque regions.

Yes but it doesn't help since if a back morph gets invalidated the front
guys are still being drawn. The point John was making is that invalidations
from completely hidden morphs shouldn't even end up in the invalidation
queue if they are invisible. Here's a rough outline how the invalidation
culling could look like if one really wants to do this:

invalidRect: aRectangle from: aMorph
	| damageRect invalidations |
	damageRect _ aRectangle.
	aMorph == self ifFalse:[
		"Clip to receiver's clipping bounds if the damage came from
a child"
		self clipSubmorphs 
			ifTrue:[damageRect _ aRectangle intersect: self
clippingBounds]].

	"<--- begin invalidation culling --->"
	invalidations := Array with: damageRect.
	aMorph owner == self ifTrue:[
		"The invalidation came from a submorph. See if any morphs in
front of aMorph overlap with the given rectangle and throw away all portions
which overlap"

		index := submorphs indexOf: aMorph.

		1 to: index do:[:i|
			todo := remaining.
			invalidations := OrderedCollection new.
			occluder := submorphs at: i.

			"process all remaining dirty regions"
			todo do:[:aRectangle|
				invalidations addAll: (occluder
areasRemainingToFill: aRectangle).
			].
			invalidations isEmpty ifTrue:[
				"There is no pending damage to pass along"
				^self].
		].
	].
	"<--- end invalidation culling --->"

	"... now pass up the invalidations to the parent ..."
	invalidations do:[:aRectangle|
		owner invalidRect: aRectangle from: self.
	].

Note that the overall complexity of this method is *significant* if we have
very little overlap between the submorphs of the receiver. Given that this
would happen for each and every invalidation, at each level of the morph
hierarchy this scheme explodes rapidly unless you have a Really Good Guess
about which morphs may overlap the region (this is what I said about
efficient region encoding and querying).

It might be worthwhile to play with this only for PasteUps but I am
uncertain how much of a real-life improvement this would be.

Cheers,
  - Andreas



More information about the Squeak-dev mailing list