Commit Graph

5036 Commits

Author SHA1 Message Date
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 2549990e2e avm2: Implement String.prototype methods + valueOf 2023-03-16 03:43:37 +01:00
Aaron Hill 16ff2a17e3 avm2: Stub TextureBase.dispose 2023-03-15 21:13:01 -05:00
Aaron Hill acbc802c94 avm2: Fix VertexBuffer3D.uploadDataFromByteArray size calculation
We were ignoreing 'data32PerVertex'.
To make the code clearer, I've renamed the variable to
'data32_per_vertex', and made it a 'u8' (as it has a maximum of 64)
2023-03-15 19:52:09 -05:00
nosamu 6eeb2de213 avm2: Stub flash.text.TextFormat.display getter and setter 2023-03-15 16:51:58 -07:00
nosamu 9a7b8c7e6a avm2: Add flash.text.TextFormatDisplay class 2023-03-15 16:51:58 -07:00
Nathan Adams 9c0e199fa4 avm2: Throw AVM error for null arg in removeChild() 2023-03-16 00:14:22 +01:00
Aaron Hill 92d6d652b4 avm2: Stub generateFilterRect, setStencilReferenceValue, and setSamplerStateAt
These are needed by Fancy Pants World 4
2023-03-15 17:53:07 -05:00
nosamu 0ac697059f avm2: Stub Loader.unloadAndStop 2023-03-15 15:08:13 -07: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
Bale bb2d88b1d8 chore: Fix typo in comment 2023-03-15 13:57:58 -07: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 9e6a1f3234 core: Slightly neater way to get root_mc in context_menu.rs 2023-03-15 10:18:32 +01:00
Nathan Adams c116f29821 core: Run avm2 timers when rootless 2023-03-15 10:18:32 +01:00
Nathan Adams a87bbfb40e core: Don't panic flushing AVM1 sharedobjects if there's no root movie 2023-03-15 10:18:32 +01:00
Nathan Adams 75bf002fc6 core: Make Stage::root_clip() return Option 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
Lord-McSweeney a00af10182 avm2: Fix stub type for Responder 2023-03-14 08:18:56 +01:00
Nathan Adams 74d424e82f avm2: Add ParamtersExt::get_value 2023-03-14 07:35:52 +01:00
Nathan Adams df29536197 avm2: Document ParametersExt and replace get() with [] 2023-03-14 07:35:52 +01:00
Nathan Adams fb0c9fd481 avm2: Make ParametersExt expect() values to always exist from AS 2023-03-14 07:35:52 +01:00
Nathan Adams 85f1b5b428 avm2: Replace get_object_of_class with get_object as coercion already happens in AS definition 2023-03-14 07:35:52 +01:00
Nathan Adams 4fd0db2791 avm2: Introduce ParametersExt and use it inside bitmapdata 2023-03-14 07:35:52 +01:00
EmperorBale b880cfec7e core: Update regress to version 0.5 2023-03-14 07:14:17 +01:00
nosamu e1c6fc33e9 avm2: Implement URLVariables.decode 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 fea885f3af render: Implement Context3DTextureFormat.BGRA using an RGBA texture
Webgl doesn't support BGRA textures, so this lets us use
Stage3D textures on the web backend. As a bonus, this speeds up
uploading an BitmapData to a Context3dTextureFormat.BGRA texture,
since we no longer need to change the format before copying.

This makes Solarmax2 playable on the web backend.
2023-03-13 13:30:15 -05:00
Adrian Wielgosik 38c585a8f9 avm2: Store the activation class on method 2023-03-13 10:23:08 -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
Nathan Adams b527054a1e
render: Make retrieve_offscreen_texture pass the raw buffer (#9936) 2023-03-13 00:00:42 +00: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 3d29b81a8c avm2: Support any name in XML get_property_local
Fixes #9999
2023-03-12 18:32:11 -05:00
Tom Schuster f53c83cfa4 Partly implement XML child and elements
This makes #3294 (rollercoaster-creator-2) fully playable.

Missing is any (*) matching for child()/elements() and the existing attributes() method.
Also missing is support for number indexes with child().
2023-03-12 18:06:13 -05: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
Lord-McSweeney 120f24b2ba avm2: Implement flash.text.CSMSettings 2023-03-11 12:27:28 -06:00
Marty_SVK 8668d83ea6 progresses Resort Empire
now it is blocked by unimplemented BitmapData.threshold
2023-03-11 15:41:46 +01:00
nosamu be153b2417 avm2: Stub Stage.fullScreenWidth and fullScreenHeight 2023-03-11 15:02:03 +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 a8198c0fab avm2: Remove `run_frame_avm2` and FramePhase::Update
These were unused for all AVM2 objects.
I've renamed the `run_frame` method to `run_frame_avm1`,
as it's only used for AVM1-specific logic.
2023-03-10 19:37:19 -07:00
Aaron Hill 80b98a055e avm2: Stub NetConnection and Responder
These are needed for BTD5
2023-03-10 16:58:15 -06:00
Lord-McSweeney 522e781e3c avm2: Fix stub types for Font 2023-03-10 20:55:54 +01: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