-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] convert rectangular clips into clipsToBounds. #51662
[iOS] convert rectangular clips into clipsToBounds. #51662
Conversation
| ClipViewSetMaskView(clipView); | ||
| [(FlutterClippingMaskView*)clipView.maskView clipRect:(*iter)->GetRect() | ||
| matrix:transformMatrix]; | ||
| clip_rect = transformMatrix.mapRect((*iter)->GetRect()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not be correct, its possible that a skew transform makes a rect non rectangular, we'd need to check that. Also I think once we hit a case where there is a non-clipRect, we'd need to stop using clipsToBounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a mapRect variant that tells you if it was rect-to-rect, I think you have to use bool mapRect(src,dst) to get this info. Alternately, SkMatrix has a getter to ask if it preserves rects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh nice, thank you!
|
The math here can get a bit hairy, and it only covers the rectangle case. I think I will start by trying if Our But with ^ Just my guess of how CALayer is implemented internally :) |
|
That sounds like a good idea @hellohuanlin , I'll close this one! |
See also how macOS is doing this with
|
|
So I did a benchmark on this PR and got the result below (10 runs, iPhone 11). I will try again with more runs (maybe 20) for a more accurate/stable result later. Main branch After this PR Observation
For average frames, the noise and delta are close, so it may be hard to notice a trend by just looking at the graph. However, we should be able to use Google Sheet to see a clear improvement over a course of a week (~50 runs). For 90th/99th/worst frames, since we only sample a very small subset of frames, the noise is much larger. I think we can ignore the data (unless we see a noticeable regression). I still believe that it improves these cases, it's just the variance and we get unlucky. So I believe it's still a very good change to make. |
|
There is a utility in the repo to "pretty print" these A/B tables in Ascii: https://github.com/flutter/flutter/blob/master/dev/devicelab/bin/summarize.dart |
This one almost workes. The idea is that most of our clips are rectangular, and so we can avoid the expensive software rasterization using the UIView clipToBounds functionality.
flutter/flutter#142830