Commit Graph

822 Commits

Author SHA1 Message Date
Aaron Hill 729d5a2c65 avm2: Don't overwrite existing entry in `export_class`
This makes the behavior consistent with `export_definition`
2023-05-13 11:15:54 +03:00
Aaron Hill 3c6820c6e1 avm2: Check length and copy vector in Matrix3D constructor 2023-05-13 11:00:31 +03:00
iwannabethedev 93450b28b0 avm2: Add 'static length' for most types. 2023-05-11 22:16:55 +02:00
Aaron Hill e488cc9f7a wgpu: Allow unaligned writes to IndexBuffer3D
wgpu requires buffer copy sizes and offsets to be 4-byte aligned.
Unfortunately, ActionScript can perform 2-byte aligned uploads
into an IndexBuffer3D.

To support this, we now keep a copy of the IndexBuffer3D on the CPU.
When performing an upload to the buffer, we round the offset down
and the size up to the nearest 4-byte aligned value. The cpu buffer
is used to fill out the write with existing data, so that we don't
corrupt the contents of the GPU buffer.

To avoid introducing a new RefCell, I've changed IndexBuffer3D
to use a `Box` instead of an `Rc` to store the trait object.
This allows us to pass a mutable reference down to the backend.
2023-05-10 18:20:29 -05:00
Huw Pritchard b79b192a58 avm2: Implement PrintJobOptions 2023-05-09 20:51:44 -05:00
Aaron Hill 1908d85f65 avm2: Initialize `Object` instance vtable before other classes
Early class construction is tricky - `Object` defines properties
that need to get copied into subclass instance vtables, but `Class`
defines `prototype`, which needs to be copied into the *class* vtable
of `Object`.

To accomplish this, I've split out instance vtable initialization
into a separate `init_instance_vtable`. We call
`object_class.init_instance_vtable` before
`class_class.init_instance_vtable`, but do things in the opposite
order for `into_finished_class` (`class_class.into_finished_class` is
called before `object_class.into_finished_class`)
2023-05-07 07:46:30 -05:00
iwannabethedev 724df48186 avm2: Add AS 'length()' to XML. 2023-05-06 12:02:06 -05:00
friedkeenan 8d96626026 avm2: Add test for ApplicationDomain::getQualifiedDefinitionNames 2023-05-04 19:51:04 -05:00
Tom Schuster f6c0685992 avm2: Allow setting XML methods as properties 2023-05-04 19:34:14 -05:00
Toad06 ee7403952a avm1: Allow `button.enabled` to hold any value 2023-04-30 21:08:27 +03:00
Toad06 86c27078d3 avm1: `button.enabled = undefined` doesn't disable the button 2023-04-30 21:08:27 +03:00
Tom Schuster 69134d7d8d tests: Test XML.hasOwnProperty 2023-04-29 16:34:10 -05:00
relrelb 81dcc66c01 tests: Expand `as_broadcaster`
Verify that `AsBroadcaster` is actually a usable constructor.
2023-04-26 21:21:57 +03:00
Nathan Adams cc731a78ee avm2: Respect data, method and contentType in Loader.load() 2023-04-26 12:46:23 +02:00
Lord-McSweeney f412f62127 avm2/tests: use try_get_object in JSON/Add test for undefined receiver 2023-04-26 00:17:44 +02:00
Lord-McSweeney 58212ec280 avm2: Throw AVM errors for JSON operations (and add tests) 2023-04-26 00:17:44 +02:00
Aaron Hill 6eba8d07ee avm2: Implement MorphShape class and use it for MorphShape displayobject 2023-04-25 18:43:43 +02:00
Toad06 ad4dc943fa avm1: Fix some issues with buttons 2023-04-25 17:50:25 +02:00
Aaron Hill 4432c45eb3 avm2: Mark 'callee' property as non-enumerable on 'arguments' array
Some SWFs iterate over the 'arguments' array, and the 'callee' property
should not get enumerated.
2023-04-25 17:29:20 +02:00
relrelb ff7c458739 core: Accept borrowed strings in `NavigatorBackend::navigate_to_url`
This avoids some unnecessary clones.
2023-04-24 22:06:47 +03:00
Tom Schuster 8b3491fe53 tests: Update the XML abstract equality test 2023-04-23 22:07:54 -05:00
Aaron Hill 15af946cf1 avm2: Stop after first frame when movieclip doesn't extend MovieClip
It's possible to have a DefineSprite tag with multiple frames,
but with a corresponding SymbolClass that directly extends
`Sprite` (and therefore does *not* extend `MovieClip`). When this
happens, Flash Player stops after the first frame.
2023-04-23 16:48:38 -05:00
Aaron Hill 33e9713279 avm2: Fix get_super and set_super with normal methods
Doing `super.someNonGetter` gives you back a function object.
We were previously attempting to call normal methods as though
they were getters. Additionally, we were failing to properly
get the property from the superclass vtable.
2023-04-23 16:28:59 -05:00
Nathan Adams 4f4327b152 wgpu: Fix drawing a transparent bitmap with MSAA 2023-04-18 23:15:42 +02:00
Tom Schuster da689b7687 tests: Test XMLList.child 2023-04-11 14:49:32 -04:00
Nathan Adams 35f3a21110 core: Fix bitmapdata.floodFill() replacing X with X + test. Fixes #10642 2023-04-11 10:40:57 -04:00
Mike Welsh 89e9b15c60 tests: Improve test for `Graphics.beginBitmapFill` 2023-04-11 11:36:49 +02:00
Toad06 81d907b9f0 tests: `MovieClip.focusEnabled` in avm1 2023-04-09 14:11:24 -07:00
Tom Schuster 5289009959 tests: Add some tests for XML abstract equality 2023-04-09 12:02:20 -07:00
Mike Welsh 6ad5c30188 tests: Test for correct variables in `loadvariables_method` test 2023-04-08 13:37:25 -07:00
Mike Welsh 35810a8c7e tests: Add `log_fetch` option
Adds a `TestNavigatorBackend` that has the ability to log HTTP
requests for tests.
2023-04-08 13:37:25 -07:00
Mike Welsh a38f74d989 tests: Add `NavigatorTestBackend` 2023-04-08 13:37:25 -07:00
Tom Schuster d9e69563d3 avm2: Implement XMLList.copy 2023-04-07 12:29:49 -05:00
Udeshya 54a8672390
avm2: Trim xml text nodes when being parsed (#10341) 2023-04-06 22:41:46 -05:00
Aaron Hill 962cf92223 avm2: Implement Context3D.setSamplerStateAt
This fixes pixelated backgrounds in Fancy Pants World 4 Part 3
2023-04-05 16:44:07 -07:00
Toad06 5e165a0682 avm1: Fix some issues with `Selection.getFocus()` and `setFocus()` 2023-04-05 15:53:18 -07:00
Mike Welsh 83aff3c7ba tests: Add Julia fractal Stage3D test 2023-04-05 12:22:13 -07:00
Mike Welsh de80de731d tests: Add test for scrollRect within masker 2023-04-04 13:10:45 -07:00
Mike Welsh e21f3744b5 tests: Add visual test for TextField as mask 2023-04-04 13:10:45 -07:00
Nathan Adams 06bc4e1403 wgpu: Fix sync issue introduced in #9753 and added test 2023-04-04 11:11:57 -07:00
Mike Welsh 63aa67d196 tests: Add test for `Matrix3D.transformVector` and `deltaTransformVector` 2023-04-03 17:09:16 -07:00
Udeshya 34775965ea
avm2: Implement `Transform.pixelBounds` 2023-04-02 23:25:10 +00:00
AllinolCP f0a8e50be1 avm2: implement decodeURI 2023-04-02 14:49:07 -07:00
Tom Schuster 5a18a409f7 avm2: Only reject a single explicit namespace in XML 2023-04-02 16:09:03 -05:00
Toad06 35528913bf core: Make `ExternalInterface` support undefined values 2023-04-02 13:48:14 -07:00
Tom Schuster 86395f194f avm2: Strip BOM in ByteArray::toString 2023-04-01 12:48:22 -07:00
Aaron Hill 18f5ba18e9 core: Don't overwrite font descriptor with a duplicate
If a SWF contains multiple DefineFont tags with the same
font name (but different font IDs), the first tag will win
when a font is looked up by *name*. This affects the behavior
of EditText objects, which can have embedded HTML like
`<font face="MyFontName">` which performs a font lookup by name.

This fixes Fancy Pants World 4 Part 3, which contains two
DefineFont3 tags with the name FancyFont. The second font is
missing many glyphs, so using it causes us to be unable to
render the squiggle and life count text.
2023-03-31 22:47:00 -07:00
Nathan Adams fcaf462423 core: Fix set_pixels_from_byte_array respecting the bytearray position + tests 2023-03-31 21:32:15 -07:00
Mike Welsh 6fda813f0c tests: Add test for localToGlobal with zero scale object 2023-03-31 16:26:11 -07:00
Mike Welsh c7387eace4 tests: Add tests for hitTesting zero scale graphics 2023-03-31 16:26:11 -07:00
Nathan Adams 94e5aa8f34 core: Fix calculating dirty area of BitmapData.draw() with rotation 2023-03-31 16:57:52 +02:00
Nathan Adams f0ebefd624 tests: Add bitmapdata recursive draw test 2023-03-31 16:57:52 +02:00
Nathan Adams 78f9bb13d6 render: Fix PixelRegion::for_region_i32 for negative coordinates 2023-03-31 16:57:52 +02:00
Nathan Adams e614265c17 core: Move fill_rect from BitmapData to bitmap_data_operations, fixed a bug when using non-standard values, and added better tests for fill_rect showing the bug 2023-03-31 16:57:52 +02:00
Toad06 fea8e8c90a tests: `MovieClip.setMask` in avm1 2023-03-31 02:39:39 -07:00
Tom Schuster ce4ddee792 avm2: Shim flash.xml.XMLNode using XML 2023-03-31 00:11:52 -07:00
onkrot 5632ade09c avm2: Hookup `DisplayObject.opaqueBackground` 2023-03-29 23:11:01 -07:00
Tom Schuster d16a8726c9 tests: Add test for XML.childIndex 2023-03-29 14:40:29 -05:00
Tom Schuster bbf4363395 tests: Add test for XML.copy 2023-03-29 11:04:32 -05:00
Nathan Adams 42e23ce100 tests: Add tests for LoaderInfo properties that error 2023-03-28 11:57:00 +02:00
Adrian Wielgosik 4e84632609 avm2: Fix edge cases in RegExp constructor 2023-03-27 19:09:09 -05:00
Mike Welsh 87dad709b8 tests: Add test for `SharedObject.clear` 2023-03-26 22:22:27 -05:00
Aaron Hill 1f22f868a0 tests: Use antiAlias=4 in Stage3D tests
This is the only antialiasing level supported by Mesa lavapipe,
which we use to run our tests on CI.
2023-03-26 18:05:41 -07:00
Aaron Hill a52cb7461e wgpu: Implement MSAA support for Stage3D
When we receieve a nonzero 'antiAlias' parameter, we create
create a non-multisampled resolve buffer to use with WGPU.

Several tests were already requesting antialiasing, so their
output images are now anti-aliased without any changes to
the tests themselves.
2023-03-26 18:05:41 -07:00
Aaron Hill da6384b30e Warn instead of panicking 2023-03-26 17:22:52 -07:00
Aaron Hill 7f829dd646 avm2: Don't overwrite symbol class entry with a different SwfMovie
If you use a `Loader` to load an SWF containing a class that shadows
an already-defined class, the class definition from the Loader SWF
will be ignoredin favor of the already-defined class. This commit
applies this log to symbol classes as well - the symbol registry for the class
should continue to point to the existing MovieClip in the parent.
This results in the child SWF instantiating the class from the parent
SWF when the child places the affected movie clip on the timeline.

This fixes a bug in Fancy Pants World 4 Part 3, where the sub-level
SWF was replacing the symbol class entry for the parent 'shipInteract'
class with the dummy clip provided in the sub-level SWF (instead
of continuing to use the correct clip from the parent SWF).
2023-03-26 17:22:52 -07:00
yoganlava da0b245fb8 avm2: Fully implement XML.elements() 2023-03-25 23:12:51 -07:00
EmperorBale 8bb4f21065 avm2: Add test for function double borrow issue 2023-03-25 21:57:04 -07:00
Tom Schuster 53d9118834 avm2: Implement XML set for simple element cases 2023-03-25 20:40:44 -07:00
Aaron Hill b140029e95 render: Fix BitmapData.applyFilter with non-full sourceRect
Previously, we were scaling down the source image to fit into
the smaller sourceRect, instead of cropping at the original scale.
This broke the background textures in Fancy Pants World 4 Part 2,
as the scaled-down output image resulted in a smaller rectangle
being returned from 'getColorBoundsRect'

We now crop the image by properly constructing the UV-coordinate
transformation matrix. We were also using the wrong value for the
'destPoint' y coordinate, which I fixed.

This slightly changes the image output of two tests - the new images
now more closely match the Flash output.
2023-03-25 18:44:01 -07:00
Moulins 5b4096de8b wstr: Revert incorrect optimization in hash calculation
Calling `Hash::write_bytes` isn't guaranteed to be equivalent to a
sequence of `Hash::write_u8`.

Additionally, make sure the hash is truly prefix-free by hashing the
length first.
2023-03-25 18:27:51 -07:00
relrelb 39b53c76d6 ci: Deny warnings on Web
As suggested in https://github.com/ruffle-rs/ruffle/pull/6935#pullrequestreview-967181111.
2023-03-24 19:16:32 -07:00
Mike Welsh 1726d24098 tests: Add tests for calling undefined AVM2 function 2023-03-24 18:21:32 -07:00
Toad06 4161050db5 tests: `XML.getBytesLoaded` and `XML.getBytesTotal` in avm1` 2023-03-22 17:51:42 -07:00
Mike Welsh 44c9e3073c tests: Test full TypeError message in removeChild test 2023-03-22 17:13:36 -07:00
Adrian Wielgosik d77cf83e07 avm2: Fix si8/si16 opcodes 2023-03-22 22:55:43 +01:00
Nathan Adams edbdf224ae avm2: Skip BOM when reading utf8 from ByteArrays 2023-03-21 12:20:43 +01:00
Toad06 911982eb7d tests: Test MovieClip methods for loaded images 2023-03-20 01:36:04 +01:00
Huw Pritchard 645ff76bcd
avm2: Add 11 AS3 classes (#10003) 2023-03-20 00:19:31 +00:00
AllinolCP b69af5d70a tests: add tests for XML.parent() 2023-03-19 16:06:01 -07:00
Nathan Adams 078672782c wgpu: Skip Alpha/Erase blends with no parent Layer 2023-03-19 14:59:48 -07:00
Mike Welsh e76154009c tests: Add image tests for BitmapData.colorTransform 2023-03-19 09:59:13 +01:00
Nathan Adams ea424f3d1e avm2: Fix panic when constructing custom BitmapData from timeline 2023-03-19 07:47:40 +01:00
Nathan Adams ae25ace3f6 tests: Recreated edittext tests 2023-03-19 06:55:07 +01:00
Nathan Adams 909a399911 tests: Add visual test for font selection 2023-03-19 06:55:07 +01:00
Mike Welsh dfeba5330e tests: Add AVM1 BitmapData.hitTest test 2023-03-18 19:47:39 -07:00
Mike Welsh b173176fee tests: Add test for #9885
A simpliied test case to test the #9885, where a hang occurred when
a button is removed while executing code in a v5 SWF.
2023-03-18 19:25:16 -07:00
Nathan Adams 1004f3fee9 tests: Add a test for a shape with HAS_FILL_WINDING_RULE 2023-03-18 19:14:08 -07:00
Nathan Adams dc17f7dc30 tests: Add a test for rendering a self-intersecting glyph 2023-03-18 19:14:08 -07:00
Tom Schuster e9e342fe23 avm2: Implement String call handler 2023-03-18 17:51:22 -07:00
Tom Schuster 5aac938e86 avm2: Implement XMLList.text() 2023-03-18 12:18:24 -07:00
Tom Schuster c285c1eb75 avm2: Implement XML.text 2023-03-18 11:12:15 -05:00
Aaron Hill 580c18844e naga-agal: Remove 'do_extend'
This was a leftover from before we started usiung vec4 everywhere
for compatibility with AGAL. There are a few specific opcodes that
don't need extension, but it doesn't depend on the destination
register.
2023-03-17 20:11:59 -05:00
Aaron Hill 1e973af747 avm2: Implement Context3D.setRenderToTexture/setRenderToBackBuffer
In the process, I fixed a bug where we were clearing the depth
and stencil buffers with the incorrect value.

This makes Fancy Pants World 4 Part 1 playable to completion
(though there are still some rendering issues that need
to be fixed).
2023-03-17 20:11:59 -05:00
Aaron Hill d8a6195d67 tests: Use 'warn' log level for wpgu crates in regression tests
This makes the test output much less verbose.
2023-03-17 19:42:48 -05:00
Tom Schuster 750291c993 avm2: Stub XML settings 2023-03-17 14:25:19 -05:00
Aaron Hill 9ff6ee21df avm2: Handle early class lookup during parameter resolution
This factors out the early-resolution logic I added in `op_coerce`,
making it useable during paramter resolution as well. This lets
a static initializer reference the containing class in parameter
types, even though the ClassObject hasn't yet been initialized.
2023-03-17 13:23:14 -05:00
Aaron Hill ba88b52167 avm2: Correctly apply 'skip_next_enter_frame' to Loader
We were missing the initial 'set_skip_next_enter_frame(true)'
call, and we weren't properly clearing it in `enter_frame`.
Loaders appear to have the same behavior as MovieClips.

This makes us correctly run the first framescript for the loaded
SWF.
2023-03-17 12:44:56 -05:00
MrCheeze 8c180f97b6 core: Allow duplicate frame and scene labels (close #9943) 2023-03-17 12:54:16 +01:00
Mike Welsh 4c672bbfb8 tests: Update `SoundChannel.position` test
Currently ignored, but add a test case for the cached position
behavior (#9952).
2023-03-16 21:25:41 -07:00