-
Notifications
You must be signed in to change notification settings - Fork 6k
[macOS] Implement platform view mutators #38699
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
LayerPlayground example: Mutators.mov |
8fdc4ad to
8381eb6
Compare
5ea3e49 to
8fd2e80
Compare
|
@cyanglaz might also be a reviewer with some context on this PR. |
cyanglaz
left a comment
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.
Did a quick first scan through. I will do a detailed review next week.
|
|
||
| @interface FlutterMutatorView (Private) | ||
|
|
||
| @property(readonly, nonatomic, nonnull) NSMutableArray<NSView*>* pathClipViews; |
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.
If the intention is to not mutate the array, it should be declared as NSArray.
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 is only only accessed from tests, I'll make it NSArray.
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.
If they are only accessed from tests, we can move the category to the test file instead.
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.
Agreed; we should keep test-specific code with the tests.
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.
I like the idea. I think in other parts of engine we also have private methods that could go into test. Maybe for a follow-up PR.
|
|
||
| NSView* lastView = self; | ||
|
|
||
| for (size_t i = 0; i < paths.count; ++i) { |
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.
iOS had a gesture problem when using this approach: flutter/flutter#46167
I'm not sure how drag/scroll events are handled on mac, it might or might not apply to macOS.
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.
I haven't tried to address input yet. It is possible that this won't work with NSGestureRecognizer or rotate/magnify/swipe. Still, I'd want to avoid rasterizing the clip path as much as possible, since it uses additional memory and likely perform quite badly when clip shape changes frequently (i.e. animation).
So if current approach proves problematic and we can't change nesting on fly, alternatively we could always precreate N clip views, where N-1 views would be masked to CAShapeLayer, and the N-th one will contain rest of the paths rasterized.
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.
Maybe dragging a PlatformView is a lot less common on macOS.
At least we should test it and document if the issue does exist.
precreate N clip views, where N-1 views would be masked to CAShapeLayer, and the N-th one will contain rest of the paths rasterized.
This sounds good to me. We can probably also adapt this on iOS to improve performance when there are no complex nested clips.
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.
Another thing is that this PR clips to path only when round rect corners are affected. And in future possibly for path-based clip regions, but there's no way to pass those through embedder API yet. So in many cases, when the resulting clip is a rectangle, clipping is performed by container layer bounds set to intersection of clip rectangles. Which should be quite cheap. While I think the iOS version will clip to path even for rectangular clip? It's been a while, I might be misremembering it.
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.
Another thing is that this PR clips to path only when round rect corners are affected.
Nice, this is a good performance enhancement.
While I think the iOS version will clip to path even for rectangular clip? It's been a while, I might be misremembering it.
Yes you are correct. We can definitely improve iOS performance by doing something similar: setting the frame of the ChildClippingView when the final clip result is a rect, and remove the maskView. This would be a good improvement.
|
Should get to this over the next couple days - just got back from vacation and catching up on email/reviews. Thanks for sending this! |
|
@cbracken Friendly ping. |
0769368 to
92872c4
Compare
cbracken
left a comment
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.
Apologies for the long turn-around on this. Overall, this looks great. Thanks for authoring. Just the tweaks relating to the test specific properties, other than that lgtm.
92872c4 to
7470f77
Compare
|
May I land this? |
|
Yes. This is good to go. |
…120928) * 7cf63a03f [Impeller] use IPSampleDecal in advanced blends. (flutter/engine#39523) * 9da851557 Remove extraneous if (flutter/engine#39683) * 6602fc753 [macOS] Implement platform view mutators (flutter/engine#38699)
This implements support for platform view mutators currently provided through the embedder API, namely:
Notes
CAShapeLayermasks, which avoids the need for rasterizing mask layer.Clipping to arbitrary path is not currently supported by embedder API. However once there is a way to represent it in the embedder API it should be fairly straightforward to add to
FlutterMutatorView.Fixes flutter/flutter#118142
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.