[Pkg] The Trunk: GraphicsTests-tpr.33.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Mar 21 21:25:26 UTC 2013


tim Rowledge uploaded a new version of GraphicsTests to project The Trunk:
http://source.squeak.org/trunk/GraphicsTests-tpr.33.mcz

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

Name: GraphicsTests-tpr.33
Author: tpr
Time: 21 March 2013, 9:24:55.556 pm
UUID: 2e72384c-4a49-475d-a45e-2707a3cb5957
Ancestors: GraphicsTests-tpr.32

(second attemt to save this)
Add test for Form>pixelValueAt: primitive extension.
Add <timeout: > pragma to some slow running tests (on a Pi) so they get a chance to complete.

=============== Diff against GraphicsTests-nice.31 ===============

Item was changed:
  ----- Method: BitBltTest>>testAllAlphasRgbAdd (in category 'bugs') -----
  testAllAlphasRgbAdd
  	"self run: #testAllAlphasRgbAdd"
  	| sourceForm destForm blt correctAlphas |
+ 	<timeout: 15>
       correctAlphas := 0.
       0  to: 255 do: [:sourceAlpha |
           sourceForm := Form extent: 1 @ 1 depth: 32.
           sourceForm bits at: 1 put: sourceAlpha << 24 + (33 << 16) + (25 << 8) + 27.
           0 to: 255 do: [:destAlpha |
               destForm := Form extent: 1 @ 1 depth: 32.
               destForm bits at: 1 put: destAlpha << 24 + (255 << 16) + (255 << 8) + 255.
                blt := BitBlt new.
                blt sourceForm: sourceForm.
                blt sourceOrigin: 0 @ 0.
                blt setDestForm: destForm.
                blt destOrigin: 0 @ 0.
                blt combinationRule: 20.	"rgbAdd"
                blt copyBits.
                correctAlphas := correctAlphas
                  + (((blt destForm bits at: 1) digitAt: 4) = (destAlpha + sourceAlpha min: 255)
                           ifTrue: [1]
                           ifFalse: [0])
        ]].
       self assert: 65536 equals: correctAlphas!

Item was changed:
  ----- Method: BitBltTest>>testAllAlphasRgbMax (in category 'bugs') -----
  testAllAlphasRgbMax
  	"self run: #testAllAlphasRgbMax"
  	| sourceForm destForm blt correctAlphas |
+ 	<timeout: 10>
       correctAlphas := 0.
       0  to: 255 do: [:sourceAlpha |
           sourceForm := Form extent: 1 @ 1 depth: 32.
           sourceForm bits at: 1 put: sourceAlpha << 24 + (33 << 16) + (25 << 8) + 27.
           0 to: 255 do: [:destAlpha |
               destForm := Form extent: 1 @ 1 depth: 32.
               destForm bits at: 1 put: destAlpha << 24 + (255 << 16) + (255 << 8) + 255.
                blt := BitBlt new.
                blt sourceForm: sourceForm.
                blt sourceOrigin: 0 @ 0.
                blt setDestForm: destForm.
                blt destOrigin: 0 @ 0.
                blt combinationRule: 27.	"rgbMax"
                blt copyBits.
                correctAlphas := correctAlphas
                  + (((blt destForm bits at: 1) digitAt: 4) = (destAlpha max: sourceAlpha)
                           ifTrue: [1]
                           ifFalse: [0])
        ]].
       self assert: 65536 equals: correctAlphas!

Item was changed:
  ----- Method: BitBltTest>>testAllAlphasRgbMin (in category 'bugs') -----
  testAllAlphasRgbMin
  	"self run: #testAllAlphasRgbMin"
  	| sourceForm destForm blt correctAlphas |
+ 	<timeout: 10>
       correctAlphas := 0.
       0  to: 255 do: [:sourceAlpha |
           sourceForm := Form extent: 1 @ 1 depth: 32.
           sourceForm bits at: 1 put: sourceAlpha << 24 + (33 << 16) + (25 << 8) + 27.
           0 to: 255 do: [:destAlpha |
               destForm := Form extent: 1 @ 1 depth: 32.
               destForm bits at: 1 put: destAlpha << 24 + (255 << 16) + (255 << 8) + 255.
                blt := BitBlt new.
                blt sourceForm: sourceForm.
                blt sourceOrigin: 0 @ 0.
                blt setDestForm: destForm.
                blt destOrigin: 0 @ 0.
                blt combinationRule: 28.	"rgbMin"
                blt copyBits.
                correctAlphas := correctAlphas
                  + (((blt destForm bits at: 1) digitAt: 4) = (destAlpha min: sourceAlpha)
                           ifTrue: [1]
                           ifFalse: [0])
        ]].
       self assert: 65536 equals: correctAlphas!

Item was changed:
  ----- Method: BitBltTest>>testAllAlphasRgbMinInvert (in category 'bugs') -----
  testAllAlphasRgbMinInvert
  	"self run: #testAllAlphasRgbMinInvert"
  	| sourceForm destForm blt correctAlphas |
+ 	<timeout: 10>
       correctAlphas := 0.
       0  to: 255 do: [:sourceAlpha |
           sourceForm := Form extent: 1 @ 1 depth: 32.
           sourceForm bits at: 1 put: sourceAlpha << 24 + (33 << 16) + (25 << 8) + 27.
           0 to: 255 do: [:destAlpha |
               destForm := Form extent: 1 @ 1 depth: 32.
               destForm bits at: 1 put: destAlpha << 24 + (255 << 16) + (255 << 8) + 255.
                blt := BitBlt new.
                blt sourceForm: sourceForm.
                blt sourceOrigin: 0 @ 0.
                blt setDestForm: destForm.
                blt destOrigin: 0 @ 0.
                blt combinationRule: 29.	"rgbMinInvert"
                blt copyBits.
                correctAlphas := correctAlphas
                  + (((blt destForm bits at: 1) digitAt: 4) = (destAlpha min: 255-sourceAlpha)
                           ifTrue: [1]
                           ifFalse: [0])
        ]].
       self assert: 65536 equals: correctAlphas!

Item was changed:
  ----- Method: BitBltTest>>testAllAlphasRgbMul (in category 'bugs') -----
  testAllAlphasRgbMul
  	"self run: #testAllAlphasRgbMul"
  	| sourceForm destForm blt correctAlphas |
+ 	<timeout: 10>
       correctAlphas := 0.
       0  to: 255 do: [:sourceAlpha |
           sourceForm := Form extent: 1 @ 1 depth: 32.
           sourceForm bits at: 1 put: sourceAlpha << 24 + (33 << 16) + (25 << 8) + 27.
           0 to: 255 do: [:destAlpha |
               destForm := Form extent: 1 @ 1 depth: 32.
               destForm bits at: 1 put: destAlpha << 24 + (255 << 16) + (255 << 8) + 255.
                blt := BitBlt new.
                blt sourceForm: sourceForm.
                blt sourceOrigin: 0 @ 0.
                blt setDestForm: destForm.
                blt destOrigin: 0 @ 0.
                blt combinationRule: 37.	"rgbMul"
                blt copyBits.
                correctAlphas := correctAlphas
                  + (((blt destForm bits at: 1) digitAt: 4) = ((destAlpha+1) * (sourceAlpha+1)- 1 // 256)
                           ifTrue: [1]
                           ifFalse: [0])
        ]].
       self assert: 65536 equals: correctAlphas!

Item was changed:
  ----- Method: BitBltTest>>testAllAlphasRgbSub (in category 'bugs') -----
  testAllAlphasRgbSub
  	"self run: #testAllAlphasRgbSub"
  	| sourceForm destForm blt correctAlphas |
+ 	<timeout: 10>
       correctAlphas := 0.
       0  to: 255 do: [:sourceAlpha |
           sourceForm := Form extent: 1 @ 1 depth: 32.
           sourceForm bits at: 1 put: sourceAlpha << 24 + (33 << 16) + (25 << 8) + 27.
           0 to: 255 do: [:destAlpha |
               destForm := Form extent: 1 @ 1 depth: 32.
               destForm bits at: 1 put: destAlpha << 24 + (255 << 16) + (255 << 8) + 255.
                blt := BitBlt new.
                blt sourceForm: sourceForm.
                blt sourceOrigin: 0 @ 0.
                blt setDestForm: destForm.
                blt destOrigin: 0 @ 0.
                blt combinationRule: 21.	"rgbSub"
                blt copyBits.
                correctAlphas := correctAlphas
                  + (((blt destForm bits at: 1) digitAt: 4) = (destAlpha - sourceAlpha) abs
                           ifTrue: [1]
                           ifFalse: [0])
        ]].
       self assert: 65536 equals: correctAlphas!

Item was changed:
  ----- Method: BitBltTest>>testAlphaCompositing2Simulated (in category 'bugs') -----
  testAlphaCompositing2Simulated
  	"self run: #testAlphaCompositing2Simulated"
  
+ 	<timeout: 60>
  	Smalltalk at: #BitBltSimulation ifPresent: [:bitblt|
  	| bb f1 f2 mixColor result eps |
  	f1 := Form extent: 1 at 1 depth: 32.
  	f2 := Form extent: 1 at 1 depth: 32.
  	eps := 0.5 / 255.
  	0 to: 255 do:[:i|
  		f1 colorAt: 0 at 0 put: Color transparent.
  		mixColor := Color red alpha: i / 255.0.
  		f2 colorAt: 0 at 0 put: mixColor.
  		mixColor := f2 colorAt: 0 at 0.
  		bb := BitBlt toForm: f1.
  		bb sourceForm: f2.
  		bb combinationRule: Form blend.
  		bb copyBitsSimulated.
  		result := f1 colorAt: 0 at 0.
  		self assert: (result red - mixColor alpha) abs < eps.
  		self assert: result alpha = mixColor alpha.
  	].]!

Item was changed:
  ----- Method: BitBltTest>>testAlphaCompositingSimulated (in category 'bugs') -----
  testAlphaCompositingSimulated
  	"self run: #testAlphaCompositingSimulated"
  	
+ 	<timeout: 60>
  	Smalltalk at: #BitBltSimulation ifPresent:[:bitblt|
  	| bb f1 f2 mixColor result eps |
  	f1 := Form extent: 1 at 1 depth: 32.
  	f2 := Form extent: 1 at 1 depth: 32.
  	eps := 0.5 / 255.
  	0 to: 255 do:[:i|
  		f1 colorAt: 0 at 0 put: Color blue.
  		mixColor := Color red alpha: i / 255.0.
  		f2 colorAt: 0 at 0 put: mixColor.
  		mixColor := f2 colorAt: 0 at 0.
  		bb := BitBlt toForm: f1.
  		bb sourceForm: f2.
  		bb combinationRule: Form blend.
  		bb copyBitsSimulated.
  		result := f1 colorAt: 0 at 0.
  		self assert: (result red - mixColor alpha) abs < eps.
  		self assert: (result blue - (1.0 - mixColor alpha)) abs < eps.
  		self assert: result alpha = 1.0.
  	]].!

Item was added:
+ ----- Method: BitBltTest>>testPivelValueAt (in category 'bugs') -----
+ testPivelValueAt
+ "tests for the pixel peeking extension to bitBlt"
+ "	self run: #testPixelValueAt"
+ 	|formList pixels |	
+ "make a Form of each depth"
+ 	formList := #(1 2 4 8 16 32) collect:[:d| Form extent: 17 at 7 depth: d].
+ 	pixels := Dictionary new.
+ 	pixels at: 1 put: 1; at: 2 put: 3; at:4 put: 7; at: 8 put: 16rFF; at: 16 put: 16rFFFF ; at: 32 put: 16rFFFFFFFF.
+ 
+ "poke pixels to 
+ topleft (to test handling 0)
+ bottomright (to test limits)
+ middle (just because)
+ peek at each location (to make sure it matches expectations)"
+ 	formList do:[:f| |d pixval|
+ 		d := f depth.
+ 		pixval := pixels at: d.
+ 		f pixelValueAt: 0 at 0 put: pixval.
+ 		f pixelValueAt: 16 at 6 put: pixval.
+ 		f pixelValueAt: 7 at 3 put: pixval.
+ 			self assert: (f pixelValueAt: 0 at 0) = pixval. 
+ 			self assert: (f pixelValueAt: 1 at 0) = 0. 
+ 			self assert: (f pixelValueAt: 16 at 6) = pixval. 
+ 			self assert:(f pixelValueAt: 15 at 6) = 0. 
+ 			self assert: (f pixelValueAt: 7 at 3) = pixval.
+ 			self assert: (f pixelValueAt: 6 at 3) = 0.
+ 	]!



More information about the Packages mailing list