-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
canvas: Reimplement masking #7026
Conversation
ff29ff6
to
ed77ebb
Compare
Use `CanvasRenderingContext2d.clip` for masking instead of using intermediate canvases.
This looks good to me, I'm also impressed about the performance improvement in almost all files. For instance, Ultimate Flash Sonic was running pretty smoothly when played in windowed mode on Newgrounds but was really too slow and so unplayable with larger dimensions or in fullscreen mode. Now it's always smooth. :) While I'm at it, I'd like to mention that the issue I mentioned here showed up again. This is not related to this PR but one of the following commits: nightly-2022-05-18...nightly-2022-05-20 (likely #7029?). Firefox and Chrome on Windows are both affected (canvas render only). The issue is particularly noticeable in Super Mario 63, in the first / tutorial level. |
Thanks! Will fix the bitmap issue in another PR. |
Which became unused in ruffle-rs#7026.
Reimplement masking on the canvas backend using the native
CanvasRenderinContext2d.clip
method.When I first implemented masking in canvas, I didn't think
clip
could handle all of the nuances of Flash masking, so I ended up with a hacky+slow solution of drawing to off-screen canvases and usingglobalCompositeOperation
to blend onto the main canvas. But I think we can handle nearly all of the cases natively usingclip
now:clip(Path2D)
is now supported in all major browsers.clip
. But Flash operates the same as canvas and omits strokes.clip
calls.Fixes Gridlock drawing a blank screen in canvas backend (#6976).