Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a1c98a6

Browse files
author
Chris Yang
committed
comments and documents
1 parent c870949 commit a1c98a6

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
// Reuse a maskView from the pool, or allocate a new one.
6767
- (FlutterClippingMaskView*)getMaskViewWithFrame:(CGRect)frame;
6868

69-
// Mark all the maskViews available.
69+
// Insert the `maskView` into the pool.
7070
- (void)insertViewToPool:(FlutterClippingMaskView*)maskView;
7171

7272
@end
@@ -291,27 +291,30 @@ class FlutterPlatformViewsController {
291291
int CountClips(const MutatorsStack& mutators_stack);
292292

293293
void ClipViewSetMaskView(UIView* clipView);
294+
294295
// Applies the mutators in the mutators_stack to the UIView chain that was constructed by
295296
// `ReconstructClipViewsChain`
296297
//
297-
// Clips are applied to the super view with a CALayer mask. Transforms are applied to the
298-
// current view that's at the head of the chain. For example the following mutators stack [T_1,
299-
// C_2, T_3, T_4, C_5, T_6] where T denotes a transform and C denotes a clip, will result in the
300-
// following UIView tree:
301-
//
302-
// C_2 -> C_5 -> PLATFORM_VIEW
303-
// (PLATFORM_VIEW is a subview of C_5 which is a subview of C_2)
304-
//
305-
// T_1 is applied to C_2, T_3 and T_4 are applied to C_5, and T_6 is applied to PLATFORM_VIEW.
306-
//
307-
// After each clip operation, we update the head to the super view of the current head.
298+
// Clips are applied to the `embedded_view`'s super view(|ChildClippingView|) using a
299+
// |FlutterClippingMaskView|. Transforms are applied to `embedded_view`
308300
//
309301
// The `bounding_rect` is the final bounding rect of the PlatformView
310302
// (EmbeddedViewParams::finalBoundingRect). If a clip mutator's rect contains the final bounding
311303
// rect of the PlatformView, the clip mutator is not applied for performance optimization.
304+
//
305+
// This method is only called when thew `embedded_view` needs to be re-composited at the current
306+
// frame. See: `CompositeWithParams` for details.
312307
void ApplyMutators(const MutatorsStack& mutators_stack,
313308
UIView* embedded_view,
314309
const SkRect& bounding_rect);
310+
311+
// Composite the PlatformView with `view_id`.
312+
// Every frame, during the paint traversal of the layer tree, this method is called for all
313+
// the PlatformViews in `views_to_recomposite_`.
314+
//
315+
// Note that `views_to_recomposite_` does not represent all the views in the view hierarchy,
316+
// if a PlatformView does not change its composition parameter from last frame, it is not
317+
// included in the `views_to_recomposite_`.
315318
void CompositeWithParams(int64_t view_id, const EmbeddedViewParams& params);
316319

317320
// Allocates a new FlutterPlatformViewLayer if needed, draws the pixels within the rect from

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ @interface FlutterClippingMaskViewPool ()
463463
// This prevents the pool to grow infinately and limits the maximum memory a pool can use.
464464
@property(assign, nonatomic) NSUInteger capacity;
465465

466+
// The pool contains the views that are available to use.
467+
// The number of items in the pool must not excceds `capacity`.
466468
@property(retain, nonatomic) NSMutableSet<FlutterClippingMaskView*>* pool;
467469

468470
@end
@@ -496,6 +498,10 @@ - (FlutterClippingMaskView*)getMaskViewWithFrame:(CGRect)frame {
496498

497499
- (void)insertViewToPool:(FlutterClippingMaskView*)maskView {
498500
FML_DCHECK(![self.pool containsObject:maskView]);
501+
FML_DCHECK([self.pool.count <= self.capacity]);
502+
if (self.pool.count == self.capacity) {
503+
return;
504+
}
499505
[self.pool addObject:maskView];
500506
}
501507

0 commit comments

Comments
 (0)