[squeak-dev] The Trunk: Graphics-mt.158.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Nov 22 14:31:44 UTC 2010

Levente Uzonyi uploaded a new version of Graphics to project The Trunk:

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

Name: Graphics-mt.158
Author: mt
Time: 16 November 2010, 8:35:03.184 pm
UUID: 347b600f-3afe-ac4c-acc6-4703d7a3c0bc
Ancestors: Graphics-mt.157

- nicer version of fix for font rendering with translucent colors (thanks to Juan Vuletich)
-> subpixel rendering will be disabled in that case
- minor code clean-up (using Form-constants instead of magic numbers)

=============== Diff against Graphics-mt.157 ===============

Item was changed:
  ----- Method: BitBlt>>installStrikeFont:foregroundColor:backgroundColor: (in category 'private') -----
  installStrikeFont: aStrikeFont foregroundColor: foregroundColor backgroundColor: backgroundColor
  	| lastSourceDepth targetColor |
  	sourceForm ifNotNil:[lastSourceDepth := sourceForm depth].
  	sourceForm := aStrikeFont glyphs.
  	"Ignore any halftone pattern since we use a color map approach here"
  	halftoneForm := nil.
  	sourceY := 0.
  	height := aStrikeFont height.
  	sourceForm depth = 1 ifTrue: [
  		self combinationRule: Form paint.
  		(colorMap notNil and:[lastSourceDepth = sourceForm depth]) ifFalse: [
  			"Set up color map for a different source depth (color font)"
  			"Uses caching for reasonable efficiency"
  			colorMap := self cachedFontColormapFrom: sourceForm depth to: destForm depth.
  			colorMap at: 1 put: (destForm pixelValueFor: backgroundColor)].
  		colorMap at: 2 put: (destForm pixelValueFor: foregroundColor).
  	ifFalse: [
+ 		(Preferences subPixelRenderFonts and: [ foregroundColor = Color black
+ 			"Only use rgbMul with opaque colors as alpha values get lost for translucent colors."
+ 			or: [ Preferences subPixelRenderColorFonts and: [foregroundColor isOpaque] ]]) ifTrue: [
- 		(Preferences subPixelRenderFonts and: [ foregroundColor = Color black or: [ Preferences subPixelRenderColorFonts ]]) ifTrue: [
  			destForm depth > 8 ifTrue: [
+ 				"rgbMul is equivalent to component alpha blend if text is black (only faster, hehe)"
+ 				self combinationRule: Form rgbMul.
- 				"Only choose #rgbMul if color is not translucent for better result quality. Alpha values are ignored with #rgbMul."
- 				foregroundColor isTranslucent
- 					ifTrue: [self combinationRule: Form blend]
- 					ifFalse: [self combinationRule: Form rgbMul].
  				colorMap := (destForm depth = 32 or: [ (foregroundColor = Color black) not ]) ifTrue: [
  					"rgbMul / rgbAdd IS component alpha blend for any color of text (neat trick, eh!!)"
  					"This colorMap is to be used on the second pass with rule 20 (rgbAdd)
  					See #displayString:from:to:at:strikeFont:kern:"
  					"Note: In 32bpp we always need the second pass, as the source could have transparent pixels, and we need to add to the alpha channel"
  					self colorConvertingMap: foregroundColor from: sourceForm depth to: destForm depth keepSubPixelAA: true]]
  			ifFalse: [
+ 				self combinationRule: Form paint.
- 				self combinationRule: 25.		"Paint"
  				targetColor := foregroundColor = Color black ifFalse: [ foregroundColor ].
  				colorMap := self colorConvertingMap: targetColor from: sourceForm depth to: destForm depth keepSubPixelAA: true]
  		ifFalse: [
  			"Do not use rule 34 for 16bpp display. TTCFont uses it, but it builds a glyphs cache for each color used!!"
+ 			self combinationRule: (destForm depth = 32 ifTrue: [Form blendAlphaScaled] ifFalse: [Form paint]).
- 			self combinationRule: (destForm depth = 32 ifTrue: [34 "alphaBlendScaled"] ifFalse: [25 "Paint"]).
  			colorMap := self colorConvertingMap: foregroundColor from: sourceForm depth to: destForm depth keepSubPixelAA: false

Item was added:
+ ----- Method: Form class>>blendAlphaScaled (in category 'mode constants') -----
+ blendAlphaScaled
+ 	"Answer the integer denoting BitBlt's blend-with-alpha-scaled rule."
+ 	^ 34!

More information about the Squeak-dev mailing list