[Cuis-dev] Updates to VectorGraphics and precompiled MacVM
David T. Lewis
lewis at mail.msen.com
Mon May 24 12:19:00 PDT 2021
On Thu, May 20, 2021 at 10:56:13AM -0300, Juan Vuletich via Cuis-dev wrote:
> Hi Folks,
>
> Recently, I've been working on improving the VectorGraphics plugin. I
> added a new primitive that will help quick display of SVG icons. Please
> pull all repos.
>
> An updated Mac VM is available at
> https://www.dropbox.com/sh/6xzdebt158ha1cc/AAAW2LxSYHOSZ8PTfhC9XIs0a?dl=0 .
>
> If you are able to build VMs, please try generating VectorEnginePlugin
> from the updated VMMaker and Cuis-Smalltalk-Dev repos, build for your
> platform, test, and share the precompiled VMs with us.
>
> To see a possible use of the new primitive, play with M3Exp01Morph.
>
Attached is a patch to make M3Exp01Morph in VectorGraphics work on a V3
Cuis image with interpreter VM.
The problem:
(Float64Array new: 1) at: 1 put: Float pi; yourself. ==> #[8.619199512815383e97]
With patch applied, it now works:
(Float64Array new: 1) at: 1 put: Float pi; yourself. ==> #[3.141592653589793]
I also needed to recompile M3Exp01Morph>>drawOn: to fix the compiled path
sequences in that method (no change to the method, just a recompile).
Explanation: On images before Cog/Spur, Float objects are stored internally
in big-endian format. For Cog/Spur, they are stored in the native word
ordering of the platfrom. Float64Array>>floatAt:put: needs to check image
format in addition to platform endianness in order to determine if word
swapping is needed.
Dave
-------------- next part --------------
'From Cuis 5.0 [latest update: #4607] on 24 May 2021 at 2:20:35 pm'!
!Float class methodsFor: 'testing' stamp: 'dtl 5/24/2021 14:17:21'!
nativeWordOrdering
"True if this image stores float objects internally in native word order.
If false, double word floats are stored in big-endian order regardless
of the machine native word order."
^ Smalltalk imageFormatVersion anyMask: 1
! !
!Float64Array methodsFor: 'accessing' stamp: 'dtl 5/24/2021 14:17:31'!
floatAt: index put: aNumber
"Store the argument (e.g., 64 bit Float) at the given index
Use the same internal representation as BoxedFloat64. I.e. a BoxedFloat64 and a Float64Array of size 1 hold the same bits.
Allow subclasses to redefine #at:put:"
"This breaks with SmallFloat64"
"self replaceWordsFrom: index * 2 - 1 to: index * 2 with: aFloat asFloat startingAt: 1."
"Float >>basicAt: acts as if Floats were stored in big endian format. Our instances are in platform endianess."
| aFloat |
aFloat _ aNumber asFloat.
(Smalltalk isLittleEndian and: [Float nativeWordOrdering])
ifTrue: [
self basicAt: index * 2 - 1 put: (aFloat basicAt: 2).
self basicAt: index * 2 put: (aFloat basicAt: 1) ]
ifFalse: [
self basicAt: index * 2 - 1 put: (aFloat basicAt: 1).
self basicAt: index * 2 put: (aFloat basicAt: 2) ].
^aFloat! !
!Float class reorganize!
('instance creation' basicNew basicNew: fromIEEE32Bit: new new: readFrom: signBit:mantissaBits:exponentBits: signPart:mantissaPart:exponentPart:)
('constants' denormalized e emax emin epsilon fmax fmin fminDenormalized fminNormalized halfPi infinity ln10 ln2 maxExactInteger nan negativeInfinity negativeZero one pi precision radix twoPi zero)
('class initialization' initClassCachedState initialize releaseClassCachedState)
('testing' nativeWordOrdering)
!
-------------- next part --------------
'From Cuis 5.0 [latest update: #4607] on 24 May 2021 at 2:21:31 pm'!
!M3Exp01Morph methodsFor: 'drawing' stamp: 'jmv 5/13/2021 18:46:28'!
drawOn: aCanvas
"A canvas is already set with a proper transformation from our coordinates to those of the Canvas target."
aCanvas strokeWidth: 3 color: `Color gray alpha: 0.5` fillColor: `Color lightGreen alpha: 0.3` do: [
aCanvas
pathSequence: `#[
0.0 15.0 15.0
3.0 30.0 30.0 15.0 24.0 21.0 30.0
3.0 45.0 15.0 40.0 29.0 45.0 24.0
3.0 30.0 0.0 45.0 6.0 39.0 0.0
3.0 15.0 15.0 21.0 0.0 15.0 6.0
] asFloat32Array`
].
aCanvas strokeWidth: 3 color: Color black do: [
aCanvas
pathSequence: `#[
0.0 21.0 19.0
2.0 30.0 24.0 23.0 23.0
2.0 39.0 19.0 37.0 23.0
0.0 25.0 11.0
1.0 25.0 13.0
0.0 35.0 11.0
1.0 35.0 13.0
] asFloat32Array`
].! !
More information about the Cuis-dev
mailing list