Commit Graph

242 Commits

Author SHA1 Message Date
relrelb cab49ae6e1 swf: Introduce `Color::WHITE`
And use it where possible, to improve code readablity.
2022-05-12 12:12:06 -07:00
relrelb 0b0f8a1a7a swf: Introduce `Color::BLACK`
And use it where possible, to improve code readablity.
2022-05-12 12:12:06 -07:00
relrelb 84b865018d swf: Mark some `SwfStr` functions as const 2022-05-10 09:34:57 +03:00
relrelb 781d091d42 swf: Return concrete data types in `Reader` methods
Where possible, return the specific data type instead of the generic
`Tag` type. Most reader methods do this already, so this brings the
rest in-line.
2022-05-09 14:59:38 -07:00
Mike Welsh 402e072707 swf: Implement Default for BlendMode 2022-05-06 11:33:52 -07:00
relrelb f6153ff7c1 chore: Appease clippy 2022-05-06 10:36:38 -07:00
Mike Welsh 146b8adc68 swf: Clean up LineStyle
* Remove LineStyle::color, instead using fill_style with
   FillStyle::Color to indicate solid color.
 * Store `flags` in the struct instead of separate bools/values.
 * Add getters/setters for ease of use.
 * Add builder-style methods for setting LineStyle properties.
 * Fix misnamed ALLOW_CLOSE flag to NO_CLOSE.
2022-04-11 22:50:40 -07:00
Mike Welsh 478f970fc8 chore: Appease clippy 2022-04-09 18:23:51 -07:00
dependabot[bot] 860c2e313f build(deps): bump encoding_rs from 0.8.30 to 0.8.31
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.30 to 0.8.31.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases)
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.30...v0.8.31)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-08 10:40:26 -07:00
Mike Welsh ac765bd187 chore: Update copyright
I (Michael R. Welsh) assign to Ruffle LLC all rights, title, and
interest to copyrights of my personal contributions to Ruffle,
effective March 26, 2022.
2022-03-26 18:13:14 -07:00
relrelb 9234336dfc swf: Rename `PlaceFlag::IS_IMAGE` to `PlaceFlag::HAS_IMAGE`
To match the SWF19 spec.
2022-03-26 11:33:26 -07:00
relrelb 094da8f1a4 swf: Organize clippy attributes
Move them to specific places as possible.
2022-03-26 11:33:26 -07:00
relrelb 71b0a6e32e swf: Use bitflags for `FontInfoFlag` 2022-03-26 11:33:26 -07:00
relrelb fd06fa0537 swf: Use bitflags for `LineStyleFlag` 2022-03-26 11:33:26 -07:00
relrelb e88c7102f5 swf: Use bitflags for `PlaceFlag` 2022-03-26 11:33:26 -07:00
relrelb 6d2005c2fe swf: Simplify `read_str_with_len`
Read the length in the function itself rather than receiving it as
an argument.
2022-03-26 11:33:26 -07:00
relrelb 1230b5e713 swf: Use bitflags for `FontFlag` 2022-03-26 11:33:26 -07:00
relrelb 71a1757d29 swf: Make `Glyph::advance` non-`Option`
Simply use `0` instead of `None`.
2022-03-26 11:33:26 -07:00
relrelb 984342abf3 swf: Avoid some `Vec::resize` usages
Use the `vec![]` macro instead.
2022-03-26 11:33:26 -07:00
dependabot[bot] da613a6fc5 build(deps): bump libflate from 1.1.2 to 1.2.0
Bumps [libflate](https://github.com/sile/libflate) from 1.1.2 to 1.2.0.
- [Release notes](https://github.com/sile/libflate/releases)
- [Commits](https://github.com/sile/libflate/compare/1.1.2...1.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 11:20:34 -07:00
dependabot[bot] f9e361ddae build(deps): bump bitstream-io from 1.2.0 to 1.3.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 10:52:26 -07:00
relrelb e9167cf43c swf: Add minimal offset table enforcement in `DefineFont2/3`
Previously, the offset table and code table offset were completely
ignored. But as it seems, Flash does look into these offsets in
order to avoid exceedingly reading glyph shapes. For now, avoid
exceedingly reading empty and 1-byte glyph shapes, and add debug
assertions that verify the correctness of the offset table and code
table offset, to help diagnosing related bugs in the future.
2022-03-14 22:50:24 +02:00
Jean Marchand 9969e0ce5a avm2: Fix invalid option 2022-02-12 23:35:32 +02:00
Mike Welsh 55da3cd7d0 chore: Add .cargo/config.toml for workspace-level lint config
Currently it is not directly possible to configure lints for the
entire workspace via TOML, which forced us to repeat `#![allow]`
blocks in each crate.

embark pointed out this workaround to configure lints at the
workspace level via RUSTFLAGS:

https://github.com/EmbarkStudios/rust-ecosystem/issues/22#issuecomment-947011395

Remove the common `#![allow]` blocks and switch to this method for
global lint config.

Temporarily allow `needless_borrow` lint, buggy pending this fix:
https://github.com/rust-lang/rust-clippy/pull/8355
2022-01-29 14:22:44 -08:00
Mike Welsh b181debff6 swf: Use bitflags for `avm1::GetUrl2` 2022-01-17 21:35:57 -08:00
Mike Welsh 4c3e14eae5 core: Clean up `DefineFunction` action
* Have `DefineFunction` and `DefineFunction2` go through the same
   code path by implementing `From<DefineFunction>` for
   `DefineFunction2`.
 * Change `register` to a `Option<NonZeroU8>` for size optimization.
 * Add `function::Param` to store param info instead of a tuple.
2022-01-17 21:35:57 -08:00
Mike Welsh 2b2346b65e swf: Add `avm1::Action::End`
Returning an `Action::End` instead of `None` when reading the end
of an action.
2022-01-17 21:35:57 -08:00
Mike Welsh d5862809c7 swf: Remove extraneous ? in avm1::Writer 2022-01-17 21:35:57 -08:00
Mike Welsh 265bcc278a swf: Add avm1::Writer::write_small_action
Convenience method for writing zero-length actions.
2022-01-17 21:35:57 -08:00
Mike Welsh 9141451ca1 swf: Use structs for avm1 `Action` variants
Use a struct for all variants of `avm1::Action`.
This makes the style more consistent instead of using a mix of
struct and tuple variants, and allows the data to be easily passed
around.
2022-01-17 21:35:57 -08:00
Adrian Wielgosik 22a0711d85 avm2: Use TU's method cache for callstatic, newfunction opcodes 2021-12-17 21:09:40 -07:00
David Wendt 2aee3555ab chore: Fix all new clippy lints added in latest Rust nightly 2021-12-17 20:53:26 -07:00
dependabot[bot] ef679d25c7 build(deps): bump encoding_rs from 0.8.29 to 0.8.30
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.29 to 0.8.30.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases)
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.29...v0.8.30)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-13 23:22:28 +02:00
Adrian Wielgosik 685911a77c swf: Box ShapeRecord::StyleChange variant 2021-12-08 22:14:17 +01:00
relrelb da4b5986b1 chore: Appease clippy 2021-12-08 22:36:55 +02:00
relrelb 0b6cd45415 swf: Fix reserved gradient values handling
* Map 3 to `GradientSpread::Pad`
* Map 2 and 3 to `GradientInterpolation::Rgb`

Fix #1505.
2021-12-04 21:32:47 +02:00
Adrian Wielgosik a305b80789 swf: Support font layout without swf-v7 fields 2021-11-20 22:48:36 +01:00
relrelb 34d1fa5226 avm1: Introduce `TextFormatObject`
`TextFormat` objects differ from regular objects in that
`TextField.setTextFormat` and `TextField.setNewTextFormat` accept
only the former, and ignore the latter.

Also, `TextFormat.prototype` has native accessors that coerce the
values on get/set.
2021-10-30 10:03:36 -07:00
Adrian Wielgosik 8cc00f32bb chore: Stop using traits available in prelude 2021-10-21 10:24:05 -07:00
Adrian Wielgosik bc82a4f705 build: Bump Rust edition to 2021 2021-10-21 10:24:05 -07:00
dependabot[bot] 5cab790bd7 build(deps): bump encoding_rs from 0.8.28 to 0.8.29
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.28 to 0.8.29.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases)
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.28...v0.8.29)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 14:01:23 -07:00
relrelb d069b8dcd6 swf: Avoid one usage of `Reader::pos` 2021-10-08 13:22:45 -07:00
relrelb 693f49904f swf: Extract `BitReader::new` 2021-10-08 13:22:45 -07:00
relrelb 281455be6d swf: Improve `ActionTry` read/write
* Use `TryFlags` instead of hard-coded binary literals.
* Rename `try_length`, `catch_length`, `finally_length` to `try_size`,
`catch_size`, `finally_size` to match SWF19 namings.
* Refactor write and fix a few bugs there:
    * The actions length should not include the try, catch, finally
    bodies, only the metadata of `flags`, `try_size`, `catch_size`,
    `finally_size` and catch variable (either as `u8` or `SwfStr`).
    * A placeholder byte should be written in place of the catch variable
    when there is no catch clause.
2021-10-02 23:01:32 +03:00
relrelb d49ea10267 swf: Rename `TryBlock` fields
* `try_actions` -> `try_body`
* `catch` -> `catch_body`
* `finally` -> `finally_body`

This aligns with the names used in SWF19, and is more consistent.
2021-10-02 23:01:32 +03:00
relrelb d2908d8fcd swf: Fix write of With opcode
The actions length should be written as an additional u16.
2021-10-02 23:01:32 +03:00
TÖRÖK Attila a1ee508ff8
chore: Fix nightly clippy lint: clippy::if_then_panic (#5400)
* chore: Fix nightly clippy lint: clippy::if_then_panic

* chore: Fix nightly clippy lint: clippy::if_then_panic in swf tests too

* Address review notes
2021-10-02 16:14:53 +03:00
Giles Cope 42c2b40052 unused deps 2021-09-18 15:28:24 +02:00
Chris Midgley 2dd83c23e8 avm2: add more opcodes
Taken from https://jindrapetrik.github.io/as3_pcode_instructions.en.html
2021-09-16 02:51:04 -07:00
Chris Midgley d52a350b9b avm2: reorder opcodes to be alphabetical 2021-09-16 02:51:04 -07:00