Flutter Engine
The Flutter Engine
Instance Methods | Class Methods | Properties | 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:
 
(instancetype) - initWithFrame: [implementation]
 
(CAShapeLayer *) - shapeLayer [implementation]
 
(void) - dealloc [implementation]
 
(BOOL- pointInside:withEvent: [implementation]
 
(void) - addTransformedPath:matrix: [implementation]
 

Class Methods

(Class) + layerClass [implementation]
 

Properties

CATransform3D reverseScreenScale [implementation]
 

Detailed Description

Definition at line 31 of file FlutterPlatformViews_Internal.h.

Method Documentation

◆ addTransformedPath:matrix:

- (void) addTransformedPath: (CGPathRef)  path
matrix: (CATransform3D)  matrix 
implementation

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

431 :(CGPathRef)path matrix:(CATransform3D)matrix {
432 CGAffineTransform affine =
433 CGAffineTransformMake(matrix.m11, matrix.m12, matrix.m21, matrix.m22, matrix.m41, matrix.m42);
434 CGPathAddPath(pathSoFar_, &affine, path);
435 [self shapeLayer].path = pathSoFar_;
436 CGPathRelease(path);
437}
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
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: switches.h:57

◆ clipPath:matrix:

- (void) clipPath: (const SkPath&)  path
matrix: (const SkMatrix&)  matrix 

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

366 :(const SkPath&)path matrix:(const SkMatrix&)matrix {
367 if (!path.isValid()) {
368 return;
369 }
370 if (path.isEmpty()) {
371 return;
372 }
373 CGMutablePathRef pathRef = CGPathCreateMutable();
374
375 // Loop through all verbs and translate them into CGPath
376 SkPath::Iter iter(path, true);
377 SkPoint pts[kMaxPointsInVerb];
378 SkPath::Verb verb = iter.next(pts);
379 SkPoint last_pt_from_last_verb = SkPoint::Make(0, 0);
380 while (verb != SkPath::kDone_Verb) {
381 if (verb == SkPath::kLine_Verb || verb == SkPath::kQuad_Verb || verb == SkPath::kConic_Verb ||
382 verb == SkPath::kCubic_Verb) {
383 FML_DCHECK(last_pt_from_last_verb == pts[0]);
384 }
385 switch (verb) {
386 case SkPath::kMove_Verb: {
387 CGPathMoveToPoint(pathRef, nil, pts[0].x(), pts[0].y());
388 last_pt_from_last_verb = pts[0];
389 break;
390 }
391 case SkPath::kLine_Verb: {
392 CGPathAddLineToPoint(pathRef, nil, pts[1].x(), pts[1].y());
393 last_pt_from_last_verb = pts[1];
394 break;
395 }
396 case SkPath::kQuad_Verb: {
397 CGPathAddQuadCurveToPoint(pathRef, nil, pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y());
398 last_pt_from_last_verb = pts[2];
399 break;
400 }
401 case SkPath::kConic_Verb: {
402 // Conic is not available in quartz, we use quad to approximate.
403 // TODO(cyanglaz): Better approximate the conic path.
404 // https://github.com/flutter/flutter/issues/35062
405 CGPathAddQuadCurveToPoint(pathRef, nil, pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y());
406 last_pt_from_last_verb = pts[2];
407 break;
408 }
409 case SkPath::kCubic_Verb: {
410 CGPathAddCurveToPoint(pathRef, nil, pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y(),
411 pts[3].x(), pts[3].y());
412 last_pt_from_last_verb = pts[3];
413 break;
414 }
415 case SkPath::kClose_Verb: {
416 CGPathCloseSubpath(pathRef);
417 break;
418 }
419 case SkPath::kDone_Verb: {
420 break;
421 }
422 }
423 verb = iter.next(pts);
424 }
425 // The `matrix` is based on the physical pixels, convert it to UIKit points.
426 CATransform3D matrixInPoints =
427 CATransform3DConcat(flutter::GetCATransform3DFromSkMatrix(matrix), _reverseScreenScale);
428 [self addTransformedPath:pathRef matrix:matrixInPoints];
429}
Definition: SkPath.h:59
@ kClose_Verb
Definition: SkPath.h:1471
@ kMove_Verb
Definition: SkPath.h:1466
@ kConic_Verb
Definition: SkPath.h:1469
@ kDone_Verb
Definition: SkPath.h:1472
@ kCubic_Verb
Definition: SkPath.h:1470
@ kQuad_Verb
Definition: SkPath.h:1468
@ kLine_Verb
Definition: SkPath.h:1467
#define FML_DCHECK(condition)
Definition: logging.h:103
double y
double x
CATransform3D GetCATransform3DFromSkMatrix(const SkMatrix &matrix)
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

◆ clipRect:matrix:

- (void) clipRect: (const SkRect&)  clipSkRect
matrix: (const SkMatrix&)  matrix 

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

288 :(const SkRect&)clipSkRect matrix:(const SkMatrix&)matrix {
289 CGRect clipRect = flutter::GetCGRectFromSkRect(clipSkRect);
290 CGPathRef path = CGPathCreateWithRect(clipRect, nil);
291 // The `matrix` is based on the physical pixels, convert it to UIKit points.
292 CATransform3D matrixInPoints =
293 CATransform3DConcat(flutter::GetCATransform3DFromSkMatrix(matrix), _reverseScreenScale);
294 [self addTransformedPath:path matrix:matrixInPoints];
295}
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
CGRect GetCGRectFromSkRect(const SkRect &clipSkRect)

◆ clipRRect:matrix:

- (void) clipRRect: (const SkRRect&)  clipSkRRect
matrix: (const SkMatrix&)  matrix 

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

297 :(const SkRRect&)clipSkRRect matrix:(const SkMatrix&)matrix {
298 CGPathRef pathRef = nullptr;
299 switch (clipSkRRect.getType()) {
301 break;
302 }
303 case SkRRect::kRect_Type: {
304 [self clipRect:clipSkRRect.rect() matrix:matrix];
305 return;
306 }
309 CGRect clipRect = flutter::GetCGRectFromSkRect(clipSkRRect.rect());
310 pathRef = CGPathCreateWithRoundedRect(clipRect, clipSkRRect.getSimpleRadii().x(),
311 clipSkRRect.getSimpleRadii().y(), nil);
312 break;
313 }
316 CGMutablePathRef mutablePathRef = CGPathCreateMutable();
317 // Complex types, we manually add each corner.
318 SkRect clipSkRect = clipSkRRect.rect();
319 SkVector topLeftRadii = clipSkRRect.radii(SkRRect::kUpperLeft_Corner);
320 SkVector topRightRadii = clipSkRRect.radii(SkRRect::kUpperRight_Corner);
321 SkVector bottomRightRadii = clipSkRRect.radii(SkRRect::kLowerRight_Corner);
322 SkVector bottomLeftRadii = clipSkRRect.radii(SkRRect::kLowerLeft_Corner);
323
324 // Start drawing RRect
325 // Move point to the top left corner adding the top left radii's x.
326 CGPathMoveToPoint(mutablePathRef, nil, clipSkRect.fLeft + topLeftRadii.x(), clipSkRect.fTop);
327 // Move point horizontally right to the top right corner and add the top right curve.
328 CGPathAddLineToPoint(mutablePathRef, nil, clipSkRect.fRight - topRightRadii.x(),
329 clipSkRect.fTop);
330 CGPathAddCurveToPoint(mutablePathRef, nil, clipSkRect.fRight, clipSkRect.fTop,
331 clipSkRect.fRight, clipSkRect.fTop + topRightRadii.y(),
332 clipSkRect.fRight, clipSkRect.fTop + topRightRadii.y());
333 // Move point vertically down to the bottom right corner and add the bottom right curve.
334 CGPathAddLineToPoint(mutablePathRef, nil, clipSkRect.fRight,
335 clipSkRect.fBottom - bottomRightRadii.y());
336 CGPathAddCurveToPoint(mutablePathRef, nil, clipSkRect.fRight, clipSkRect.fBottom,
337 clipSkRect.fRight - bottomRightRadii.x(), clipSkRect.fBottom,
338 clipSkRect.fRight - bottomRightRadii.x(), clipSkRect.fBottom);
339 // Move point horizontally left to the bottom left corner and add the bottom left curve.
340 CGPathAddLineToPoint(mutablePathRef, nil, clipSkRect.fLeft + bottomLeftRadii.x(),
341 clipSkRect.fBottom);
342 CGPathAddCurveToPoint(mutablePathRef, nil, clipSkRect.fLeft, clipSkRect.fBottom,
343 clipSkRect.fLeft, clipSkRect.fBottom - bottomLeftRadii.y(),
344 clipSkRect.fLeft, clipSkRect.fBottom - bottomLeftRadii.y());
345 // Move point vertically up to the top left corner and add the top left curve.
346 CGPathAddLineToPoint(mutablePathRef, nil, clipSkRect.fLeft,
347 clipSkRect.fTop + topLeftRadii.y());
348 CGPathAddCurveToPoint(mutablePathRef, nil, clipSkRect.fLeft, clipSkRect.fTop,
349 clipSkRect.fLeft + topLeftRadii.x(), clipSkRect.fTop,
350 clipSkRect.fLeft + topLeftRadii.x(), clipSkRect.fTop);
351 CGPathCloseSubpath(mutablePathRef);
352
353 pathRef = mutablePathRef;
354 break;
355 }
356 }
357 // The `matrix` is based on the physical pixels, convert it to UIKit points.
358 CATransform3D matrixInPoints =
359 CATransform3DConcat(flutter::GetCATransform3DFromSkMatrix(matrix), _reverseScreenScale);
360 // TODO(cyanglaz): iOS does not seem to support hard edge on CAShapeLayer. It clearly stated that
361 // the CAShaperLayer will be drawn antialiased. Need to figure out a way to do the hard edge
362 // clipping on iOS.
363 [self addTransformedPath:pathRef matrix:matrixInPoints];
364}
SkVector getSimpleRadii() const
Definition: SkRRect.h:111
Type getType() const
Definition: SkRRect.h:76
const SkRect & rect() const
Definition: SkRRect.h:264
SkVector radii(Corner corner) const
Definition: SkRRect.h:271
@ kOval_Type
non-zero width and height filled with radii
Definition: SkRRect.h:69
@ kSimple_Type
non-zero width and height with equal radii
Definition: SkRRect.h:70
@ kEmpty_Type
zero width or height
Definition: SkRRect.h:67
@ kNinePatch_Type
non-zero width and height with axis-aligned radii
Definition: SkRRect.h:71
@ kRect_Type
non-zero width and height, and zeroed radii
Definition: SkRRect.h:68
@ kComplex_Type
non-zero width and height with arbitrary radii
Definition: SkRRect.h:72
@ kUpperLeft_Corner
index of top-left corner radii
Definition: SkRRect.h:252
@ kLowerRight_Corner
index of bottom-right corner radii
Definition: SkRRect.h:254
@ kUpperRight_Corner
index of top-right corner radii
Definition: SkRRect.h:253
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition: SkRRect.h:255
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

◆ dealloc

- (void) dealloc
implementation

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

275 {
276 CGPathRelease(pathSoFar_);
277}

◆ initWithFrame:

- (instancetype) initWithFrame: (CGRect)  frame
implementation

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

247 :(CGRect)frame {
248 return [self initWithFrame:frame screenScale:[UIScreen mainScreen].scale];
249}
double frame
Definition: examples.cpp:31

◆ initWithFrame:screenScale:

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

Definition at line 237 of file FlutterPlatformViews_Internal.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 pathSoFar_ = CGPathCreateMutable();
256 }
257 return self;
258}
instancetype initWithFrame

◆ layerClass

+ (Class) layerClass
implementation

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

260 {
261 return [CAShapeLayer class];
262}

◆ pointInside:withEvent:

- (BOOL) pointInside: (CGPoint)  point
withEvent: (UIEvent*)  event 
implementation

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

284 :(CGPoint)point withEvent:(UIEvent*)event {
285 return NO;
286}

◆ reset

- (void) reset

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

268 {
269 CGPathRelease(pathSoFar_);
270 pathSoFar_ = CGPathCreateMutable();
271 [self shapeLayer].path = nil;
272 [self setNeedsDisplay];
273}

◆ shapeLayer

- (CAShapeLayer *) shapeLayer
implementation

Definition at line 237 of file FlutterPlatformViews_Internal.mm.

264 {
265 return (CAShapeLayer*)self.layer;
266}

Property Documentation

◆ reverseScreenScale

- (CATransform3D) reverseScreenScale
readwritenonatomicassignimplementation

Definition at line 237 of file FlutterPlatformViews_Internal.mm.


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