Commit Graph

4231 Commits

Author SHA1 Message Date
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
David Wendt 51401ae660 core: Remove AVM2 compatibility hacks surrounding place frame.
They are no longer needed, frame advance happens at enterframe time.
2022-08-25 19:24:56 -06:00
David Wendt 1eef8a47c9 core: Movie clips run all their tags at `enter_frame`, and place/remove actions are queued until later.
This prevents repeated place/remove actions at the same depth from resulting in repeated event dispatches.
2022-08-25 19:24:56 -06:00
David Wendt 963144e59c core: Centralize all the various calls to `enter_frame`/`construct_frame` into a single method, `catchup_display_object_to_frame`.
The rationale for the catch-up logic is as follows:

 * We must always enter-frame and construct objects, even if those respective display events haven't happened yet.
 * Display objects created in event handlers still need to run catchup phases, otherwise they will tag-stream desync
 * Frame scripts are never triggered by catchup phases
 * `exit_frame` is not a catchup phase as it is *only* an event broadcast currently
2022-08-25 19:24:56 -06:00
David Wendt 0400d4dee4 core: `Player` should start in the `Idle` phase 2022-08-25 19:24:56 -06:00
David Wendt f0ef8adb42 core: Add a new frame phase to represent non-frame work such as input event handlers. 2022-08-25 19:24:56 -06:00
David Wendt ae530b5d6b core: Track what part of the frame processing loop we're in 2022-08-25 19:24:56 -06:00
David Wendt ee2454e09f core: Frame actions should start with `enterFrame`; not `exitFrame`. 2022-08-25 19:24:56 -06:00
David Wendt 1f0b8bdda4 core: In AVM2, movie clips process `RemoveObject` before any other frame actions are done. 2022-08-25 19:24:56 -06:00
David Wendt 318b018da8 core: `enter_frame` should be an event that all display objects get and can respond to 2022-08-25 19:24:56 -06:00
relrelb d152cc3e64 avm2: Port `Math` to ActionScript 2022-08-25 16:03:08 -07:00
relrelb 4e9cc919a1 avm2: Fix bindings of empty namespace
Previously native functions defined inside a `package {}` block
(without a package name) would cause a syntax error by two consecutive
`::`.
2022-08-25 16:03:08 -07:00
= 620820be9e core: Replaced tag_utils Error with an actual Error enum 2022-08-25 23:43:21 +02:00
= 67eb34fbc5 core: Remove Error from player.rs, it wasn't needed 2022-08-25 23:43:21 +02:00
= b7dcd26c38 core: Use Cow<str> for FullscreenError in UI backend, as it can't ever be anything else 2022-08-25 23:43:21 +02:00
= 1c7bfd8c5f core: Use real Error enums for video backend 2022-08-25 23:43:21 +02:00
= 461c977be0 render: unregister_bitmap is infallible, removed error path 2022-08-25 23:43:21 +02:00
= 03eb769a33 render: Made render use a real Error enum and not generic box<error> 2022-08-25 23:43:21 +02:00
= 5b5ee7d448 core: Made audio backend use actual real error enums, and not box<error> 2022-08-25 23:43:21 +02:00
= 2d2869f44f core: Font::from_swf_tag is currently infallible, remove error path 2022-08-25 23:43:21 +02:00
= 1df8de5bac core: set_text and set_html_text are currently infallible, remove error path 2022-08-25 23:43:21 +02:00
Mike Welsh 78247a37ab avm1: Load correct _root and _parent registers if base clip is removed
Normally a function closures also closes around its base clip.
If the base clip is removed, and then the function is executed, the
base clip then defaults to `this`.

However, Ruffle was incorrectly using the wrong base clip when
loading the `_root` and `_parent` registers in this case.

Fixes #5645.
2022-08-25 00:01:02 -07:00
Roman Rogowski 66d144bbdd core: Fix incorrect rendering of word-wrap text boxes (close #1095) 2022-08-24 22:51:51 -07:00
relrelb a8edce8294 core: Remove unneeded `Box` 2022-08-24 22:36:20 +03:00
Aaron Hill c7216bf842 avm2: Set URLRequest.method default to GET
This was missed when I added 'method'
2022-08-23 17:54:10 -05:00
onkrot 14abd01e91 avm2: Pull flash.crypto package method from globals to crypto.as 2022-08-23 09:58:19 -05:00
onkrot db22992b86 avm2: Pull flash.utils package methods from globals to utils.as 2022-08-23 09:58:19 -05:00
onkrot 1a243bdd86 avm2: Implement all remaining matrix methods 2022-08-23 10:44:12 +02:00
Aaron Hill 86e6983943 avm2: Partially implement Loader.load
This PR implements the `Loader.load` method, as well as
the associated `LoaderInfo` properties and events.

We can now load in an external AVM2 SWf: it will be added
as a child of `Loader` object, and will render properly
to the screen.

Limitations:
* The only supported `URLRequest` property is `url`
* `LoaderContext` is not supported at all - we always use the default
  behavior
* Only `Loader.load` is implemented - we do not yet support unloading.
* We fire a plain 'Event' for the 'progress' event, instead of using
  the (not yet implemented) 'ProgressEvent' class

The main changes in this PR are:
* The AVM2 `Loader` class now has an associated display object,
  `LoaderDisplay`. This is basically a stub, and just renders
  its single child (if it exists).
* `LoaderStream::Stage` is renamed to `LoaderStream::NotYetLoaded`.
  This is used for both the `Stage` and an 'uninitialized'
  `Loader.contentLoaderInfo`. In both cases, certain properties throw
  errors, while others return actual values.
* The rust `Loader` manager now handles both AVM1 and AVM2 movie loads.
2022-08-22 19:36:29 -07:00
dependabot[bot] 25a77869ab build(deps): bump serde from 1.0.143 to 1.0.144
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.143 to 1.0.144.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.143...v1.0.144)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 16:51:56 -07:00
Aaron Hill 98c7f443ce core: Only store viewport dimensions in `RenderBackend`
Previously, the viewport height and width were stored in
both `Stage` and the `RenderBackend`. Any changes to the viewport
dimensions (e.g. due to window resizing) needed to be updated in both
places to keep our handling of the viewport consistent.

This PR adds a new `ViewportDimensions` type, which holds the
width, height, and scale factor. It is stored inside the
`RenderBackend` impl, and is retrieved using the newly added
method `RenderBackend.get_viewport_dimensions`. After a `Player`
has been constructed, any code that needes access to the viewport
dimensions will ultimate go through this method.

Unfortunately, `Stage` needs to use the viewport dimensions
in `build_matrices`. Therefore, any code modifying the viewport
dimensions should go through `player.set_viewport_dimensions`,
which ensures that the stage matrices are rebuilt after the render
backend is updated.
2022-08-22 13:44:30 -07:00
Mike Welsh 3629a55c00 core: Mouse picking respects order of children (fix #7393)
When doing mouse picking, interactive children were considered
before all non-interactives, which could cause an `_droptarget` to
be set to an underlying movieclip even if a shape occluded it.

Now consider all children in render order so that the top-most
shape will capture the mouse input.
2022-08-21 21:16:02 -07:00
= 3a1947445e core: Made SwfSlice::to_subslice return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
= 44cfaa9200 core: Made SwfSlice::to_unbounded_subslice return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
= 55566037f7 core: Made SwfSlice::resize_to_reader return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
= 0cfbdc0385 core: Made SwfSlice::to_start_and_end return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
Adrian Wielgosik b18329c8fe web: Allow modifying player volume via JS 2022-08-20 11:53:42 -07:00
Mike Welsh b38fce230d audio: Add AudioBackend::volume/set_volume 2022-08-20 11:53:42 -07:00
David Wendt f66e54bd03 core: Log a `debug` message every time we run a goto. 2022-08-19 18:52:21 -07:00
David Wendt fe828d7c24 core: At the end of a goto, fix tag stream desyncs caused by not hitting the target frame.
If we try to go to a frame that doesn't exist, or hasn't been loaded yet, we will stop on the last available frame, but skip any tags that would have run there. This is technically a desync, but it hasn't caused any problems so far as any further timeline interaction would trigger a rewind (which isn't affected by desyncs).

Of course, now that we're actually testing the tag stream position it *does* cause problems. We actually have to fix up the position to be correct even though it will never be used (hopefully). It may be prudent to do this outside of the `timeline_debug` feature as well in the future.
2022-08-19 18:52:21 -07:00
David Wendt 32542fdbc8 core: When `timeline_debug` is enabled, assert every goto's tag stream positions against the list of stream boundaries. 2022-08-19 18:52:21 -07:00
David Wendt 72e40423fa core: Calculate the start and end position of every frame when the `timeline_debug` feature is enabled. 2022-08-19 18:52:21 -07:00
Mike Welsh 89cb1212ad render: Disable most blend modes
Avoid blend modes except ADD and SUBTRACT until they can be
implemented properly.
2022-08-19 14:59:08 -07:00