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 246 of file FlutterPlatformViews.mm.

Method Documentation

◆ clipPath:matrix:

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

Definition at line 249 of file FlutterPlatformViews.mm.

418 :(const flutter::DlPath&)dlPath matrix:(const flutter::DlMatrix&)matrix {
420
421 CGPathReceiver receiver;
422
423 // TODO(flar): https://github.com/flutter/flutter/issues/164826
424 // CGPaths do not have an inherit fill type, we would need to remember
425 // the fill type and employ it when we use the path.
426 dlPath.Dispatch(receiver);
427
428 // The `matrix` is based on the physical pixels, convert it to UIKit points.
429 CATransform3D matrixInPoints =
430 CATransform3DConcat(GetCATransform3DFromDlMatrix(matrix), _reverseScreenScale);
431 paths_.push_back([self getTransformedPath:receiver.TakePath() matrix:matrixInPoints]);
432}
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 249 of file FlutterPlatformViews.mm.

325 :(const flutter::DlRect&)clipDlRect matrix:(const flutter::DlMatrix&)matrix {
326 CGRect clipRect = GetCGRectFromDlRect(clipDlRect);
327 CGPathRef path = CGPathCreateWithRect(clipRect, nil);
328 // The `matrix` is based on the physical pixels, convert it to UIKit points.
329 CATransform3D matrixInPoints =
330 CATransform3DConcat(GetCATransform3DFromDlMatrix(matrix), _reverseScreenScale);
331 paths_.push_back([self getTransformedPath:path matrix:matrixInPoints]);
332 CGAffineTransform affine = [self affineWithMatrix:matrixInPoints];
333 // Make sure the rect is not rotated (only translated or scaled).
334 if (affine.b == 0 && affine.c == 0) {
335 rectSoFar_ = CGRectIntersection(rectSoFar_, CGRectApplyAffineTransform(clipRect, affine));
336 } else {
338 }
339}
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 249 of file FlutterPlatformViews.mm.

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

◆ initWithFrame:screenScale:

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

Definition at line 249 of file FlutterPlatformViews.mm.

256 :(CGRect)frame screenScale:(CGFloat)screenScale {
257 if (self = [super initWithFrame:frame]) {
258 self.backgroundColor = UIColor.clearColor;
259 _reverseScreenScale = CATransform3DMakeScale(1 / screenScale, 1 / screenScale, 1);
260 rectSoFar_ = self.bounds;
262 }
263 return self;
264}
instancetype initWithFrame

◆ reset

- (void) reset

Definition at line 249 of file FlutterPlatformViews.mm.

274 {
275 paths_.clear();
276 rectSoFar_ = self.bounds;
278 [self shapeLayer].path = nil;
279 [self setNeedsDisplay];
280}

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