Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
FlutterClippingMaskView Class Reference

#include <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 252 of file FlutterPlatformViews.mm.

Method Documentation

◆ clipPath:matrix:

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

Definition at line 255 of file FlutterPlatformViews.mm.

424 :(const flutter::DlPath&)dlPath matrix:(const flutter::DlMatrix&)matrix {
426
427 CGPathReceiver receiver;
428
429 // TODO(flar): https://github.com/flutter/flutter/issues/164826
430 // CGPaths do not have an inherit fill type, we would need to remember
431 // the fill type and employ it when we use the path.
432 dlPath.Dispatch(receiver);
433
434 // The `matrix` is based on the physical pixels, convert it to UIKit points.
435 CATransform3D matrixInPoints =
436 CATransform3DConcat(GetCATransform3DFromDlMatrix(matrix), _reverseScreenScale);
437 paths_.push_back([self getTransformedPath:receiver.TakePath() matrix:matrixInPoints]);
438}
BOOL containsNonRectPath_
static CATransform3D GetCATransform3DFromDlMatrix(const DlMatrix &matrix)
impeller::Matrix DlMatrix

◆ clipRect:matrix:

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

Definition at line 255 of file FlutterPlatformViews.mm.

331 :(const flutter::DlRect&)clipDlRect matrix:(const flutter::DlMatrix&)matrix {
332 CGRect clipRect = GetCGRectFromDlRect(clipDlRect);
333 CGPathRef path = CGPathCreateWithRect(clipRect, nil);
334 // The `matrix` is based on the physical pixels, convert it to UIKit points.
335 CATransform3D matrixInPoints =
336 CATransform3DConcat(GetCATransform3DFromDlMatrix(matrix), _reverseScreenScale);
337 paths_.push_back([self getTransformedPath:path matrix:matrixInPoints]);
338 CGAffineTransform affine = [self affineWithMatrix:matrixInPoints];
339 // Make sure the rect is not rotated (only translated or scaled).
340 if (affine.b == 0 && affine.c == 0) {
341 rectSoFar_ = CGRectIntersection(rectSoFar_, CGRectApplyAffineTransform(clipRect, affine));
342 } else {
344 }
345}
CGRect rectSoFar_
static CGRect GetCGRectFromDlRect(const DlRect &clipDlRect)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switch_defs.h:52

◆ clipRRect:matrix:

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

Definition at line 255 of file FlutterPlatformViews.mm.

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

◆ initWithFrame:screenScale:

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

Definition at line 255 of file FlutterPlatformViews.mm.

262 :(CGRect)frame screenScale:(CGFloat)screenScale {
263 if (self = [super initWithFrame:frame]) {
264 self.backgroundColor = UIColor.clearColor;
265 _reverseScreenScale = CATransform3DMakeScale(1 / screenScale, 1 / screenScale, 1);
266 rectSoFar_ = self.bounds;
268 }
269 return self;
270}
instancetype initWithFrame

◆ reset

- (void) reset

Definition at line 255 of file FlutterPlatformViews.mm.

280 {
281 paths_.clear();
282 rectSoFar_ = self.bounds;
284 [self shapeLayer].path = nil;
285 [self setNeedsDisplay];
286}

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