| Flutter iOS Embedder |

Instance Methods | List of all members
FlutterClippingMaskView Class Reference

`#import <FlutterPlatformViews_Internal.h>`

Inheritance diagram for FlutterClippingMaskView:

## Instance Methods
(instancetype) | - initWithFrame:screenScale:
(void) | - reset
(void) | - clipRect:matrix:
(void) | - clipRRect:matrix:
(void) | - clipPath:matrix:

## Detailed Description

Definition at line 241 of file FlutterPlatformViews.mm.

## Method Documentation

## ◆ clipPath:matrix:

- (void) clipPath: |  | (const flutter::DlPath&) | path
matrix: |  | (const flutter::DlMatrix&) | matrix

Definition at line 244 of file FlutterPlatformViews.mm.

413 :(const flutter::DlPath&)dlPath matrix:(const flutter::DlMatrix&)matrix {
414 containsNonRectPath_ = YES;
415
416 CGPathReceiver receiver;
417
418 // TODO(flar): https://github.com/flutter/flutter/issues/164826
419 // CGPaths do not have an inherit fill type, we would need to remember
420 // the fill type and employ it when we use the path.
421 dlPath.Dispatch(receiver);
422
423 // The `matrix` is based on the physical pixels, convert it to UIKit points.
424 CATransform3D matrixInPoints =
425 CATransform3DConcat(GetCATransform3DFromDlMatrix(matrix), _reverseScreenScale);
426 paths_.push_back([self getTransformedPath:receiver.TakePath() matrix:matrixInPoints]);
427 }
containsNonRectPath_
BOOL containsNonRectPath_
Definition: FlutterPlatformViews.mm:241
GetCATransform3DFromDlMatrix
static CATransform3D GetCATransform3DFromDlMatrix(const DlMatrix &matrix)
Definition: FlutterPlatformViewsController.mm:44

## ◆ clipRect:matrix:

- (void) clipRect: |  | (const flutter::DlRect&) | clipDlRect
matrix: |  | (const flutter::DlMatrix&) | matrix

Definition at line 244 of file FlutterPlatformViews.mm.

320 :(const flutter::DlRect&)clipDlRect matrix:(const flutter::DlMatrix&)matrix {
321 CGRect clipRect = GetCGRectFromDlRect(clipDlRect);
322 CGPathRef path = CGPathCreateWithRect(clipRect, nil);
323 // The `matrix` is based on the physical pixels, convert it to UIKit points.
324 CATransform3D matrixInPoints =
325 CATransform3DConcat(GetCATransform3DFromDlMatrix(matrix), _reverseScreenScale);
326 paths_.push_back([self getTransformedPath:path matrix:matrixInPoints]);
327 CGAffineTransform affine = [self affineWithMatrix:matrixInPoints];
328 // Make sure the rect is not rotated (only translated or scaled).
329 if (affine.b == 0 && affine.c == 0) {
330 rectSoFar_ = CGRectIntersection(rectSoFar_, CGRectApplyAffineTransform(clipRect, affine));
331 } else {
332 containsNonRectPath_ = YES;
333 }
334 }
rectSoFar_
CGRect rectSoFar_
Definition: FlutterPlatformViews.mm:244
GetCGRectFromDlRect
static CGRect GetCGRectFromDlRect(const DlRect &clipDlRect)
Definition: FlutterPlatformViewsController.mm:77

## ◆ clipRRect:matrix:

- (void) clipRRect: |  | (const flutter::DlRoundRect&) | clipDlRRect
matrix: |  | (const flutter::DlMatrix&) | matrix

Definition at line 244 of file FlutterPlatformViews.mm.

336 :(const flutter::DlRoundRect&)clipDlRRect matrix:(const flutter::DlMatrix&)matrix {
337 if (clipDlRRect.IsEmpty()) {
338 return;
339 } else if (clipDlRRect.IsRect()) {
340 [self clipRect:clipDlRRect.GetBounds() matrix:matrix];
341 return;
342 } else {
343 CGPathRef pathRef = nullptr;
344 containsNonRectPath_ = YES;
345
346 if (clipDlRRect.GetRadii().AreAllCornersSame()) {
347 CGRect clipRect = GetCGRectFromDlRect(clipDlRRect.GetBounds());
348 auto radii = clipDlRRect.GetRadii();
349 pathRef =
350 CGPathCreateWithRoundedRect(clipRect, radii.top_left.width, radii.top_left.height, nil);
351 } else {
352 CGMutablePathRef mutablePathRef = CGPathCreateMutable();
353 // Complex types, we manually add each corner.
354 flutter::DlRect clipDlRect = clipDlRRect.GetBounds();
355 auto left = clipDlRect.GetLeft();
356 auto top = clipDlRect.GetTop();
357 auto right = clipDlRect.GetRight();
358 auto bottom = clipDlRect.GetBottom();
359 flutter::DlRoundingRadii radii = clipDlRRect.GetRadii();
360 auto& top_left = radii.top_left;
361 auto& top_right = radii.top_right;
362 auto& bottom_left = radii.bottom_left;
363 auto& bottom_right = radii.bottom_right;
364
365 // Start drawing RRect
366 // These calculations are off, the AddCurve methods add a Bezier curve
367 // which, for round rects should be a "magic distance" from the end
368 // point of the horizontal/vertical section to the corner.
369 // Move point to the top left corner adding the top left radii's x.
370 CGPathMoveToPoint(mutablePathRef, nil, //
371 left + top_left.width, top);
372 // Move point horizontally right to the top right corner and add the top right curve.
373 CGPathAddLineToPoint(mutablePathRef, nil, //
374 right - top_right.width, top);
375 CGPathAddCurveToPoint(mutablePathRef, nil, //
376 right, top, //
377 right, top + top_right.height, //
378 right, top + top_right.height);
379 // Move point vertically down to the bottom right corner and add the bottom right curve.
380 CGPathAddLineToPoint(mutablePathRef, nil, //
381 right, bottom - bottom_right.height);
382 CGPathAddCurveToPoint(mutablePathRef, nil, //
383 right, bottom, //
384 right - bottom_right.width, bottom, //
385 right - bottom_right.width, bottom);
386 // Move point horizontally left to the bottom left corner and add the bottom left curve.
387 CGPathAddLineToPoint(mutablePathRef, nil, //
388 left + bottom_left.width, bottom);
389 CGPathAddCurveToPoint(mutablePathRef, nil, //
390 left, bottom, //
391 left, bottom - bottom_left.height, //
392 left, bottom - bottom_left.height);
393 // Move point vertically up to the top left corner and add the top left curve.
394 CGPathAddLineToPoint(mutablePathRef, nil, //
395 left, top + top_left.height);
396 CGPathAddCurveToPoint(mutablePathRef, nil, //
397 left, top, //
398 left + top_left.width, top, //
399 left + top_left.width, top);
400 CGPathCloseSubpath(mutablePathRef);
401 pathRef = mutablePathRef;
402 }
403 // The `matrix` is based on the physical pixels, convert it to UIKit points.
404 CATransform3D matrixInPoints =
405 CATransform3DConcat(GetCATransform3DFromDlMatrix(matrix), _reverseScreenScale);
406 // TODO(cyanglaz): iOS does not seem to support hard edge on CAShapeLayer. It clearly stated
407 // that the CAShaperLayer will be drawn antialiased. Need to figure out a way to do the hard
408 // edge clipping on iOS.
409 paths_.push_back([self getTransformedPath:pathRef matrix:matrixInPoints]);
410 }
411 }

## ◆ initWithFrame:screenScale:

- (instancetype) initWithFrame: |  | (CGRect) | frame
screenScale: |  | (CGFloat) | screenScale

Definition at line 244 of file FlutterPlatformViews.mm.

251 :(CGRect)frame screenScale:(CGFloat)screenScale {
252 if (self = [super initWithFrame:frame]) {
253 self.backgroundColor = UIColor.clearColor;
254 _reverseScreenScale = CATransform3DMakeScale(1 / screenScale, 1 / screenScale, 1);
255 rectSoFar_ = self.bounds;
256 containsNonRectPath_ = NO;
257 }
258 return self;
259 }
initWithFrame
instancetype initWithFrame
Definition: FlutterTextInputPlugin.h:179

## ◆ reset

- (void) reset |  |  |

Definition at line 244 of file FlutterPlatformViews.mm.

269 {
270 paths_.clear();
271 rectSoFar_ = self.bounds;
272 containsNonRectPath_ = NO;
273 [self shapeLayer].path = nil;
274 [self setNeedsDisplay];
275 }

The documentation for this class was generated from the following files:

- shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm
- shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h