Commit Graph

7646 Commits

Author SHA1 Message Date
Aaron Hill 81a5f3f10a core: Always check mergeAlpha in BitmapData.copyPixels
Previously, we would only use mergeAlpha if alphaBitmapData
and alphaPoint. However, mergeAlpha can be used even when
those parameters are null.

Some of the AVM1 argument handling was also incorrect - I've fixed
it, and extended the existing test with the output-based test
added for AVM2.
2022-09-11 11:12:09 -05:00
Aaron Hill 1d6b3b6f57 chore: Fix Clippy lints and allow `clippy::bool_to_int_with_if`
In several cases, the current code seems preferable to the
code required by `clippy::bool_to_int_with_if`. Let's suppress
this for now to get the build passing, and decide later if this
is something that we want to enable.
2022-09-11 13:31:46 +02:00
Nathan Adams 92044c9c02 wgpu: Merge bitmap bind groups 2 and 3 2022-09-11 09:07:53 +02:00
Nathan Adams d867a370fc wgpu: Cache direct bitmap draw bind groups (smoothing vs not) 2022-09-11 09:07:53 +02:00
Nathan Adams 57ddb6bdcb wgpu: Refactor out bitmap bind group from drawtype 2022-09-11 09:07:53 +02:00
Nathan Adams dd7f23f319 wgpu: Add documentation for pipeline binding groups 2022-09-11 09:07:53 +02:00
Nathan Adams 2d48d78990 wgpu: Removed redundant _pipeline suffix in Pipelines 2022-09-11 09:07:53 +02:00
Nathan Adams a38cadfd39 wgpu: Cache shape pipelines per texture format & msaa 2022-09-11 09:07:53 +02:00
Nathan Adams a8ff81ee38 wgpu: Make vertex buffer descriptions const 2022-09-11 09:07:53 +02:00
Aaron Hill b62c17577b wgpu: Switch to arena 2022-09-11 09:07:53 +02:00
Nathan Adams c63aa2cfc8 wgpu: Moved Draw creation outside of backend 2022-09-11 09:07:53 +02:00
Nathan Adams b2e02db72f wgpu: Extracted a create_texture_transforms method 2022-09-11 09:07:53 +02:00
Nathan Adams e7e0905647 wgpu: Moved Mesh, Draw and DrawType to their own file, and code that constructs a DrawType there too 2022-09-11 09:07:53 +02:00
Nathan Adams f36bcac742 wgpu: Move actual frame rendering to Surface, deduplicates some code 2022-09-11 09:07:53 +02:00
Nathan Adams b2ecd39648 wgpu: Enable MSAA for offscreen textures 2022-09-11 09:07:53 +02:00
Nathan Adams 69aba474e1 wgpu: Split off srgb and msaa code from backend to a Surface enum 2022-09-11 09:07:53 +02:00
Nathan Adams 03f7719c49 wgpu: Move quad into its own structure under Descriptors 2022-09-11 09:07:53 +02:00
Nathan Adams a8e8b01a6c wgpu: Use a static buffer for srgb transform uniforms, reworked it from Frame 2022-09-11 09:07:53 +02:00
Nathan Adams a1d1da5d25 wgpu: Simplify stencil usage from Frame's perspective 2022-09-11 09:07:53 +02:00
Nathan Adams 794b30e10e wgpu: Split draw_x into prep_x and draw 2022-09-11 09:07:53 +02:00
Nathan Adams 91f3230a45 wgpu: Split off Frame into CommandRenderer and Frame - command renderer translates commands into draw calls on frame 2022-09-11 09:07:53 +02:00
Nathan Adams 22ba32b785 wgpu: Remove target from Frame 2022-09-11 09:07:53 +02:00
Nathan Adams 8616c898cc wgpu: Remove globals from Frame 2022-09-11 09:07:53 +02:00
Nathan Adams 14ecc98780 wgpu: Pass quad vbo/ibo as slices 2022-09-11 09:07:53 +02:00
Nathan Adams 09172c8b12 wgpu: Simplified rendering code down to 'apply transform, draw x' 2022-09-11 09:07:53 +02:00
Nathan Adams 5f671c0018 wgpu: Fixed panic if rendering to a texture smaller than 1x1 2022-09-11 09:07:53 +02:00
Nathan Adams d5ab88f40d wgpu: Make buffer blocks Pin<Box<Block>> 2022-09-11 09:07:53 +02:00
Nathan Adams 08471c6fb7 wgpu: Don't keep setting globals bind group, it only needs to be set once 2022-09-11 09:07:53 +02:00
Nathan Adams 41239039eb wgpu: Moved all bind group layouts into their own struct 2022-09-11 09:07:53 +02:00
Nathan Adams f33e6904cd wgpu: Moved bind layouts out of Pipelines, they don't change 2022-09-11 09:07:53 +02:00
Nathan Adams 39e1224bda wgpu: Don't recompile shaders for each Pipelines 2022-09-11 09:07:53 +02:00
Nathan Adams 7e013183a7 wgpu: Removed Descriptors::pipelines, we don't need 3 pipelines 2022-09-11 09:07:53 +02:00
Nathan Adams 8b6c6f8a62 wgpu: Removed DescriptorsTargetData::surface_format and frame_buffer_format as they aren't needed to be target specific 2022-09-11 09:07:53 +02:00
Nathan Adams 6755e1ccbd wgpu: Pass the pipelines to frame instead of deciding based on a macro 2022-09-11 09:07:53 +02:00
Nathan Adams 13657e16ca wgpu: Make render_offscreen use its own Frame instead of making a whole new renderer backend 2022-09-11 09:07:53 +02:00
Nathan Adams 697369536c wgpu: Split off code that actually renders a frame 2022-09-11 09:07:53 +02:00
Nathan Adams 267ea0fd13 render: Introduced render commands, moved to a command list model instead of direct rendering 2022-09-11 09:07:53 +02:00
Nathan Adams c7f420dde5 wgpu: Moved WgpuRenderBackend into backend.rs 2022-09-11 09:07:53 +02:00
Nathan Adams 70d96654d7 wgpu: Move descriptors out into its own file 2022-09-11 09:07:53 +02:00
Aaron Hill a638b0498e core: Render Bitmap even if bitmap_data is None
We only need to access bitmap_data to check if we need to
update a dirty texture.
2022-09-11 07:06:11 +03:00
Aaron Hill 8370bc792d core: Use correct background alpha in BitmapData.draw
Previously, we would always use a transparent background,
even if the BitmapData is not transparent. This would normally
be corrected on the next frame when we copied the pixels to the
CPU. However, if an SWF ran `BitmapData.draw` on every frame,
this would never be corrected.
2022-09-09 19:24:21 -05:00
Aaron Hill 5de21428f5 core: Update dirty BitmapData before rendering
We now have a `MutationContext` available, so this doesn't need
to be done in `run_frame`
2022-09-09 16:36:40 -07:00
Aaron Hill 2f81f5814d render: Add `premultiplied_alpha` parameter for image capture
When rendering offscreen, we want the resulting image to use
premultiplied alpha, since the image will be stored in a texture.

However, when capturing an image in the exporter or test framework,
we want to use straight alpha, so that the resulting image can
be saved as a PNG.

Previously, we incorrectly used straight alpha everywhere, resulting
in incorrect output when using BitmapData.draw with transparency.
2022-09-09 15:46:48 -07:00
Adrian Wielgosik 4421fbff6a
avm2: Convert all Qname::new(...).into() to Multiname::new() (#7930) 2022-09-09 23:33:30 +02:00
Aaron Hill ca030169f7 avm2: Implement BitmapData.rect and stub BitmapData.applyFilter
These are the last BitmapData methods needed for Solarmax
(the victory screen after beating the last level now renders).
2022-09-09 13:05:13 -05:00
Aaron Hill bb138d9082 avm2: Implement some of SharedObject
Our AVM2 `SharedObject` support is now *almost* equivalent
to our avm1 `SharedObject` support. We implement serialization
and deserialization for primitives, arrays, and `Object` instances
with local properties. We also implement serialization for `Date`,
but not `Xml` (since our AVM2 `Xml` class is just a stub at the moment).

This is enough to make 'This is the only level too' save level
progress to disk.

Currently, we always serialize to AMF3. When we implement
the `defaultObjectEncoding` and `objectEncoding`, we'll need
to adjust this.
2022-09-08 21:22:05 -05:00
relrelb ca701c4aeb webgl: Remove `Texture` wrapper
`width` and `height` are already stored in `Bitmap`, so simply use
a `WebGlTexture` directly.
2022-09-08 21:04:02 -05:00
Aaron Hill 974738fe10 tests: Add BitmapData.copyPixels image test from PR #2488 2022-09-08 19:52:48 -05:00
Aaron Hill c090fe30ad core: Mark DisplayObject as non-removed when added to display list
An AVM2 movie can repeatedly remove and add a DisplayObject from/to
a parent. This was causing SolarMax to stop working after advancing
to the next level.
2022-09-08 18:19:25 -05:00
relrelb 7ec587355b text: Store background and border colors as `swf::Color`
Instead of `u32`.
2022-09-08 08:44:50 +03:00