Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
021480d
Resolving merge conflicts.
emilyabest Jun 10, 2022
5027753
Removed trailing whitespace
emilyabest Jul 15, 2022
24731fa
Removed conflict code. Initial attempt with backdrop filter case.
emilyabest Jul 15, 2022
83b6607
Removed duplicate test
emilyabest Jul 18, 2022
fb0684c
Reverted code to pass the unit tests. Prepared method calls for mergi…
emilyabest Jul 19, 2022
31567f4
Ran whitespace check
emilyabest Jul 19, 2022
2bca987
Bringing back old checks.
emilyabest Jul 19, 2022
e830e4a
Updated code to plug into Javon's PR. Started unit tests for integrat…
emilyabest Jul 19, 2022
c881e11
Saving applyBackdropFilterWithRadius method for reference.
emilyabest Jul 20, 2022
81d2d71
Removed applyBackdropFilterWithRadius method. This is the new startin…
emilyabest Jul 20, 2022
bc2e1b1
Updated unit tests to use applyBackdropFilter method
emilyabest Jul 21, 2022
ff81803
Ran clang checks
emilyabest Jul 21, 2022
359a10d
First implementation to allow multiple backdrop filters. Also reorgan…
emilyabest Jul 21, 2022
cfd473d
Fixed BAD ACCESS error with private instance variable. Prepped for gi…
emilyabest Jul 22, 2022
ac3d4cf
Ran formatting checks
emilyabest Jul 22, 2022
c501a80
Condensed applyBackdropFilter method
emilyabest Jul 25, 2022
b4c64b6
Updated spacing.
emilyabest Jul 25, 2022
0f147e9
Formatted code
emilyabest Jul 25, 2022
604113e
Quick fix for failing applyBackdropFilters unit test. Started PR comm…
emilyabest Jul 27, 2022
ade2908
Added unit tests for non-DlImageBlurFilters. Made activeGaussianFilte…
emilyabest Jul 27, 2022
6a1e014
Formatting checks
emilyabest Jul 27, 2022
e07cb72
Minor formatting changes
emilyabest Jul 28, 2022
d9bcea9
Minor changes for visual testing.
emilyabest Jul 28, 2022
4ae563b
Ran formatting checks
emilyabest Jul 28, 2022
8e48100
Merge branch 'main' into BackdropView
emilyabest Jul 28, 2022
b18c2ad
Updated code to work with Chris' PR
emilyabest Aug 1, 2022
732c94d
Formatted code
emilyabest Aug 1, 2022
d6066ec
Resolved memory leak failure. Commented pass by reference alternative.
emilyabest Aug 2, 2022
2450016
Reorganized extraction method to use a for loop
emilyabest Aug 2, 2022
995fd57
Formatted code. Previous commit also updates API checks
emilyabest Aug 2, 2022
20a7d8f
Added unit test for invalid UIVEV API
emilyabest Aug 3, 2022
d81676f
Formatting check
emilyabest Aug 3, 2022
4e9da14
Implemented Chris' last comments, reverted back to original check to …
emilyabest Aug 4, 2022
2bdaec3
Formatting checks
emilyabest Aug 4, 2022
dc064ed
Removed typo
emilyabest Aug 4, 2022
beb4090
Formatting checks
emilyabest Aug 4, 2022
5599649
Moved blurEffectView release. Working on GitHub error.
emilyabest Aug 9, 2022
def8905
Formatting checks
emilyabest Aug 9, 2022
d010037
Adding gaussianFilter copies
emilyabest Aug 9, 2022
029d7cc
Formatting checks
emilyabest Aug 9, 2022
673b641
Simplified applyBackdropBlurFilter method
emilyabest Aug 10, 2022
aeef63e
Formatting checks
emilyabest Aug 10, 2022
b434756
Moved blurEffectView release to dealloc. Simplified while loops to cl…
emilyabest Aug 10, 2022
9429015
Simplified applyBackdropBlurFilters method
emilyabest Aug 10, 2022
cfea8e9
Trying a different init method for newGaussianFilters.
emilyabest Aug 10, 2022
3ed695d
Added autorelease after copying _gaussianFilter
emilyabest Aug 11, 2022
c4ab9cb
Merge branch 'main' into BackdropViewPreRebase
emilyabest Aug 12, 2022
a1ca917
review feedbacks
Aug 13, 2022
ee25e17
remove TODOs
Aug 18, 2022
92cc72b
fixes
Aug 18, 2022
1dca0dd
update golden
Aug 18, 2022
0702129
Merge branch 'main' into BackdropView
Aug 22, 2022
c810c40
Revert "Revert "Pushing BackdropFilter Mutator (#34355)" (#35543)"
Aug 22, 2022
a043cca
merge main
Aug 29, 2022
fd24904
update golden
Aug 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implemented Chris' last comments, reverted back to original check to …
…call applyBlurBackdropFilters
  • Loading branch information
emilyabest committed Aug 4, 2022
commit 4e9da148fbae273040aeb96f0db2aae2a30dae1c
28 changes: 14 additions & 14 deletions shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree {
NSMutableArray* blurRadii = [[[NSMutableArray alloc] init] autorelease];

// TODO EMILY: this line is for visual simulator tests, delete before landing PR
// int numFilters = 0;

// int numFilters = 0;
auto iter = mutators_stack.Begin();
while (iter != mutators_stack.End()) {
switch ((*iter)->GetType()) {
Expand All @@ -417,16 +417,16 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree {

// TODO EMILY: these lines are for visual simulator tests, delete before landing
// PR
// if(numFilters < 1) {
// flutter::DlBlurImageFilter filter =
// flutter::DlBlurImageFilter(5, 5,
// flutter::DlTileMode::kDecal);
//
// NSNumber* blurRadius = @(filter.asBlur()->sigma_x());
// [blurRadii addObject:blurRadius];
//
// numFilters++;
// }
// if(numFilters < 1) {
// flutter::DlBlurImageFilter filter =
// flutter::DlBlurImageFilter(5, 5,
// flutter::DlTileMode::kDecal);
//
// NSNumber* blurRadius = @(filter.asBlur()->sigma_x());
// [blurRadii addObject:blurRadius];
//
// numFilters++;
// }
break;
}
case kClipRect:
Expand Down Expand Up @@ -456,10 +456,10 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree {
++iter;
}

if (canApplyBlurBackdrop && ([blurRadii count] > 0)) {
if(canApplyBlurBackdrop) {
canApplyBlurBackdrop = [clipView applyBlurBackdropFilters:blurRadii];
}

// Reverse the offset of the clipView.
// The clipView's frame includes the final translate of the final transform matrix.
// So we need to revese this translate so the platform view can layout at the correct offset.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,97 @@ - (void)testApplyMultipleBackdropFilters {
}
}

- (void) testAddBackdropFilters {
flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate;
auto thread_task_runner = CreateNewThread("FlutterPlatformViewsTest");
flutter::TaskRunners runners(/*label=*/self.name.UTF8String,
/*platform=*/thread_task_runner,
/*raster=*/thread_task_runner,
/*ui=*/thread_task_runner,
/*io=*/thread_task_runner);
auto flutterPlatformViewsController = std::make_shared<flutter::FlutterPlatformViewsController>();
auto platform_view = std::make_unique<flutter::PlatformViewIOS>(
/*delegate=*/mock_delegate,
/*rendering_api=*/flutter::IOSRenderingAPI::kSoftware,
/*platform_views_controller=*/flutterPlatformViewsController,
/*task_runners=*/runners);

FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
FlutterResult result = ^(id result) {
};
flutterPlatformViewsController->OnMethodCall(
[FlutterMethodCall
methodCallWithMethodName:@"create"
arguments:@{@"id" : @2, @"viewType" : @"MockFlutterPlatformView"}],
result);

XCTAssertNotNil(gMockPlatformView);

UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease];
flutterPlatformViewsController->SetFlutterView(mockFlutterView);
// Create embedded view params
flutter::MutatorsStack stack;
// Layer tree always pushes a screen scale factor to the stack
SkMatrix screenScaleMatrix =
SkMatrix::Scale([UIScreen mainScreen].scale, [UIScreen mainScreen].scale);
stack.PushTransform(screenScaleMatrix);
// Push a backdrop filter
auto filter = std::make_shared<flutter::DlBlurImageFilter>(5, 2, flutter::DlTileMode::kClamp);
stack.PushBackdropFilter(filter);

auto embeddedViewParams =
std::make_unique<flutter::EmbeddedViewParams>(screenScaleMatrix, SkSize::Make(10, 10), stack);

flutterPlatformViewsController->PrerollCompositeEmbeddedView(2, std::move(embeddedViewParams));
flutterPlatformViewsController->CompositeEmbeddedView(2);
XCTAssertTrue([gMockPlatformView.superview.superview isKindOfClass:[ChildClippingView class]]);
ChildClippingView* childClippingView = (ChildClippingView*)gMockPlatformView.superview.superview;
[mockFlutterView addSubview:childClippingView];

[mockFlutterView setNeedsLayout];
[mockFlutterView layoutIfNeeded];

// childClippingView has the CAFilter, no additional filters were added
XCTAssertEqual(1, (int)[childClippingView.layer.filters count]);
// No new views were added
XCTAssertEqual(0, (int)[gMockPlatformView.subviews count]);

//
// Simulate adding 1 backdrop filter (create a new mutators stack)
// Create embedded view params
flutter::MutatorsStack stack2;
// Layer tree always pushes a screen scale factor to the stack
stack2.PushTransform(screenScaleMatrix);
// Push backdrop filters
for (int i = 0; i < 2; i++) {
stack2.PushBackdropFilter(filter);
}

embeddedViewParams = std::make_unique<flutter::EmbeddedViewParams>(screenScaleMatrix,
SkSize::Make(10, 10), stack2);

flutterPlatformViewsController->PrerollCompositeEmbeddedView(2, std::move(embeddedViewParams));
flutterPlatformViewsController->CompositeEmbeddedView(2);
[mockFlutterView setNeedsLayout];
[mockFlutterView layoutIfNeeded];

// childClippingView has CAFilters for the multiple backdrop filters
XCTAssertEqual(2, (int)[childClippingView.layer.filters count]);
// No new views were added
XCTAssertEqual(0, (int)[gMockPlatformView.subviews count]);

// All filters have sigma X radius
for (int i = 0; i < 2; i++) {
NSObject* gaussianFilter = childClippingView.layer.filters[i];
XCTAssertEqualObjects(@"gaussianBlur", [gaussianFilter valueForKey:@"name"]);
XCTAssertEqualObjects(@(5), [gaussianFilter valueForKey:@"inputRadius"]);
}
}

- (void)testRemoveBackdropFilters {
flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate;
auto thread_task_runner = CreateNewThread("FlutterPlatformViewsTest");
Expand Down Expand Up @@ -896,18 +987,18 @@ - (void)testApplyBackdropFilterAPIChanged {
// Each test requires a new childClippingView
// Valid UIVisualEffectView API
ChildClippingView* childClippingView1 = [[ChildClippingView alloc] init];
childClippingView1.viewToExtractFrom = [[UIVisualEffectView alloc]
childClippingView1.blurEffectView = [[UIVisualEffectView alloc]
initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
XCTAssertTrue([childClippingView1 applyBlurBackdropFilters:blurRadii]);

// Invalid UIVisualEffectView initialization
ChildClippingView* childClippingView2 = [[ChildClippingView alloc] init];
childClippingView2.viewToExtractFrom = [[UIVisualEffectView alloc] init];
childClippingView2.blurEffectView = [[UIVisualEffectView alloc] init];
XCTAssertFalse([childClippingView2 applyBlurBackdropFilters:blurRadii]);

// Invalid UIView
ChildClippingView* childClippingView3 = [[ChildClippingView alloc] init];
childClippingView3.viewToExtractFrom = [[UIView alloc] init];
childClippingView3.blurEffectView = [[UIView alloc] init];
XCTAssertFalse([childClippingView3 applyBlurBackdropFilters:blurRadii]);

// Invalid UIVisualEffectView API for "name"
Expand All @@ -927,7 +1018,7 @@ - (void)testApplyBackdropFilterAPIChanged {
}

ChildClippingView* childClippingView4 = [[ChildClippingView alloc] init];
childClippingView4.viewToExtractFrom = editedUIVisualEffectView1;
childClippingView4.blurEffectView = editedUIVisualEffectView1;
XCTAssertFalse([childClippingView4 applyBlurBackdropFilters:blurRadii]);

// Invalid UIVisualEffectView API for "inputRadius"
Expand All @@ -947,7 +1038,7 @@ - (void)testApplyBackdropFilterAPIChanged {
}

ChildClippingView* childClippingView5 = [[ChildClippingView alloc] init];
childClippingView5.viewToExtractFrom = editedUIVisualEffectView2;
childClippingView5.blurEffectView = editedUIVisualEffectView2;
XCTAssertFalse([childClippingView5 applyBlurBackdropFilters:blurRadii]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
// The UIView used to extract the gaussianBlur filter. This must be a UIVisualEffectView
// initalized with UIBlurEffect to extract the correct filter. Made a public property
// for custom unit tests.
@property(nonatomic, strong) UIView* viewToExtractFrom;
@property(nonatomic, retain) UIView* blurEffectView;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ @implementation ChildClippingView {
NSObject* _gaussianFilter;
}

// Lazy initializes viewToExtractFrom as the expected UIVisualEffectView. The backdropFilter blur
// Lazy initializes blurEffectView as the expected UIVisualEffectView. The backdropFilter blur
// requires this UIVisualEffectView initialization. The lazy initalization is only used to allow
// custom unit tests.
- (UIView*)viewToExtractFrom {
if (!_viewToExtractFrom) {
_viewToExtractFrom = [[[UIVisualEffectView alloc]
initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]] retain];
- (UIView*)blurEffectView {
if (!_blurEffectView) {
// blurEffectView is only needed to extract its gaussianBlur filter. It is released after
// searching its subviews and extracting the filter.
_blurEffectView = [[[UIVisualEffectView alloc]
initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]] retain];
}
return _viewToExtractFrom;
return _blurEffectView;
}

// The ChildClippingView's frame is the bounding rect of the platform view. we only want touches to
Expand All @@ -95,7 +97,7 @@ - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent*)event {
- (NSObject*)extractGaussianFilter {
NSObject* gaussianFilter = nil;

for (UIView* view in self.viewToExtractFrom.subviews) {
for (UIView* view in self.blurEffectView.subviews) {
if ([view isKindOfClass:NSClassFromString(@"_UIVisualEffectBackdropView")]) {
for (CIFilter* filter in view.layer.filters) {
if ([[filter valueForKey:@"name"] isEqual:@"gaussianBlur"]) {
Expand All @@ -114,6 +116,7 @@ - (NSObject*)extractGaussianFilter {
break;
}
}
[self.blurEffectView release];

return gaussianFilter;
}
Expand All @@ -128,7 +131,6 @@ - (BOOL)applyBlurBackdropFilters:(NSArray*)blurRadii {
"access the gaussianBlur CAFilter.";
return NO;
}
[self.viewToExtractFrom release];
}

BOOL updatedFilters = NO;
Expand Down