Commit Graph

347 Commits

Author SHA1 Message Date
Tom Schuster dd53b4e06b avm2: Reduce the size of Op on 64bit 2024-01-04 21:15:09 +01:00
friedkeenan 834e745652 swf: Make avm2 Writer::write_op public 2023-12-17 15:41:44 +01:00
friedkeenan c7966cea77 swf: Add test for avm2 Writer::write_op 2023-12-17 15:41:44 +01:00
Nathan Adams 1ff23cdd77 swf: Fixed writing DefineFontInfo tags with wide chars 2023-10-29 14:31:45 +01:00
Nathan Adams 11e1d2f6be swf: Fixed writing out DefineText2 (we previously wrote it as DefineText 1) 2023-10-29 14:31:45 +01:00
Nathan Adams 878f1fc64e swf: Removed ButtonAction::key_code and fixed writing button tags 2023-10-29 14:31:45 +01:00
Nathan Adams 5b41db9138 swf: Fixed writing bevel filters 2023-10-29 14:31:45 +01:00
sleepycatcoding fc0f03a687 swf: Fix writing of a DefineButton2 with zero actions
Previously, `swf` crate always wrote out the action offset, but this should be 0 when there are no actions.
2023-10-27 20:27:12 +02:00
Adrian Wielgosik cea0f1b1f1 swf: Add test for DefineFont2/3 roundtrips 2023-10-08 12:13:16 +02:00
Adrian Wielgosik 3e5482a761 swf: Better adjust offsets for has_wide_offsets in writer 2023-10-08 12:13:16 +02:00
Adrian Wielgosik 9ab50bcd74 swf: Fix writing an all-zeros straight ShapeRecord 2023-10-08 12:13:16 +02:00
Adrian Wielgosik f08ee6de58 swf: Add a missing offset to DefineFont2/3 offset table 2023-10-08 12:13:16 +02:00
Adrian Wielgosik cc5c46dda2 swf: Fix writing of an all-zeros curve ShapeRecord 2023-10-08 12:13:16 +02:00
Nathan Adams f2ca88bb34 core: Readd max(0) to blur size 2023-08-12 13:00:27 +02:00
Nathan Adams 1a4a808c23 render: Make Filter::calculate_dest_rect work in Twips 2023-08-12 13:00:27 +02:00
Nathan Adams da090f0bd7 render: Move filter size calculation from wgpu to render/swf 2023-08-12 13:00:27 +02:00
TÖRÖK Attila 41377c5472 swf: Different blur impotency check 2023-07-26 13:03:11 +02:00
relrelb 5f6d8d72ea render: Skip unreasonably large bitmaps
Some SWFs report unreasonable bitmap dimensions, and trying to reserve
enough capacity for them always fails. To avoid panics, skip those bitmaps.

Fixes #1191
Fixes #2759
Fixes #10701
2023-07-24 09:37:37 +03:00
Nathan Adams b201e19cc7 wgpu: Don't create an extra fresh texture for applying filters to a CAB 2023-07-20 23:19:20 +02:00
Lord-McSweeney 5975714f75 avm2+swf+tests: Store metadata on Traits and VTable, report metadata in describeType; parse ABC metadata key-value pairs correctly; add test 2023-07-19 16:24:23 +02:00
Kornelius Rohrschneider 687c0e7516 core: Complete MovieClip error state & Change uncompressed_len to i32
Previously, the MovieClip error state contained one TODO in order to be
completely implemented: The HeaderExt variable uncompressed_len needs to
be -1 in the error state, but its type has been u32.
The type has now been changed to i32, and the variable is set to -1 in
the default_error_header function. Therefore, the MovieClip error state
is now fully implemented.

Other connected functions and variables like SwfMovie::uncompressed_len
or MovieClip::total_bytes have been adjusted to this type change. Code
has been adjusted if needed where this value is used.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider 893052c2a6 core: Add MovieClip error state
A load_error_swf function has been added to the Loader. It makes the
MovieClip enter the error state in which some attributes have certain
error values to signal that no valid file could be loaded. This happens
if no file could be loaded or if the loaded content is no valid
supported content.
The function creates an error state movie stub using the new
SwfMovie::error_movie function (which uses a new default_error_header
function) and configures remaining variables with the
movie_not_available method.
One TODO in order for the error state to be completely implemented has
been added.

Since the error state of the MovieClip includes the final URL of the SWF
file obtained after any redirects, the load_error_swf and
movie_loader_error functions (now) take an swf_url attribute.
To get this URL in case no file could be loaded, the
NavigatorBackend::fetch method has been changed to return an
ErrorResponse struct (including the url and the actual error) in the
error case. The Response struct returned in the success case has been
renamed to SuccessResponse.
All fetch implementations have been adapted accordingly. Code has been
adjusted to return the actual error where that's needed.

Documentation has been added and improved.
2023-07-17 00:08:02 +02:00
Lord-McSweeney 3e193214df swf: Ignore bad ConstantPool string reads 2023-07-15 12:10:36 +02:00
Lord-McSweeney 61a4ded851 swf: Ignore bad ActionTry opcodes 2023-07-15 12:10:36 +02:00
Nathan Adams c3fdfc17dd swf: Scale filter distances where appropriate 2023-07-12 18:51:11 +02:00
Nathan Adams 5c13d323b3 wgpu: Implement the undocumented ability to disable compositeSource for glow/shadow 2023-07-12 18:51:11 +02:00
Nathan Adams 8cb6e5bdf0 wgpu: Implement drop shadow filter 2023-07-12 18:51:11 +02:00
Nathan Adams 8f78fd410b swf: Don't require Coordinate (only Twips) for Rectangles, only when using valid-checking stuff 2023-07-12 18:51:11 +02:00
Nathan Adams 44024e77c3 swf: Add inner_blur_filter() method to filters that contain blurs 2023-07-12 18:51:11 +02:00
Nathan Adams 2459ae5230 chore: Fix clippy 'useless-vec' 2023-07-12 18:17:43 +02:00
Nathan Adams 146d565c02 render: Add Filter::scale() and use it to scale filter values (currently just blur_) 2023-07-03 20:13:40 +02:00
David Wendt 34625524ad swf: Zero is a valid video codec and it indicates no codec. 2023-06-30 16:14:28 -06:00
Nathan Adams a5915a9bdb swf: Make Color Copy 2023-06-29 20:32:36 +02:00
Nathan Adams c0247c020a swf: Add write_swf_raw_tags for reconstructing a swf from its parts 2023-06-21 18:27:12 +02:00
Nathan Adams a26a64d88f core: Format Rectangle to 2 decimal places 2023-06-03 09:11:06 +02:00
Nathan Adams e12e2a2e54 core: Initial Debug UI 2023-06-03 09:11:06 +02:00
relrelb ee30646745 avm1: Migrate `DisplacementMapFilter` to `NativeObject` 2023-05-27 23:08:42 +03:00
iwannabethedev 8cd5414c5d
Fix overflow bug in `shape_utils::winding_number_line()` 2023-05-17 07:21:13 +03:00
Toad06 aac0c43372 swf: Bail out if swf version is 0 2023-05-16 20:23:23 +02:00
relrelb 660acac427 swf: Use `PointDelta<Twips>` in `ShapeRecord` 2023-05-11 08:55:44 +03:00
relrelb b93a32af0f swf: Use `Point<Twips>` in `StyleChangeData::move_to`
No functionality change.
2023-05-11 08:55:44 +03:00
relrelb 182ae6c9a9 swf: Introduce `ShapeRecordFlag`
No functionality change.
2023-05-02 20:24:38 +03:00
relrelb 3046d68da1 swf: Introduce `PointDelta`
Generally, when transforming a difference between two points, `p1`
and `p2`, with a matrix `m`, we would like the following property
to hold:

```
m * (p1 - p2) == m * p1 - m * p2
```

Unfortunately, it wasn't like this before, because matrices have a
translation component, which is non-linear. In `m * p1 - m * p2`,
the translations of `m * p1` and `m * p2` are the same and therefore
cancel out each other. However, in `m * (p1 - p2)` the translation
stays.

In order to preserve this property, introduce a new `PointDelta`
type which is not subject to translation when transformed by a matrix.

For now, the following operations are supported:

* `Point - Point -> PointDelta`
* `Point + PointDelta -> Point`
* `Point += PointDelta`
* `Point - PointDelta -> Point`
* `Point -= PointDelta`

As a consequence, the expression `position + global_to_local_matrix * mouse_delta`
in `update_drag()` now ignores translation, which fixes #817.
2023-04-29 22:29:37 +03:00
relrelb 60ffe07ae7 chore: Use `swf::Point` in many places
Convert nearly all instances of `(Twips, Twips)` (maybe besides in
`shape_utils.rs`) to `swf::Point<Twips>`.
2023-04-27 22:14:03 +03:00
relrelb 814cb00821 avm1: Migrate `GlowFilter` to `NativeObject` 2023-04-08 13:40:32 +03:00
relrelb 236a97bf31 render: Replace `ColorTransform` with `swf::ColorTransform` 2023-03-29 23:27:20 -07:00
Mike Welsh 74b2ff6997 swf: Inline `Color` methods 2023-03-26 18:20:15 -07:00
Mike Welsh df5f5451f4 swf: Inline `Point` methods 2023-03-26 18:20:15 -07:00
Mike Welsh 49ea1b0f36 swf: Inline `Twips` methods 2023-03-26 18:20:15 -07:00
Toad06 e2415be734 core: Store correct data for loaded images 2023-03-20 01:36:04 +01:00