Commit Graph

839 Commits

Author SHA1 Message Date
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
Nathan Adams 33064465b3 tests: Ignore stage3d_raytrace on WARP 2023-03-04 15:50:57 -06:00
relrelb 3967fe8e74 tests: Expand `movieclip_getbounds`
Add a case of uninitialized bounds.
2023-03-04 21:54:23 +02:00
Aaron Hill a4c8f27743 avm2: Implement Matrix3D.appendScale
This is based off the the MIT-licensed OpenFL code, which
just needed a few tweaks to convert it from Haxe to ActionScript.
2023-03-03 18:32:04 -06:00
Aaron Hill 59f4953730 avm2: Adding missing AGAL files to 'stage3d_raytrace'
These aren't necessary to run the included test.swf,
but they are needed into order to rebuild it from test.fla
2023-03-03 18:11:10 -06:00
Aaron Hill 2748b95c86 avm2: Improve Stage3D support for textures, register types, and opcodes
This is a very large diff, but most of it comes from test files and
output.

This PR ads partial support for the following Stage3D shader features:
* Normal (square), rectangle, and cube textures
* Varying and temporary registers
* Lots of opcodes

The combination of these allows us to get a raytracing program
fully working in Ruffle. I've included it as image test.
Currently, this test is very slow (about 90 seconds on my machine),
as the code I'm using (https://github.com/saharan/OGSL) includes
its own shader language and compiler. THe raytracing demo
first compiles its own shader language to AGAL, and then starts
rendering the scene.

Limitations:
* Many opcodes are still unimplemented
* Most non-default texture options (e.g. mipmaps) are not implemented
2023-03-03 15:58:46 -06:00
Aaron Hill 1d883688e0 avm2: Correctly check when toJSON is missing, and use vtable properties
We were previously calling `get_property` to determine if a `toJSON`
property exists, but that produces an error if the method is missing
on a sealed class.

Additionally, JSON serialization wasn't taking into account properties
from the vtable. All public properties (including fields, const fields,
and getter methods) get serialized.

Unfortunately, our vtable property order currently doesn't match
Flash's. I've hand-edited the test output for now (all of the actual
properties are there, just in a different order), and added a note
2023-03-03 15:34:26 -06:00
Adrian Wielgosik 1ba3ec0bf0 avm2: Implement BitmapData.getVector 2023-03-03 12:47:54 +01:00
Aaron Hill a07ff36726 avm2: Implement describeType
This includes all of the XML elements described in 'describeType' docs.
Unfortunately, the order of elements produced by Flash depends on
the iteration order of internal hashtables. As a result, the test
manually stringifies an XML object, sorting the stringified children,
to produce consistent output between Flash and Ruffle.
2023-03-02 20:37:59 -06:00
Nathan Adams fcaa17308c avm2: Workaround haxe calling addChild(this) before super() 2023-03-02 00:38:24 +01:00
Nathan Adams 6e5e8b13fc core: Use a lookup table in Color::to_un_multiplied_alpha to match Flash's output 2023-03-01 23:24:35 +01:00
CUB3D 4723c0414b avm1: Remove resolved todos, add comment and test about known reference launder issue 2023-03-01 22:36:39 +01:00
CUB3D 38f897eff4 test: Even more tests 2023-03-01 22:36:39 +01:00
CUB3D af9810c22e avm1: More scope fixes 2023-03-01 22:36:39 +01:00
CUB3D ca0e2488cb avm1: Dont double borrow the cache, update test output 2023-03-01 22:36:39 +01:00
CUB3D 6d4c04c1c3 avm1: Cleanup todos, add even more tests 2023-03-01 22:36:39 +01:00
CUB3D 6ba75d6045 avm1: Refactor movieclip path logic 2023-03-01 22:36:39 +01:00
CUB3D 6f13276341 tests: Uniform test naming 2023-03-01 22:36:39 +01:00
CUB3D 11d76fc2c4 tests: Add more string paths tests 2023-03-01 22:36:39 +01:00
CUB3D c71070f015 tests: Add string paths keypress event test, add support for keydown in input.json 2023-03-01 22:36:39 +01:00
CUB3D 619dbe8566 test: Add test for clip constructors and timers 2023-03-01 22:36:39 +01:00
CUB3D 71a58db8a4 test: Add test for unload and variable scopes 2023-03-01 22:36:39 +01:00
CUB3D 03f5fd8154 test: Add test for string paths aliasing 2023-03-01 22:36:39 +01:00
CUB3D 87947976d3 test: Add test for basic string paths 2023-03-01 22:36:39 +01:00
CUB3D b43510535f test: Add button v5/v6 tests 2023-03-01 22:36:39 +01:00
Aaron Hill 076016b1be avm2: Get XMLList 'filter' syntax working
This requires the ability to do a limited 'set_property',
as well as `get_enumerant_value`.

To prevent modification of XMLLists derived from queries,
I've introduced a `target` field on `XMLList`. This is
`None` for lists created with `new XMLList()`, and `Some`
when the list was derived from a query on an existing `XML`
/`XMLList`. We only allow `set_property` when `target` is `None`:
this is enough for filtering to work, and prevents silent incorrect
execution when trying to modify an existing node.
2023-03-01 12:04:02 -06:00
Aaron Hill 44a301e16a avm2: Add `attribute` and `attributes` methods to `XML/XMLList` 2023-03-01 10:51:21 -06:00
Aaron Hill 78c9de7b8f avm2: Fix constructing empty XMLList
A default empty text node should only be created for XML.
2023-03-01 15:57:34 +01:00
EmperorBale 93ce5e2328 tests: Extend loader_applicationDomain test 2023-02-28 13:04:24 -08:00
Nathan Adams f79015e201 render: Use swf Filter types where possible. Gradient types had to be split into duplicate classes to allow for different trait impls based on which gradient filter type it is. 2023-02-28 16:25:12 +01:00
Nathan Adams a7edeb4638 tests: Add avm2/gradient_glow_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams d869a6e0ab tests: Add avm2/gradient_bevel_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams 0a40a2d43f tests: Add avm2/glow_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams bfee81485d tests: Add avm2/drop_shadow_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams 238b25daf5 tests: Add avm2/displacement_map_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams 30a114a441 tests: Add avm2/convolution_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams ec605db19c tests: Add avm2/color_matrix_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams aabfc6c9c0 tests: Add avm2/blur_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Nathan Adams e240bf8472 tests: Add avm2/bevel_filter test for swf->core->avm2 and avm2->core->avm2 testing 2023-02-28 16:25:12 +01:00
Aaron Hill 54eb6e33ca avm2: Ignore XML comments and processing instructions by default
This matches the default value of the settings on XML.
2023-02-27 15:53:39 -06:00
Aaron Hill 82d03b4062 avm2: Ignore XML declaration and doctype
These are completely ignored by AVM2
2023-02-27 13:41:18 -06:00
Aaron Hill c04b463f1f avm2: Implement XML.children, XMLList.children, and related methods 2023-02-27 13:25:16 -06:00
Aaron Hill 7f58b92348 avm2: Implement encodeURI and encodeURIComponent 2023-02-27 12:40:39 -06:00
Nathan Adams cfcd257932 avm2: Xml(foo) converts foo to string 2023-02-27 17:37:28 +01:00
Aaron Hill f9fc4b3179
avm2: Store interfaces from superclases/superinterfaces in ClassObject (#9728) 2023-02-25 23:57:50 +00:00
Aaron Hill c7709dffec avm2: Handle Event::CData when parsing XML 2023-02-25 17:26:31 -06:00
Adrian Wielgosik 8bdf215462 avm2: Add a test for box-then-to-bool bug 2023-02-25 23:31:17 +01:00
Aaron Hill b26f2fd6fb
avm2: Initial incomplete implementation of XML (#9647) 2023-02-25 20:06:36 +00:00
EmperorBale 216bb1bb28 tests: Add test for duplicate definitions 2023-02-24 11:55:58 -08:00
Nathan Adams edd7f80341 wgpu: Fix blown out colors when transforming them above 100% - fixes #9698 2023-02-24 19:01:41 +01:00
Aaron Hill 455124d3ba render: Fix blending onto BitmapData contents
When rendering to an offscreen texture for `Bitmapdata.draw`,
we first render to a temporary frame buffer, and then copy the contents
of the frame buffer back to the target texture. However, this results
in blend modes being incorrectly applied - for example, rendering with
BlendMode.SUBTRACT will subtract against the framebuffer (which starts
with each pixel as 0x00000000), instead of the previous BitmapData
contents.

To fix this, we now use our texture target as the frame buffer
when performing `render_offscreen`. This ensure that we blend
over existing pixels (taking into account the `blendMode` provided
in the `BitmapData.draw` call).

When multisampling is enabled, we use a copy pipeline to copy
the existing contents of our texture to a fresh multisampled frame
buffer (the non-multisampled texture target becomes our resolve buffer).
2023-02-23 09:52:56 -06:00
Nathan Adams e17b154d47 avm2: Iterate the inheritance chain for class-symbol linkage 2023-02-22 22:27:13 +01:00
Aaron Hill c258423dc3 avm2: Allow resolving interfaces before ClassObjects are available
The Adobe Animate compiler can emit a 'newclass' opcode for
a concrete class before the 'newclass' opcodes for the interfaces
it implements. As a result, we cannot rely on looking up an interface
`ClassObject` when resolving a class's interfaces.

We now store a map of exported classes in `Domain`, and use this
to lookup interfaces before their `ClassObject`s have been created.

Additionally, `link_interfaces` was failing to consider superinterfaces,
which meant that methods from superinterfaces were not being copied
into the vtable. I've fixed this along with the other changes.
2023-02-22 14:41:01 -06:00
Bale 2cfa97e84d
avm2: ByteArray.readUTF/readUTFBytes should cut off after null byte (#9673)
* avm2: Fix #9668

* tests: Extend ByteArray test
2023-02-22 18:47:59 +00:00
Nathan Adams a550c877f6 tests: Update avm2/simplebutton_constr_params test to check the button on frame 2 2023-02-22 18:49:04 +01:00
Nathan Adams aef466f8f3 avm2: Implemented BitmapData.drawWithQuality 2023-02-22 17:36:55 +01:00
Lord-McSweeney 74640ed44e
tests: Remove ^M characters from Dictionary tests (#9656)
* Remove ^M characters from Dictionary test

Using Github's automatic line ending conversion to CRLF.

* Remove ^M characters from dictionary_delete test

* Remove ^M characters from dictionary_in test
2023-02-22 09:57:50 +02:00
nosamu 1e2ab9cd0e tests: Add new clipDepth test 2023-02-21 16:39:42 +02:00
EmperorBale fa6d01c505 tests: Extend `movielcip.gotoAndPlay` test 2023-02-17 18:46:43 -08:00
EmperorBale 46bd6bbee9 tests: Add test for scopechain resolution order 2023-02-18 01:37:12 +01:00
CUB3D f7b0c021a9 avm1: The this property should be mutable 2023-02-17 14:39:10 -06:00
Aaron Hill 4149913967
core: Introduce dedicated avm2 mouse picking logic (#9565)
The mouse picking behavior in AVM2 interacts in complicated
ways with `mouseEnabled` and `mouseChildren.` It's sufficiently
different from AVM1 that I decided to split the logic into separate
`mouse_pick_avm1` and `mouse_pick_avm2` methods.

The `mouseChildren` property is now fully implemented.
Additionally, the `click_block` tests now work correctly
under Ruffle.

Combined with the orphan-movie PR, this is enough to make
SteamBirds fully playable (though performance greatly degrades
over a course of a level).
2023-02-17 19:04:52 +00:00
TÖRÖK Attila c9864bbeb4 tests: Require the "mp3" feature of core as well, just to be sure. 2023-02-16 06:23:35 +01:00
TÖRÖK Attila 0e1bddff65 tests: Fix build when running from inside the `tests` folder. 2023-02-16 06:23:35 +01:00
Aaron Hill 4e25a4fcae avm1: Add ignored test for strange rewind behavior
Ruffle doesn't correctly remove certain objects from the stage
when processing an AVM1 rewind goto.
2023-02-15 15:21:29 -06:00
EmperorBale 1e12f2d49b tests: Add test for finddef opcode 2023-02-14 14:22:02 -08:00
TÖRÖK Attila 35e21ce51d tests: Add a regression test for SoundMixer.computeSpectrum() 2023-02-14 18:47:33 +01:00
TÖRÖK Attila 4d0fee0cf8 tests: Add TestAudioBackend, used only on request 2023-02-14 18:47:33 +01:00
Adrian Wielgosik 5eb887c628 avm2: Stub describeType to have .@name work 2023-02-13 23:55:00 +01:00
Aaron Hill a52a41de97 core: Fix stageX and stageY getters for MouseEvent
These getters were previously calling `local_to_global`
with the unused localX/localY coordinate set to 0. Howver,
`local_to_global` does a matrix multiplication, which in general
will depend on both the x and y values. This was causing the getters
to return incorrect results when any of the `transform.matrix` values
included a non-diagonal matrix.

We now call `local_to_transform` with the real `localX` and `localY`
values.
2023-02-13 21:19:20 +01:00
Aaron Hill c597f9f996 core: Fix Clippy lints on nightly 2023-02-13 03:38:54 +01:00
Bale 73e9fd55fb
avm2: Make sure scripts get initialized after all scripts have been loaded when lazy init is disabled (#9478)
* avm2: Initialize scripts **after** all scripts have been loaded

* tests: Add test for eager initialization
2023-02-11 00:38:38 +00:00
Aaron Hill 4b76d1b32a
core: Support using URLVariables as a POST request body (#9489)
This is needed by the Newgrounds API. We don't have the ability
to make fake requests to HTTP urls in our test frameworks,
so I haven't added any tests for this. However, I tested locally
that this allows the Newgrounds API to work (and got a medal
in Cloud Wars).
2023-02-11 00:18:10 +00:00
nosamu a2cd3ee06e tests: Update fills_and_lines expected image 2023-02-10 23:43:01 +01:00
golfinq 37ec94f95b Avm2: Implement Stage.invalidate 2023-02-08 17:47:21 -07:00
Adrian Wielgosik 61a5161a20 avm2: Convert most errors in get/set/initproperty to AVM errors 2023-02-07 18:50:15 -06:00
Adrian Wielgosik c844d2ab6f avm2: Only store actually-passed arguments to 'arguments' 2023-02-07 18:35:30 -06:00
Nathan Adams dff558170e avm2: Implement BitmapData.getPixels() 2023-02-07 19:10:25 +01:00
Nathan Adams 43d9c3deed avm2: Make sure SoundChannel.soundTransform always returns a value 2023-02-07 18:26:27 +01:00
Nathan Adams bc7773596b avm2: addFrameScript allows null to unset the script, and only allows one script per frame 2023-02-07 18:26:27 +01:00
CUB3D 48f4df51a5 avm1: Correct depth calculation for AVM1 clips pending removal and add tests 2023-02-06 10:53:45 -07:00
CUB3D 6b6e07c7cb test: Update unload fla 2023-02-06 10:53:45 -07:00
CUB3D 2d11a250da avm1: Retrieving the child of a container should prioritise lowest depth 2023-02-06 10:53:45 -07:00
CUB3D a356be15fe avm1: Only delay removals on AVM1, check for dynamic unload handlers 2023-02-06 10:53:45 -07:00
CUB3D 755425ebfa avm1: Delay clip removals when a child has an unload listener
When removing a clip, first check if it has an unload event listener somewhere
it's hierarchy.
If it does, enqueue the removal to happen on the next frame, by moving it to a negative depth.
2023-02-06 10:53:45 -07:00
Nathan Adams a220703618 core: Made PlayerBuilder take quality instead of setting it after the Player was made 2023-02-06 16:08:04 +01:00
Nathan Adams 1cb3ea7bf9 wgpu: Store quality, not sample_count, and calculate the correct sample count per format 2023-02-06 16:08:04 +01:00
Nathan Adams 00c7e8f634 avm2: Fixed bytearray compress/decompress methods setting position of resulting bytearray 2023-02-05 19:22:01 +01:00
Nathan Adams e73389aa71 wgpu: Implement blur filter 2023-02-05 18:41:43 +01:00
Nathan Adams 284a58c817 avm2: Implement BitmapData.apply_filter for ColorMatrixFilter 2023-02-05 18:41:43 +01:00
Nathan Adams 5e2f1a66eb tests: Enable tests that no longer need to be ignored 2023-02-04 15:26:45 -06:00
Nathan Adams 06361ce01d tests: Add overlay_onto_stage test to ensure blend buffers are cleared before use 2023-01-29 20:45:01 +01:00
Moulins e36b03bce9 core::html: correctly encode text in FormatSpans::to_html
Fixes issue #9327
2023-01-29 11:19:16 -06:00
CUB3D f829157deb avm1: Defining a local that already exists on the target of a with scope, defines it on the target not the parent 2023-01-29 18:05:25 +01:00
Nathan Adams 7b1c101c81 wgpu: Fix repeat & reflect gradients 2023-01-29 17:17:44 +01:00
Nathan Adams 85dc100ee9 avm2: Implement Sprite.dropTarget - though it's wrong right now 2023-01-29 00:52:52 +01:00
Nathan Adams d918d47f66 tests: Temporarily remove EditText from text_blocks_clicks as it's broken in ruffle atm 2023-01-29 00:39:06 +01:00
Nathan Adams 8108e64bfa tests: Add avm1 text_blocks_clicks test 2023-01-29 00:39:06 +01:00
Aaron Hill 184734267d tests: Deny unknown fields when deserializing test.toml files
This will catch typos and misplaced options when modifying tests.
2023-01-28 16:27:43 -06:00
Nathan Adams b14831417a tests: Added avm2 click_test test from #9287, ignored as it fails 2023-01-28 13:13:37 -07:00
Nathan Adams 666a55e503 tests: Added avm1 click_test test from #9287, ignored as it fails 2023-01-28 13:13:37 -07:00
Aaron Hill daeb132e53 tests: Handle trailing newlines more consistently
Previously, we would strip trailing newlines from the contents
of 'output.txt' files, and skip adding a trailing newline after
the final recorded `trace` call.

To reduce the amount of processing we do of expected/ruffle output,
and to make fpcompare tests easier, I've removed the special handling
of newlines. When recording `trace` calls, we now build up a single
large `String`, with a newline after every `trace` message. When
reading in an 'output.txt' file, we do not strip any newlines.

This required adding trailings newlines to lots of 'output.txt' files,
to match the behavior of Ruffle and Flash (the last 'trace' message
ends with a newline, just like every other 'trace' message).
2023-01-28 13:59:00 -06:00
Nathan Adams 48c9cdd5ad tests: Ported visual tests from ruffle-rs/visual-tests repo 2023-01-28 12:15:59 -07:00
Nathan Adams a6c6ae13fe tests: Adjust tolerance of existing image tests 2023-01-28 12:15:59 -07:00
Nathan Adams 051927775c tests: Clippy lint 2023-01-28 12:15:59 -07:00
Nathan Adams 9c4190b20b tests: Readd suffix to actual/difference files 2023-01-28 12:15:59 -07:00
Nathan Adams 67ec70d960 tests: Set default log filter to warn for wgpu 2023-01-28 12:15:59 -07:00
Nathan Adams cdb2c5fe04 tests: Allow image tolerance & max_outliers on image comparison tests. Changed all existing image tests to use 1 sample count since this changes them all anyway 2023-01-28 12:15:59 -07:00
Nathan Adams d70d9067ec tests: Fix clippy lints 2023-01-28 12:15:59 -07:00
Nathan Adams 4ef88eaaa0 tests: Fix imgchecks feature compiling 2023-01-28 12:15:59 -07:00
Nathan Adams c73aa5b9d5 tests: Add sample_count to render options 2023-01-28 12:15:59 -07:00
Nathan Adams cbe17c4455 tests: Filter early to avoid creating test info (and thus wgpu) for tests that won't run 2023-01-28 12:15:59 -07:00
Nathan Adams 9b43836d1d tests: Allow executing of with_renderer tests always, but image comparison is still gated 2023-01-28 12:15:59 -07:00
Nathan Adams 836468b6dd tests: Add player_options.with_renderer option, automatically set when image = true 2023-01-28 12:15:59 -07:00
Nathan Adams 6acf6009ef tests: Made PlayerOptions non optional (just empty default), and it works with a PlayerBuilder instead of a Player 2023-01-28 12:15:59 -07:00
Nathan Adams e614f788af tests: Refactor code so all testing goes through Test::test(), allows for approximations with custom hooks 2023-01-28 12:15:59 -07:00
Nathan Adams 8b02045c6b tests: Readd custom assert_eq 2023-01-28 12:15:59 -07:00
Nathan Adams a340318486 tests: Refactor runner methods to take in &Test and not direct values 2023-01-28 12:15:59 -07:00
Nathan Adams 56bc2b5051 tests: Added Test::should_run() 2023-01-28 12:15:59 -07:00
Nathan Adams dda8debadc tests: Move shared object tests to their own file 2023-01-28 12:15:59 -07:00
Nathan Adams 792d68d370 tests: Move TestLogBackend to runner 2023-01-28 12:15:59 -07:00
Nathan Adams 99da686822 tests: Move external interface tests to their own file 2023-01-28 12:15:59 -07:00