Skip to content
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

Optimize clipping #9

Open
RazrFalcon opened this issue Nov 7, 2020 · 6 comments
Open

Optimize clipping #9

RazrFalcon opened this issue Nov 7, 2020 · 6 comments

Comments

@RazrFalcon
Copy link
Owner

Currently, we're using just a simple alpha mask, unlike Skia, which has a very complicated clipping algorithm. It's like 5000 LOC. But this algorithms is always faster that just a mask and uses less memory.

@rvolgers
Copy link

rvolgers commented Dec 5, 2020

These blog posts have some interesting details on Skia's complex clipping, and what can go wrong with it:

https://googleprojectzero.blogspot.com/2018/07/drawing-outside-box-precision-issues-in.html

https://googleprojectzero.blogspot.com/2019/02/the-curious-case-of-convexity-confusion.html

The main focus of these posts is on in-depth discussion of vulnerabilities. But the general discussion of the algorithms and awareness of past problems might be useful. May need to Ctrl+F "skia" and/or "clipping" to get to the good bits.

@RazrFalcon
Copy link
Owner Author

Since this is mostly a port, we would get all those fixes for free. But yes, it was an interesting insight. I didn't know there are blog posts about Skia by the developers itself.

As for the security, it shouldn't be an issue, since in tiny-skia pixels access is checked.

@rvolgers
Copy link

rvolgers commented Dec 5, 2020

As for the security, it shouldn't be an issue, since in tiny-skia pixels access is checked.

My main reason for posting these links is so the risk can be taken into account in future development decisions, such as keeping pixel access checked or not, or implementing complex clipping.

If you were already planning to keep all pixel access checked, perhaps it will help others understand that direction.

@RazrFalcon
Copy link
Owner Author

Sure. I just wanted to clarify that I'm trying to stick to Skia as close as possible, because basically each line is an edge-case.

@notgull
Copy link

notgull commented Dec 9, 2023

I just ran into this in https://src.notgull.net/notgull/theo/issues/1. At the moment I'm using the clip mask in order to compute the clip mask for my hardware rendered backends as well (as it was simpler to implement). However, using the mask slows the application to a crawl; from 60 FPS to 20 FPS or lower.

@RazrFalcon
Copy link
Owner Author

Yes, we should at least add the rectangle clip shortcut.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants