Commit Graph

4573 Commits

Author SHA1 Message Date
EmperorBale 7aa821da4f core: Use class index for `class_id`, instead of slot_id 2022-09-17 12:31:43 -07:00
EmperorBale e1eaa9770a avm2: Switch ByteArray to AS
avm2: Fix ByteArray

avm2: Implement ByteArray.defaultObjectEncoding

avm2: Rename ByteArray allocator
2022-09-17 12:31:43 -07:00
David Wendt 173b04cc5c avm2: Allow access to `Stage.loaderInfo.url` 2022-09-17 12:32:15 -06:00
David Wendt 0925412110 avm2: `LoaderInfo` needs to specifically know if it's the stage's loader or not. 2022-09-17 12:32:15 -06:00
David Wendt dbe6eb324c avm2: Explicitly delay all frame construction until the first frame is loaded.
This prevents the root from being constructed until we know its `SymbolClass`, and is roughly equivalent to delaying the work until `ShowFrame`. (We don't actually run any work on `ShowFrame` in our current movieclip impl.)
2022-09-16 21:44:11 -06:00
David Wendt 247a28d7e9 avm2: Impl `Sprite.useHandCursor` 2022-09-16 19:25:46 -06:00
David Wendt 6f1509d4cd avm2: Don't attempt to print registers that are out-of-bounds. 2022-09-16 15:46:36 -06:00
David Wendt 38c6369f6e avm2: Fix `avm_debug` not printing debugging information 2022-09-16 15:46:36 -06:00
David Wendt 187352b1db chore: Fix stubs to use the new `Error<'gc>` property 2022-09-15 20:25:21 -06:00
David Wendt e7379a26e9 docs: Mark `z` as needing a version-gate once we have that set up 2022-09-15 20:25:21 -06:00
David Wendt 2b2089e9cb docs: Bitmap subclasses tickle the "initialized by movie" code path because the DisplayObject code actually does its job here 2022-09-15 20:25:21 -06:00
David Wendt bd8ff4f024 avm2: Add support for Bitmaps being associated to subclasses of `flash.display.Bitmap` 2022-09-15 20:25:21 -06:00
David Wendt fc02715faa avm2: Stub `z`, `scaleZ`, and all 3D rotation properties 2022-09-15 20:25:21 -06:00
David Wendt 3c0b9b9f62 avm1: Implement `ActionWaitForFrame` and `ActionWaitForFrame2`. 2022-09-15 19:14:41 -06:00
David Wendt aa9e24fb9d core: Limit gotos to the currently loaded frame count 2022-09-15 19:14:41 -06:00
David Wendt c7e29e4173 chore: Various nitpicks and compilation fixes 2022-09-15 19:14:41 -06:00
David Wendt af9db3e9c7 docs: Drop "action" language for `ExecutionLimit` as that is confusable for AVM actions.
We now call them "operations" and clarify that they could be either AVM actions or SWF bytes.
2022-09-15 19:14:41 -06:00
David Wendt 44f1cdfdec avm2: `LoaderInfo` reports correct total size for SWFs loaded in-memory 2022-09-15 19:14:41 -06:00
David Wendt f3ca7f7673 avm2: Still-loading SWFs do not report a `url` 2022-09-15 19:14:41 -06:00
David Wendt 8f5afe09a1 core: Refactor `movie_loader` and its `loadBytes` variant to call into the same code. 2022-09-15 19:14:41 -06:00
David Wendt 86ecf6076e core: `loadBytes` does not emit `open` 2022-09-15 19:14:41 -06:00
TÖRÖK Attila d0277f7fe8 avm2: Add `Loader.loadBytes` 2022-09-15 19:14:41 -06:00
David Wendt 006269e1f8 core: Delay completion events until after the SWF is reported as fully loaded. 2022-09-15 19:14:41 -06:00
David Wendt 0a25f265d6 core: `LoaderInfo` now optionally contains a reference to the root clip in the not-loaded state so that things like `bytesLoaded` work 2022-09-15 19:14:41 -06:00
David Wendt 4976dc973d core: Emit a progress event after every preload tick.
This does not cover root movies, which already get progress events as part of a prior commit.
2022-09-15 19:14:41 -06:00
David Wendt e589df650f core: Centralize compressed length calculations into `movieclip.rs` 2022-09-15 19:14:41 -06:00
David Wendt 1323355a69 avm2: Fire progress events when the root movie is preloaded.
This is currently somewhat buggy, `homestuck_02791.swf` stops at 12% for some reason. I tried handing it both compressed and uncompressed lengths with no luck.
2022-09-15 19:14:41 -06:00
David Wendt 07bd7dda2e core: Do not overflow when querying loaded bytes on a fully-loaded movie. 2022-09-15 19:14:41 -06:00
David Wendt 029fecaa94 avm2: Implement `LoaderInfo.bytesLoaded`.
This requires estimating a count of bytes loaded of the original compressed stream, even though we only have uncompressed byte totals at this point. I instead rescale the uncompressed bytes by the compressed count to roughly estimate what would be the `bytesLoaded` had we been actually streaming bytes in and preloading them synchronously.
2022-09-15 19:14:41 -06:00
David Wendt bd08a6ebfe avm1: Expose preload progress to AVM1 via `getBytesLoaded` 2022-09-15 19:14:41 -06:00
David Wendt 0eff0bf91a core: Remove all synchronous preloading from core.
Backends that need synchronous preload behavior now explicitly ask for it as follows:

 * `tests` - repeatedly call `preload` in a loop with an exhausted execution limit to stress-test the chunked preload
 * `exporter`, `scanner` - synchronous/unlimited preload to match prior behavior

These may change in the future.
2022-09-15 19:14:41 -06:00
David Wendt 3d799acd96 core: Report to callers of preload if all preloading work was done or not. 2022-09-15 19:14:41 -06:00
David Wendt 10e944a911 core: Turns out this is NOT redundant, I just misread the loop points 2022-09-15 19:14:41 -06:00
David Wendt 15b781ff04 chore: Remove old version of code left behind during rebasing 2022-09-15 19:14:41 -06:00
David Wendt 89fcca4f0b core: Only mark the end of the frame if we hit the end of the tag stream. 2022-09-15 19:14:41 -06:00
David Wendt f272cba7e6 core: If we're marked as finished, set the preload position to `u64::MAX` so that the repeated call protection trips 2022-09-15 19:14:41 -06:00
David Wendt 31802ea96f chore: Reduce the number of necessary reads of the preload progress 2022-09-15 19:14:41 -06:00
David Wendt ea284ed6bf core: Preload should always start from the place we left off from. 2022-09-15 19:14:41 -06:00
David Wendt afd29d19a4 core: Don't do any work if a clip is preloaded after finishing preload. 2022-09-15 19:14:41 -06:00
David Wendt 86f9ee4821 core: Add a "preload everything we know about" method 2022-09-15 19:14:41 -06:00
David Wendt 940de4bb7e core: Add a special loader state for "downloaded but still parsing", and a function that ticks the preload.
Currently we do this automatically with no execution limit.
2022-09-15 19:14:41 -06:00
David Wendt 70e638b21f core: Actually decrease the current action limit correctly 2022-09-15 19:14:41 -06:00
David Wendt a05827eb90 core: Add a concept of an `ExecutionLimit` that checks both actions and runtime.
Actions are abstract; here we're using it to count bytes loaded (as a proxy for execution time). AVM code could potentially be adapted to count operations run instead.
2022-09-15 19:14:41 -06:00
David Wendt c80abff3a9 core: Allow chunked preloading within a `DefineSprite` tag 2022-09-15 19:14:41 -06:00
David Wendt 3a265adcc4 core: Ensure empty movie clips are born preloaded.
An "empty clip" is any clip created by the `new` or `new_with_avm2` function, intended for dynamically-created movie clips with no association to a movie symbol.
2022-09-15 19:14:41 -06:00
David Wendt f96017e6f3 avm2: Preload dynamically created movie clips
If we don't preload every movie clip we make, then they'll indicate themselves as not having been fully loaded yet, even though they are.
2022-09-15 19:14:41 -06:00
David Wendt 0f2237e171 core: Make frame loaded count no longer be off by one
The preload frame counting logic starts from one and continues to the end of the file, which results in a completely preloaded movie having one more frame "loaded" than there is in the file. This fixes that.
2022-09-15 19:14:41 -06:00
David Wendt 079b20a4f2 core: On unexpected EOF, mark the clip preload as completed 2022-09-15 19:14:41 -06:00
David Wendt 85cf383c84 core: Allow callers of `decode_tags` to flag when they would like decoding to stop 2022-09-15 19:14:41 -06:00
David Wendt f7f5316b71 core: Prohibit playing movie clip frames that haven't been preloaded yet. 2022-09-15 19:14:41 -06:00
David Wendt 0ab10d9ab0 core: Make the preload chunk size configurable per caller.
Right now, we do not actually set a chunk limit, as we still need infrastructure for backgrounding the preload calls.
2022-09-15 19:14:41 -06:00
David Wendt b5cbfaf093 core: When preloading other movie clips, forcibly preload them synchronously. 2022-09-15 19:14:41 -06:00
David Wendt 4e9bb3a173 core: Implement chunked decoding infrastructure.
We currently do not actually enforce a decoding limit; just add the functionality necessary to do so.
2022-09-15 19:14:41 -06:00
golfinq c63f915ae2 avm2: Implement missing enums 2022-09-15 15:42:29 -07:00
Daniel Jacobs cf721d45f9 Revert "web: Bump `wasm-bindgen` to 0.2.83"
This reverts commit 084b252030.
2022-09-15 22:33:07 +02:00
relrelb 084b252030 web: Bump `wasm-bindgen` to 0.2.83
As usual, also bump its helper crates (`js-sys`, `web-sys` and
`wasm-bindgen-futures`) to the latest versions.

Due to https://github.com/rustwasm/wasm-bindgen/pull/3031, use the
`serde-wasm-bindgen` crate as a replacement to the deprecated
`JsValue::from_serde` function.
2022-09-14 09:03:31 +03:00
Aaron Hill e08f8d47ab Allow clippy::needless_lifetimes to keep explicit 'gc parameter
This makes it clear what the lifetime is used for.
2022-09-13 18:55:08 -05:00
Aaron Hill c4ce06a500 avm2: Use Box<dyn std::error::Error> for FromWStr impl
We don't currently have an `Activation` available in this
method, and we can't specify a 'gc lifetime without modifying
the trait itself.
2022-09-13 18:55:08 -05:00
Aaron Hill 3e65a554fa avm2: Add 'gc lifetime parameter to avm2::Error 2022-09-13 18:55:08 -05:00
relrelb b1760063ec avm2: Implement `flash.filters.DisplacementMapFilterMode` 2022-09-13 21:20:55 +03:00
relrelb 5d5093f0fd avm2: Implement `flash.filters.BitmapFilterType` 2022-09-13 21:20:55 +03:00
dependabot[bot] cf26158030 build(deps): bump url from 2.2.2 to 2.3.1
Bumps [url](https://github.com/servo/rust-url) from 2.2.2 to 2.3.1.
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v2.2.2...v2.3.1)

---
updated-dependencies:
- dependency-name: url
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-13 09:42:27 +03:00
dependabot[bot] 69a43297df build(deps): bump convert_case from 0.5.0 to 0.6.0
Bumps [convert_case](https://github.com/rutrum/convert-case) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/rutrum/convert-case/releases)
- [Commits](https://github.com/rutrum/convert-case/commits)

---
updated-dependencies:
- dependency-name: convert_case
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-13 09:20:12 +03:00
dependabot[bot] e86b3f0efb build(deps): bump percent-encoding from 2.1.0 to 2.2.0
Bumps [percent-encoding](https://github.com/servo/rust-url) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/percent-encoding-v2.1.0...v2.2.0)

---
updated-dependencies:
- dependency-name: percent-encoding
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-13 08:45:46 +03:00
Adrian Wielgosik 1c940009a1 avm2: Convert Capabilities, System to AS 2022-09-12 02:03:34 +02:00
TÖRÖK Attila 866f5c83c5 avm2: Add `flash.filters.BitmapFilterQuality` 2022-09-11 22:05:15 +02:00
Aaron Hill fbcefc49dc avm2: Fix "Property does not exist" error message
The `multiname` is now a `Gc`, so we need to dereference it
to get a useful Debug impl.
2022-09-11 11:34:52 -05:00
Aaron Hill 81a5f3f10a core: Always check mergeAlpha in BitmapData.copyPixels
Previously, we would only use mergeAlpha if alphaBitmapData
and alphaPoint. However, mergeAlpha can be used even when
those parameters are null.

Some of the AVM1 argument handling was also incorrect - I've fixed
it, and extended the existing test with the output-based test
added for AVM2.
2022-09-11 11:12:09 -05:00
Aaron Hill 1d6b3b6f57 chore: Fix Clippy lints and allow `clippy::bool_to_int_with_if`
In several cases, the current code seems preferable to the
code required by `clippy::bool_to_int_with_if`. Let's suppress
this for now to get the build passing, and decide later if this
is something that we want to enable.
2022-09-11 13:31:46 +02:00
Nathan Adams 267ea0fd13 render: Introduced render commands, moved to a command list model instead of direct rendering 2022-09-11 09:07:53 +02:00
Aaron Hill a638b0498e core: Render Bitmap even if bitmap_data is None
We only need to access bitmap_data to check if we need to
update a dirty texture.
2022-09-11 07:06:11 +03:00
Aaron Hill 8370bc792d core: Use correct background alpha in BitmapData.draw
Previously, we would always use a transparent background,
even if the BitmapData is not transparent. This would normally
be corrected on the next frame when we copied the pixels to the
CPU. However, if an SWF ran `BitmapData.draw` on every frame,
this would never be corrected.
2022-09-09 19:24:21 -05:00
Aaron Hill 5de21428f5 core: Update dirty BitmapData before rendering
We now have a `MutationContext` available, so this doesn't need
to be done in `run_frame`
2022-09-09 16:36:40 -07:00
Adrian Wielgosik 4421fbff6a
avm2: Convert all Qname::new(...).into() to Multiname::new() (#7930) 2022-09-09 23:33:30 +02:00
Aaron Hill ca030169f7 avm2: Implement BitmapData.rect and stub BitmapData.applyFilter
These are the last BitmapData methods needed for Solarmax
(the victory screen after beating the last level now renders).
2022-09-09 13:05:13 -05:00
Aaron Hill bb138d9082 avm2: Implement some of SharedObject
Our AVM2 `SharedObject` support is now *almost* equivalent
to our avm1 `SharedObject` support. We implement serialization
and deserialization for primitives, arrays, and `Object` instances
with local properties. We also implement serialization for `Date`,
but not `Xml` (since our AVM2 `Xml` class is just a stub at the moment).

This is enough to make 'This is the only level too' save level
progress to disk.

Currently, we always serialize to AMF3. When we implement
the `defaultObjectEncoding` and `objectEncoding`, we'll need
to adjust this.
2022-09-08 21:22:05 -05:00
Aaron Hill c090fe30ad core: Mark DisplayObject as non-removed when added to display list
An AVM2 movie can repeatedly remove and add a DisplayObject from/to
a parent. This was causing SolarMax to stop working after advancing
to the next level.
2022-09-08 18:19:25 -05:00
relrelb 7ec587355b text: Store background and border colors as `swf::Color`
Instead of `u32`.
2022-09-08 08:44:50 +03:00
EmperorBale ece4b9a76d avm2: Small cleanup 2022-09-07 13:54:33 -07:00
EmperorBale 7da912bbb4 avm2: Only store stack traces if avm_debug is enabled 2022-09-07 13:54:33 -07:00
EmperorBale a9d95b7d4e core: Fix code generator creating invalid code 2022-09-07 13:54:33 -07:00
EmperorBale 53ae55ff6f avm2: Improve stack trace output 2022-09-07 13:54:33 -07:00
EmperorBale 7fa19c2ea3 avm2: Store stack trace in Error objects 2022-09-07 13:54:33 -07:00
relrelb e0aba46bb2 chore: Remove unused `image` dependency
This basically reverts #7254 for all `.toml` files, except for `wgpu`
where it's actually needed on both desktop and web.
2022-09-07 13:09:29 -07:00
Aaron Hill 7218146e04 avm2: Implement BitmapData.dispose
We now check if a BitmapData has been disposed by checking
for a zero width or height (which cannot happen otherwise).
As a result, we no longer need the 'disposed' field on the AVM1
BitmapData object.
2022-09-07 11:02:53 -07:00
Aaron Hill b764c4f6c1 avm2: Implement BitmapData.fillRect and BitmapData.getPixel32 2022-09-07 12:29:49 -05:00
Mike Welsh 2ffbd8a1c7 core: Remove EditTextStaticData 2022-09-06 20:02:23 -07:00
Mike Welsh 459a19f146 core: Use bitflags for EditText 2022-09-06 20:02:23 -07:00
Mike Welsh b1404edfdc swf: Use bitflags for EditText 2022-09-06 20:02:23 -07:00
dowgird 53ed748a54 avm2: added flash.utils.escapeMultiByte 2022-09-06 19:44:48 -07:00
Mike Welsh f438e2032f avm1: Add is_streaming flag to Sound
`Sound.loadSound` with `isStreaming` of true causes any previously
playing audio on the same object to be stopped.
2022-09-06 19:04:16 -07:00
Mike Welsh dec4e30655 avm2: Add SoundLoaderContext 2022-09-06 19:04:16 -07:00
Mike Welsh e2f1f0174b audio: Implement Mp3Decoder::seek_to_sample_frame 2022-09-06 19:04:16 -07:00
Mike Welsh fe46d5046a avm2: Implement Sound.load 2022-09-06 19:04:16 -07:00
Mike Welsh 4a04923d04 audio: Add mp3_metadata function 2022-09-06 19:04:16 -07:00
Mike Welsh 3137306975 audio: Support loading external MP3s 2022-09-06 19:04:16 -07:00
Aaron Hill 93607aa86e
avm2: Implement `BitmapData.draw` for `wgpu` backend (#7254)
* avm2: Implement `BitmapData.draw` for `wgpu` backend

This method requires us to have the ability to render directly to a
texture. Fortunately, the `wgpu` backend already supports this in
the form of `TextureTarget`. However, the rendering code required
some refactoring in order to avoid creating duplicate `wgpu` resources.

The current implementation blocks on copying the pixels back
from the GPU to the CPU, so that we can immediately set them in
the Ruffle `BitmapData`. This is likely very inefficient, but will
work for a first implementation.

In the future, we could explore allowing the CPU image data and GPU
texture to be out of sync, and only synchronized when explicitly
necessary (e.g. on `getPixel` or `setPixel` calls).

* Rename `with_offscreen_backend` to `render_offscreen` and use Bitmap

* Don't panic when backend doesn't implement `render_offscreen`
2022-09-06 16:38:48 -05:00
Aaron Hill 54bf3d25f8 avm2: Remove `GcCell` from `local_registers`
We already have `&mut self` available whenever we write to it,
and we never made use of the `Clone` impl. As far as I can tell,
we don't have any unimplemented features that would require a `GcCell`.
2022-09-05 20:47:50 -07:00
Aaron Hill 45960de7dc avm2: Correctly implement DisplayObject.mask
The stub implementation was breaking code that relied on being
able to set a value for 'mask' and then retrieve it
(which used to work on a dynamic class like `MovieClip`).
2022-09-05 16:43:20 -07:00
dependabot[bot] 7f40b42131 build(deps): bump serde-xml-rs from 0.5.1 to 0.6.0
Bumps [serde-xml-rs](https://github.com/RReverser/serde-xml-rs) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/RReverser/serde-xml-rs/releases)
- [Commits](https://github.com/RReverser/serde-xml-rs/compare/0.5.1...0.6.0)

---
updated-dependencies:
- dependency-name: serde-xml-rs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:27:37 -07:00
dependabot[bot] aacc3c231a build(deps): bump clap from 3.2.18 to 3.2.20
Bumps [clap](https://github.com/clap-rs/clap) from 3.2.18 to 3.2.20.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/v3.2.20/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v3.2.18...v3.2.20)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 14:47:03 -07:00
onkrot 1e0b59dbad avm2: Implement `String`.`localeCompare`, `search`, `toLocaleLowerCase`, `toLocaleUpperCase` methods. 2022-09-05 12:15:53 -07:00
= 2b3249c9a4 core: Made core no longer depend on software video decoders 2022-09-04 17:46:58 -07:00
= f0013bdec8 video: Moved individual decoders to software video backend 2022-09-04 17:46:58 -07:00
= bf242bfb09 video: Moved SoftwareVideoBackend to software decoder crate 2022-09-04 17:46:58 -07:00
= 7c839ef8ae video: Add software video crate, moved VideoDecoder to it 2022-09-04 17:46:58 -07:00
= 8b12185d61 video: Moved NullVideoBackend from core to video 2022-09-04 17:46:58 -07:00
= aff49cd891 video: Moved VideoBackend from core to video 2022-09-04 17:46:58 -07:00
= 7c464295e2 video: Moved VideoStreamHandle from core to video 2022-09-04 17:46:58 -07:00
= fd7086adef video: Moved EncodedFrame, DecodedFrame and FrameDependency from core to video 2022-09-04 17:46:58 -07:00
= b7cf800f88 video: Made ruffle_video crate, moved core video Error to it 2022-09-04 17:46:58 -07:00
= 72da1535b7 core: Made video::Error not depend on invidiaul codecs 2022-09-04 17:46:58 -07:00
Adrian Wielgosik acdb767862 avm2: Swap Multiname flags to bitflags 2022-09-04 16:56:32 -07:00
Adrian Wielgosik 782f670c39 avm2: Store uninitialized Multinames in txunit, behind Gc 2022-09-04 16:56:32 -07:00
Adrian Wielgosik c28549ed9e avm2: Store multi-namespaces behind Gc And single namespaces directly 2022-09-04 16:56:32 -07:00
EmperorBale dd2bc1ea78
avm2: Add automatic linting for AS3 playerglobals 2022-09-04 16:33:35 -07:00
= ce0752c225 avm1: Removed export of SystemPrototypes and SharedObject 2022-09-04 12:27:29 -07:00
= 6ed1dd5942 avm1: Replace avm1::AvmString with string::AvmString 2022-09-04 12:27:29 -07:00
= ddaee950f8 avm1: Removed all public access into Avm1 modules, export only what's needed 2022-09-04 12:27:29 -07:00
= 7d7309d165 avm1: Moved start_drag from Avm1 root to activation module 2022-09-04 12:27:29 -07:00
= f2c9ae7c50 avm1: Moved root_error_handler from avm1 root to runtime module 2022-09-04 12:27:29 -07:00
= 7645c84980 avm1: Moved skip_actions from avm1 root to runtime module 2022-09-04 12:27:29 -07:00
= 2d24ed539e avm1: Moved Avm1 struct into its own file, fixing field access as needed 2022-09-04 12:27:29 -07:00
Adrian Wielgosik 9cf6f64d06 avm2: Guarantee that int+/-int makes an int 2022-09-04 08:57:18 +03:00
Adrian Wielgosik cc6abab72f avm2: Remove Value::Unsigned, add minimal implicit int->float conversion 2022-09-04 08:57:18 +03:00
TÖRÖK Attila 2b681e85b2 avm2: Remove unnecessary `extends Object` from some class stubs
As it's implicit.
2022-09-03 10:43:33 -07:00
TÖRÖK Attila 27b67d01d0 avm2: `Vector` -> `Vector.<Number>` in `ShaderEvent` 2022-09-03 10:43:33 -07:00
TÖRÖK Attila 92a2b6206e avm2: Fix the stub for `Vector` 2022-09-03 10:43:33 -07:00
relrelb 32c55dda22 core: Avoid some clones of `Matrix` and `ColorTransform`
Change `set_matrix` and `set_color_transform` to accept owned structs,
instead of references. This allows callers that already have an owned
struct to pass it directly, thus saving an unnecessary borrow + clone.

This also aligns with other methods, such as `set_sound_transform`,
which currently accepts an owned struct.
2022-09-03 09:36:51 -07:00
TÖRÖK Attila 2e3fad9165 core: Log errors coming from timer callbacks 2022-09-02 22:22:03 -07:00
TÖRÖK Attila 89434d65e8 core: Don't panic when an error occurs in an AVM2 timer callback 2022-09-02 22:22:03 -07:00
TÖRÖK Attila f75eee389a core/mp3: More lenient MP3 buffer underrun detection 2022-09-02 20:38:24 -07:00
relrelb fb39bb2b71 swf: Remove `Copy` from `Rectangle`
Use `.clone()` explicitly where needed.
2022-09-02 18:21:13 -07:00
relrelb 299da43c16 swf: Extract `ShapeFlag` 2022-09-02 18:21:13 -07:00
Aaron Hill ae452d29b8 avm2: Stub DisplayObject.mask getter/setter
This allows the loaded ArmorGames API swf to run in
'This is the only level too'
2022-09-02 17:12:18 -07:00
relrelb af006a3053 avm1: Introduce `NativeObject`
The existing `Object` enum representation is problematic for inherited
native objects, since "regular" `ScriptObject`s cannot be turned into
native objects, but rather a completely new native object needs to be
created. `TObject::create_bare_object` is an attempt to aid this
situation, but it works only for `ActionExtends` inheritance, and not
when the user manually wires up `prototype`/`__proto__` (#701).

In Flash, it seems like derived constructors initially have a "regular"
`this` object. But once the `super()` constructor is invoked, the same
`this` object becomes a native object.

To allow this in Ruffle, introduce a new `NativeObject` enum, and
store it as a member in `ScriptObject`. For a start, move `TextFormatObject`
from the `Object` enum to `NativeObject`. The plan is to gradually
move all `Object` enum variants to `NativeObject`, except for `ScriptObject`.
2022-09-02 16:41:27 -07:00
golfinq 08917b49cb
avm2: Add actionscript event classes 2022-09-02 14:35:01 -07:00
Aaron Hill 7a7ea87679 avm2: Implement Sprite.startDrag and Sprite.stopDrag
For now, I've left 'dropTarget' unimplemented - unlike in
AVM1, the drop target can be non-interactive objects like `Shape`,
so we'll need additional refactoring to implement it.

This allows 'This is the only level too' to be playable
2022-09-02 13:03:14 -07:00
relrelb d2a463b08f core: Remove unused parameter of `MovieClip::show_frame` 2022-09-02 10:42:09 -07:00
relrelb 16a1b7b832 swf: Remove `length` parameter of `read_frame_label`
Use `unwrap_or_default()` to optionally read a byte.
Also remove unused `context` parameter of `MovieClip::frame_label`.
2022-09-02 10:42:09 -07:00
relrelb 9ec3137891 swf: Remove `tag_length` parameter of `read_define_button_cxform`
It was not needed since `Reader` accounts for it internally.
2022-09-02 10:42:09 -07:00
relrelb 3da3567365 core: Avoid some allocations on JPEG tags
Read a slice instead of allocating a new `Vec`.
2022-09-02 10:42:09 -07:00
relrelb cc166439d8 avm2: `Activation::is_of_type` is infallible 2022-09-02 10:10:40 -07:00
relrelb ce5bf557f5 avm2: `ExternalValue::from_avm2` is infallible 2022-09-02 10:10:40 -07:00
relrelb c2e78ffead chore: Appease clippy
Resolve 2 instances of `only_used_in_recursion`.
2022-09-02 10:10:40 -07:00
relrelb 0d6462cfab render: Remove `gc-arena` dependency
It was only used to make structs `#[derive(gc_arena::Collect)]`, and
generally it doesn't make much sense that `render` needs to be GC-aware.
So instead annotate `render` fields in `core` with `#[collect(require_static)]`.
2022-09-02 09:49:18 -07:00
Aaron Hill cc9e283191 avm2: Improve Debug impl for EventObject 2022-08-30 09:35:20 -05:00
Aaron Hill 1a7c5339a7 avm2: Implement DisplayObject.localToGlobal and DisplayObject.globalToLocal
While writing tests for these methods, I discovered and fixed some
issues with how 'scrollRect' interacted with 'dobj.transform.matrix'
2022-08-29 23:12:40 -05:00
relrelb 3645061910 core: Simplify `DisplayObjectContainer::highest_depth`
The `less_than` parameter remained just `Depth::MAX` since #7199,
which makes it useless. As such it can be removed.
2022-08-29 17:26:15 -06:00
Aaron Hill e9697439de avm2: Skip over holes during array enumeration
This brings us closer to matching the Flash Player
enumeration behavior. Unfortunately, the precise enumeration
order for ScriptObject properties depends on the precise
order in the internal avmplus hashmap. This order is deterministic,
but adding/removing a property effectively randomizes it. Hopefully
there aren't any SWFS that depend on the *exact* order.
2022-08-29 15:53:44 -07:00
dependabot[bot] 802de0e7d1 build(deps): bump futures from 0.3.23 to 0.3.24
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.23 to 0.3.24.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.23...0.3.24)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 23:38:43 +03:00
Toad06 c4e64c5e26 avm1: Function calls in SWF4 bump the version to 5 2022-08-29 02:17:09 -07:00
TÖRÖK Attila e86efd5c63 avm2: Add flash.utils.[set|clear][Timeout|Interval](...) 2022-08-29 01:44:57 -07:00
relrelb 5c29da6707 avm1: Implement `MovieClip.scrollRect`
The core functionality and AVM2 bindings were implemented in #7739.
2022-08-28 22:18:33 -07:00
= f180183ec5 core: Add audio feature, made dasp optional 2022-08-28 21:10:05 -07:00
= c6c22cebc9 core: Make nellymoser optional, enable on desktop and web 2022-08-28 21:10:05 -07:00
= f5245d72da core: Make core not use minimp3 by default - only desktop uses it 2022-08-28 21:10:05 -07:00
relrelb 81f803d77e avm1: Remove `DisplayObject::prev_avm1_clip`
It is no longer needed.
2022-08-28 19:21:03 -06:00
relrelb de6163569e avm1: Simplify frame execution logic
Handle removed clips inline in `Avm1::run_frame`, such that
`DisplayObject::prev_avm1_clip` is no longer used. Thus it can be
removed in a follow-up commit.
2022-08-28 19:21:03 -06:00
relrelb 0b7d8ea007 avm1: Move frame lifecycle logic to `Avm1::run_frame`
This allows better encapsulation of AVM1.
2022-08-28 19:21:03 -06:00
Aaron Hill 397de91a2a core: Do not run sounds on no-op goto.
When we run a 'goto' where the initial and target frame are the same,
we need to skip triggering any sounds in the target frame.
Some games like 'This is the only level too' rely on this behavior:
they repeatedly run 'movieClip.gotoAndStop(current_frame_id)',
where 'current_frame_id' is the id of a frame that starts playing
a sound. Without this change, the sound will restart every frame
intead of playing exactly once.
2022-08-28 18:55:29 -06:00
David Wendt e353553835 core: When reporting errors in the AVM2 constructor from MovieClip, also report the name of the class being constructed. 2022-08-28 18:17:57 -06:00
David Wendt 4b9ee55b56 avm2: The failsafe for self-referencing class properties should allow the use of `null` and `undefined`. 2022-08-28 17:54:22 -06:00
Aaron Hill ae8e5b2f33 avm2: Don't error when executing 'null as SomeType'
We previously used 'coerce_to_object', which produced
an error with `Value::Null`. Instead, we can just ues
`value.as_type_of`, which will correctly handle `null`
2022-08-28 16:33:15 -05:00
Aaron Hill c531994b1c avm2: Fire KeyboardEvent.KEY_UP and KeyboardEvent.KEY_DOWN
The 'charCode' and 'keyCode' properties are now implemented
on `KeyboardEvent`

The input injection code we use does not support keyboard events,
so we can't yet write a regression test for this. However,
both 'You need to burn the rope' and 'This is the Only Level TOO'
now properly handle keyboard events with this PR.
2022-08-28 14:15:57 -05:00
Aaron Hill e3e0488ed4 avm2: Delete enumerant when property is deleted 2022-08-28 12:03:19 -05:00
Aaron Hill 1296121dc5 avm2: Make 'set_local_property_is_enumerable` infallible
We always returned `Ok(())`
2022-08-28 12:03:19 -05:00
EmperorBale f8289b47d8
avm2: Implement call stack & stack traces (#7564)
* avm2: Implement call stack

* avm2: Class traits should have a special prefix

* avm2: Stack tracebacks should also contain error message

* avm2: Move method naming to Executable

* avm2: Handle getter and setter methods in tracebacks

* chore: Formatting

* chore: Add comments

* avm2: Make full_name write to a string, instead of creating a new one

* core: Make GcArena publicly accessible

* core: Add Deref impl for Either type

* desktop: Add AVM2 call stack to panic message

* avm2: Prefix native methods with a `/`

* chore: Appease clippy

* avm2: Check if method actually contains bytecode instead of unwrapping

* web: Add AVM2 stack trace to panic message

* chore: Formatting

* chore: Clippy

* avm2: Fix stack traces for free standing functions

* core: Remove global data from context

* core: Rename GcGlobalData to GcCallstack

* core: Introduce StaticCallstack, make GcArena private again

Co-authored-by: Adrian Wielgosik <4729533+adrian17@users.noreply.github.com>
2022-08-28 18:30:20 +02:00
Aaron Hill 6a01fa93c5 avm2: Implement `String.toLowerCase` and `String.toUpperCase`
These are implemented in the same way as in AVM1. Testing
in Flash Player shows that the behavior is the same.
2022-08-28 01:32:53 -05:00
Aaron Hill 576c35a768 avm2: Declare 'Array.concat' as a public method
Previously, it was only declared in the AS3 namespace. However,
some SWFs look it up as a public method.
2022-08-27 20:20:19 -05:00
relrelb 2f106da04c avm2: Port toplevel constants to ActionScript
Declare `NaN`, `Infinity` and `undefined` in ActionScript, similarly
to how `avmplus` does in its `actionscript.lang.as`.

Note that `null` is only removed, without an ActionScript declaration,
as it seems like `avmplus` neither declares it. Probably `null` is
only usable as a compile-time constant.
2022-08-26 15:45:36 -07:00
Callum Thomson 046514eeb9
avm1: Enumerate should push Undefined if the target isn't an object 2022-08-26 14:01:42 -07:00
Aaron Hill 249648674c Fix bounds computation 2022-08-26 13:04:01 -07:00
Aaron Hill 5fb95e6961 Use round-to-even for scrollRect 2022-08-26 13:04:01 -07:00
Aaron Hill fa0c843a4d avm2: Implement DisplayObject.scrollRect
This property causes a DisplayObject to be both translated
and cropped.
2022-08-26 13:04:01 -07:00
relrelb 72d8c152b9 core: Make `Player::load_device_font` infallible
It is always called with the same known data, which should parse
successfully.
2022-08-26 12:24:15 -07:00
relrelb ad84c2bbcb avm2: Rename `Avm2::load_abc` to `Avm2::do_abc`
This aligns with the name of `DoAbc` tags.
2022-08-26 11:37:04 -07:00
relrelb ad91992cb5 swf: Simplify `DoAbc` tag handling
Extract `swf::Reader::read_do_abc()` which, as the name suggests,
reads a `DoAbc` tag, and use it before calling to `Avm2::load_abc`.
Finally, introduce `DoAbcFlag` using `bitflags`.
This greatly simplifies the ABC loading code.
2022-08-26 11:37:04 -07:00
EmperorBale 18bd7879e5 core: Add better error message when java could not be found 2022-08-26 10:11:35 +02:00
Aaron Hill c4157fd0ce Miscellaneous stubs
This gets Solarmax to the main level select screen
(once BitmapData.draw support is added)
2022-08-25 19:57:03 -07:00
Aaron Hill 61d0f73fdb core: Use catchup_display_object_to_frame in Loader 2022-08-25 19:24:56 -06:00
David Wendt 2c93da9a70 docs: Add comments documenting subtle points of AS3 loop & tag queueing behavior 2022-08-25 19:24:56 -06:00
David Wendt 074f2ff76f core: Replace `Vec` of queued tags with a more restrictive enum that enforces our queueing invariants 2022-08-25 19:24:56 -06:00
David Wendt 59623a8452 core: Fix a potential stack overflow caused by gotos triggering frame scripts on one another. 2022-08-25 19:24:56 -06:00
David Wendt 05caa0fceb core: Explicit gotos drain the tag queue of any prior operations.
This is in keeping with the whole idea of a "recursive frame": gotos run the entire frame lifecycle on the target clip, including broadcasts for `frameConstructed` and `exitFrame`.
2022-08-25 19:24:56 -06:00
David Wendt 6f0de246ed core: Clear queued tags if AS3 attempts a goto in the middle of a loop. 2022-08-25 19:24:56 -06:00
David Wendt ed28578c12 core: Fast-forwarding gotos should run frame scripts on all removed children 2022-08-25 19:24:56 -06:00
David Wendt bcb1030883 core: Only `Construct` and `Enter` phases want forced script frames on gotos 2022-08-25 19:24:56 -06:00
David Wendt 3677a0107b core: Only force-queue frame scripts if the goto is not a no-op. 2022-08-25 19:24:56 -06:00
David Wendt ac2b82f26e core: Gotos *always* queue the target frame's scripts on the target clip, even if we already executed that script beforehand. 2022-08-25 19:24:56 -06:00
David Wendt 9bff6406d1 core: Allow queueing both a remove and a place tag at the same depth, in that order only. 2022-08-25 19:24:56 -06:00
David Wendt 2929681a93 core: No-op gotos should be treated as rewinding. 2022-08-25 19:24:56 -06:00
David Wendt 7a09bbfaab core: In AVM2, run removals before frame advance.
We still retain the queue system as events are fired at removal time, and those events can trigger more gotos. If such a goto happens, AS3 code will hit a clip still in the old state rather than an inconsistent one. I don't have test coverage for this exact scenario just yet.
2022-08-25 19:24:56 -06:00
David Wendt d691543c4c core: Child removals appear to resolve in reverse render order. 2022-08-25 19:24:56 -06:00
David Wendt 8feb3fc7b0 core: Fast-forward removals as the result of a goto happen before the frame number advances. 2022-08-25 19:24:56 -06:00
David Wendt 66c24ff188 core: Queue new object placement at loop time on the tag queue. 2022-08-25 19:24:56 -06:00
David Wendt 0353d176e4 core: Movie clip rewinds should not remove any children until after the new timeline position has been set. 2022-08-25 19:24:56 -06:00
David Wendt 99003643ac core: Same-frame gotos should only proceed on AVM2. 2022-08-25 19:24:56 -06:00
David Wendt cdfc6f5eae core: Explicit gotos must run even if they are no-ops. 2022-08-25 19:24:56 -06:00
David Wendt cb86340fb1 core: `frameConstructed` during a goto fires after the goto commands have fully completed. 2022-08-25 19:24:56 -06:00