Eliot Miranda uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-eem.321.mcz
==================== Summary ====================
Name: Graphics-eem.321
Author: eem
Time: 16 January 2016, 9:43:19.481889 am
UUID: 63221468-923b-4e2d-a262-1fb47958bb0c
Ancestors: Graphics-eem.320
Rewrite Color>>pixelValueForDepth: to avoid need for normalization and for creating 4-byte LargeIntegers in 64-bits.
=============== Diff against Graphics-eem.320 ===============
Item was changed:
----- Method: Color>>pixelValueForDepth: (in category 'conversions') -----
pixelValueForDepth: d
+ "Answers an integer representing the bits that appear in a single pixel of this color in a Form of the given depth.
+ The depth must be one of 1, 2, 4, 8, 16, or 32. Contrast with pixelWordForDepth: and bitPatternForDepth:, which
+ answer either a 32-bit word packed with the given pixel value or a multiple-word Bitmap containing a pattern.
+ The inverse is the class message colorFromPixelValue:depth:"
+ "Details:
+ For depths of 8 or less, the result is a colorMap index.
+ For depths of 16 and 32, it is a direct color value with 5 or 8 bits per color component."
+ "Transparency:
+ The pixel value zero is reserved for transparent.
+ For depths greater than 8, black maps to the darkest possible blue."
- "Returns an integer representing the bits that appear in a single pixel of this color in a Form of the given depth. The depth must be one of 1, 2, 4, 8, 16, or 32. Contrast with pixelWordForDepth: and bitPatternForDepth:, which return either a 32-bit word packed with the given pixel value or a multiple-word Bitmap containing a pattern. The inverse is the class message colorFromPixelValue:depth:"
- "Details: For depths of 8 or less, the result is a colorMap index. For depths of 16 and 32, it is a direct color value with 5 or 8 bits per color component."
- "Transparency: The pixel value zero is reserved for transparent. For depths greater than 8, black maps to the darkest possible blue."
| val |
+ d > 8 ifTrue: "most common case"
+ [d = 32 ifTrue: "eight bits per component; top 8 bits set to all ones (opaque alpha)"
+ ["this subexpression is a SmallInteger in both 32- and 64-bits."
+ val := ((rgb bitShift: -6) bitAnd: 16rFF0000) bitOr:
+ (((rgb bitShift: -4) bitAnd: 16rFF00) bitOr:
+ ((rgb bitShift: -2) bitAnd: 16rFF)).
+ "16rFF000000 & 16rFF000001 are LargeIntegers in 32-bits, SmallIntegers in 64-bits."
+ ^val = 0 ifTrue: [16rFF000001] ifFalse: [16rFF000000 + val]].
+
+ d = 16 ifTrue: "five bits per component; top bits ignored"
+ [val := (((rgb bitShift: -15) bitAnd: 16r7C00) bitOr:
- d > 8 "most common case"
- ifTrue:
- [d = 32 ifTrue: [
- "eight bits per component; top 8 bits set to all ones (opaque alpha)"
- val := (LargePositiveInteger new: 4)
- at: 4 put: 16rFF;
- at: 3 put: ((rgb bitShift: -22) bitAnd: 16rFF);
- at: 2 put: ((rgb bitShift: -12) bitAnd: 16rFF);
- at: 1 put: ((rgb bitShift: -2) bitAnd: 16rFF);
- normalize. "normalize is not necessary as long as SmallInteger maxVal highBit < 32, but let's be future proof"
- ^val < 16rFF000001 ifTrue: [16rFF000001] ifFalse: [val]].
-
- d = 16 ifTrue: [
- "five bits per component; top bits ignored"
- val := (((rgb bitShift: -15) bitAnd: 16r7C00) bitOr:
((rgb bitShift: -10) bitAnd: 16r03E0)) bitOr:
((rgb bitShift: -5) bitAnd: 16r001F).
+ ^val = 0 ifTrue: [1] ifFalse: [val]].
- ^val < 1 ifTrue: [1] ifFalse: [val]].
+ d = 12 ifTrue: "for indexing a color map with 4 bits per color component"
+ [val := (((rgb bitShift: -18) bitAnd: 16r0F00) bitOr:
- d = 12 ifTrue: [ "for indexing a color map with 4 bits per color component"
- val := (((rgb bitShift: -18) bitAnd: 16r0F00) bitOr:
((rgb bitShift: -12) bitAnd: 16r00F0)) bitOr:
((rgb bitShift: -6) bitAnd: 16r000F).
+ ^val = 0 ifTrue: [1] ifFalse: [val]].
- ^val < 1 ifTrue: [1] ifFalse: [val]].
+ d = 9 ifTrue: "for indexing a color map with 3 bits per color component"
+ [val := (((rgb bitShift: -21) bitAnd: 16r01C0) bitOr:
+ ((rgb bitShift: -14) bitAnd: 16r0038)) bitOr:
+ ((rgb bitShift: -7) bitAnd: 16r0007).
+ ^val = 0 ifTrue: [1] ifFalse: [val]]].
- d = 9 ifTrue: [ "for indexing a color map with 3 bits per color component"
- val := (((rgb bitShift: -21) bitAnd: 16r01C0) bitOr:
- ((rgb bitShift: -14) bitAnd: 16r0038)) bitOr:
- ((rgb bitShift: -7) bitAnd: 16r0007).
- ^val < 1 ifTrue: [1] ifFalse: [val]]].
d = 8 ifTrue: [^ self closestPixelValue8].
d = 4 ifTrue: [^ self closestPixelValue4].
d = 2 ifTrue: [^ self closestPixelValue2]..
d = 1 ifTrue: [^ self closestPixelValue1].
self error: 'unknown pixel depth: ', d printString
!
Eliot Miranda uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-eem.321.mcz
==================== Summary ====================
Name: Graphics-eem.321
Author: eem
Time: 16 January 2016, 9:43:19.481889 am
UUID: 63221468-923b-4e2d-a262-1fb47958bb0c
Ancestors: Graphics-eem.320
Rewrite Color>>pixelValueForDepth: to avoid need for normalization and for creating 4-byte LargeIntegers in 64-bits.
=============== Diff against Graphics-eem.320 ===============
Item was changed:
----- Method: Color>>pixelValueForDepth: (in category 'conversions') -----
pixelValueForDepth: d
+ "Answers an integer representing the bits that appear in a single pixel of this color in a Form of the given depth.
+ The depth must be one of 1, 2, 4, 8, 16, or 32. Contrast with pixelWordForDepth: and bitPatternForDepth:, which
+ answer either a 32-bit word packed with the given pixel value or a multiple-word Bitmap containing a pattern.
+ The inverse is the class message colorFromPixelValue:depth:"
+ "Details:
+ For depths of 8 or less, the result is a colorMap index.
+ For depths of 16 and 32, it is a direct color value with 5 or 8 bits per color component."
+ "Transparency:
+ The pixel value zero is reserved for transparent.
+ For depths greater than 8, black maps to the darkest possible blue."
- "Returns an integer representing the bits that appear in a single pixel of this color in a Form of the given depth. The depth must be one of 1, 2, 4, 8, 16, or 32. Contrast with pixelWordForDepth: and bitPatternForDepth:, which return either a 32-bit word packed with the given pixel value or a multiple-word Bitmap containing a pattern. The inverse is the class message colorFromPixelValue:depth:"
- "Details: For depths of 8 or less, the result is a colorMap index. For depths of 16 and 32, it is a direct color value with 5 or 8 bits per color component."
- "Transparency: The pixel value zero is reserved for transparent. For depths greater than 8, black maps to the darkest possible blue."
| val |
+ d > 8 ifTrue: "most common case"
+ [d = 32 ifTrue: "eight bits per component; top 8 bits set to all ones (opaque alpha)"
+ ["this subexpression is a SmallInteger in both 32- and 64-bits."
+ val := ((rgb bitShift: -6) bitAnd: 16rFF0000) bitOr:
+ (((rgb bitShift: -4) bitAnd: 16rFF00) bitOr:
+ ((rgb bitShift: -2) bitAnd: 16rFF)).
+ "16rFF000000 & 16rFF000001 are LargeIntegers in 32-bits, SmallIntegers in 64-bits."
+ ^val = 0 ifTrue: [16rFF000001] ifFalse: [16rFF000000 + val]].
+
+ d = 16 ifTrue: "five bits per component; top bits ignored"
+ [val := (((rgb bitShift: -15) bitAnd: 16r7C00) bitOr:
- d > 8 "most common case"
- ifTrue:
- [d = 32 ifTrue: [
- "eight bits per component; top 8 bits set to all ones (opaque alpha)"
- val := (LargePositiveInteger new: 4)
- at: 4 put: 16rFF;
- at: 3 put: ((rgb bitShift: -22) bitAnd: 16rFF);
- at: 2 put: ((rgb bitShift: -12) bitAnd: 16rFF);
- at: 1 put: ((rgb bitShift: -2) bitAnd: 16rFF);
- normalize. "normalize is not necessary as long as SmallInteger maxVal highBit < 32, but let's be future proof"
- ^val < 16rFF000001 ifTrue: [16rFF000001] ifFalse: [val]].
-
- d = 16 ifTrue: [
- "five bits per component; top bits ignored"
- val := (((rgb bitShift: -15) bitAnd: 16r7C00) bitOr:
((rgb bitShift: -10) bitAnd: 16r03E0)) bitOr:
((rgb bitShift: -5) bitAnd: 16r001F).
+ ^val = 0 ifTrue: [1] ifFalse: [val]].
- ^val < 1 ifTrue: [1] ifFalse: [val]].
+ d = 12 ifTrue: "for indexing a color map with 4 bits per color component"
+ [val := (((rgb bitShift: -18) bitAnd: 16r0F00) bitOr:
- d = 12 ifTrue: [ "for indexing a color map with 4 bits per color component"
- val := (((rgb bitShift: -18) bitAnd: 16r0F00) bitOr:
((rgb bitShift: -12) bitAnd: 16r00F0)) bitOr:
((rgb bitShift: -6) bitAnd: 16r000F).
+ ^val = 0 ifTrue: [1] ifFalse: [val]].
- ^val < 1 ifTrue: [1] ifFalse: [val]].
+ d = 9 ifTrue: "for indexing a color map with 3 bits per color component"
+ [val := (((rgb bitShift: -21) bitAnd: 16r01C0) bitOr:
+ ((rgb bitShift: -14) bitAnd: 16r0038)) bitOr:
+ ((rgb bitShift: -7) bitAnd: 16r0007).
+ ^val = 0 ifTrue: [1] ifFalse: [val]]].
- d = 9 ifTrue: [ "for indexing a color map with 3 bits per color component"
- val := (((rgb bitShift: -21) bitAnd: 16r01C0) bitOr:
- ((rgb bitShift: -14) bitAnd: 16r0038)) bitOr:
- ((rgb bitShift: -7) bitAnd: 16r0007).
- ^val < 1 ifTrue: [1] ifFalse: [val]]].
d = 8 ifTrue: [^ self closestPixelValue8].
d = 4 ifTrue: [^ self closestPixelValue4].
d = 2 ifTrue: [^ self closestPixelValue2]..
d = 1 ifTrue: [^ self closestPixelValue1].
self error: 'unknown pixel depth: ', d printString
!
tim Rowledge uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-tpr.979.mcz
==================== Summary ====================
Name: Kernel-tpr.979
Author: tpr
Time: 14 January 2016, 5:07:09.653455 pm
UUID: 066512f9-4f6d-4079-bfbf-92fe82801f6a
Ancestors: Kernel-tpr.978
{Authorisation error: let's try again. Sigh}
Add Time class>eventMillisecondClock (which gets its value from the same api as the vm event creation prim) and use it instead of the new 64bit based clock - this allows d-click code to work.
=============== Diff against Kernel-ul.977 ===============
Item was changed:
----- Method: EventSensor>>createMouseEvent (in category 'mouse') -----
createMouseEvent
"create and return a new mouse event from the current mouse
position; this is useful for restarting normal event queue
processing after manual polling"
| buttons modifiers pos mapped eventBuffer |
eventBuffer := Array new: 8.
buttons := self primMouseButtons.
pos := self primMousePt.
modifiers := buttons bitShift: -3.
buttons := buttons bitAnd: 7.
mapped := self mapButtons: buttons modifiers: modifiers.
eventBuffer
at: 1
put: EventTypeMouse;
+ at: 2 put: Time eventMillisecondClock;
- at: 2 put: Time millisecondClockValue;
at: 3 put: pos x;
at: 4 put: pos y;
at: 5 put: mapped;
at: 6 put: modifiers.
^ eventBuffer!
Item was changed:
----- Method: EventSensor>>nextEventSynthesized (in category 'private') -----
nextEventSynthesized
"Return a synthesized event. This method is called if an event driven client wants to receive events but the primary user interface is not event-driven (e.g., the receiver does not have an event queue but only updates its state). This can, for instance, happen if a Morphic World is run in an MVC window. To simplify the clients work this method will always return all available keyboard events first, and then (repeatedly) the mouse events. Since mouse events come last, the client can assume that after one mouse event has been received there are no more to come. Note that it is impossible for EventSensor to determine if a mouse event has been issued before so the client must be aware of the possible problem of getting repeatedly the same mouse events. See HandMorph>>processEvents for an example on how to deal with this."
| kbd array buttons pos modifiers mapped |
"First check for keyboard"
array := Array new: 8.
kbd := self primKbdNext.
kbd ifNotNil:
["simulate keyboard event"
array at: 1 put: EventTypeKeyboard. "evt type"
+ array at: 2 put: Time eventMillisecondClock. "time stamp"
- array at: 2 put: Time millisecondClockValue. "time stamp"
array at: 3 put: (kbd bitAnd: 255). "char code"
array at: 4 put: EventKeyChar. "key press/release"
array at: 5 put: (kbd bitShift: -8). "modifier keys"
^ array].
"Then check for mouse"
pos := self primMousePt.
buttons := mouseButtons.
modifiers := buttons bitShift: -3.
buttons := buttons bitAnd: 7.
mapped := self mapButtons: buttons modifiers: modifiers.
array
at: 1 put: EventTypeMouse;
+ at: 2 put: Time eventMillisecondClock;
- at: 2 put: Time millisecondClockValue;
at: 3 put: pos x;
at: 4 put: pos y;
at: 5 put: mapped;
at: 6 put: modifiers.
^ array
!
Item was changed:
----- Method: EventSensor>>primGetNextEvent: (in category 'private-I/O') -----
primGetNextEvent: array
"Store the next OS event available into the provided array.
Essential. If the VM is not event driven the ST code will fall
back to the old-style mechanism and use the state based
primitives instead."
| kbd buttons modifiers pos mapped |
<primitive: 94>
"Simulate the events"
array at: 1 put: EventTypeNone. "assume no more events"
"First check for keyboard"
kbd := super primKbdNext.
kbd = nil ifFalse:[
"simulate keyboard event"
array at: 1 put: EventTypeKeyboard. "evt type"
+ array at: 2 put: Time eventMillisecondClock. "time stamp"
- array at: 2 put: Time millisecondClockValue. "time stamp"
array at: 3 put: (kbd bitAnd: 255). "char code"
array at: 4 put: EventKeyChar. "key press/release"
array at: 5 put: (kbd bitShift: -8). "modifier keys"
^self].
"Then check for mouse"
buttons := super primMouseButtons.
pos := super primMousePt.
modifiers := buttons bitShift: -3.
buttons := buttons bitAnd: 7.
mapped := self mapButtons: buttons modifiers: modifiers.
(pos = mousePosition and:[(mapped bitOr: (modifiers bitShift: 3)) = mouseButtons])
ifTrue:[^self].
array
at: 1 put: EventTypeMouse;
+ at: 2 put: Time eventMillisecondClock;
- at: 2 put: Time millisecondClockValue;
at: 3 put: pos x;
at: 4 put: pos y;
at: 5 put: mapped;
at: 6 put: modifiers.
!
Item was added:
+ ----- Method: Time class>>eventMillisecondClock (in category 'clock') -----
+ eventMillisecondClock
+ "In order to make certain event handling code work (cf MouseEvent>asMouseMove) we need access
+ to the tick kept by ioMSecs() "
+ "Time eventMillisecondClock"
+ <primitive: 135>
+ ^0!
tim Rowledge uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-tpr.979.mcz
==================== Summary ====================
Name: Kernel-tpr.979
Author: tpr
Time: 14 January 2016, 5:07:09.653455 pm
UUID: 066512f9-4f6d-4079-bfbf-92fe82801f6a
Ancestors: Kernel-tpr.978
{Authorisation error: let's try again. Sigh}
Add Time class>eventMillisecondClock (which gets its value from the same api as the vm event creation prim) and use it instead of the new 64bit based clock - this allows d-click code to work.
=============== Diff against Kernel-ul.977 ===============
Item was changed:
----- Method: EventSensor>>createMouseEvent (in category 'mouse') -----
createMouseEvent
"create and return a new mouse event from the current mouse
position; this is useful for restarting normal event queue
processing after manual polling"
| buttons modifiers pos mapped eventBuffer |
eventBuffer := Array new: 8.
buttons := self primMouseButtons.
pos := self primMousePt.
modifiers := buttons bitShift: -3.
buttons := buttons bitAnd: 7.
mapped := self mapButtons: buttons modifiers: modifiers.
eventBuffer
at: 1
put: EventTypeMouse;
+ at: 2 put: Time eventMillisecondClock;
- at: 2 put: Time millisecondClockValue;
at: 3 put: pos x;
at: 4 put: pos y;
at: 5 put: mapped;
at: 6 put: modifiers.
^ eventBuffer!
Item was changed:
----- Method: EventSensor>>nextEventSynthesized (in category 'private') -----
nextEventSynthesized
"Return a synthesized event. This method is called if an event driven client wants to receive events but the primary user interface is not event-driven (e.g., the receiver does not have an event queue but only updates its state). This can, for instance, happen if a Morphic World is run in an MVC window. To simplify the clients work this method will always return all available keyboard events first, and then (repeatedly) the mouse events. Since mouse events come last, the client can assume that after one mouse event has been received there are no more to come. Note that it is impossible for EventSensor to determine if a mouse event has been issued before so the client must be aware of the possible problem of getting repeatedly the same mouse events. See HandMorph>>processEvents for an example on how to deal with this."
| kbd array buttons pos modifiers mapped |
"First check for keyboard"
array := Array new: 8.
kbd := self primKbdNext.
kbd ifNotNil:
["simulate keyboard event"
array at: 1 put: EventTypeKeyboard. "evt type"
+ array at: 2 put: Time eventMillisecondClock. "time stamp"
- array at: 2 put: Time millisecondClockValue. "time stamp"
array at: 3 put: (kbd bitAnd: 255). "char code"
array at: 4 put: EventKeyChar. "key press/release"
array at: 5 put: (kbd bitShift: -8). "modifier keys"
^ array].
"Then check for mouse"
pos := self primMousePt.
buttons := mouseButtons.
modifiers := buttons bitShift: -3.
buttons := buttons bitAnd: 7.
mapped := self mapButtons: buttons modifiers: modifiers.
array
at: 1 put: EventTypeMouse;
+ at: 2 put: Time eventMillisecondClock;
- at: 2 put: Time millisecondClockValue;
at: 3 put: pos x;
at: 4 put: pos y;
at: 5 put: mapped;
at: 6 put: modifiers.
^ array
!
Item was changed:
----- Method: EventSensor>>primGetNextEvent: (in category 'private-I/O') -----
primGetNextEvent: array
"Store the next OS event available into the provided array.
Essential. If the VM is not event driven the ST code will fall
back to the old-style mechanism and use the state based
primitives instead."
| kbd buttons modifiers pos mapped |
<primitive: 94>
"Simulate the events"
array at: 1 put: EventTypeNone. "assume no more events"
"First check for keyboard"
kbd := super primKbdNext.
kbd = nil ifFalse:[
"simulate keyboard event"
array at: 1 put: EventTypeKeyboard. "evt type"
+ array at: 2 put: Time eventMillisecondClock. "time stamp"
- array at: 2 put: Time millisecondClockValue. "time stamp"
array at: 3 put: (kbd bitAnd: 255). "char code"
array at: 4 put: EventKeyChar. "key press/release"
array at: 5 put: (kbd bitShift: -8). "modifier keys"
^self].
"Then check for mouse"
buttons := super primMouseButtons.
pos := super primMousePt.
modifiers := buttons bitShift: -3.
buttons := buttons bitAnd: 7.
mapped := self mapButtons: buttons modifiers: modifiers.
(pos = mousePosition and:[(mapped bitOr: (modifiers bitShift: 3)) = mouseButtons])
ifTrue:[^self].
array
at: 1 put: EventTypeMouse;
+ at: 2 put: Time eventMillisecondClock;
- at: 2 put: Time millisecondClockValue;
at: 3 put: pos x;
at: 4 put: pos y;
at: 5 put: mapped;
at: 6 put: modifiers.
!
Item was added:
+ ----- Method: Time class>>eventMillisecondClock (in category 'clock') -----
+ eventMillisecondClock
+ "In order to make certain event handling code work (cf MouseEvent>asMouseMove) we need access
+ to the tick kept by ioMSecs() "
+ "Time eventMillisecondClock"
+ <primitive: 135>
+ ^0!