5#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
7#include "flutter/display_list/effects/dl_image_filter.h"
8#include "flutter/fml/platform/darwin/cf_utils.h"
9#import "flutter/shell/platform/darwin/ios/ios_surface.h"
21 std::unique_ptr<IOSSurface> ios_surface,
22 std::unique_ptr<Surface>
surface)
23 : overlay_view(overlay_view),
24 overlay_view_wrapper(overlay_view_wrapper),
25 ios_surface(
std::move(ios_surface)),
33 mask_view_pool_.
reset(
40 return weak_factory_->GetWeakPtr();
45 CATransform3D
transform = CATransform3DIdentity;
60 layer.anchorPoint = CGPointZero;
61 layer.position = CGPointZero;
70 const CGFloat epsilon = 0.01;
71 return radius1 - radius2 < epsilon;
84- (void)updateVisualEffectView:(UIVisualEffectView*)visualEffectView;
98 blurRadius:(CGFloat)blurRadius
99 visualEffectView:(UIVisualEffectView*)visualEffectView {
105 FML_DLOG(
ERROR) <<
"Apple's API for UIVisualEffectView changed. Update the implementation to "
106 "access the gaussianBlur CAFilter.";
109 _backdropFilterView = visualEffectView;
110 _backdropFilterViewConfigured = NO;
122+ (void)prepareOnce:(UIVisualEffectView*)visualEffectView {
126 for (NSUInteger
i = 0;
i < visualEffectView.subviews.count;
i++) {
127 UIView* view = visualEffectView.subviews[i];
128 if ([NSStringFromClass([view
class]) hasSuffix:
@"BackdropView"]) {
130 for (NSObject* filter in view.layer.filters) {
131 if ([[filter valueForKey:
@"name"] isEqual:
@"gaussianBlur"] &&
132 [[filter valueForKey:
@"inputRadius"] isKindOfClass:[NSNumber class]]) {
133 _gaussianBlurFilter = filter;
137 }
else if ([NSStringFromClass([view
class]) hasSuffix:
@"VisualEffectSubview"]) {
150 if (!
self.backdropFilterViewConfigured) {
151 [
self updateVisualEffectView:_backdropFilterView];
152 self.backdropFilterViewConfigured = YES;
154 return _backdropFilterView;
157- (void)updateVisualEffectView:(UIVisualEffectView*)visualEffectView {
158 NSObject* gaussianBlurFilter = [_gaussianBlurFilter copy];
160 UIView* backdropView = visualEffectView.subviews[_indexOfBackdropView];
161 [gaussianBlurFilter setValue:@(_blurRadius) forKey:@"inputRadius"];
162 backdropView.layer.filters = @[ gaussianBlurFilter ];
164 UIView* visualEffectSubview = visualEffectView.subviews[_indexOfVisualEffectSubview];
165 visualEffectSubview.layer.backgroundColor = UIColor.clearColor.CGColor;
166 visualEffectView.frame = _frame;
168 self.backdropFilterView = visualEffectView;
185- (
BOOL)pointInside:(CGPoint)point withEvent:(
UIEvent*)event {
186 for (UIView* view in
self.subviews) {
187 if ([view pointInside:[
self convertPoint:point toView:view] withEvent:
event]) {
196 if (
self.filters.count == 0 &&
filters.count == 0) {
200 NSUInteger index = 0;
201 for (index = 0; index <
self.filters.count; index++) {
202 UIVisualEffectView* backdropFilterView;
204 if (
self.backdropFilterSubviews.count <= index) {
205 backdropFilterView = filter.backdropFilterView;
206 [self addSubview:backdropFilterView];
207 [self.backdropFilterSubviews addObject:backdropFilterView];
209 [filter updateVisualEffectView:self.backdropFilterSubviews[index]];
212 for (NSUInteger
i =
self.backdropFilterSubviews.count;
i > index;
i--) {
213 [self.backdropFilterSubviews[i - 1] removeFromSuperview];
214 [self.backdropFilterSubviews removeLastObject];
219 if (!_backdropFilterSubviews) {
220 _backdropFilterSubviews = [[NSMutableArray alloc] init];
222 return _backdropFilterSubviews;
239- (void)addTransformedPath:(CGPathRef)path matrix:(CATransform3D)matrix;
244 CGMutablePathRef pathSoFar_;
248 return [
self initWithFrame:frame screenScale:[UIScreen mainScreen].scale];
251- (instancetype)
initWithFrame:(CGRect)frame screenScale:(CGFloat)screenScale {
253 self.backgroundColor = UIColor.clearColor;
254 _reverseScreenScale = CATransform3DMakeScale(1 / screenScale, 1 / screenScale, 1);
255 pathSoFar_ = CGPathCreateMutable();
261 return [CAShapeLayer class];
264- (CAShapeLayer*)shapeLayer {
265 return (CAShapeLayer*)
self.layer;
269 CGPathRelease(pathSoFar_);
270 pathSoFar_ = CGPathCreateMutable();
271 [
self shapeLayer].path = nil;
272 [
self setNeedsDisplay];
276 CGPathRelease(pathSoFar_);
284- (
BOOL)pointInside:(CGPoint)point withEvent:(
UIEvent*)event {
292 CATransform3D matrixInPoints =
294 [
self addTransformedPath:path matrix:matrixInPoints];
298 CGPathRef pathRef =
nullptr;
299 switch (clipSkRRect.
getType()) {
304 [
self clipRect:clipSkRRect.rect() matrix:matrix];
316 CGMutablePathRef mutablePathRef = CGPathCreateMutable();
326 CGPathMoveToPoint(mutablePathRef, nil, clipSkRect.
fLeft + topLeftRadii.
x(), clipSkRect.
fTop);
328 CGPathAddLineToPoint(mutablePathRef, nil, clipSkRect.
fRight - topRightRadii.
x(),
330 CGPathAddCurveToPoint(mutablePathRef, nil, clipSkRect.
fRight, clipSkRect.
fTop,
331 clipSkRect.
fRight, clipSkRect.
fTop + topRightRadii.
y(),
332 clipSkRect.
fRight, clipSkRect.
fTop + topRightRadii.
y());
334 CGPathAddLineToPoint(mutablePathRef, nil, clipSkRect.
fRight,
335 clipSkRect.
fBottom - bottomRightRadii.
y());
336 CGPathAddCurveToPoint(mutablePathRef, nil, clipSkRect.
fRight, clipSkRect.
fBottom,
340 CGPathAddLineToPoint(mutablePathRef, nil, clipSkRect.
fLeft + bottomLeftRadii.
x(),
342 CGPathAddCurveToPoint(mutablePathRef, nil, clipSkRect.
fLeft, clipSkRect.
fBottom,
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);
353 pathRef = mutablePathRef;
358 CATransform3D matrixInPoints =
363 [
self addTransformedPath:pathRef matrix:matrixInPoints];
367 if (!
path.isValid()) {
370 if (
path.isEmpty()) {
373 CGMutablePathRef pathRef = CGPathCreateMutable();
387 CGPathMoveToPoint(pathRef, nil, pts[0].
x(), pts[0].
y());
388 last_pt_from_last_verb = pts[0];
392 CGPathAddLineToPoint(pathRef, nil, pts[1].
x(), pts[1].
y());
393 last_pt_from_last_verb = pts[1];
397 CGPathAddQuadCurveToPoint(pathRef, nil, pts[1].
x(), pts[1].
y(), pts[2].
x(), pts[2].
y());
398 last_pt_from_last_verb = pts[2];
405 CGPathAddQuadCurveToPoint(pathRef, nil, pts[1].
x(), pts[1].
y(), pts[2].
x(), pts[2].
y());
406 last_pt_from_last_verb = pts[2];
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];
416 CGPathCloseSubpath(pathRef);
423 verb = iter.next(pts);
426 CATransform3D matrixInPoints =
428 [
self addTransformedPath:pathRef matrix:matrixInPoints];
431- (void)addTransformedPath:(CGPathRef)path matrix:(CATransform3D)matrix {
432 CGAffineTransform affine =
434 CGPathAddPath(pathSoFar_, &affine,
path);
435 [
self shapeLayer].path = pathSoFar_;
449@property(nonatomic) NSMutableSet<FlutterClippingMaskView*>*
pool;
455- (instancetype)initWithCapacity:(NSInteger)capacity {
459 _pool = [[NSMutableSet alloc] initWithCapacity:1];
467 if (
self.pool.count == 0) {
470 screenScale:UIScreen.mainScreen.scale];
473 maskView.frame =
frame;
475 [
self.pool removeObject:maskView];
482 if (
self.pool.count ==
self.capacity) {
485 [
self.pool addObject:maskView];
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
SkVector getSimpleRadii() const
const SkRect & rect() const
SkVector radii(Corner corner) const
@ kOval_Type
non-zero width and height filled with radii
@ kSimple_Type
non-zero width and height with equal radii
@ kEmpty_Type
zero width or height
@ kNinePatch_Type
non-zero width and height with axis-aligned radii
@ kRect_Type
non-zero width and height, and zeroed radii
@ kComplex_Type
non-zero width and height with arbitrary radii
@ kUpperLeft_Corner
index of top-left corner radii
@ kLowerRight_Corner
index of bottom-right corner radii
@ kUpperRight_Corner
index of top-right corner radii
@ kLowerLeft_Corner
index of bottom-left corner radii
void reset(NST *object=Traits::InvalidValue(), scoped_policy::OwnershipPolicy policy=scoped_policy::OwnershipPolicy::kAssume)
#define FML_DLOG(severity)
#define FML_DCHECK(condition)
NSArray< PlatformViewFilter * > * filters
NSMutableArray * backdropFilterSubviews()
CATransform3D reverseScreenScale
instancetype initWithFrame
clipRRect(r.rrect, r.opAA.op(), r.opAA.aa())) DRAW(ClipRect
unsigned useCenter Optional< SkMatrix > matrix
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
clipPath(r.path, r.opAA.op(), r.opAA.aa())) DRAW(ClipRRect
BOOL BlurRadiusEqualToBlurRadius(CGFloat radius1, CGFloat radius2)
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
void ResetAnchor(CALayer *layer)
CATransform3D GetCATransform3DFromSkMatrix(const SkMatrix &matrix)
CGRect GetCGRectFromSkRect(const SkRect &clipSkRect)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
static constexpr SkPoint Make(float x, float y)
constexpr float y() const
constexpr float x() const
SkScalar fBottom
larger y-axis bounds
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
SkScalar fTop
smaller y-axis bounds