Commit Graph

6429 Commits

Author SHA1 Message Date
sleepycatcoding 705042c1ee chore: Fix a warning 2023-08-05 14:42:09 +02:00
sleepycatcoding dccf254281 avm1: Implement some event handlers 2023-08-05 14:42:09 +02:00
sleepycatcoding 78a68f95ea avm1: Implement send() 2023-08-05 14:42:09 +02:00
sleepycatcoding b64c45f797 avm1: Implement connect() 2023-08-05 14:42:09 +02:00
sleepycatcoding 931c355779 avm1: Use Gc instead of GcCell 2023-08-05 14:42:09 +02:00
sleepycatcoding 7237295364 chore: fmt 2023-08-05 14:42:09 +02:00
sleepycatcoding cd92677b2a core: Add SocketKind and use it to separate XMLSocket and Socket 2023-08-05 14:42:09 +02:00
sleepycatcoding 662c7f986d avm1: Implement onData 2023-08-05 14:42:09 +02:00
sleepycatcoding 879750d3e1 avm1: Stub rest of XMLSocket methods 2023-08-05 14:42:09 +02:00
sleepycatcoding 13ce61a00a avm1: Implement close() 2023-08-05 14:42:09 +02:00
sleepycatcoding 9c92cf0c98 avm1: Implement timeout 2023-08-05 14:42:09 +02:00
sleepycatcoding 773168fe10 avm1: Create simple XMLSocket stub 2023-08-05 14:42:09 +02:00
sleepycatcoding c9c4efe574 avm2: Review remarks 2023-08-05 14:17:02 +02:00
sleepycatcoding e8bc47a569 avm2: Return correct error if Event.clone() returns null 2023-08-05 14:17:02 +02:00
sleepycatcoding 925ed2e82b avm2: Clone event if it has been dispatched before 2023-08-05 14:17:02 +02:00
Lord-McSweeney 76a7c69522 avm2: Use Error #2008 in some places in TextField 2023-08-05 13:42:16 +02:00
Lord-McSweeney 3fbde2076c avm2: Use Error #2004 for flash.crypto::generateRandomBytes 2023-08-05 13:42:16 +02:00
Lord-McSweeney fd04463476 avm2: Use make_error_2008 for set objectEncoding on ByteArray 2023-08-05 13:42:16 +02:00
Lord-McSweeney f753d840b6 avm2: Add errors #2024, #2150, and #3738 2023-08-05 13:42:16 +02:00
Lord-McSweeney 855825b6ac avm2: Create a make_error_1506 function and use it 2023-08-05 13:42:16 +02:00
Lord-McSweeney c39d006a78 avm2: Use correct error #2025 in various places in DisplayObjectContainer 2023-08-05 13:42:16 +02:00
Adrian Wielgosik f75b36a32a core: Remove lots of uses of derive(Collect) 2023-08-04 21:43:18 +02:00
Nathan Adams 5f200dc2a9 avm2: Use correct error in write ops when reading past bounds 2023-08-03 16:28:25 +02:00
Nathan Adams af46301020 avm2: Use correct error in Li ops when reading past bounds 2023-08-03 16:28:25 +02:00
Nathan Adams 3d76953574 avm2: Use correct error when accessing domain memory out of bounds 2023-08-03 16:28:25 +02:00
sleepycatcoding f5f5680e3a avm2: Fix an error message 2023-08-02 22:16:16 +02:00
sleepycatcoding 7d61f8f947 avm2: Wrap Socket instead of extending 2023-08-02 22:16:16 +02:00
sleepycatcoding 43ce490c0f chore: fmt 2023-08-02 22:16:16 +02:00
sleepycatcoding 3fd53b8ca1 avm2: Implement connect() special-case 2023-08-02 22:16:16 +02:00
sleepycatcoding 85db727f17 avm2: Implement XMLSocket 2023-08-02 22:16:16 +02:00
Nathan Adams ab27c8b4ee render: Calculate correct bounds for shapes containing curves 2023-08-02 18:43:33 +02:00
Nathan Adams 020dc34b59 avm2: Throw errors in theoretically unreachable scenario in XmlDocument 2023-08-02 15:55:08 +02:00
Nathan Adams 3834462abf avm2: Hook up XMLDocument.ignoreWhite 2023-08-02 15:55:08 +02:00
Nathan Adams 6f2420d983 avm2: Implement ignoreComments/ignoreProcessingInstructions/ignoreWhitespace 2023-08-02 15:55:08 +02:00
Nathan Adams da7ee01730 avm2: Implement XML.settings/XML.setSettings/XML.defaultSettings, and add appropriate properties to XML class 2023-08-02 15:55:08 +02:00
Nathan Adams 10e59067d0 avm2: Rewrote XMLDocument/XMLNode to be more correct 2023-08-02 15:55:08 +02:00
Lord-McSweeney 84e4215ece avm2+tests: Various Vector-related fixes; activate now-passing Vector tests 2023-08-02 15:26:53 +02:00
renovate[bot] 477ff400a7 chore(deps): lock file maintenance rust dependencies 2023-08-02 13:36:13 +02:00
TÖRÖK Attila 515df16a38 debug_ui: Indent non-expandable items in object- and display trees 2023-08-02 10:32:22 +02:00
relrelb 006393c581 chore: Appease nightly clippy 2023-08-01 22:44:00 +03:00
Aaron Hill 66eadc8f7c avm2: Implement Loader.uncaughtErrorEvents
This can just delegate to LoaderInfo
2023-07-31 21:29:02 -04:00
Adrian Wielgosik 2621dd78ee avm2: Vector doesn't support propertyIsEnumerable 2023-08-01 00:13:46 +02:00
Adrian Wielgosik b61e92ee12 avm2: Fix property_is_enumerable on arrays 2023-08-01 00:13:46 +02:00
Aaron Hill 1107851d15 core: Fix debug_ui mouse search on HiDPI display
We need to scale the mouse position that egui gives us
by the scale factor, in order to get in the format
expected by our inverse view matrix
2023-07-31 17:38:20 -04:00
sleepycatcoding 2ba3b90754 core: Redesign socket data passing
This allows to make socket tests more reliable
2023-07-31 22:32:03 +02:00
Abiel Deneke 6552b4e132 avm2: Implement `Matrix3D.prependScale` 2023-07-31 17:00:44 +02:00
TÖRÖK Attila a023ca605d core: Don't divide by zero in BitmapData::perlinNoise() if baseX or baseY is 0.0 2023-07-31 16:41:01 +02:00
Tom Schuster 8fa6a0d249 avm2: Make XMLList set_property_local (aka [[put]]) less error happy
This doesn't really enable any new functionality, but prevents throwing
Errors for things that are allowed in Flash/ECMA-357.
2023-07-30 11:41:11 +02:00
Tom Schuster f237aa1da2 avm2: Implement XMLNode.nodeValue 2023-07-30 11:14:00 +02:00
Aaron Hill 4406a70fc9 avm2: Enable Vector.<ObjectSubclass> serialization tests
This also fixes a minor bug (we should always deserialize
to a `Vector.<Object>`, not a `Vector.<*>`)
2023-07-29 15:30:24 -04:00
Adrian Wielgosik 86ba4fef9b avm2: Add void type 2023-07-29 19:57:44 +02:00
Nathan Adams f9be8be99e avm2: Make 'new Math()' and 'Math(value)' throw errors 2023-07-29 15:24:30 +02:00
Lord-McSweeney bcd96f5b40 avm2: Stub flash.text.engine:EastAsianJustifier 2023-07-29 10:48:30 +02:00
Lord-McSweeney 6a96a14098 avm2: Improve flash.text.engine stub 2023-07-29 10:48:30 +02:00
Adrian Wielgosik b68ac23cbb avm2: Remove redundant check for Vector<undefined> 2023-07-28 23:42:04 +02:00
Adrian Wielgosik 30d4026227 avm2: Expand comments 2023-07-28 23:42:04 +02:00
Adrian Wielgosik 2352c200e0 chore: clippy 2023-07-28 23:42:04 +02:00
Adrian Wielgosik 22d7ffdefc avm2: fix Vector null display 2023-07-28 23:42:04 +02:00
Adrian Wielgosik b8a5b9ede1 avm2: Refactor VectorStorage value_type to accurately reflect stored <T>. 2023-07-28 23:42:04 +02:00
Adrian Wielgosik 733e84957d avm2: Do not panic on Vector.<1> 2023-07-28 23:42:04 +02:00
Adrian Wielgosik f504e9d0b4 avm2: Refactor Vector.<T> class creation 2023-07-28 23:42:04 +02:00
Nathan Adams d1703610a9 avm2: Temporarily limit arrays to 1<<28 2023-07-28 22:22:47 +02:00
Marc Bornand c8e4ec98f0 avm2: Add PressAndTapGestureEvent 2023-07-28 20:50:40 +02:00
Marc Bornand f61c1f8713 avm2: Add TransfromGestureEvent 2023-07-28 20:50:40 +02:00
Lord-McSweeney cf5c02ca1b avm2+tests: Fully implement XML.appendChild, add a test 2023-07-28 15:21:38 +02:00
Lord-McSweeney e542cedbb2 avm2: Special case Number.toString for Infinity and NaN
This avoids getting into an infinite loop.
2023-07-28 13:11:15 +02:00
sleepycatcoding 02d815e86b avm2: Implement XML addition operations 2023-07-27 23:39:06 +02:00
Nathan Adams 70fb674d8b avm2: Implement correct errors for write_bytes with offset+length > u32::MAX 2023-07-27 19:47:16 +02:00
Nathan Adams 3b6068bbe7 avm2: Change EofError to ByteArrayError 2023-07-27 19:47:16 +02:00
Nathan Adams f6d2620605 avm2: Throw correct error when setting bytearray.endian to wrong value 2023-07-27 19:47:16 +02:00
Nathan Adams 1bbefbe472 avm2: Throw correct error when writing a too-large string to ByteArray 2023-07-27 19:47:16 +02:00
Jaroslav Bělák 08ab99f2ed core: Implement ToXMLString for Attribute and Comment node kind 2023-07-27 15:04:24 +02:00
Nathan Adams cb23067382 avm2: Implement UninitializedError 2023-07-27 09:49:47 +02:00
Nathan Adams 5fc37c7e13 avm2: Implement call handler for Error 2023-07-27 09:49:47 +02:00
Aaron Hill 583caa3389
avm2: Implement DisplayObject.blendShader (#12238) 2023-07-26 23:25:26 +00:00
Aaron Hill 99ed2c6d4a
avm2: Fix handling of default domain memory (#12308) 2023-07-26 18:26:26 +00:00
Nathan Adams 55906c22fa desktop: Change 'socket mode' text to 'TCP Connections' 2023-07-26 19:44:39 +02:00
Nathan Adams 0f4edf9574 avm2: Implement fscommand() 2023-07-26 17:00:15 +02:00
Nathan Adams 1a0a82d898 core: Move fscommand execution outside of ExternalInterfaceProvider, so it can be implemented without causing ExternalInterface.available to become true 2023-07-26 17:00:15 +02:00
sleepycatcoding c8b6a1cb4c core: Send data directly to socket task
This improves socket latency. Sometimes the ping is better in Ruffle than
in Flash Player!
2023-07-26 14:01:03 +02:00
sleepycatcoding f3917c8c62 core: Run async tasks until stalled
Previously it used run which tries to run until completion, but we can't do
that if we are testing socket behavior.
2023-07-26 14:01:03 +02:00
TÖRÖK Attila 365f6bee6e avm2: Clamp filter quality to (0, 15) instead of (1, 15) 2023-07-26 13:03:11 +02:00
Aaron Hill a91b0cf5cb avm2: Don't error in DisplayObject.removeChildren when `to` is max
Our previous special-case wasn't broad enough
2023-07-25 21:44:23 -04:00
Aaron Hill 3c64e8e249 avm2: Implement AMF Vector serialization/deserialization
Some of the tests are currently disabled because (separate from this PR)
we can't actually run `toString()` on a Vector.<Object>, due to our
broken vector handling.
2023-07-25 09:35:50 -04:00
Lord-McSweeney 38b4357f59 avm1: Implement Button.filters 2023-07-25 14:20:36 +02:00
CUB3D 7346f9f6cb avm1: Differentiate between clips with no name set and empty string names 2023-07-25 08:25:37 +02:00
renovate[bot] 3e63a88c34 chore(deps): lock file maintenance rust dependencies 2023-07-25 08:23:28 +03:00
TÖRÖK Attila cee19c5735 core: Fix dirty region set by bitmap::set_pixel 2023-07-25 00:38:08 -04:00
sleepycatcoding f2c9237ea1
avm2: Allow setting prototype to undefined (#12282)
* avm2+tests: Allow setting prototype to undefined

This is used internally by Adobe Flex in many places. Also add test.

* avm2: Set prototype when constructing a Function with null prototype

* tests: Expand prototype_set_null test

* chore: fmt
2023-07-24 20:41:38 +00:00
Aaron Hill 7a5c729d63 core: Use a slightly better DefineFont4 stub
This makes a Character available for a SymbolClass to link with
2023-07-24 14:58:01 -04:00
Nathan Adams 92e3e44453 avm1: Reverse iteration when applying filters - fixes #12272 2023-07-24 13:44:02 +02:00
Aaron Hill 8941a0bb79 avm2: Clamp ByteArray.position when ByteArray.length is set
Note that ByteArray.position can manually be set out-of-range
afterwards.
2023-07-23 14:51:30 -04:00
Aaron Hill 005fdffd05 avm2: Correctly set fields on ShaderInput and ShaderParameter
The special meta key `defaultValue` should be used to set
the default `value` field. Also, `index` is the position
within *just* the image or texture params, not within
all of the params.
2023-07-23 13:52:26 -04:00
sleepycatcoding 6c4f707e36 chore: fmt 2023-07-23 09:13:01 +02:00
sleepycatcoding 48fcc5ffe9 avm2: Check is_connected in flush() and close() 2023-07-23 09:13:01 +02:00
sleepycatcoding 5218bbf32f chore: fmt 2023-07-23 09:13:01 +02:00
sleepycatcoding adeb50a3d7 avm2: Check if socket is open before trying to read or write 2023-07-23 09:13:01 +02:00
sleepycatcoding 74b66fdd73 core+desktop: Rename SocketBehavior to SocketMode
Also change command line flag from --socket to --socket-mode
2023-07-23 09:13:01 +02:00
sleepycatcoding 2c79d22578 avm2: Do not panic when SocketHandle does not exist 2023-07-23 09:13:01 +02:00
sleepycatcoding 68fd0ce73c core: Differentiate between TimedOut and Failed connection 2023-07-23 09:13:01 +02:00
sleepycatcoding ac1badc64f core: remove Option for connection timeout 2023-07-23 09:13:01 +02:00
sleepycatcoding 5144162e68 avm2: Set timeout in AS3 constructor 2023-07-23 09:13:01 +02:00
sleepycatcoding 568d8dfe11 core: Fix panic when socket is closed before connecting 2023-07-23 09:13:01 +02:00
sleepycatcoding 6e6205d20d core: Use timeout in Navigator::connect_socket 2023-07-23 09:13:01 +02:00
sleepycatcoding f54e0e9097 avm2: Make get/setTimeout native 2023-07-23 09:13:01 +02:00
sleepycatcoding a3a49335eb chore: Fmt 2023-07-23 09:13:01 +02:00
sleepycatcoding 6c3b6e5109 avm2: Implement read/writeObject() 2023-07-23 09:13:01 +02:00
sleepycatcoding ea3d6e2a5c avm2: Implement set/getobjectEncoding() 2023-07-23 09:13:01 +02:00
sleepycatcoding 9de2912765 avm2: Implement read/writeMultiByte() 2023-07-23 09:13:01 +02:00
sleepycatcoding 5ed9dbc16b avm2: Implement read/writeUTF 2023-07-23 09:13:01 +02:00
sleepycatcoding 6ca6bb1d78 avm2: Implement read/writeUTFBytes 2023-07-23 09:13:01 +02:00
sleepycatcoding ad51041457 avm2: Implement readBytes() 2023-07-23 09:13:01 +02:00
sleepycatcoding e1a82570fe avm2: small cleanup 2023-07-23 09:13:01 +02:00
sleepycatcoding 22eb150756 desktop: add SocketBehavior and host whitelist
This adds a way to modify socket behavior to restrict, ask, or allow all
connections. Also adds a whitelist which can be used to allow specific hosts
without enabiling ask or allow all behaviors.
2023-07-23 09:13:01 +02:00
sleepycatcoding 4c540c9f17 avm2: Implement read/writeBoolean() 2023-07-23 09:13:01 +02:00
sleepycatcoding 45d3e141f8 avm2: Improve IOErrorEvent for Socket
IOErrorEvent now uses a error message and ID.
2023-07-23 09:13:01 +02:00
sleepycatcoding 0699c34881 chore: Fmt 2023-07-23 09:13:01 +02:00
sleepycatcoding 676516a99c core: use get instead of get_mut
We did not need mutability for this.
2023-07-23 09:13:01 +02:00
sleepycatcoding ea7264eab5 core: Dispatch IOErrorEvent when connection fails 2023-07-23 09:13:01 +02:00
sleepycatcoding d1a17ebeb1 chore: Fix clippy lint 2023-07-23 09:13:01 +02:00
sleepycatcoding 5080c19d11 core: Make socket connection async
Changes socket system to use asynchronous means to not generate lagspikes
when connecting to servers.
2023-07-23 09:13:01 +02:00
sleepycatcoding 2da61bc57f avm2: Some nits
Use ProgressEvent for socketData event instead of a bare event.
Remove unwraps and use correct errors/exceptions.
Correct name in make_error_2008 call.
Use expect() for getting ByteArray instead of an error.
Correct some get_*() calls
2023-07-23 09:13:01 +02:00
sleepycatcoding fc06dcbed6 avm2: Add SecurityError to globals 2023-07-23 09:13:01 +02:00
sleepycatcoding f64ca6aa85 avm2: Use ParametersExt 2023-07-23 09:13:01 +02:00
sleepycatcoding 6da0dbc287 avm2: Implement close() 2023-07-23 09:13:01 +02:00
sleepycatcoding dea9797891 avm2: Implement many primitive write methods 2023-07-23 09:13:01 +02:00
sleepycatcoding 238bc6784c avm2: Implement many primitive read methods 2023-07-23 09:13:01 +02:00
sleepycatcoding bca70dd102 core: Add read bytes to read buffer 2023-07-23 09:13:01 +02:00
sleepycatcoding 2dcc3e7930 avm2: Add read_buffer and implement bytesAvailable 2023-07-23 09:13:01 +02:00
sleepycatcoding 487d881793 avm2: Implement flush() 2023-07-23 09:13:01 +02:00
sleepycatcoding 3dfb6e3bb1 avm2: Implement writeByte and writeBytes 2023-07-23 09:13:01 +02:00
sleepycatcoding 60de72fc3e avm2: Implement endian() methods 2023-07-23 09:13:01 +02:00
sleepycatcoding d6f6d432fa avm2: Implement connect and connected 2023-07-23 09:13:01 +02:00
sleepycatcoding c22f97445a avm2: Add SocketObject 2023-07-23 09:13:01 +02:00
sleepycatcoding ad72c56cb4 core: Implement socket backend 2023-07-23 09:13:01 +02:00
Nathan Adams 4219f39668 avm2: Throw proper error when setting name of timeline objects 2023-07-23 01:18:53 +02:00
Aaron Hill 5ee6218ab4 avm2: Fix `super_vtable` in `describeType`
This more closely matches what avmplus does.
2023-07-22 17:50:10 -04:00
Nathan Adams 586c3bebf6 core: Remove unsupported content warning 2023-07-22 23:08:42 +02:00
Abiel Deneke 8f6e9d8f63 avm2: Don't change the length of a fixed output Vector 2023-07-22 16:11:08 -04:00
Nathan Adams d1cfb1b8d1 avm2: Implement delete_property_local for XMLList 2023-07-22 18:24:08 +02:00
nosamu 02476f70dd avm2: Stub GameInputDevice, LocaleID, NumberFormatter, and NumberParseResult 2023-07-21 22:51:13 -04:00
Nathan Adams 4410d666ed avm2: Implement Bitmap.pixelSnapping 2023-07-22 00:34:17 +02:00
Nathan Adams 289f73c85f core: Add pixel snapping (default auto) to Bitmaps, and force it for cacheAsBitmap 2023-07-22 00:34:17 +02:00
Lord-McSweeney 68c5024f21 tests: Add test for LocalConnection.send 2023-07-22 00:00:24 +02:00
Lord-McSweeney 7b21815660 avm2: Improve LocalConnection.send stub 2023-07-22 00:00:24 +02:00
Nathan Adams 98ce792a5b avm1: Implement BitmapData.applyFilter() 2023-07-21 21:43:54 +02:00
Aaron Hill f328797d04 avm2: Fix bugs with describeType interfaces and methods
Interfaces should only be listed when calling describeType
with a class instance (not with a `Class` object).

Additionally, AS3 methods can actually be displayed under
some circumstances. This is due to weird legacy behavior
that avmplus implements. A full fix requirs us to implement
namespace versioning, but we can get closer by special-casing
playerglobals (which is special-cased by namespace versioning
anyway).
2023-07-21 15:23:56 -04:00
nosamu 2ee127ccb6 core: Fix cacheAsBitmap size limit & remove print statement 2023-07-21 09:22:12 +02:00
Nathan Adams 67c33ef9c3 core: Disable cacheAsBitmap for swfs that are too large (depending on swf version) 2023-07-20 23:19:20 +02:00
Nathan Adams b201e19cc7 wgpu: Don't create an extra fresh texture for applying filters to a CAB 2023-07-20 23:19:20 +02:00
Nathan Adams e66f2397b5 core: Avoid some work in render_base if we're not cacheAsBitmap 2023-07-20 23:19:20 +02:00
Nathan Adams f030680084 core: Don't invalidate self on changing blend mode 2023-07-20 23:19:20 +02:00
Nathan Adams b6a8e0a471 core: Don't invalidate self on changing visibility 2023-07-20 23:19:20 +02:00
Nathan Adams 1fd8ca7bad core: Reduce the amount of false-invalidations 2023-07-20 23:19:20 +02:00
Nathan Adams 400ff32723 wgpu: Implement a naive DisplacementMap filter 2023-07-20 12:41:30 +02:00
Lord-McSweeney 7c33932f53 core: Allow NetStream script data to call any functions 2023-07-19 17:26:24 -06:00
Lord-McSweeney 42c1facf55 avm1+tests: Implement onMetaData event for AVM1, fix netStatus test for AVM2 2023-07-19 17:26:24 -06:00
Lord-McSweeney 14b78aafcc avm2: Support onCuePoint and onMetadata NetStream.client function handlers 2023-07-19 17:26:24 -06:00
Aaron Hill 715abd8985 avm2: Use invisible mask descendants for mouse picking and rendering
The 'DisplayObject.visible' flag seems to be ignored for mask objects
(and their descendants) - mouse picking still takes them into account,
and they get rendered as part of the mask.

This commit changes display object rendering and AVM2 mouse picking
to ignore DisplayObject.visibility when dealing with mask objects/
descendants.
2023-07-19 23:18:28 +02:00
CUB3D 771f568509 core: Trying to access a named shape should resolve to the parent as they have no object representation 2023-07-19 22:32:42 +02:00
sleepycatcoding 4c1c3cc105 avm2+tests: Allow concating XMLLists; add test 2023-07-19 16:03:10 -04:00
Lord-McSweeney 5975714f75 avm2+swf+tests: Store metadata on Traits and VTable, report metadata in describeType; parse ABC metadata key-value pairs correctly; add test 2023-07-19 16:24:23 +02:00
Nathan Adams b8081ac609 core: Use actual bounding box of curves instead of an approximation 2023-07-19 02:09:12 +02:00
Nathan Adams 00ea6180dc avm2: Default line caps should be Round, not None 2023-07-19 02:09:12 +02:00
Aaron Hill 0fa16dfe69 avm2: Remove redundant 'depth' variable in XML parsing 2023-07-19 00:20:14 +02:00
MartySVK 6667ea1d94
avm2: Stub flash.globalization.CurrencyFormatter.format (#12108)
* fixes Rogue Soul 2

* return after stub_method
2023-07-17 21:00:43 +00:00
relrelb 151ad97686 avm1: Migrate `SharedObject` to `NativeObject` 2023-07-17 11:34:06 +03:00
renovate[bot] 268403faad chore(deps): lock file maintenance rust dependencies 2023-07-17 09:55:56 +03:00
nosamu de9ea9571b avm2: Implement SharedObject.size 2023-07-17 00:53:52 +02:00
nosamu fea0df192f avm1: Implement SharedObject.getSize() 2023-07-17 00:53:52 +02:00
MrCheeze 08e13b5056 core: Make underlines the same color as their text 2023-07-17 00:32:46 +02:00
Kornelius Rohrschneider ac5b3d9b2f core: Move use_new_invalid_bounds to Avm1 & Add documentation
The variable use_new_invalid_bounds has been moved from the
UpdateContext and the Player to the Avm1 struct because it is only used
for AVM1 code. A getter method and an activator method setting it to
true have been added as well.
The get_bounds function, which uses the variable, has been adapted to
use the getter and the activator.

Additionally, documentation has been added and improved.
The MovieClip now contains documentation about all MovieClip states and
the use_new_invalid_bounds documentation has been extended to explain
the logic of how the variable is set and used.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider 48192efe8a core: Remove MovieClip::oldest_parent_swf_version
The MovieClip variable oldest_parent_swf_version and its getter method
have been removed because they were unnecessary, as the UpdateContext
already provides the root movie.
The call of the getter method has been replaced by
activation.context.swf.version().
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider a0493c770e core: Implement suggested changes to PR
The suggested changes in the feedback to the pull request have been
implemented.
Therefore, this commit consists of multiple smaller changes:

- The unload_movie method has been renamed to avm1_unload_movie.
- The movieclip_default_state test now doesn't test
  getTextSnapshot().getCount() because the underlying methods haven't
  been implemented in AVM1 yet.
  This should be reverted when they have been implemented or stubbed in
  AVM1.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider c74a43e643 core: Add MovieClip unloaded state
An unload_movie method has been added to the MovieClip. It unloads the
MovieClip, which means that one frame after it has been called,
avm1_unload and the new transform_to_unloaded_state method get called
and the MovieClip enters the unloaded state in which some attributes
have certain values.
To do this, it creates and spawns a future which calls avm1_unload and
transform_to_unloaded_state (which actually makes the MovieClip enter
the unloaded state).
It uses the new MovieUnloader (which has been added to the Loader enum)
to pass the MovieClip to the asynchronous code. The MovieUnloader saves
a handle and the target clip, and the asynchronous code retrieves it
from the LoadManager.

unload_movie is now called when a MovieClip should be unloaded.
TODOs have been added, describing to check whether other avm1_unload
calls also need to be delayed by one frame and whether unload_movie also
needs to be called in other places.

Additionally, a spelling mistake has been corrected.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider d2ac9d32b4 core: Correct MovieClip default state
Previously, the MovieClip default state contained wrong values for
opaqueBackground, transform.pixelBounds and getRect & getBounds with
another default MovieClip as the parameter.
This has been corrected; the calculation of these values has been fixed.

To do that, a use_new_invalid_bounds_value variable has been added to
the UpdateContext and the Player (from which the UpdateContext is
created).
Additionally, an oldest_parent_swf_version variable has been added to
the MovieClip with a getter method for it. It is calculated and saved on
demand in the getter.
These variables are retrieved in the get_bounds function and used to set
use_new_invalid_bounds_value and to calculate the correct bounds.

Ruffle now uses the correct MovieClip default state.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider 96e0f445bb core: Correct MovieClip image state
The set_cur_preload_frame and set_current_frame methods have been added
to the MovieClip.
If the Loader now loads an image, these methods are called to set the
MovieClip image state correctly.

Additionally, load_error_swf now uses set_cur_preload_frame instead of
the removed movie_not_available method.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider 400edf5368 core: Add MovieClip initial loading state
A load_initial_loading_swf function has been added to the Loader. It
makes the MovieClip enter the initial loading state in which some
attributes have certain initial loading values to signal that the file
is currently being loaded and neither an error has occurred nor the
first frame has been successfully loaded yet.
The Loader calls the function when initialising the loading before it
gets an error or success.

Additionally, load_error_swf has been improved: If a local URL is
fetched on a WASM target, the _url property will now be correctly set as
in the flash player.

The documentation has been improved.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider a0d0b8e638 core: Refactor & improve NavigatorBackend implementations
All NavigatorBackend implementations have been refactored, resulting in
improved code quality, less duplicated code, more consistent and easier
to understand procedures, additional error handling and better error
messages.

A resolve_url method has been added to the NavigatorBackend trait. It
takes a URL and and resolves it to the actual URL from which a file can
be fetched (including handling of relative links and pre-processing). It
has been implemented in each NavigatorBackend implementation.

Duplicated code has been put into new public functions in
core/src/backend/navigator.rs which are called by all NavigatorBackend
implementations.

ExternalNavigatorBackend:
- The navigate_to_url and fetch methods have been adapted to use
  resolve_url, removing redundant code.
- Error handling has been added in case that the URL can't be converted
  to a PathBuf.
- A TODO about differences between the flash player fetch and the
  Ruffle fetch implementation has been added.

WebNavigatorBackend:
- The previous resolve_url method exclusively to the WebNavigatorBackend
  has been replaced by the new resolve_url method. It is used by
  navigate_to_url and fetch.
- resolve_url now always pre-processes the URL if it's valid (even if no
  base_url exists) and explicitly returns whether the URL can be parsed.
- navigate_to_url now traces an explanatory error each if the URL can't
  be parsed or is local.
- fetch now returns an explanatory error each if the URL can't be parsed
  or is local (previously, a vague "Got JS error" has been returned).

TestNavigatorBackend & NullNavigatorBackend:
- fetch pre-processes the URL now (using the resolve_url implementation).
- If the URL isn't local, an explanatory error is returned (previously,
  it was just an "Invalid URL" error).
- If the URL can't be parsed, an explanatory error with the reason is
  returned (previously, it was just an "Invalid URL" error).

Additionally, error messages in all NavigatorBackend implementations
have been improved and made more consistent, e.g. if a local file can't
be read.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider 687c0e7516 core: Complete MovieClip error state & Change uncompressed_len to i32
Previously, the MovieClip error state contained one TODO in order to be
completely implemented: The HeaderExt variable uncompressed_len needs to
be -1 in the error state, but its type has been u32.
The type has now been changed to i32, and the variable is set to -1 in
the default_error_header function. Therefore, the MovieClip error state
is now fully implemented.

Other connected functions and variables like SwfMovie::uncompressed_len
or MovieClip::total_bytes have been adjusted to this type change. Code
has been adjusted if needed where this value is used.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider 893052c2a6 core: Add MovieClip error state
A load_error_swf function has been added to the Loader. It makes the
MovieClip enter the error state in which some attributes have certain
error values to signal that no valid file could be loaded. This happens
if no file could be loaded or if the loaded content is no valid
supported content.
The function creates an error state movie stub using the new
SwfMovie::error_movie function (which uses a new default_error_header
function) and configures remaining variables with the
movie_not_available method.
One TODO in order for the error state to be completely implemented has
been added.

Since the error state of the MovieClip includes the final URL of the SWF
file obtained after any redirects, the load_error_swf and
movie_loader_error functions (now) take an swf_url attribute.
To get this URL in case no file could be loaded, the
NavigatorBackend::fetch method has been changed to return an
ErrorResponse struct (including the url and the actual error) in the
error case. The Response struct returned in the success case has been
renamed to SuccessResponse.
All fetch implementations have been adapted accordingly. Code has been
adjusted to return the actual error where that's needed.

Documentation has been added and improved.
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider 5352c86202 core: Remove duplicated functions
Duplicated functions have been removed (and replaced by corresponding
calls to the other functions).
2023-07-17 00:08:02 +02:00
Kornelius Rohrschneider 2d629dbf72 core: Correct _framesloaded value if movie couldn't be loaded
If an SWF tries to load a movie that can't be loaded, the Flash Player
sets _framesloaded of the MovieClip to -1. This has previously not been
implemented in Ruffle.

A new movie_not_available function has been added to the MovieClip
class. It sets the cur_preload_frame variable to 0.
This function is now called in the movie_loader_error function of the
Loader class (if a movie can't be loaded).

The frames_loaded function (which returns _framesloaded of the
MovieClip, which is given to the SWF) now returns an i32 and not an u16
value. This allows it to return a negative value. Code has been adjusted
where an u16 value is expected (clamping negative values to 0).
frames_loaded now returns cur_preload_frame - 1. Previously, it has
returned cur_preload_frame - 1 and clamped it to zero, but since the -1,
in case cur_preload_frame is zero, is explicitly wanted, this has been
corrected.
2023-07-17 00:08:02 +02:00
MrCheeze 901594b99f
avm2: Do not remove an EditText's selection on unfocus (fix #9006) + implement selectionBegin/selectionEnd/caretIndex (#9067)
* avm2: Do not remove an EditText's selection on unfocus (fix #9006)

There are significant differences between how selection and caret info
work between AVM1 and AVM2.

In AVM1, there is only a single, global selection, which applies to
whichever element is currently focused. Therefore changing the focus
necessarily erases any information of what was selected before. There
can also be no active selection at all.

In AVM2, every text field has its own independent selection info. It is
NOT optional, the default selection is just a caret at position 0. If a
field loses focus, the selection is not rendered, but it is still
present. Movies such as #9006 rely on the same selection still being
there once you give back focus to the field.

Ruffle's model of selections (an Option per text field) is different
from both the AVM1 model (an optional singleton) and the AVM2 model
(mandatory per text field). This fix does not change that, it is only a
narrow fix targeted at 9006.

* avm2: implement selectionBegin/selectionEnd/caretIndex and add a test.

The selection test validates a few situations, including the behaviour
when unfocusing that was fixed in the previous commit.

The test does not validate how the selection changes after replacing
text, as there are still some inaccuracies there.

* avm2: Additional selection fixes needed after merging with master.

1. The default caret for an AVM2 textbox is at the end of the textbox,
   not the beginning.
2. Selection should not be changed when focusing on a textbox in AVM2.
3. Fixed a test whose output.txt didn't actually match the flash player
   output.

* avm2: Make the selection AVM checks compatible with mixed AVM, and revert the on_focus_changed parameters

---------

Co-authored-by: Nathan Adams <dinnerbone@dinnerbone.com>
2023-07-15 16:17:45 +00:00
Nathan Adams 26cf380aa4 avm2: Fix Array.sort(function) 2023-07-15 17:53:05 +02:00
CUB3D 14712b46c6 chore: Fix clippy lint 2023-07-15 11:45:02 +02:00
CUB3D d7a780f5ea core: Fix caching order, add test 2023-07-15 11:45:02 +02:00
CUB3D 27bc6e9609 avm1: Fix panic on writing self-referential SharedObjects 2023-07-15 11:45:02 +02:00
Abiel Deneke 4afcadf4fd avm2: Implement `Matrix3D.transformVectors` 2023-07-14 23:39:39 -04:00
michiel2005 6b423a7eef Ran cargo fmt 2023-07-14 16:51:07 -06:00
michiel2005 fc32dc3671 Removed some code that was double checking without any need. 2023-07-14 16:51:07 -06:00
michiel2005 c812a8af54 checked for movie equality in check_display_object_equality().
Makes code more readable.
2023-07-14 16:51:07 -06:00
michiel2005 4f605947e5 Well, we don't talk about this mistake. 2023-07-14 16:51:07 -06:00
michiel2005 2307bd7e74 Changed down_object to pressed and removed one issue in my code Lord-McSweeney found 2023-07-14 16:51:07 -06:00
michiel2005 8834b3b42b Added changes as Adrian recommended 2023-07-14 16:51:07 -06:00
michiel2005 412f2880ad Removed a unnecessary variable 2023-07-14 16:51:07 -06:00
michiel2005 90cb88d50e We're also checking for the depth now when searching for displayobjects 2023-07-14 16:51:07 -06:00
michiel2005 aaede767fe Made sure that the objects are actually in the same movie and added a bit of documentation 2023-07-14 16:51:07 -06:00
michiel2005 8141e7b54c avm1: fix buttons that were not clickable after a goto 2023-07-14 16:51:07 -06:00
Moulins 3ea67668c0 render: make Context3D renderers fully GC-agnostic
The 'gc_arena' dependency was only used to manipulate the `GcCell`s
containing the vertex and fragment shaders; replacing these by a
reference to a plain old `Cell` means tha  the Context3D traits and
types do not need to interact with GC'd object anymore.

As a knock-on effect, we can also remove the `Activation` parameter
from most of the `Context3DObject` methods.
2023-07-14 16:06:36 -06:00
Moulins a0ad308de0 avm2: use an inner RefLock instead of GcCell in Context3D-related objects 2023-07-14 16:06:36 -06:00
relrelb 204cf4b2bc avm1: Migrate `Xml` to `NativeObject` 2023-07-14 17:10:10 +03:00
Nathan Adams f150a32d86 core: Only scale filters with stage view matrix 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 d721072825 core: Extract DrawCacheInfo type from big tuple inside render_base 2023-07-12 18:51:11 +02:00
Nathan Adams f9ec5eb9b8 avm1: Make XMLNode constructor use NativeObject directly 2023-07-12 18:33:58 +02:00
Nathan Adams d4b81cae5c avm1: Migrate XMLNode to NativeObject 2023-07-12 18:33:58 +02:00
renovate[bot] f0607d6a1f chore(deps): lock file maintenance rust dependencies 2023-07-11 22:42:51 +02:00
nosamu 17df97a59a core: Fix panic from oversized bitmap warning
And warn only once per bitmap
2023-07-11 22:02:35 +02:00
Adrian Wielgosik ffc6e2ffdc core: Mark stack-heavy DO functions as noinline 2023-07-10 11:32:50 +02:00
Aaron Hill e16a4833ac avm2: Stub Program3D.dispose 2023-07-10 00:23:25 -04:00
moulins f5b4fbce77
Upgrade to new `gc-arena` API (#11182)
* core: add temporary, ruffle-internal copy of `gc-arena` crate

This will allow bumping the upstream `gc-arena` version while
reexporting our own version of the old `GcCell` API, so that
Ruffle's code can be gradually migrated.

Once the migration is done, this crate should be removed.

* core: bump `gc-arena` to kyren/gc-arena#56

Add back the removed `GcCell` to our internal facade crate

* core: bump `gc-arena` to current master

This bump renames `Gc::allocate` to `Gc::new`

* core: rename `GcCell::allocate` to `GcCell::new`, to match `Gc`

* core: bump gc-arena to (slighly after) v0.3.1

Add typedefs for old `*Context` names in the gc-arena facade crate

* core: replace uses of `CollectionContext<'_>` by `&Collection`

* core: Add `gc()` convenience method for `*Context` and `Activation` types

This allows shortening most instances of `[activation.]context.gc_context`
to `activation.gc()` or `context.gc()` (but not all instances, because of
borrowck) Note that this doesn't actually do these shortenings to avoid
major code churn.
2023-07-09 17:04:25 -04:00
Aaron Hill b6fae8e214 wgpu: Cache Program3D bind group layout
The bind group layout only depends on the texture registers
(and 2D/cubemap type) accessed by the fragment shader, not on
the runtime texture bound with Context3D. This means that we can
build and cache it when we compile the AGAL program to a Naga
module.

Since the bind group layout is used for the overall pipeline, I've
refactored the shader caching code into `ShaderPairAgal`, which
holds both the vertex and fragment shader bytecode, and compiles
both in the `compile` function.
2023-07-09 12:39:10 -04:00
Adrian Wielgosik a0d6389bd6 avm2: Replace Activation.resolve_type by domain lookup 2023-07-08 19:51:38 +02:00
Adrian Wielgosik b38bd604db avm2: Fix Multiname-with-params formatting 2023-07-08 01:55:44 +02:00
Lord-McSweeney 5337975cba avm2: Remove old hack now that DOs use an instance allocator 2023-07-07 23:14:54 +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
Lord-McSweeney b68008426a avm2: Use the current SWF version instead of root SWF version in MC.gotoAndPlay 2023-07-07 21:19:16 +02:00
Aaron Hill 4cf0735692 avm2: Implement Utils3D.projectVector and Utils3D.projectVectors 2023-07-06 11:34:40 -04:00
Lord-McSweeney f8fa8a68cf avm2: Replace Option<Object<'gc>> with Object<'gc> in all native methods 2023-07-06 10:56:49 -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
Lord-McSweeney ab51654c17 avm2: Remove unused Activation.is_executing 2023-07-05 19:07:50 -04:00
Lord-McSweeney 2725d49119 avm2: Clean up Activation a little 2023-07-05 19:07: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
Aaron Hill 4695d1fa63 avm2: Implement 'change' event for TextField 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 a99b30927f avm1: Panic if we see a shader filter 2023-07-05 19:18:00 +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
Nathan Adams 2b48f579e6 avm1: Implement MovieClip.filters 2023-07-05 19:18:00 +02:00
Nathan Adams 681ff3dd24 avm1: Add helper method to get/set strength in filter objects 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
Aaron Hill f22bef99b4 core: Fix some Clippy lints on the latest nightly 2023-07-04 20:50:46 +02:00
Lord-McSweeney 275c42b39c core: Correctly apply blend modes and filters from button records 2023-07-04 20:24:12 +02:00
Lord-McSweeney c943866745 core+avm1: Implement FLV onCuePoint for AVM1 2023-07-04 00:36:25 +02: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
renovate[bot] 13b1078142 chore(deps): lock file maintenance rust dependencies 2023-07-03 08:28:13 +03:00
Aaron Hill 768eaa1a01 avm2: Store at most a single type parameter in names/clasess
The only generic class is `Vector`, which only has a single parameter.
However, we currently store a list of type parameters in several places,
which requires redundant checks that the list only has one entry.

Instead, we now store an `Option` everwhere except for
`swf::Multiname::TypeName` (since the actual SWF format supports
multiple type parameters). We still perform the same check when loading
bytecode (the swf Multiname should only have at most one type
parameter), but the rest of the codebase can deal with an `Option`
instead.
2023-07-02 16:02:53 -04:00
Aaron Hill b77c1fc78f core: Fix Nightly clippy lint 2023-07-02 14:32:45 +02:00
Aaron Hill f7c50865a0 core: Update formatting with latest nightly 'cargo fmt' 2023-07-02 14:32:45 +02:00
Adrian Wielgosik bd043c09c7 cargo fmt 2023-07-01 23:38:09 +02:00
David Wendt 679f179a60 docs: Document the aliasing situation with `VideoSource::Swf` 2023-07-01 23:38:09 +02:00
David Wendt d382b29fb1 core: Allocate a new `VideoSource` when attaching netstreams rather than attaching the stream to every instance of the video 2023-07-01 23:38:09 +02:00
David Wendt b2544618ab core: `VideoStream` should not hold the last decoded frame as this data structure is shared across multiple instances of the same character 2023-07-01 23:38:09 +02:00
Adrian Wielgosik 7eb7f2ee2c avm2: Correctly set and use Video class from Rust 2023-07-01 22:45:20 +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
Aaron Hill 710be15f78 core: Bail out of operations::color_transform if [xy]_min==[xy]_max
In the special case where y_min==y_max==(height-1),
we would create a bad 'encompassing' region - subtracing
one from the max would make it smaller than the min,
causing `PixelRegion::encompassing_pixels` to treat it
as the minimum, and add one to `height - 1`

There's no work to do when x_min==x_max or y_min==y_max,
so we can also skip the sync and GC write in this case.
2023-07-01 09:55:59 -04:00
Nathan Adams 5e608764ec core: Add debug feature to find display objects by mouse 2023-07-01 12:58:32 +02:00
Aaron Hill c2fcdf6fd6 avm2: Implement Stage3D.requestContext3DMatchingProfiles
For now, we just ignore the parameters and call requestContext3D
2023-06-30 23:22:56 -04:00
Crowdin Bot 29a5c6a4cd chore: Update translations from Crowdin 2023-07-01 00:47:31 +02: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
David Wendt 8ac8b926ac core: If a video does not have an `onMetaData` block, register a compatible-ish datastream so that we can still play the video 2023-06-30 16:14:28 -06:00
David Wendt b9aaaf5259 flv: ScreenVideo v2 also wants the FLV video data byte 2023-06-30 16:14:28 -06:00
David Wendt 3ff1db014f flv: Screen Video wants the FLV `VideoData` header byte 2023-06-30 16:14:28 -06:00
David Wendt ff1ed66729 flv: VP6 video packets have a horizontal and vertical adjustment before the actual video data. 2023-06-30 16:14:28 -06:00
David Wendt 98ee78be1a avm2: Make netstream event initialization more concise 2023-06-30 16:14:28 -06:00
David Wendt 04ee039d3c avm2: Use `ParametersExt` to grab parameters in `Video.init()` 2023-06-30 16:14:28 -06:00
David Wendt faf8fb5d3f avm2: Move as much `Video` initialization as possible into an instance allocator function 2023-06-30 16:14:28 -06:00
David Wendt 45e6f07009 core: Pause the stream if we hit a tag parsing error. 2023-06-30 16:14:28 -06:00
David Wendt af0149c476 core: Log netstream signature verification errors 2023-06-30 16:14:28 -06:00
David Wendt b639af1ada avm2: `Video.init` doesn't need to call `super_init` 2023-06-30 16:14:28 -06:00
David Wendt d2f806a901 core: The AVM2 version of this test wants a spurious status event 2023-06-30 16:14:28 -06:00
David Wendt ab21b5b106 core: The stop event is `NetStream.Play.Stop` 2023-06-30 16:14:28 -06:00
David Wendt fc50a688fb core: Update stream time after processing tags 2023-06-30 16:14:28 -06:00
David Wendt 4dd9508471 avm1: Implement onStatus events for NetStream 2023-06-30 16:14:28 -06:00
David Wendt 63b27a4a20 avm2: Pass status events through to AVM2. 2023-06-30 16:14:28 -06:00
David Wendt 757ae40abc core: Add stubs for stream event triggers 2023-06-30 16:14:28 -06:00
David Wendt da2ef5392e core: Make the `NetStream`/AVM link bidirectional 2023-06-30 16:14:28 -06:00
David Wendt 067474dea5 chore: Remove unused variables from stream.rs 2023-06-30 16:14:28 -06:00
David Wendt d498a412e5 core: Retain original SWF dimensions for self bounds 2023-06-30 16:14:28 -06:00
David Wendt b164319e32 core: FLV metadata is stored as an array, not an object. 2023-06-30 16:14:28 -06:00
David Wendt 643b053e8d core: Don't mark the video stream as corrupt if we haven't gotten the full header yet 2023-06-30 16:14:28 -06:00
David Wendt 587a99fae7 core: Netstream loaders are... well, netstream loaders. 2023-06-30 16:14:28 -06:00
David Wendt 0e207cce8d core: Actually spawn the loader future for the netstream 2023-06-30 16:14:28 -06:00
David Wendt 7e986bd90d avm1: `NetStream` constructor must return itself 2023-06-30 16:14:28 -06:00
David Wendt 766ee5302d core: Properly expose AVM1/2 objects for videos. 2023-06-30 16:14:28 -06:00
David Wendt a52f738009 core: Silence various errors triggered by loading an empty video stream 2023-06-30 16:14:28 -06:00
David Wendt 257403d04e core: Errors in tag parsing should include the explanation of the underlying error 2023-06-30 16:14:28 -06:00
David Wendt f690162a4f avm2: Actually create an unconnected `Video` when one is constructed via `new Video` 2023-06-30 16:14:28 -06:00
David Wendt c86360a10b core: `Video`s attached to a `NetStream` get their bitmap size and data from the attached `NetStream`. 2023-06-30 16:14:28 -06:00
David Wendt 9e318fc8e8 core: Process basic FLV video data tags and funnel them to the video backend.
This works a bit differently from SWF videos, we do not retain decoded video frames or valid seek points indefinitely. This assumes code interacting with `NetStream` is at least mildly aware of how a video codec is supposed to work and what the performance implications of that are.
2023-06-30 16:14:28 -06:00
David Wendt 3d5156b90d core: Update the stream offset after each tag is processed.
The `preload_offset` is only ever moved forward, of course.
2023-06-30 16:14:28 -06:00
David Wendt 3410d9fcf8 core: Process `onMetaData` to get our stream definition with.
We use `preload_offset` to avoid processing the same metadata multiple times.
2023-06-30 16:14:28 -06:00
David Wendt 286acddfea core: Introduce the notion of a separate preload step.
We don't actually process tags out of order, we're just tracking what tags have already been processed. FLV embeds critical video metadata in a ScriptData tag that we need to pull data out of and process.
2023-06-30 16:14:28 -06:00
David Wendt bc9fd3613e core: Add stub FLV processing 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 1c151a86d6 avm2: Stub isXMLName 2023-06-29 15:51:39 -04:00
Nathan Adams a5915a9bdb swf: Make Color Copy 2023-06-29 20:32:36 +02:00
Lord-McSweeney 04747f86b6 avm2: Stub AVM1Movie 2023-06-29 12:05:01 -04:00
EmperorBale e846d035e5 avm2: Use `method_name` as last resort if available in stack trace 2023-06-29 11:49:48 -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
Crowdin Bot 1430e98851 chore: Update translations from Crowdin 2023-06-28 23:19:47 +02:00
Niv.Kaminer 053bcf9376 core: Update sounds in rootless SWF (close #11666) 2023-06-26 16:59:01 -04:00
renovate[bot] 3057aa59dd chore(deps): lock file maintenance rust dependencies 2023-06-25 21:53:00 -04:00
renovate[bot] f62dd17284 fix(deps): update rust crate indexmap to v2 2023-06-25 20:27:33 -04:00
Nathan Adams 0ca206ce4f core: Add dumb filter list inside debug ui 2023-06-25 21:58:46 +02:00
Nathan Adams 628d8f66ad render: Add filters to BitmapCacheEntry 2023-06-25 21:58:46 +02:00
Lord-McSweeney a38dec3f9c core: Erase filters in GotoPlaceObject::new if initial PlaceObject has none 2023-06-25 18:27:54 +02:00
Lord-McSweeney 0dba2ac37c core: Overwrite filters in GotoPlaceObject::merge 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
Nathan Adams f24aabf74e core: Don't hold a borrow on Avm1Button whilst adding children - fixes #11706 2023-06-24 22:33:42 +02:00
MrCheeze 1baccb483a core: Apply filters when modifying an object, not just when instantiating 2023-06-24 17:22:32 +02:00
Nathan Adams 6d77ff1fc4 core: Store just abcd fields of Matrix inside BitmapCache, as we don't use tx/ty 2023-06-24 01:42:04 +02:00
Nathan Adams 4f9cc4e3c4 core: Clear this on scrollRect, not just ancestors 2023-06-24 01:42:04 +02:00
Nathan Adams 668cc31fa4 chore: Comment changes regarding cacheAsBitmap 2023-06-24 01:42:04 +02:00
Nathan Adams a5b28b50bf core: Don't invalidate things more than once per frame, to avoid repeat walking of the DO tree 2023-06-24 01:42:04 +02:00
Nathan Adams cdb0774642 core: Hook up DisplayObject::opaque_background 2023-06-24 01:42:04 +02:00
Nathan Adams ee444853b4 avm1: Implement MovieClip.cacheAsBitmap 2023-06-24 01:42:04 +02:00
Nathan Adams d94c73cebe core: Rename bitmap cache methods and make clear which one is preference and which one is actual 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 f0b72ee89c core: Add cacheAsBitmap debug buttons 2023-06-24 01:42:04 +02:00
Nathan Adams f81b1f83b9 core: Fix panic in recursive set_maskee/set_masker 2023-06-24 01:42:04 +02:00
Nathan Adams 1a9bec3062 core: Don't use cacheAsBitmap when bitmapdata.draw() as it'll keep reinvalidating it 2023-06-24 01:42:04 +02:00
Nathan Adams f43560ab88 render: Switch to providing cacheAsBitmap entries all at once on submit frame 2023-06-24 01:42:04 +02:00
Nathan Adams 2594453831 render: Add render_offscreen_for_cache for more optimised CacheAsBitmap 2023-06-24 01:42:04 +02:00
Nathan Adams 5a67b2dcb7 core: Don't rerender cacheAsBitmap if the color transform changes (unlike Flash - but it should be fine!) 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 0f01efb322 core: Invalidate cacheAsBitmap when video change 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 fe742194b1 core: Implement cacheAsBitmap behaviour 2023-06-24 01:42:04 +02:00
Niv.Kaminer 69b09ab1ef avm2: Implement Serialization for ByteArrayObject 2023-06-23 08:29:53 -04:00
Crowdin Bot b1149cd267 chore: Update translations from Crowdin 2023-06-23 11:49:47 +02:00
Fancy2209 9ab4c163c7
Fix TouchEvent.as (#11685)
* Update TouchEvent.as

* Oops
2023-06-23 08:14:23 +00:00
Lord-McSweeney 8127971dfd avm2: Remove AIR-only FocusDirection class 2023-06-22 08:47:10 +03:00
Lord-McSweeney f6360b343e avm2: flash.sampler stubs 2023-06-21 21:03:29 +03:00
Nathan Adams a078d91c31 core: Simplify open_character_button a bit 2023-06-21 18:27:12 +02:00
Nathan Adams 8dd3b50da6 core: Deemphasise invalid rects in debug ui 2023-06-21 18:27:12 +02:00
Nathan Adams 00e02d1511 core: Add debug window to list known movies 2023-06-21 18:27:12 +02:00
Nathan Adams c0247c020a swf: Add write_swf_raw_tags for reconstructing a swf from its parts 2023-06-21 18:27:12 +02:00
Nathan Adams 4e0628b730 core: Refactor out a show_avm2_value for debugger 2023-06-21 18:27:12 +02:00
Nathan Adams e6b087dbc2 core: Remove swf saving for now, we need to reconstruct the swf from the data 2023-06-21 18:27:12 +02:00
Nathan Adams d8e6bf7535 core: Show root DO's in debug view 2023-06-21 18:27:12 +02:00
Nathan Adams 0523a5b149 core: Remove UpdateContext param from DisplayObject::avm2_root() 2023-06-21 18:27:12 +02:00
Nathan Adams 647006b8d0 core: Add more avm2 debug info 2023-06-21 18:27:12 +02:00
Nathan Adams 5b429e3bf5 core: Add filtering to avm2 debug window 2023-06-21 18:27:12 +02:00
Nathan Adams 89962cf970 core: Add avm2 objects to debug menu 2023-06-21 18:27:12 +02:00
Nathan Adams aaf9ecfa32 core: Add AVM1 values to debug UI 2023-06-21 18:27:12 +02:00
Nathan Adams afdd617d29 avm1: Add include_hidden: bool to get_keys() 2023-06-21 18:27:12 +02:00
Nathan Adams 310b03b570 core: Add searching to DO debug children list 2023-06-21 18:27:12 +02:00
Nathan Adams c5a1ca0e57 core: Show invalid bounds + selfbounds/scrollrect on DO debug info 2023-06-21 18:27:12 +02:00
Nathan Adams c8a41e327a core: Add character info to DO debug window 2023-06-21 18:27:12 +02:00
Nathan Adams b24cc60a5d core: Add swf info to debug menu 2023-06-21 18:27:12 +02:00
Nathan Adams cb2349e33a core: Store character name<->id map, not name<->character, so we can query id for name 2023-06-21 18:27:12 +02:00
Adrian Wielgosik b3c40ecda1 avm2: Optimize coerce_to_primitive for boxed primitives 2023-06-21 00:20:03 +02:00
Crowdin Bot 67a5a2923f chore: Update translations from Crowdin 2023-06-20 23:52:03 +02:00
Nathan Adams 6b76af2d40 core: Fix avm2button bounding box 2023-06-20 23:22:53 +02:00
Toad06 18fb5064d3 avm1: Correct `matrix::object_to_matrix_or_default` 2023-06-19 21:09:06 +03:00
relrelb a8f9033091 avm1: Make `DisplayPropertyMap` immutable 2023-06-18 07:50:10 +03:00
Toad06 22ae6bfec3 avm1: Correct `WaitForFrame` and `WaitForFrame2` actions 2023-06-17 19:23:18 -05:00
Lord-McSweeney b02d8900c5 avm2: Remove or validate some uses of coerce_to_object 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
Crowdin Bot ca549e482c chore: Update translations from Crowdin 2023-06-17 19:25:33 +02:00
renovate[bot] 7a21756ddb chore(deps): lock file maintenance rust dependencies 2023-06-17 11:00:52 -05:00
Nathan Adams 6208c50273 core: Simplify TDisplayObject::swf_version(), we don't need to iterate the heirarchy 2023-06-17 10:37:13 +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
Lord-McSweeney b998fc0197 avm2: Minimal stub of ShaderFilter 2023-06-15 16:42:12 -05:00
renovate[bot] fc933f485f fix(deps): update wasm-bindgen 2023-06-15 20:50:04 +02: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 ad97322807 avm2: Implement ErrorObject.display without using Activation
This lets us print the full error message and stack stacke
in contexts where an Activation is not available, including
the `Debug` impl.

The 'name' and 'error' fields are accessed using hardcodd slot
ids. This is pretty hacky, but will work until we have better
handling of slot properties.
2023-06-15 09:31:36 -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
Lord-McSweeney b4b726d7ab avm2: nit: Add error number in error message for BitmapData.drawWithQuality 2023-06-14 20:32:06 -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 f649344f64 avm2: nit: Fix warning message in Avm2::peek 2023-06-14 19:16:08 +02:00
Lord-McSweeney 6006aa82c2 avm2+tests: Support primitives besides null in MovieClip.addFrameScript; add test 2023-06-14 18:16:39 +02:00
nosamu 202fe2f1bb core: Add options to set and force the stage alignment 2023-06-14 16:04:14 +02:00
Nathan Adams 0b86c02c5c desktop: Fix interaction between egui and ruffle cursors 2023-06-14 13:43:17 +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
Lord-McSweeney 10a8acb166 avm2: Stub NetConnection.addHeader 2023-06-13 20:51:08 -05:00
nosamu 60d3788466 avm2: Improve PerspectiveProjection stub 2023-06-13 19:31:18 -05: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
nosamu 61f1cf88a5 avm2: Throw AVM error in Array constructor 2023-06-13 23:54:13 +02: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
Moulins d04fc61bb5 core: slightly simplify string interner by using new hashbrown APIs
- we can now get a `&RawTable` from a `&HashSet`, meaning we can store a
`HashSet` directly in the interner;
- `RawTable::iter_hash` now allows the removal of already-yielded
elements during iteration, which simplifies `WeakSet::entry`
2023-06-12 22:58:20 +02:00
relrelb 1dc28d898e avm1: Migrate `Transform` to `NativeObject` 2023-06-12 20:16:45 +03:00
Aaron Hill 2dfc0bac5b core: Log url when movie fetch fails 2023-06-12 10:55:13 -05:00
Crowdin Bot 834297f110 chore: Update translations from Crowdin 2023-06-12 12:28:05 +02:00
Aaron Hill ce0ba7795c avm2: Throw TypeError when 'astype' receives a null/undefined class 2023-06-12 02:31:03 -05:00
Aaron Hill 7e56c20973 avm2: Implement KeyboardEvent.updateAfterEvent 2023-06-12 01:44:46 -05:00
Aaron Hill 6b808a9a9d avm2: Stub Matrix3D-related methods on Transform
This allows verification to succeed on classes that override these
methods.
2023-06-12 01:17:39 -05:00
Lord-McSweeney b7088695fe avm2: Stub undocumented TextField.insertXMLText 2023-06-11 11:17:21 -05:00
relrelb 226a2be2bd core: Fix drag constraint with `lockCenter` set to `false`
Previously `last_mouse_position` was updated irrespectively of
whether the dragged object was inside or outside the constraint
box. Change it follow mouse deltas, after clamping is performed.

Fixes #11254.
2023-06-11 07:34:14 +03:00
Lord-McSweeney dced6445ee avm2: Stub flash.net.getClassByAlias and improve flash.net.registerClassAlias stub 2023-06-10 16:09:57 -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
relrelb dcb6bbe50b avm1: Migrate `GradientGlowFilter` to `NativeObject` 2023-06-10 12:46:22 +03:00
Nathan Adams 75979b561a avm1: Rename try_resolve_level -> get_level, resolve_level -> get_or_create_level 2023-06-10 10:37:15 +02: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
renovate[bot] a621472336 chore(deps): lock file maintenance rust dependencies 2023-06-09 20:17:25 +03:00
Aaron Hill a387476de7 core: Unify loader event handler and AVM2 data into MovieLoaderVMData
`AVM2Data` was always provided with
`MovieLoaderEventHandler::Avm2LoaderInfo`, so we can unify
them into a single enum.
2023-06-09 11:47:11 -05: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
Nathan Adams 137986c384 core: Add PlayerBuilder::with_external_interface 2023-06-09 13:03:46 +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
Lord-McSweeney 455b96710e avm2: Fix MouseCursorData.frameRate stubs 2023-06-07 22:39:41 -05:00
Aaron Hill 9d8ac81b58 avm2: Use WeakObject in `broadcast_list`
This ensures that we don't keep the underlying listener
object alive after all event listeners (including broadcast
listeners) have been unregistered.
2023-06-07 21:15:26 -05:00
EmperorBale 4815ca5e90 avm2: Implement WeakObject
This also adds a new required function to TObject called `downgrade`, that will convert the `Object` to a `WeakObject`.
2023-06-07 17:51:26 -07:00
EmperorBale 5e20b079d9 avm2: Add weak variant of every object 2023-06-07 17:51:26 -07:00
Toad06 8ce8b775a7 avm1: Fix coercion order in SWFv4 actions 2023-06-08 01:33:08 +02:00
Moulins 3f1bcecfbb avm1: Add version gate for `{MovieClip, Button}.blendMode`
Theses properties are only available on SWF >= 8
2023-06-08 01:18:06 +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
Crowdin Bot 93f5869005 chore: Update translations from Crowdin 2023-06-08 00:57:49 +02:00
Aaron Hill 0e0399963e avm2: Throw exception when ExternalInterface is not available 2023-06-07 17:24:25 -05:00
Aaron Hill b240f05390 avm2: Stub Graphics.beginShaderFill 2023-06-07 17:06:33 -05:00
Aaron Hill 1efcd584c2 avm2: Wrap orphan list in an `Rc` for correct iteration behavior
When we iterate over the orphan list to run frame lifecyle methods,
the orphan list may be modified (e.g. an event listener creates a new
orphan object). To ensure that we iterate over all of the orphans
originally present, this commit wraps the orphan list in an `Rc`
(just like we do for the render list). Modifications to the list use
`Rc::make_mut`, and iteration operates on a clone of the `Rc`.
2023-06-07 16:23:06 -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 ccb5027de0 avm2: Preserve MultinameFlags::ATTRIBUTE when filling a lazy Multiname 2023-06-07 14:08:10 -05:00
Aaron Hill 638471fc2d avm2: Stub flash.printing.PrintJob 2023-06-07 03:47:29 -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
Aaron Hill d037038170 avm2: Make `caller_domain` an `Option`, and call `expect` when actually needed
There are only a few places where we actually need to use the
`caller_domain`, so we don't actually need it available for most native
method calls. This means that `Activation::from_nothing` can be used
in the vast majority of cases without causing a panic later on.
2023-06-06 21:05:19 +02:00
Nathan Adams 10134467c9 avm2: Don't error on removeChildren() for empty containers - fixes #11382 2023-06-05 18:30:08 -05:00
renovate[bot] f1fe998869 chore(deps): lock file maintenance rust dependencies 2023-06-04 22:53:18 -05:00
relrelb 9c8e212641 avm1: Migrate `GradientBevelFilter` to `NativeObject` 2023-06-03 21:33:12 +03:00
Nathan Adams 136417c58c core: Make debug windows scrollable 2023-06-03 09:11:06 +02:00
Nathan Adams 85f6fd3889 core: Add movie clip info to debug menu 2023-06-03 09:11:06 +02:00
Nathan Adams a26a64d88f core: Format Rectangle to 2 decimal places 2023-06-03 09:11:06 +02:00
Nathan Adams c9d0a08863 core: Move debug children list's button into header 2023-06-03 09:11:06 +02:00
Nathan Adams 9f384df27b core: Don't have dynamic_root in UpdateContext unless egui feature is enabled 2023-06-03 09:11:06 +02:00
Nathan Adams a641c564de core: Show debug rect on hovering stuff 2023-06-03 09:11:06 +02:00
Nathan Adams 16ce9aa437 core: Add debug rects to debugger 2023-06-03 09:11:06 +02:00
Nathan Adams a6b8883acd core: Add mask/masker/clip info to debug UI 2023-06-03 09:11:06 +02:00
Nathan Adams 59eceb8b7a core: Add AVM1 path to debug UI 2023-06-03 09:11:06 +02:00
Nathan Adams 77bd1cd1c8 core: Add depth and color transform to debug ui 2023-06-03 09:11:06 +02:00
Nathan Adams e12e2a2e54 core: Initial Debug UI 2023-06-03 09:11:06 +02:00
Nathan Adams eb70a4f361 core: Update gc_arena to 63dab12871321e0e5ada10ff1f1de8f4cf1764f9 2023-06-03 09:11:06 +02: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
relrelb e5da68c1df avm1: Migrate `ConvolutionFilter` to `NativeObject` 2023-06-02 23:39:02 +03: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
Lord-McSweeney 5fdbfe2fd4 avm2: Partial implementation of Loader.unload 2023-05-31 21:03:18 -05: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
Crowdin Bot 6dc3743f4b chore: Update translations from Crowdin 2023-05-30 23:21:28 +02:00
relrelb c952106ee3 avm1: Correct `ActionCloneSprite` and `duplicateMovieClip()`
* `ActionCloneSprite` coerces `depth` before `target`.
* `duplicateMovieClip()` coerces `name` before `depth`.
* `duplicateMovieClip()` returns `undefined` on SWF<6.
2023-05-30 23:10:36 +03:00
Nathan Adams 0c10e2a7b7 desktop: Add advanced open dialog 2023-05-29 22:12:56 +02:00
TÖRÖK Attila b8fc64df6f core/avm1: Accept Value as smaller than 16 bytes on 32 bit platforms. 2023-05-29 07:58:53 -05:00
renovate[bot] 847dece735 chore(deps): lock file maintenance rust dependencies 2023-05-28 23:54:33 -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 2ae15b05e8 core: Store Color as an u32 instead of a i32
This is a packed ARGB value, so it doesn't make sense for it to be
signed.
2023-05-28 16:52:09 -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
relrelb ee30646745 avm1: Migrate `DisplacementMapFilter` to `NativeObject` 2023-05-27 23:08:42 +03:00
Lord-McSweeney 420643b045 avm2: Stub Worker 2023-05-27 00:58:34 -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
Crowdin Bot e98230c988 chore: Update translations from Crowdin 2023-05-27 00:34:44 +02:00
Aaron Hill 9fad8ddd9d core: Fix nightly clippy lints 2023-05-26 17:06:28 -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
Adrian Wielgosik a1797a351d avm2: Avoid a function call on every push() 2023-05-24 23:33:09 +02:00
Aaron Hill 9a1a21ef3a avm2: Implement Stage3D.visible 2023-05-24 14:20:40 -05:00
MartySVK 3be933d7c2
avm2: Stub ContextMenu.builtInItems setter (#11187) 2023-05-24 01:50:03 +00:00
iwannabethedev 1e0714aaa1 core: Fix serialization of arrays with dynamic properties. 2023-05-23 19:46:24 -05:00
iwannabethedev 83520d0daf avm2: Minor refactoring of duplicated code. 2023-05-24 02:30:52 +02: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
renovate[bot] 5d2477fe98 chore(deps): lock file maintenance rust dependencies 2023-05-22 19:12:08 +03:00
nosamu bb15c90d82 avm2: Implement XML.hasSimpleContent and 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
relrelb c230dcf0f8 avm1: Migrate `BitmapData` to `NativeObject` 2023-05-21 21:02:14 +03:00
nosamu 7dfc36c6fc web: Support pasting from clipboard 2023-05-21 15:26:42 +02:00
nosamu ee956927b7 core: Fix TextField.maxChars handling and address other reviews 2023-05-21 15:26:42 +02:00
nosamu 4e579b7e68 core: Move left/right arrow handling to `text_control_input` 2023-05-21 15:26:42 +02:00
nosamu 0dbb4c46e4 core: Move `Delete` and `Backspace` handling to `text_control_input()`
Co-authored-by: jmckiern <jmckiern@tcd.ie>
2023-05-21 15:26:42 +02:00
nosamu fab72ac01c core: Implement handling of text control input
Co-authored-by: jmckiern <jmckiern@tcd.ie>
2023-05-21 15:26:42 +02:00
jmckiern 67d74047a9 core: Add clipboard_content getter 2023-05-21 15:26:42 +02: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
Aaron Hill 54cf9065fb core: Don't create a fake root clip when instantiating Stage
AVM2 can handle a missing root movie, and AVM1 doesn't seem
to rely on having a root movie during Stage initialization.
2023-05-21 08:11:11 +03:00
Lord-McSweeney 7c9b0378f6 nit: avm2: Fix stub message in Socket 2023-05-21 07:31:50 +03:00
iwannabethedev 7b12cb882f core: Fix error message in 'pixelDissolve()'. 2023-05-21 01:47:06 +02:00
iwannabethedev 0f30b378b0 core: Re-arrange internal implementation of 'pixelDissolve()'. 2023-05-21 01:47:06 +02:00
iwannabethedev deae231176 core: Clean up TODOs in 'pixelDissolve()'. 2023-05-21 01:47:06 +02:00
iwannabethedev 6f98d39c25 core: Implement 'pixelDissolve()' for AVM1. 2023-05-21 01:47:06 +02:00
iwannabethedev 40c40f278c core: 'pixelDissolve()' bug fix and clean-up. 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