[squeak-dev] The Trunk: Morphic-mt.1902.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Feb 21 08:31:48 UTC 2022

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:

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

Name: Morphic-mt.1902
Author: mt
Time: 21 February 2022, 9:31:41.263853 am
UUID: 6fc55666-eb72-8240-8d39-22e44c25d2fc
Ancestors: Morphic-ct.1901

Adds commentary about the current situation of a morph's drop-shadow cache.

Thanks to Christoph (ct) for pointing this out!

=============== Diff against Morphic-ct.1901 ===============

Item was changed:
  ----- Method: Morph>>updateDropShadowCache (in category 'drawing') -----
+ 	"Draws the receiver's drop shadow into a separate form (or cache) to be used repeatedly in #drawDropShadowOn:, which is itself guarded via #hasDropShadow (see #fullDrawOn:).
+ 	Note that this cache is not so much about performance as it is about visual aesthetics. While the shadow itself is just one or more repeated calls to fill/frame a (rounded rectangle), we finally cut out (or mask or erase) the inner portion so that translucent receiver's wont look awkward. This is not possible with direct drawing calls to BitBlt onto Display.
+ 	Also note that with the advent of the Spur object memory (http://www.mirandabanda.org/cogblog/category/spur/) in the OpenSmalltalk VM, we got a different garbage collector (GC) that does not yet have the most efficient incremental collection strategies. As an effect, repeated invalidation of the drop-shadow cache now entails frequent full-GC pauses and thus noticeable lags (or stuttering) in the environment. This has been the case since the release of Squeak 5.0, where we started to use the Spur object memory and hence the new GC.
+ 	To make the full-GC pauses less noticeable, we started to temporarily disable the drop shadow in situations where responsiveness is importent. For example, we do this for frequently used morphs such as all system windows when being resized using their corner (or edge) grips. You can get an overview of thus points by browsing senders of #targetHadDropShadow and #hasDropShadow: (or actually the code 'hasDropShadow: false', which typically starts the temporary disabling of the shadow).
+ 	February 2022: We are currently working on improving the incremental compaction in the OpenSmalltalk VM. Once that issue has been solved, we can remove that source code that disables the drop shadow temporarily."
  	| shadowOffset shadowBounds offset form canvas drawBlock localBounds mask maskCanvas |
+ 	self flag: #hasDropShadow. "Marker for senders browsing."
+ 	self flag: #targetHadDropShadow. "Marker for senders browsing."
  	(shadowOffset := self shadowOffset) isRectangle
  		ifTrue: [
  			shadowBounds := 0 at 0 corner: (self bounds outsetBy: shadowOffset) extent.
  			offset := 0 at 0.
  			localBounds := shadowOffset topLeft extent: self extent ]
  		ifFalse: [
  			| extent |
  			extent := self extent.
  			shadowBounds := 0 at 0 corner: extent + shadowOffset abs.
  			offset := shadowOffset max: 0 at 0.
  			localBounds := (shadowOffset negated max: 0 at 0) extent: extent ].
  	form := Form extent: shadowBounds extent depth: Display depth.
  	canvas := form getCanvas.
  	drawBlock := self useSoftDropShadow
  		ifFalse: [
  			[:c | self wantsRoundedCorners
  					ifTrue: [c fillRoundRect: localBounds radius: self cornerRadius fillStyle: self shadowColor]
  					ifFalse: [c fillRectangle: localBounds fillStyle: self shadowColor]]]
  		ifTrue: [
  			[:c | self wantsRoundedCorners
  					ifTrue: [0 to: 9 do: [:i |
  							fillRoundRect: (shadowBounds insetBy: i)
  							radius: (self cornerRadius max: 20) -i
  							fillStyle: (self shadowColor alpha: self shadowColor alpha * (i+1))]]
  					ifFalse: [0 to: 9 do: [:i | 
  							fillRoundRect: (shadowBounds insetBy: i) radius: 20-i
  							fillStyle: (self shadowColor alpha: self shadowColor alpha * (i+1))]]]].
  		translateBy: offset
  		during: [ :shadowCanvas | drawBlock value: shadowCanvas].
  	"Support transparent morph colors without having the shadow to shine through.."
  	mask := Form extent: shadowBounds extent depth: Display depth.
  	maskCanvas := mask getCanvas.
  	self wantsRoundedCorners
  		ifTrue: [maskCanvas fillRoundRect: (localBounds insetBy: self borderWidth) radius: self cornerRadius fillStyle: Color black]
  		ifFalse: [maskCanvas fillRectangle: (localBounds insetBy: self borderWidth) fillStyle: Color black].
  		displayOn: form
  		at: 0 at 0
  		rule: Form erase.
  	self setProperty: #dropShadow toValue: form.!

More information about the Squeak-dev mailing list