Commit Graph

822 Commits

Author SHA1 Message Date
Toad06 8ce8b775a7 avm1: Fix coercion order in SWFv4 actions 2023-06-08 01:33:08 +02:00
Moulins b71b8f9de5 avm1: fix coercions for the `blendMode` property of display objects
`mc.blendMode = 3` is a valid way of modifying the blend mode of a DO;
on the other hand, booleans and objects *shouldn't* be coerced.
2023-06-08 01:18:06 +02:00
Aaron Hill 0e0399963e avm2: Throw exception when ExternalInterface is not available 2023-06-07 17:24:25 -05:00
Aaron Hill d2999a2572 core: Fix parsing of PixelBender sampleNearest and sampleLinear
This fixes a panic on startup for Sniper Team
2023-06-07 15:59:31 -05:00
Aaron Hill 5fd7dc2c9b core: Correctly handle '.' and '<' in obfuscated QNames
QName can contain characters like '.' and '<' as part of the
package or class name (though this requires editing the SWF
or using a nonstandard compiler). This broke our attempt to parse
generic type paramters by looking for '.<'

Instead, our 'Vector' special casing now operates on the unparsed
'AVMString' name, instead of attempting to construct a 'QName'.
This means that we don't need to handle generic paramters at
all for obfuscated names (which will never start with '__AS3__'
or 'Vector.<')

This fixes a bug in Red Ball 4v3, which has an obfuscated class
'!D.<H'
2023-06-06 18:12:58 -05:00
Aaron Hill 0d5ead4c02 core: Ignore newer PlaceObject tag in same frame with duplicate depth
If we have two PlaceObject tags in the same frame with the same depth,
only the first one actually places an object. The second one is ignored
(Flash Player logs a warning).
2023-06-06 14:50:07 -05:00
Nathan Adams 10134467c9 avm2: Don't error on removeChildren() for empty containers - fixes #11382 2023-06-05 18:30:08 -05:00
Aaron Hill 2cd518013c
wgpu: Don't skip alpha/erase blend modes for BitmapData.draw (#11323)
We can skip these when we're drawing to a fresh buffer, but not when we're blending over an existing BitmapData texture.
2023-06-02 21:16:05 +00:00
Aaron Hill 21429cc205 avm2: Add PixelBender bytecode parsing to ShaderData
We now parse PixelBender bytecode, and populate the parameters
from the bytecode on `ShaderData`. This is enough to progress
Steamlands, which needs to access dynamically set properties
on `ShaderData`

Bytecode execution is not implemented yet.
2023-06-02 15:23:32 -05:00
Aaron Hill 999e2f5b71 wgpu: Implement Context3D.setScissorRectangle 2023-06-02 14:56:14 -05:00
relrelb abb0e33431 chore: Use Rust's `OnceCell`/`OnceLock`
They were stabilized in Rust 1.70.0, which was released yesterday.
This removes the `once_cell` dependency.
2023-06-02 22:21:38 +03:00
Aaron Hill 8b257ef6da avm2: Always run `construct_frame` in `initialize_for_allocator`
When we create a DisplayObject from ActionScript, we should always
run `construct_frame` on it, regardless of what frame phase we
are currently in.

This fixes a regression in Fancy Pants World 4 Part 1, where entering
the first door produced an error.
2023-05-31 17:33:25 -05:00
relrelb df1cd29a12 tests: Expand `duplicate_movie_clip` 2023-05-30 23:10:36 +03:00
Aaron Hill d18df2d3f1 tests: Add non-power-of-2 texture test 2023-05-28 23:35:53 -05:00
Aaron Hill 0955ab40e6 avm2: Fix rounding behavior in BitmapData rectangle operations
Flash Player performs `x + width` and `y + height` as floating
point operations before `round_to_even`. This affects the extent
covered by a `Rectangle` in various BitmapData methods, as the sum
of two values might be large enough to be rounded up to a larger
value (when rounding `x` and `width` individually would have
produced a smaller overall extent).
2023-05-28 18:46:55 -05:00
Aaron Hill 3f93abffd5 avm2: Allow replacing and deleting XML attributes 2023-05-28 15:52:57 -05:00
Aaron Hill 14c6d1d959 avm2: Implement URLRequest.requestHeaders
These are directly set on the underlying navigator's HTTP
request type, and get printed out in our test navigator backend.

No validation of the header names is performed - on web, this will be
enforced by the browser.
2023-05-28 12:07:37 -05:00
Nathan Adams aeb089ac0f avm2: Move DisplayObject assignment into an initializer 2023-05-26 22:06:20 -05:00
Aaron Hill cf4ca543bd core: Use clone-on-write behavior for render list iteration
When we iterate over a render list (in order to call
`enter_frame`, `construct_frame, etc.) we need to be sure
that we iterate over all of the original `DisplayObjects`
in the list, even if the list is modified during iteration
(e.g. some ActionScript code calls `parent.addChildAt`).

Previously, `RenderIter` would repeatedly call `child_by_index`
on the original `DisplayObjectContainer`, up to the original
child count. If new DisplayObjects were inserted into the list
during iteration, we could miss some of the original DisplayObjects
in the list (as they are now at a greater position in the list).

To solve this, we now store the render list as an `Rc<Vec>`,
and use `Rc::make_mut` to modify it. See the comments
for more details.
2023-05-26 21:42:06 -05:00
Aaron Hill e98ff6a6d7 avm2: Add legacy handling for configureBackBuffer with SWF version < 30
With SWF version < 30, Context3D.configureBackBuffer throws
an error with a less informative message when the width/height
are out of range. Additionally, it seems to special case
the case width=0, height=0, antiAlias=0. enableDepthAndStencil=false,
and does *not* throw an error. This is relied on by Sniper Team.
2023-05-24 18:15:30 -05:00
Nathan Adams b9322ba93a desktop: Render game separately to UI, blit both onto surface 2023-05-24 23:50:48 +02:00
iwannabethedev 1e0714aaa1 core: Fix serialization of arrays with dynamic properties. 2023-05-23 19:46:24 -05:00
Aaron Hill 358beabf5a avm2: Add Matrix3D.[recompose,decompose,copyColumnTo,invert,determinant]
The Flash Player 'Matrix3D.recompose' method throws exceptions under
certain circumstances with the "quaternion" orientation style.
I haven't yet figured this out yet, so I've marked that case as a stub.

All of the implementations are based on the OpenFL code, with some
tweaks to match Flash Player's behavior.
2023-05-23 18:51:46 -05:00
Aaron Hill c53a903d35 avm2: Suppress events for selectable was_static TextFields
TextFields have a very unusual behavior - if they are selectable
and have `was_static`, they *block* the dispatch of mouse events when
they're targeted (not even the Stage will receive the event).
This only occurs when the TextField is actually targeted
(which requires mouseEnabled=true). With mouseEnabled=false,
the event will be dispatched with an ancestor as the target,
following the usual logic.

Also, TextFields now properly propagate mouse picks to
their parent if mouseEnabled=false. Previously, setting
mouseEnabled=false for a TextField made all mouse picks
cause a miss on it. This was the cause of the Turbo Kids
regression.

Fixes #10245
2023-05-23 17:57:06 -05:00
Nathan Adams afa78ebdfe avm1: Correctly send onUnload events for movies unloaded with GetURL2 - fixes #2422 2023-05-22 23:41:41 +02:00
Aaron Hill ace87861ce avm2: Make ByteArray.readMultiByte cut string off at null byte
We already had this behavior in `readUTF` and `readUTFBytes`,
but we need it in `readMultiByte` as well.
2023-05-22 16:01:50 -05:00
Aaron Hill b94f9f3043 avm2: Coerce function return value to declared return type
This can actually affect runtime behavior - if the return type is
declared as 'int', then an instance of a custom class will get
coerced to 0 when returned by the function.
'Plants vs Zombies Demo' relies on this - it has a function which
incorrectly returns an object instead of an array index, but the
value gets silently coerced to 0 under Flash Player.
2023-05-22 13:47:32 -05:00
iwannabethedev 18ea71959b tests: Add test for XML/XMLList hasSimpleContent/hasComplexContent 2023-05-22 06:17:37 -05:00
Aaron Hill 6ac4e5256d avm2: Check parent domain in export_class
The `export_class` function mirrors `export_definition`, and needs
to avoid exporting something already defined in a parent domain.
2023-05-21 17:37:54 -05:00
Aaron Hill 95b0b29310 avm2: Initial implementation of URLStream
This is based on URLLoader, and doesn't actualy 'stream' data -
it all becomes available once the request finishes. However, this
is good enough to get Sniper Team working.
2023-05-21 15:00:08 +02:00
TÖRÖK Attila 65117499fd chore: Bump regress and toml dependencies 2023-05-21 14:42:01 +02:00
TÖRÖK Attila e54f3fef8a tests: Make the audio backend tick every frame in the runner 2023-05-21 09:50:07 +02:00
iwannabethedev 7b12cb882f core: Fix error message in 'pixelDissolve()'. 2023-05-21 01:47:06 +02:00
iwannabethedev e74a543ebb core: Add visual test for 'pixelDissolve()' for AVM1. 2023-05-21 01:47:06 +02:00
iwannabethedev 9fa79a187e core: Fix wrong test print in test. 2023-05-21 01:47:06 +02:00
iwannabethedev 6f98d39c25 core: Implement 'pixelDissolve()' for AVM1. 2023-05-21 01:47:06 +02:00
iwannabethedev 1bd9f82496 core: Implements `BitmapData.pixelDissolve()` for AVM2.
The changes have automated tests for them.

The implementation has not been implemented or tested for AVM1 yet.
2023-05-21 01:47:06 +02:00
Aaron Hill ad77cb0209 core: Refactor Loader to properly load images
We now run all of the completion logic (including adding
the new DisplayObject as a child) in `Loader::movie_loader_complete`.
Previously, some of this logic was run from `Loader::preload_tick`,
which meant that loaded images did not have the logic run.

Also, `BitmapData` and `Bitmap` instances (with corresponding AVM2
objects) are now properly constructed for loaded images.
2023-05-20 18:35:10 -05:00
Toad06 b88e19ef6c avm1: Filter buttons that use a `keyPress` event 2023-05-21 01:13:26 +02:00
Aaron Hill 5d62ef90f2 wgpu: Use intermediate buffer for Context3DCommand::CopyBitmapToTexture
In a previous PR, I introduced an optimization that used
`copy_texture_to_texture` to copy directly from a BitmapData GPU
texture to a Stage3D GPU texture.

Unfortunately, this optimization is incorrect. A BitmapData GPU
texture can be modified at any time by normal AVM2 code - in
particular, in might be modified before we submit the encoded
`copy_texture_to_texture` command. This shows up in Sniper Team,
which re-uses BitmapData objects for multiple distinct textures.
The previous 'optimization' resulted in the wrong BitmapData contents
getting uploaded to a texture (since it was changed before the copy
command was submitted).
2023-05-20 17:38:26 -05:00
TÖRÖK Attila fa90ea9cc2 tests/visual: Save color and alpha difference in separate images
So the whole thing isn't invisible if the alpha channels matches.
Also only save the alpha difference if there is any.
2023-05-20 23:41:56 +02:00
TÖRÖK Attila 3d0b8cc849 tests/visual: Save actual image even if size is wrong
This should help with creating the initial expected image
when making new tests.
2023-05-20 23:41:56 +02:00
Aaron Hill 0864853d44 avm2: Allow passing `null` to `Context3D.setProgram`
This clears the vertex and fragment shader programs
(bringing the Context3D back to its initial state).
2023-05-20 16:23:03 -05:00
Tom Schuster 2493194d2f tests: Test XMLList set 2023-05-19 20:10:47 -05:00
Aaron Hill 6025878aab avm2: Respect SKIP_INVISIBLE for DisplayObject
Previously, we allowed mouse picks of certain invisible
DisplayObjects, even when HitTestOptions::SKIP_INVISIBLE
was set.
2023-05-19 08:12:00 -05:00
Aaron Hill 7619594b1c agal: Implement Float1 to vec4f conversion 2023-05-18 16:12:22 -05:00
Aaron Hill 7004e98b23 avm2: Don't validate Context3DVertexBufferFormat when buffer is null
This matches Flash Player's behavior - some SWFS try to pass in 'null'
for both the buffer and format.
2023-05-18 15:14:29 -05:00
Aaron Hill 75569e1311 avm2: Throw error for invalid Stage3D back buffer size 2023-05-16 17:36:22 -05:00
Aaron Hill bd2be88711 wgpu: Fix MSAA and depth buffer handling in SetRenderToTexture
When multisampling is enabled, we should create a new multisampled texture,
and use the existing texture as the resolve buffer. We also need to
call `update_has_depth_texture` to keep our pipeline aware of whether
or not we currently have a depth buffer attached.

Makes progress on #10641 (it has a stack overflow after
this PR, due to an unrelated issue).
2023-05-15 09:34:30 -05:00
iwannabethedev c86aed35a2 tests/core: Add test for BitmapData.draw() with ColorTransform. 2023-05-15 00:51:54 +02:00