Commit Graph

3241 Commits

Author SHA1 Message Date
David Wendt e18caa2fbf core: Silence error relating to `Bitmap` symbol class associations 2021-09-11 12:11:35 -07:00
David Wendt dca473fc2a avm2: Impl `BitmapData.width` and `BitmapData.height` 2021-09-11 12:11:35 -07:00
David Wendt 335aec5be0 avm2: Implement `BitmapData`'s constructor.
This includes support for both embedded bitmap data (resolved via the SymbolClass mechanism) as well as empty bitmaps configured via arguments.
2021-09-11 12:11:35 -07:00
David Wendt e5151d147d core: When constructing a `Bitmap`, do not attempt to cache it's associated `BitmapData`'s handle.
Attempting to do so results in borrow-mut panics. Furthermore, it's unnecessary; the handle provided to this function is already derived from the bitmap data in this way.
2021-09-11 12:11:35 -07:00
David Wendt 54740d6093 core: Allow `BitmapData` to hold an AVM2 side. 2021-09-11 12:11:35 -07:00
David Wendt 10b98f72f5 core: Allow `Bitmap` to be reassociated with new `BitmapData` 2021-09-11 12:11:35 -07:00
David Wendt a807cf7623 avm2: Stub `flash.display.BitmapData` & storage object 2021-09-11 12:11:35 -07:00
David Wendt 609b97cfb9 core: Allow `Bitmap`s to hold an AVM2 representation 2021-09-11 12:11:35 -07:00
Chris Midgley bd26790f5b
avm1: Fix `this` inside watchers (#5276)
* fix: fix 'this' inside watchers

* tests: test value of 'this' in watcher

* lint: cargo fmt
2021-09-11 15:15:16 +03:00
relrelb 923201d2e4 chore: Appease clippy 2021-09-10 15:42:37 +02:00
Chris Midgley 3e04c2b0d2 dev: remove allow unused mut and corresponding mut 2021-09-09 19:06:49 -06:00
Daniel Jacobs 5ac9796ffd web: Support salign, quality, & scale embed/object attributes (part of #4258) 2021-09-08 16:25:47 -07:00
Tal Hayon 7d6eaf127d core: Fix EditText width and height scaling (close #3001) 2021-09-08 02:39:01 -07:00
relrelb c2fcc03c35 avm1: Remove `TObject::get_local` in favor of `TObject::get_local_stored`
`get_local` is basically equivalent to `get_local_stored` that also
handles virtual getters. So instead handle virtual getters in
`search_prototype`. This allows to inline the `get_local_sub` helper
methods into the implementations of `get_local_stored`.
The remaining usages of `get_local` were not exactly correct as they
all should ignore virtual getters. This change solves this as well
by using `get_local_stored` that ignores virtual getters.
2021-09-08 12:21:17 +03:00
relrelb 1f96c2fcb8 audio: Small cleanup 2021-09-07 18:28:17 -07:00
relrelb 65205ac6d7 audio: Store sound transform values in 30-bit integers
It seems like Flash stores sound transform values in 30-bit unsigned integers:
* Negative values are equivalent to their absolute value.
* Specifically, 0x40000000, -0x40000000 and -0x80000000 are equivalent to zero.
2021-09-07 18:28:17 -07:00
Chris Midgley 868706d775
avm1: call watcher, if defined, from virtual properties on prototype (#4827)
* avm1: extract get_watcher

* tests: add tests for TextField text watch

* avm1: call the watcher, if defined, from call_setter

* dev: shadow variable to avoid unused mut warning

* dev: remove value mutability

* chore: cargo fmt

* dev: unify virtual and stored property watcher cases

* tests: add test for watching prototyped property

* feat: when getting old values, ascend the proto chain ignoring virtual properties

* chore: lint

* dev: share complicated code

* chore: Small cleanups

Co-authored-by: relrelb <relrelbachar@gmail.com>
2021-09-08 03:41:18 +03:00
Mike Welsh 483995823f core: Add symphonia as optional MP3 decoder
Add symphonia_mp3 feature to enable symphonia as an MP3 decoder.
This is a pure Rust MP3 decoder that could be used on web.
2021-09-07 16:48:34 -07:00
Mike Welsh 94d02fa653 core: Add AudioMixer to core
Pull out the audio mixing code from desktop and add it to core.
This will allow other backends to use it (such as the web audio
backend) to get consistent audio across all platforms.
2021-09-07 16:48:34 -07:00
Tal Hayon 4625ca0e0b web: fix base param 2021-09-07 16:45:35 -07:00
dependabot[bot] 5e07d4e464 build(deps): bump syn from 1.0.75 to 1.0.76
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.75 to 1.0.76.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.75...1.0.76)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-06 14:33:56 -07:00
Adrian Wielgosik 9bd0b624fd avm2: Add more Event class stubs and constants 2021-09-05 11:56:21 +02:00
David Wendt bc4f790031 avm2: Stub `SoundMixer.areSoundsInaccessible` and `SoundMixer.computeSpectrum` 2021-09-03 16:47:02 -06:00
David Wendt 34fe35a998 avm2: Impl `SoundMixer.bufferTime` 2021-09-03 16:47:02 -06:00
David Wendt 364ee62c92 avm2: Impl `SoundChannel`'s `soundComplete` event.
This includes a test that is currently ignored because `NullAudioBackend` can't fire complete events.
2021-09-03 16:47:02 -06:00
David Wendt d5718fe408 avm2: Initialize all sounds and channels at time of allocation 2021-09-03 16:47:02 -06:00
David Wendt efcab92d97 avm2: Impl `SoundMixer.stopAll` 2021-09-03 16:47:02 -06:00
David Wendt d73ba586d0 avm2: Impl `SoundChannel.stop()` 2021-09-03 16:47:02 -06:00
David Wendt 39305f6a38 avm2: Implement `SoundChannel.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 9c6c64e4e3 core: `NullAudioBackend` should falsely report all sounds as not playing, like the real backends
This prevents sounds from being removed from the `AudioManager`, which allows sound transforms to be placed on them in tests.
2021-09-03 16:47:02 -06:00
David Wendt 6b7609ff4e avm2: Stub `SoundChannel.position`.
This also comes with an ignored test for `position`, because I originally believed this to be implementable.
2021-09-03 16:47:02 -06:00
David Wendt 4e77f89e0f avm2: Stub `SoundChannel.leftPeak` and `SoundChannel.rightPeak` 2021-09-03 16:47:02 -06:00
David Wendt 50092e6c04 avm2: Stub all remaining `Sound` methods. 2021-09-03 16:47:02 -06:00
David Wendt b6167c2f86 avm2: Allow playing sounds with a given `SoundTransform`. 2021-09-03 16:47:02 -06:00
David Wendt 5771d4c826 avm2: Deduplicate the sound transform conversion code 2021-09-03 16:47:02 -06:00
David Wendt 116fb1f323 avm2: Impl `Sound.play`
This does not (yet) implement the third `SoundTransform` parameter on `play`.
2021-09-03 16:47:02 -06:00
David Wendt 8a58956f1f avm2: Add `flash.media.SoundChannel` class & associated object storage 2021-09-03 16:47:02 -06:00
David Wendt 46de9ee46e avm2: `soundTransform` isn't a movieclip property, so don't ask for one. 2021-09-03 16:47:02 -06:00
David Wendt 1bde07089d avm2: Alias `SimpleButton.soundTransform` to the class property of `SoundMixer.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 0f625e7864 avm2: Impl `SoundMixer.soundTransform` class property 2021-09-03 16:47:02 -06:00
David Wendt 8e1122104d avm2: Correct `SoundTransform` class definition to match docs 2021-09-03 16:47:02 -06:00
David Wendt 2f6e695483 avm2: Impl `Sprite.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 3b9f0f271d avm2: `SoundTransform.pan` returns 0 if the transform sends sound to different channels 2021-09-03 16:47:02 -06:00
David Wendt 2b7a0bf898 avm2: `SoundTransform` stores it's values as square roots 2021-09-03 16:47:02 -06:00
David Wendt bd3cec0d20 avm2: Impl `flash.media.SoundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 3b6eea2a1d core: Report sound duration as `f64` and round down in AS1 2021-09-03 16:47:02 -06:00
David Wendt e4c6e29b8a core: `NullAudioBackend` should not report latency seek data as part of the size of a sound. 2021-09-03 16:47:02 -06:00
David Wendt d7f2f782c4 avm2: Impl `Sound.length`
This also adds duration tracking for `NullAudioBackend`.
2021-09-03 16:47:02 -06:00
David Wendt e25fb732ea avm2: Stub `Sound.isBuffering`, `Sound.isURLInaccessible`, and `Sound.url` 2021-09-03 16:47:02 -06:00
David Wendt 89b411593f avm2: Impl `Sound.bytesTotal` 2021-09-03 16:47:02 -06:00
David Wendt d5fb807387 avm2: Allow calling `Function.apply` without a second argument 2021-09-03 16:47:02 -06:00
David Wendt 7b31cd9a4d avm2: Allow instantiating a SWF sound by constructing it's symbol class 2021-09-03 16:47:02 -06:00
David Wendt 37eb746989 core: Don't warn when associating sounds to AS3 classes 2021-09-03 16:47:02 -06:00
David Wendt 0c591f3370 avm2: Stub implementation of `Sound` and accompanying object type 2021-09-03 16:47:02 -06:00
David Wendt 70556e5830 avm2: Forbid `applytype` opcodes with more than one argument type. 2021-09-02 17:57:58 -06:00
David Wendt e2bf0a9857 avm2: Prohibit naming types with more than one parameter, as they don't exist. 2021-09-02 17:57:58 -06:00
David Wendt 141b992a73 avm2: Storing past the end of a vector only works for the immediate one-off-the-end index 2021-09-02 17:57:58 -06:00
David Wendt 8cd2b4fd5e avm2: Fill vector holes with the default value at creation time instead of storing them. 2021-09-02 17:57:58 -06:00
David Wendt 3b48216762 avm2: Don't store more than one object parameter, because there are no classes with multiple paramters. 2021-09-02 17:57:58 -06:00
David Wendt 5c740ef1e1 chore: Grammar 2021-09-02 17:57:58 -06:00
David Wendt d1b9df61f3 avm2: Move `Vector`'s properties to the AS3 namespace and add prototype properties in the public one 2021-09-02 17:57:58 -06:00
David Wendt cc15809f49 avm2: Add the ability to have a separate class initializer for each specialization of `Vector` 2021-09-02 17:57:58 -06:00
David Wendt e087a27e56 avm2: `Vector.sort` actually *does* calculate an indexed sort array, but then discards it.
Normally we could skip sorting, but values in the vector may have side effects when coerced. So we need to make sure coercions run, at least.
2021-09-02 17:57:58 -06:00
David Wendt 280fbbde45 avm2: Pick nits in `Vector`'s `instance_init` 2021-09-02 17:57:58 -06:00
David Wendt 2095c1831a avm2: Replace some if expressions with easier-to-read equivalents 2021-09-02 17:57:58 -06:00
David Wendt 464605d015 avm2: Pre-allocate all the things 2021-09-02 17:57:58 -06:00
David Wendt bf4492c454 avm2: Add the legacy Vector types that old movies can use.
This one was rather tough to test, as I actually can't generate ABCs in Animate CC that reference these classes. I instead had to modify a compiled SWF to open the package-internal namespace that these pre-specialized classes exist in.
2021-09-02 17:57:58 -06:00
David Wendt dcf6d87363 avm2: Accept `null` as a valid type in `applytype`.
In AVM2, the `*` (any) type is represented as `null`.

This requires also changing the parameters on classes and objects to be nullable, too.

We do *not* represent `null` as a particular value on the underyling vector storage object, however. We instead change it to `Object`, as that's the root of all other types.

This may require revision if non-`Object`-extending types appear in the future.
2021-09-02 17:57:58 -06:00
David Wendt ee30f21e8e avm2: Remove unnecessary `mut` 2021-09-02 17:57:58 -06:00
David Wendt aaddcc598f avm2: Impl `Vector.toLocaleString` and test `toString` 2021-09-02 17:57:58 -06:00
David Wendt d1e49db3cc avm2: Stub `Number.toLocaleString`
This exists but is undocumented, and I accidentally wrote a Vector test that needs it.
2021-09-02 17:57:58 -06:00
David Wendt dbc6f38c34 avm2: Impl `Vector.splice` 2021-09-02 17:57:58 -06:00
David Wendt 81d0775776 avm2: Impl `Vector.sort` 2021-09-02 17:57:58 -06:00
David Wendt 9fcd846a4d avm2: Fix ineffective Vector typechecks 2021-09-02 17:57:58 -06:00
David Wendt 44a9f13047 avm2: Impl `Vector.slice` 2021-09-02 17:57:58 -06:00
David Wendt 077fd87842 avm2: Impl `Vector.reverse` 2021-09-02 17:57:58 -06:00
David Wendt aa2d729a44 avm2: Impl `Vector.removeAt` 2021-09-02 17:57:58 -06:00
David Wendt a053015558 avm2: Impl `Vector.insertAt` 2021-09-02 17:57:58 -06:00
David Wendt 6b78e86ddc avm2: Impl `Vector.shift` and `Vector.unshift` 2021-09-02 17:57:58 -06:00
David Wendt 1cfa9e0b28 avm2: Impl `Vector.push` and `.pop` 2021-09-02 17:57:58 -06:00
David Wendt 6350ce2dde avm2: Impl `Vector.map` 2021-09-02 17:57:58 -06:00
David Wendt 7628b2b49a avm2: Impl `Vector.lastIndexOf` (and the weird backward-index behavior of `indexOf`) 2021-09-02 17:57:58 -06:00
David Wendt 4624157ae0 avm2: Impl `Vector.indexOf` 2021-09-02 17:57:58 -06:00
David Wendt 622be142c3 avm2: Specialize generic classes when resolving types whose names have parameter names also in them.
Any is, as usual, special-cased. In this case, we treat it as specializing to `Object`, since all vectors should be coercible to `Object`.
2021-09-02 17:57:58 -06:00
David Wendt c06a3c10d8 avm2: Impl `Vector.filter` 2021-09-02 17:57:58 -06:00
David Wendt d079c647fa avm2: Parameter types can be `*`. 2021-09-02 17:57:58 -06:00
David Wendt f00234ce26 avm2: Consider specializations of generic classes to be of the same type as other specializations of the same class when their parameters are also of the same type.
For example, instances of `Vector.<Class>` are considered to be of type `Vector.<Interface>` in the same way that instances of `Class` are considered to be of type `Interface`. This assumes `Class` implements `Interface`.

This does *not* apply to the builtin coercions for numeric and string types, which do not extend to generic parameters. For example, `Vector.<uint>` is *not* coercible to `Vector.<int>`, even though it's contents *are*.
2021-09-02 17:57:58 -06:00
David Wendt 4d962f154e avm2: Don't run initializers on vectors as they overwrite the existing vector storage. 2021-09-02 17:57:58 -06:00
David Wendt fcc7c9e7ee avm2: Propagate the specialized class parameter into the vector storage so that coercions happen correctly. 2021-09-02 17:57:58 -06:00
Adrian Wielgosik 2560bdc804 chore: Drop unnecessary mut 2021-09-02 17:57:58 -06:00
Adrian Wielgosik 846b53dc1b avm2: Impl `Vector.forEach` 2021-09-02 17:57:58 -06:00
Adrian Wielgosik 8a77494b2f avm2: Impl `Vector.some` 2021-09-02 17:57:58 -06:00
Adrian Wielgosik 519feb9af7 avm2: `Array.every/some` should early return 2021-09-02 17:57:58 -06:00
Adrian Wielgosik 07f979b582 avm2: `Vector.every` should early return 2021-09-02 17:57:58 -06:00
David Wendt 97e6f55110 avm2: Impl `Vector.every` 2021-09-02 17:57:58 -06:00
David Wendt aa0946c64c avm2: Impl `Vector.fixed` 2021-09-02 17:57:58 -06:00
David Wendt 841ed4b5e4 avm2: Setting to an out-of-bounds index on a growable `Vector` should grow it 2021-09-02 17:57:58 -06:00
David Wendt 238959d7f8 avm2: Impl `Vector.join` and `toString` 2021-09-02 17:57:58 -06:00
David Wendt 1ce7e4e642 avm2: `Vector` is a final class (no matter what the docs say) 2021-09-02 17:57:58 -06:00
David Wendt dba9b18540 avm2: Impl `Vector.concat` 2021-09-02 17:57:58 -06:00