Commit Graph

1160 Commits

Author SHA1 Message Date
Nathan Adams 8cb6e5bdf0 wgpu: Implement drop shadow filter 2023-07-12 18:51:11 +02:00
Nathan Adams aba2394732 wgpu: Respect alpha for glows 2023-07-12 18:51:11 +02:00
Nathan Adams f150a32d86 core: Only scale filters with stage view matrix 2023-07-12 18:51:11 +02:00
Nathan Adams 1aa2ac28c2 wgpu: Slight opimitsation to blur filter by not needing to calculate full_width per fragment 2023-07-12 18:51:11 +02:00
Nathan Adams 30e7a1eac6 core: Account for filter size changes when drawing cacheAsBitmaps 2023-07-12 18:51:11 +02:00
Nathan Adams b30c522f9c wgpu: Implement glow filter 2023-07-12 18:51:11 +02:00
Nathan Adams d4b81cae5c avm1: Migrate XMLNode to NativeObject 2023-07-12 18:33:58 +02:00
Aaron Hill 9d3e96e3a4
render: Implement more Pixelbender opcodes, and fix matrices (#11896) 2023-07-09 16:54:26 +00:00
Adrian Wielgosik b38bd604db avm2: Fix Multiname-with-params formatting 2023-07-08 01:55:44 +02:00
Aaron Hill 61c50e636a
avm2: Convert `has_class_in_chain` to use a `GcCell<Class>` (#11494) 2023-07-07 16:22:38 -04:00
Aaron Hill 4cf0735692 avm2: Implement Utils3D.projectVector and Utils3D.projectVectors 2023-07-06 11:34:40 -04:00
Aaron Hill fb9dbd21b0 tests: Fix stage3d_blend test formatting 2023-07-06 11:18:39 -04:00
Aaron Hill 90dbcfca5d render: Fix writing to varying register in vertex shader 2023-07-06 11:18:39 -04:00
Aaron Hill c295e3e481 avm2: Implement NetConnection.connect with a null `command` 2023-07-06 01:20:34 -04:00
Aaron Hill 009fab1889 core: Expose `LoaderInfo.parameters` and fix other properties
When using a 'Loader', properties on the 'contentLoaderInfo' become
set during specific events in the load sequence. In particular,
'LoaderInfo.bytesTotal' becomes available during the first 'progress'
event.

Also, 'LoaderInfo.parameters' is now properly set from the URL query
parameters. In Flash player, this work even with filesystem urls
(e.g. 'file:///some/path/to/file.txt?paramOne=valOne' will load
a file named 'file.txt', setting and expose the parameter 'paramOne'
with value 'valOne' in `LoaderInfo.parameters`). This required some
cleanup to the desktop and test NavigatorBackend impls to strip
out query parameters when loading a parameter from disk.

Previously, we would set `SwfMovie.parameters` manually from the url.
Now, the various `SwfMovie` constructors automatically extract
query parameters from the provided url. Outside of `SwfMovie`,
we only append *extra* parameters (e.g. those set from `flashvars`).

This makes CPMStar ads work, since the loaded SWF needs to access
`LoaderInfo.parameters`
2023-07-05 19:47:16 -04:00
Aaron Hill 8ac8be7213 avm2: Implement Graphics.drawPath
The 'winding' argument and filling behavior described in the docs
are not yet implemented. However, this implementation is good enough
for Scratch to render its default cat image.
2023-07-05 19:21:50 -04:00
Aaron Hill bbb5619bc9 tests: Add TextField Event.CHANGE test and update test input format 2023-07-05 18:00:59 -04:00
Adrian Wielgosik 87ede6a052 avm2: Set correct `this` values in function calls 2023-07-05 22:36:20 +02:00
Aaron Hill 2d1da4d18e avm2: Throw TypeError when trying to parse malformed XML
Scratch detects if a string is valid XML by trying to construct
an XML object, and catching the thrown error.
2023-07-05 19:41:23 +02:00
Nathan Adams 4fc170e5bd avm1: Implement gradient filters conversions 2023-07-05 19:18:00 +02:00
Nathan Adams bfedfbaa98 avm1: Implement displacement map filter conversions 2023-07-05 19:18:00 +02:00
Nathan Adams 8a767492e6 avm1: Implement drop shadow filter conversions 2023-07-05 19:18:00 +02:00
Nathan Adams 40b4f9bafa avm1: Implement glow filter conversions 2023-07-05 19:18:00 +02:00
Nathan Adams 30027bc03e avm1: Implement convolution filter conversions 2023-07-05 19:18:00 +02:00
Nathan Adams df6064b2e9 avm1: Implement color matrix filter conversions 2023-07-05 19:18:00 +02:00
Nathan Adams b3629669bd avm1: Implement blur filter conversions 2023-07-05 19:18:00 +02:00
Nathan Adams 73bc637ad7 avm1: Implement bevel filter conversions 2023-07-05 19:18:00 +02:00
Aaron Hill e716b3fd7f avm2: Implement XML.descendants for attributes
We were previously only ever checking children,
and not attributes.

In order to avoid matching both attributes and elements
with a given name in 'descendants', `E4xNode::matches_name`
now checks `is_attribute` on the provided `Multiname`. This
requries changing several other parts of the codebase to
properly set this flag on `Multinames` provided by ActionScript.
2023-07-04 19:38:30 -04:00
Aaron Hill f7cbe3b7cd avm2: Implement Graphics.copyFrom 2023-07-04 16:12:29 -04: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
Nathan Adams 4ac13de2f3 wgpu: Switch PASS_SCALES to be accumulative scales, for better calculation of size upfront 2023-07-03 20:13:40 +02:00
Lord-McSweeney 7ad864ca02 avm2+tests: Implement Matrix3D.copyColumnFrom; add a test 2023-07-01 15:23:29 -04:00
Aaron Hill 6e1f00edf2
render: Implement more PixelBender features (#11800) 2023-07-01 13:50:43 -04:00
David Wendt 32524d3abd core: AVM2 display object allocators always ensure both halves of the display object are connected correctly 2023-06-30 16:14:28 -06:00
TÖRÖK Attila c7bbed958c tests: Add test of ScreenVideo FLVs (contributed by torokati44) 2023-06-30 16:14:28 -06:00
David Wendt 21b7e70d09 docs: Keep documentation of the old `num_frames` options until we can remove them 2023-06-30 16:14:28 -06:00
David Wendt 4f4a205637 tests: Add images to the netstream tests 2023-06-30 16:14:28 -06:00
David Wendt 61c269c636 docs: Document `num_ticks` and `tick_rate` 2023-06-30 16:14:28 -06:00
David Wendt 16c9cb4fdd tests: Add option to send ticks to the player instead of calling `run_frame`.
You can also specify a `tick_rate` in order to get ticks faster or slower than the stage frame rate.

We also enable video decode and ticks on the netstream tests, since our netstream impl requires ticks.
2023-06-30 16:14:28 -06:00
David Wendt 4944d81dd7 tests: Update the AVM1 test output to include event data. 2023-06-30 16:14:28 -06:00
David Wendt c00cd0537c tests: Add tests for AVM1 and AVM2 host FLV players. 2023-06-30 16:14:28 -06:00
Fancy2209 8f0a43f9d9
Add prependRotation, copyRowTo and copyRowFrom (#11698)
Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
2023-06-30 14:31:08 -04:00
Aaron Hill 9b8a8c9974 avm2: Correctly re-use objects in XML/XMLList call handlers and ctors
`XML(someXMLObj)` and `XMLList(someXMLList)` perform the
normal cast behavior (returning the same object), instead
of creating a new object like other arguments do.

This also applies to `new XMLList(someXMLObj)`
and `XML(singleElemXMLList)`
2023-06-28 21:16:05 -04:00
Nathan Adams 7e96a2fdad wgpu: Blur size is whole kernel width, minus one and half it for the shader 2023-06-28 22:42:31 +02:00
Nathan Adams c0e932422f wgpu: Change blur to 2-pass separable box blur, multiplied by quality 2023-06-28 22:42:31 +02:00
Niv.Kaminer 053bcf9376 core: Update sounds in rootless SWF (close #11666) 2023-06-26 16:59:01 -04:00
Nathan Adams 556ade2fa9 tests: Add ColorMatrixFilter visual test 2023-06-25 21:58:46 +02:00
nosamu 473c40864f tests: Add timeline filters test 2023-06-25 18:27:54 +02:00
Lord-McSweeney 2d02886f5a avm2+tests: Support CData in XML.toXMLString; add test 2023-06-25 00:25:47 -04:00
Lord-McSweeney 494902cf39 tests: Change image for blur filter test 2023-06-24 16:55:40 +02:00
Nathan Adams cdb0774642 core: Hook up DisplayObject::opaque_background 2023-06-24 01:42:04 +02:00
Nathan Adams 9795fc9311 core: Invalidate ancestors on scrollRect changes 2023-06-24 01:42:04 +02:00
Nathan Adams d49a8ce0e6 core: Invalidate cacheAsBitmap when drawing api is used 2023-06-24 01:42:04 +02:00
Nathan Adams cc8edb3bf1 core: Invalidate cacheAsBitmap when various more properties change 2023-06-24 01:42:04 +02:00
Nathan Adams 27db3e70b4 core: Invalidate cacheAsBitmap when transform changes 2023-06-24 01:42:04 +02:00
Nathan Adams 41991da624 core: Invalidate cacheAsBitmap when texts change 2023-06-24 01:42:04 +02:00
Nathan Adams 932291bbad core: Invalidate cacheAsBitmap when morphs change 2023-06-24 01:42:04 +02:00
Nathan Adams 8a3ccdd080 core: Invalidate cacheAsBitmap when graphics change 2023-06-24 01:42:04 +02:00
Nathan Adams c39217e139 core: Invalidate cacheAsBitmap when children are added or removed 2023-06-24 01:42:04 +02:00
Nathan Adams 287e721da8 tests: Add cacheAsBitmap + color transform test, to ensure invalidation when it changes 2023-06-24 01:42:04 +02:00
Niv.Kaminer 69b09ab1ef avm2: Implement Serialization for ByteArrayObject 2023-06-23 08:29:53 -04:00
Aaron Hill 26dfc6ba3e tests: Add BlendMode.MULTIPLY test 2023-06-22 14:23:15 +02:00
Nathan Adams fe48114414 tests: Increased tolerance of stage3d tests 2023-06-21 21:36:17 +02:00
Nathan Adams 6b76af2d40 core: Fix avm2button bounding box 2023-06-20 23:22:53 +02:00
Toad06 22ae6bfec3 avm1: Correct `WaitForFrame` and `WaitForFrame2` actions 2023-06-17 19:23:18 -05:00
Adrian Wielgosik 19b4bfe5d3 avm2: Extend array_concat test with new cases 2023-06-17 22:40:14 +02:00
Adrian Wielgosik 42347d7234 avm2: Extend core_exception tests with new cases 2023-06-17 22:40:14 +02:00
Adrian Wielgosik 6ccb6e7fdd Revert "avm2: Throw TypeError when 'astype' receives a null/undefined class"
This reverts commit ce0ba7795c.
2023-06-17 22:40:14 +02:00
Aaron Hill 69fce3f7f8
wpgu: Initial implementation of PixelBender shader execution (#11441)
* wpgu: Initial implementation of PixelBender shader execution

The implementation is split across four crates:
* `ruffle_render` now holds the main PixelBender bytecode parsing
   implementation (previously, this was in `ruffle_core`).
* `ruffle_core` holds some helper functions for converting between
   AVM2 `Value`s and the PixelBender vector types.
* `naga-pixelbender` (newly created) constructs a Naga `Module`
  from parsed PixelBender bytecode
* `ruffle_render_wgpu` sets up the render pipeline for the shader
  constructed by `naga-pixelbender`, and actually executes the shader.

The Actionscript-side shader parameters are passed in through uniforms.
This allows us to cache the compiled `naga::Module` and associated
wgpu types inside `ShaderData`, when it's first created. Each invocation
of a `ShaderJob` only needs to create a bind group and render pass.

Limitations:

* Only a few of the PixelBender opcodes are implemented - however, this is
enough to get Stemlands cannon rotation working, as well as a cool
"donut" shader that I found and included as a test.
* PixelBender matrix types are not supported.
* Only BitmapData is supported as an input/output type - Flash Player
  also supports using Vector and ByteArray
* ShaderJob execution is always synchronous.

* Adjust comments

* Address review comments
2023-06-15 22:50:24 +00:00
Aaron Hill f257979b86 avm2: Use a separate domain for playerglobals
We create a separate child domain, which is accessible
from the Stage and the root movieclip.

This prevents ActionScript from loading classes into the
special playerglobals domain (Domain.parentDomain is modified
to return null instead of the playerglobals domain when applicable),
so the native method lookup logic will never run for user code.
2023-06-15 12:57:39 -05:00
Aaron Hill 87850abd19 avm2: Improve support for deleting XML attributes and children
We now support deleting named children, as well as attributes.
Additionally, I've fixed our handling of `XML.parent()` - we now
properly set the parent when a child is created, and clear the parent
when `delete` is used.
2023-06-15 09:02:09 -05:00
Aaron Hill cd2c7f6f2f tests: Enable tracing_subscriber in tests
Previously, we weren't displaying any Ruffle logs when running tests.
2023-06-14 17:15:31 -05:00
AllinolCP e4d86ec9e7
core: implement screen resolution for capabilities (#11156) 2023-06-14 20:49:13 +00:00
Lord-McSweeney 6006aa82c2 avm2+tests: Support primitives besides null in MovieClip.addFrameScript; add test 2023-06-14 18:16:39 +02:00
Lord-McSweeney f5528aab75 avm2+tests: Implement Object.length and Object.init; add test for Object.length 2023-06-14 12:37:00 +02:00
Adrian Wielgosik 128416cccd avm2: Support Array(...) without new 2023-06-14 00:34:13 +02:00
Aaron Hill 40318f905e avm2: Implement call handler for XMLList
This delegates to the XMLList constructor, just as
the XML call handler delegates to the XML constructor.
2023-06-13 17:20:11 -05:00
Mike Welsh c4e4eba63f avm2: Implement BitmapData.setVector 2023-06-12 18:34:51 -05:00
Aaron Hill a006e96a44 avm2: Set named field in parent to null when child is removed
If a child named 'foo' is removed by the timeline (without
having been previous added/removed from the timeline by ActionScript),
then the 'foo' field in the parent will be set to null. This occurs
even if the 'foo' field in the parent is not currently set to
the child 'foo' (e.g. 'this.foo = someOtherObject' was executed by
ActionScript).
2023-06-12 17:33:02 -05:00
Aaron Hill bb53af36a5 avm2: Add ignored test for subclass with 'overriding' field name
The Adobe Animate compiler rejects a subclass that contains
a non-private field with the same name as a field in an ancestor
class (e.g. 'pub var foo:String' in both the subclass and superclass).

Unfortunately, Flash Player accepts this code, and creates a distinct
field for each class (even though they have the same namespace and
name). I suspect that this is caused by the optimizer replacing the
field accesses with internal slot accesses.

I've added an ignored test demonstrating this behavior - getting Ruffle
to reproduce it will be tricky.
2023-06-12 15:16:10 -05:00
Aaron Hill ce0ba7795c avm2: Throw TypeError when 'astype' receives a null/undefined class 2023-06-12 02:31:03 -05:00
Lord-McSweeney 4d8feeab2e avm2+tests: Fix String.substr with negative second value, add tests 2023-06-10 15:48:45 -05:00
Aaron Hill cfb23d1f97 avm2: Implement AMF serialization of XML objects 2023-06-10 12:13:07 -05:00
Nathan Adams 38a3f67000 avm1: Don't create _levelN for unloadMovieNum(N) 2023-06-10 10:37:15 +02:00
AllinolCP 44ff49aa53
core: Fix status code implementation for AVM1 and implement HTTPStatusEvent.HTTP_STATUS for avm2 (#11360) 2023-06-10 03:06:26 +00:00
Toad06 2894f01d50 avm1: Implement `MovieClip.lineGradientStyle` 2023-06-09 17:36:34 +02:00
Toad06 181aac46b0 avm1: Don't fail if base clip is invalid in `GetProperty`/`SetProperty` 2023-06-09 16:59:27 +02:00
Aaron Hill 59b219cda6 avm2: Run 'nested goto frame' for entire Stage and orphans
When we run a 'goto', a weird "nested frame" gets triggered.
Previously, we were only calling `construct_frame` on the target
MovieClip as part of this "nested frame". However, Flash Player
seems to treat this (in some ways) like a normal frame - *all*
objects on the Stage (and orphans) have `construct_frame` called.

In particular, `gotoAndStop`/`gotoAndPlay` is called during
an "enterFrame" event handler, then unrelated objects on the Stage
will have their children constructed during the execution of
`gotoAndStop`/`gotoAndPlay`. The same logic holds for frame scripts.

This fixes a bug in Steamlands, which relies on children on the main
timeline being constructed immediately following a call to `gotoAndStop`
on an orphan (originally triggered from an "enterFrame" handler).
2023-06-08 22:17:27 -05:00
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
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
Aaron Hill c73f68207b avm2: Add support for orphan Loader instances
Despite not being MovieClips, Loader instances appear to get
the same kind of orphan handling - you can instantiate a
Loader and call 'Loader.load' without ever adding it
to a parent, and the loader will still run.

I've changed the movie code to work with a new `DisplayObjectWeak`
enum. Currently, this just supports `MovieClip` and `Loader`,
but it can easily be extended if we ever need other weak display
objects.

This also fixes a bug where we were adding the loaded MovieClip
as a child of the Loader slightly too early.
2023-03-16 20:55:06 -05:00
Aaron Hill 32f8330199 avm2: Implement xml descendants operator, and XMLList.toXMLString
This includes the 'GetDescendants' opcode, which is used by the
the 'xml..elementName' syntax. The 'XMLList.toXMLString()
impl makes it much easier to write tests for this.
2023-03-16 18:00:20 -05:00
Nathan Adams 933dadea24 avm2: Implement Graphics.lineGradientStyle and Graphics.beginGradientFill 2023-03-16 23:06:22 +01:00
Nathan Adams 70cdf1686d avm2: Implement Graphics.lineBitmapStyle and Graphics.beginBitmapFill 2023-03-16 23:06:22 +01:00
Nathan Adams 7202946003 tests: Add tests for Graphics commands (line/curve/move) 2023-03-16 23:06:22 +01:00
Nathan Adams d7e5e0b840 tests: Add tests for Graphics shapes 2023-03-16 23:06:22 +01:00
Tom Schuster 28b5c9051c avm22: Stub Namespace.prefix and Namespace.uri 2023-03-16 16:52:37 -05:00
Tom Schuster d2754bc599 avm2: Stub XML.namespace 2023-03-16 16:52:37 -05:00
Nathan Adams 8a2d440323 avm2: Fix BitmapData.hitTest for out-of-bounds values 2023-03-16 22:31:55 +01:00
Nathan Adams a010bd0f7a avm2: Implement BitmapData.hitTest 2023-03-16 22:31:55 +01:00
Aaron Hill 04babed66c avm2: Implement XML.appendChild for XML objects
This adds a reference to the passed-in XML object to
the children list. The object will compare === with
'parent.children()[newChildIndex]`
2023-03-16 15:48:36 -05:00
Aaron Hill 8b92b2cf7c avm2: Implement adding attribute to XML object
We only support values that are neither XML nor XMLList,
since we can't yet properly stringify those.

Attempting to modify an existing attribute throws an error.
2023-03-16 14:41:01 -05:00
EmperorBale fe3ba63441 tests: Add test for Namespace 2023-03-16 12:04:29 -07:00
Aaron Hill 1dd0d237ab render: Correctly handle BYTES_4 vertex data
Each byte gets normalized into a float in the range [0, 1]
2023-03-16 13:20:11 -05:00
Nathan Adams d22b07167c avm2: Implement XML.nodeKind 2023-03-16 07:34:20 +01:00
Aaron Hill 3232690c8e avm2: Add DoAbc2 tag name to GlobalInit call stack node
This can help determine which DoAbc2 file contains the script
initializer that appears in a stack trace (though the name
can be empty).
2023-03-16 05:57:04 +01:00
Aaron Hill b140ce6d97 avm2: Implement XML construction from XML and XMLList objects 2023-03-16 05:04:26 +01:00
TÖRÖK Attila 96d1f19e6c
chore: Port to bitflags 2.0.0
* Bump bitflags to 2.0.0
* Sprinkle Clone, Copy, Eq, PartialEq, and Debug derives where needed
* Call `bits` on bitflags, as it is now a method
* Switch from `from_bits_truncate` to `from_bits_retain` on bitflags where needed
* Bump h263-rs for the bitflags 2.0.0 dependency

As part of porting to bitflags 2.0.0, see:
https://kodraus.github.io/rust/2022/10/07/bitflags2.html#upgrading-to-2x
2023-03-15 20:06:10 -07:00
Nathan Adams 9c0e199fa4 avm2: Throw AVM error for null arg in removeChild() 2023-03-16 00:14:22 +01:00
Aaron Hill 4618511771 avm2: Add custom call handlers and implement it for XML
The XML call handler is implemented as 'new XML(arg)',
so we get all of the related string coercions for free.

Our various native tables are starting to get somewhat wasteful -
if we add any more, we might want to consider a more compact
representation.
2023-03-15 16:47:32 -05:00
Tom Schuster d7f99527db avm2: Partly implement XML.toString 2023-03-15 16:18:35 -05:00
Aaron Hill ccf263fdf4 avm2: Implement Array.removeAt 2023-03-15 14:45:57 -05:00
Aaron Hill ef719c323e avm2: Add several more Matrix3D methods
These implementations are ported from the MIT-licensed OpenFL
code.
2023-03-15 11:02:27 -05:00
Jay Sackwild 4707a6b0e9
core: Enable click events on non-selectable text fields (#10005) 2023-03-15 11:01:33 +00:00
Nathan Adams c116f29821 core: Run avm2 timers when rootless 2023-03-15 10:18:32 +01:00
Nathan Adams 22d6d21196 tests: Add avm2/rootless test for detaching and reattaching movie roots 2023-03-15 10:18:32 +01:00
Nathan Adams 853a2cdcc1 avm2: Implement BitmapData.threshold 2023-03-15 01:24:20 -07:00
Aaron Hill 6bf17158cf avm2: Skip running enter_frame for children as well
When we skip running a frame for a MovieCilp, we skip all
of its children as well. However, this skip 'counts' as
a skip for any children that already wanted to skip their next
frame. For example, say  we create three objects in ActionScript,
and arrange them like 'obj1 -> obj2 -> obj3'.
The first 'obj1.enter_frame' call will not run a new frame
for any of the objects, but next time, 'obj1.enter_frame'
will run a new frame for all of the objects.

This fixes jacksmith, which was missing a frame1-framescript
due to 'enter_frame' getting incorrectly run for a deeply
nested child.
2023-03-14 23:19:53 -07:00
Aaron Hill c004101bfe core: Cache 'width' and 'height' in Bitmap when BitmapData is set
If you call 'BitmapData.dispose()', any Bitmap objects using it will
continue to report the original 'width' and 'height' values to
ActionScript. The values only refresh if you explicitly do
'Bitmap.bitmapData = bitmapDataObject' (including with the same
object).

Fancy Pants Adventure World 4 relies on this - it calls
BitmapData.dispose(), and then uses the width and height from
a previously-constructed Bitmap object.
2023-03-14 23:00:08 -07:00
Tom Schuster 1f8dccf5a2 avm2: Support wildcard/any name in XMLList get_property_local
This is similar to #10018. Improves #8330.
2023-03-14 20:00:05 -05:00
nosamu cd1a0326e7 tests: Extend URLVariables test 2023-03-13 16:49:43 -07:00
Aaron Hill 97d6de1a46
avm2: Improve handling of timeline-removed orphans (#9928)
When a DisplayObject is removed from its parent by a RemoveTag, it still runs its framescript for the current frame (but with 'this.parent == null'). It then stops executing entirely, unlike ActionScript-removed orphans, which continue to execute indefinitely.

Additionally, objects created by ActionScript during a frame skip their next 'enterFrame' logic (but still receive an enterFrame event). This results in the currentFrame lagging one frame behind objects that were placed by the timeline during the same frame.

The combination of these two changes lets us greatly simplify frame lifecycle handling for orphan movies. Most of the orphan stages were unencessary, and the remaining ones run in the same phase as the normal Stage-descendant objects.
2023-03-13 23:37:11 +00:00
Tom Schuster 5646e93b0c avm2: XML child/attribute should support the wildcard 2023-03-13 18:13:53 -05:00
Aaron Hill 66aad3ebc5 core: Use a separate matrix for stage alignment and HiDPI scaling
The stage alignment settings viewport_scale_factor should *not* be
applied to `Stage.transform.matrix`, which is only ever changed
as a result of explicit modification from ActionScript. Instead,
alignment and scaling are performed a separate step, which is
transparent to ActionScript.

I've implemented this through a new `viewport_matrix` field,
which is used during stage rendering and mouse coordinate
transformation.

This makes Stage3D instances properly scale - previously, they
would render unscaled. The linux standalone Flash Player doesn't
seem to use HiDPI mode, so I didn't realize that this was a bug
until now.

In the process of implementing this, I discovered and fixed a bug
with how we handle changing the viewport size under winit.
Calling `self.window.set_inner_size` does not immediately take
effect (at least on X11) - calling `self.window.inner_size()`
will report the old size until the next resize event.
Since build our Stage matrices from `self.window.inner_size()`
(and start running the SWF) immediately after `RuffleEvent::OnMetadata`,
we would run a few SWF frames with an incorrect viewport size. This
is visible to SWFs that have the scale mode set to "noScale", and
could break SWFs that expect the initial viewport size to be
the movie size. I've fixed this by delaying SWF execution until
we get a Resize event (if `self.window.inner_size()` does not
immediately report the size we set).
2023-03-13 02:02:40 -05:00
Aaron Hill de8448e00a
avm2: Implement Stage3D depth test, blend factors, and fix bugs (#9845) 2023-03-12 23:43:58 +00:00
Tom Schuster e266e941f6 tests: Add basic test for XML wildcards 2023-03-12 18:32:11 -05:00
Tom Schuster 2d9c1a3829 tests: Test XML child 2023-03-12 18:06:13 -05:00
TÖRÖK Attila ea3fdfa27e tests: Add a visual test for gradient focal point clamping 2023-03-12 23:54:59 +01:00
Jay Sackwild 1deebc87e8
Support click events on movie clips containing text fields (#9995)
Remove code that prevents click events from working on text fields within movie clips
2023-03-11 22:19:48 +00:00
TÖRÖK Attila b87fe2d335 tests: Add visual tests for basic video decoding and color conversion
Including source files and notes on how the SWFs were made.
2023-03-11 21:32:18 +01:00
TÖRÖK Attila b661e16927 tests: Add `with_video` option to build video decoders into the visual test runner 2023-03-11 21:32:18 +01:00
Aaron Hill 7b932ca84b avm2: Implement special XML/XMLList method calling behavior
When an XML object has simple content, you can call non-XML
methods directly on it - it will internally be stringified,
and the method will be called on the resulting string.
This lets `new XML("<p>Some content</p>".split(' ')` work.

Similarly, an XMLList object with a single XML child will
forward non-XML method calls to that object.

This PR implements this logic (based heavily on avmplus)
2023-03-11 00:51:45 -06:00
Aaron Hill 8c91c734c3 core: Only apply 'unload' and 'removed' logic to AVM1
I've also renamed these methods to 'avm1_unload' and
'avm1_removed', to make it clear that they don't
apply to AVM2.

This was causing us to incorrectly skip mouse picks,
and remove masks.
2023-03-09 12:34:16 -06:00
Aaron Hill fc223e959b avm2: Implement avmplus.getQualifiedClassName
This appears to be the same function as
'flash.utils.getQualifiedClassName'
2023-03-08 16:59:40 -06:00
Aaron Hill 8ac64289b3 avm2: Handle coercing to a class while it's being initialized
I think this might have been broken by
https://github.com/ruffle-rs/ruffle/pull/9506, but we didn't have
proper test coverage.

If we execute a 'coerce' opcode for a class while it's being
initialized (which can happen by running a method from a static
initializer), we'll be unable to resolve the ClassObject using
`resolve_type`.

This is the only case where this can happen - any
superinterfaces/superclass will already be fully initialized
when we're running a class initializer. Therefore, we can
try to lookup the class from the `Domain`, and check if it
directly matches the class of the object we're coercing
(ignoring superclasses and interfaces).
2023-03-08 16:38:24 -06:00
Aaron Hill c6c021f7f6 core: Fix setting certain DisplayObject properties to NaN
This doesn't perfectly match Flash's behavior - I haven't been
able to reproduce the values produces when the DisplayObject
starts out with certain 'Matrix' values (a non-zero 'b' or 'd').

Howver, when the 'b' and 'd' matrix values are both 0, setting
'dobj.rotation = NaN' has no effect on the matrix, while
'dobj.scaleX = NaN' and 'dobj.scaleY = NaN' both treat 'NaN'
as 0 for the purposes of updating the matrix.

This fixes the tack shooter in Bloons Tower Defense 3, which
tries to set 'rotation = NaN' for spawned tacks.
2023-03-08 16:17:38 -06:00
Aaron Hill 2c1936db18 avm2: Fix QName::from_qualified_name for Vector.<some_ns::Type>
We weren't handling names like
`__AS3__.vec::Vector.<rs.ruffle.CustomClass>`
2023-03-08 15:15:55 -06:00
EmperorBale 613d4e3160 tests: Add test for `unescape` 2023-03-07 23:49:55 -08:00
Aaron Hill 7ab7c31bb6 avm2: Run orphan framescripts that didn't get a chance to run
This is necessary to make Steambirds get past the preloader screen.
All of the previous tests continue to pass with this change.

This commit modifies the existing test to start from within
the symbol_class constructor, instead of a frame script. In
this situation, a freshly-created orphan with a framescript will
run directly after the constructor returns, *before* an enterFrame
handler for the same orphan. I've verified that this modified test
fails without my change.
2023-03-07 18:29:23 -06:00
Aaron Hill 93834b63de avm2: Don't allow mouse picking to hit a mask
Masks restrict the region where the maskee can be hit,
but the mask cannot itself be the target of a mouse click
(assuming that it's on the stage).
2023-03-07 17:34:06 -06:00
Aaron Hill b27bcf367c avm2: Fix handling of completed timers
It's possible to call 'start()' on a timer
that has currentCount >= repeatCount. This will
cause the timer to tick exactly once, and then stop agian.

We were incorrectly reporting 'timer.running' in such a scenario:
'running' should be reported as 'true' up until just before the
'TimerEvent.TIMER_COMPLETE' is fired.

This fixes gaining money from bloon popping / level completion
in BTD5.
2023-03-07 16:56:29 -06:00
Aaron Hill b8f0de8171
avm2: Export Vector classes in public __AS3__.vec namespace (#9879)
Previously, the Vector$ classes were only exported in the internal 'AS3.vec' namespace, which is used by older ActionScript code. However, newer ActionScript code can also access these classes through the public 'AS3.vec' namespace, via 'getDefintionByName'.

We now export these classes in both namespaces. In the public 'AS3.vec' namespace, they are exported like 'Vector.' instead of 'Vector$uint'
2023-03-07 22:22:24 +00:00
TÖRÖK Attila 2fca22bd4a tests: Add radial gradient visual regression test 2023-03-07 20:35:29 +01:00
Aaron Hill 1a7022c30b avm2: Consider noninteractive child/drawing when mouseEnabled=false
We still want to propagate these hits to the parent, which may
be able to handle them. My existing tests missed this case,
since all of the parent objects had content which was
behind the child content. When the only clickable content
comes from a child with 'mouseEnabled=false', we should
still fire an event targeting the parent (when applicable
based on the parent's flags).

This fixes dragging on the background (without any scenery present)
in Steambirds.
2023-03-07 08:14:22 -06:00
Aaron Hill d72a8e7125 core: Run frames for 'orphan' AVM2 MovieClips
When a MovieClip is an 'orphan' (it has no parent),
it still has frames run (including frame scripts). Some SWFS
like SteamBirds and 'This is the Only Level TOO' rely on this behavior,
so we need to implement it.

The overall idea is straightforward - we keep a global list of
orphan movies, which we add to whenever we unset the parent for a movie.
This list stores weak references for consistency with Flash.
When we run a frame, we process entries in the root movie list,
in addition to the normal recursive processing from the `Stage`.

However, exactly matching Flash's output turned out to be quite tricky.
The particular sequence of calls I make in `run_all_phases_avm2` makes Ruffle
pass two complicated test cases, but there could still be lurking bugs.

This is enough to get SteamBirds to the first level (which doesn't
render due to a different error).
2023-03-06 20:53:35 -06:00
Nathan Adams 026efe7f18 render: Moved out some Gradient fields into webgl as it's no longer needed in wgpu 2023-03-06 23:22:09 +01:00
Nathan Adams 622abe60d1 wgpu: Extract T->Color lookup from gradient shader to Mesh construction 2023-03-06 23:22:09 +01:00
Aaron Hill fde46a72a4 avm2: Fix mouse picking on MovieClip in 'button mode'
We were previously performing a redundant 'self.hit_test_shape'
call in 'avm2_mouse_pick'. All of the logic in that function
is handled in `avm2_mouse_pick.` Additionally, this call happened
before we tested out children, which would result in us targeting
a parent's drawing instead of aa child.
2023-03-06 15:57:46 -06:00
EmperorBale 730115b1a0 tests: Extend proxy tests 2023-03-05 21:32:40 -08:00
EmperorBale 46ffd31f99 tests: Extend QName tests 2023-03-05 21:32:40 -08:00
Aaron Hill 1e75e7e60a tests: Don't run render-required tests when WGPU is unavailable 2023-03-05 18:36:55 -06:00
Aaron Hill bb5e568333 avm2: Stop after the first DisplayObject-linked class in the chain
Surprisingly, Flash allows mutliple classes in an inheritance chain
to hav a linked `class_symbol`. When we instantiate a `DisplayObject`,
we need to stop at the first such `class_symbol` we find. This means
that any fields set from named children will *only* be set in the
first class we find, not in any of the parent classes (as their
corresponding library symbol will not be instantiated).

Previously, we would continue looping even after we found a
`class_symbol`, resulting in the furthest ancestor *winning*
the `set_object2` call.
2023-03-05 18:04:02 -06:00