This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
PlatformView Blur for Backdrop Filter #34596
Merged
Merged
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
021480d
Resolving merge conflicts.
emilyabest 5027753
Removed trailing whitespace
emilyabest 24731fa
Removed conflict code. Initial attempt with backdrop filter case.
emilyabest 83b6607
Removed duplicate test
emilyabest fb0684c
Reverted code to pass the unit tests. Prepared method calls for mergi…
emilyabest 31567f4
Ran whitespace check
emilyabest 2bca987
Bringing back old checks.
emilyabest e830e4a
Updated code to plug into Javon's PR. Started unit tests for integrat…
emilyabest c881e11
Saving applyBackdropFilterWithRadius method for reference.
emilyabest 81d2d71
Removed applyBackdropFilterWithRadius method. This is the new startin…
emilyabest bc2e1b1
Updated unit tests to use applyBackdropFilter method
emilyabest ff81803
Ran clang checks
emilyabest 359a10d
First implementation to allow multiple backdrop filters. Also reorgan…
emilyabest cfd473d
Fixed BAD ACCESS error with private instance variable. Prepped for gi…
emilyabest ac3d4cf
Ran formatting checks
emilyabest c501a80
Condensed applyBackdropFilter method
emilyabest b4c64b6
Updated spacing.
emilyabest 0f147e9
Formatted code
emilyabest 604113e
Quick fix for failing applyBackdropFilters unit test. Started PR comm…
emilyabest ade2908
Added unit tests for non-DlImageBlurFilters. Made activeGaussianFilte…
emilyabest 6a1e014
Formatting checks
emilyabest e07cb72
Minor formatting changes
emilyabest d9bcea9
Minor changes for visual testing.
emilyabest 4ae563b
Ran formatting checks
emilyabest 8e48100
Merge branch 'main' into BackdropView
emilyabest b18c2ad
Updated code to work with Chris' PR
emilyabest 732c94d
Formatted code
emilyabest d6066ec
Resolved memory leak failure. Commented pass by reference alternative.
emilyabest 2450016
Reorganized extraction method to use a for loop
emilyabest 995fd57
Formatted code. Previous commit also updates API checks
emilyabest 20a7d8f
Added unit test for invalid UIVEV API
emilyabest d81676f
Formatting check
emilyabest 4e9da14
Implemented Chris' last comments, reverted back to original check to …
emilyabest 2bdaec3
Formatting checks
emilyabest dc064ed
Removed typo
emilyabest beb4090
Formatting checks
emilyabest 5599649
Moved blurEffectView release. Working on GitHub error.
emilyabest def8905
Formatting checks
emilyabest d010037
Adding gaussianFilter copies
emilyabest 029d7cc
Formatting checks
emilyabest 673b641
Simplified applyBackdropBlurFilter method
emilyabest aeef63e
Formatting checks
emilyabest b434756
Moved blurEffectView release to dealloc. Simplified while loops to cl…
emilyabest 9429015
Simplified applyBackdropBlurFilters method
emilyabest cfea8e9
Trying a different init method for newGaussianFilters.
emilyabest 3ed695d
Added autorelease after copying _gaussianFilter
emilyabest c4ab9cb
Merge branch 'main' into BackdropViewPreRebase
emilyabest a1ca917
review feedbacks
ee25e17
remove TODOs
92cc72b
fixes
1dca0dd
update golden
0702129
Merge branch 'main' into BackdropView
c810c40
Revert "Revert "Pushing BackdropFilter Mutator (#34355)" (#35543)"
a043cca
merge main
fd24904
update golden
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,8 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree { | |
| @end | ||
|
|
||
| namespace flutter { | ||
| // Becomes NO if Apple's API changes and blurred backdrop filters cannot be applied. | ||
| BOOL canApplyBlurBackdrop = YES; | ||
|
|
||
| std::shared_ptr<FlutterPlatformViewLayer> FlutterPlatformViewLayerPool::GetLayer( | ||
| GrDirectContext* gr_context, | ||
|
|
@@ -318,6 +320,15 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree { | |
| } | ||
| } | ||
|
|
||
| void FlutterPlatformViewsController::PushFilterToVisitedPlatformViews( | ||
| std::shared_ptr<const DlImageFilter> filter) { | ||
| for (int64_t id : visited_platform_views_) { | ||
| EmbeddedViewParams params = current_composition_params_[id]; | ||
| params.PushImageFilter(filter); | ||
| current_composition_params_[id] = params; | ||
| } | ||
| } | ||
|
|
||
| void FlutterPlatformViewsController::PrerollCompositeEmbeddedView( | ||
| int view_id, | ||
| std::unique_ptr<EmbeddedViewParams> params) { | ||
|
|
@@ -414,6 +425,8 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree { | |
| CGRectGetWidth(flutter_view.bounds), | ||
| CGRectGetHeight(flutter_view.bounds))] autorelease]; | ||
|
|
||
| NSMutableArray* blurRadii = [[[NSMutableArray alloc] init] autorelease]; | ||
|
|
||
| auto iter = mutators_stack.Begin(); | ||
| while (iter != mutators_stack.End()) { | ||
| switch ((*iter)->GetType()) { | ||
|
|
@@ -434,11 +447,25 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree { | |
| case kOpacity: | ||
| embedded_view.alpha = (*iter)->GetAlphaFloat() * embedded_view.alpha; | ||
| break; | ||
| case kBackdropFilter: | ||
| case kBackdropFilter: { | ||
| // We only support DlBlurImageFilter for BackdropFilter. | ||
| if ((*iter)->GetFilter().asBlur() && canApplyBlurBackdrop) { | ||
| // sigma_x is arbitrarily chosen as the radius value because Quartz sets | ||
| // sigma_x and sigma_y equal to each other. DlBlurImageFilter's Tile Mode | ||
| // is not supported in Quartz's gaussianBlur CAFilter, so it is not used | ||
| // to blur the PlatformView. | ||
| [blurRadii addObject:@((*iter)->GetFilter().asBlur()->sigma_x())]; | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| ++iter; | ||
| } | ||
|
|
||
| if (canApplyBlurBackdrop) { | ||
emilyabest marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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. | ||
|
|
@@ -517,6 +544,7 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree { | |
| clip_count_.clear(); | ||
| views_to_recomposite_.clear(); | ||
| layer_pool_->RecycleLayers(); | ||
| visited_platform_views_.clear(); | ||
| } | ||
|
|
||
| SkRect FlutterPlatformViewsController::GetPlatformViewRect(int view_id) { | ||
|
|
@@ -777,6 +805,7 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree { | |
| void FlutterPlatformViewsController::ResetFrameState() { | ||
| slices_.clear(); | ||
| composition_order_.clear(); | ||
| visited_platform_views_.clear(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the fix for flutter/flutter#109783 |
||
| } | ||
|
|
||
| } // namespace flutter | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this push the outstanding clips as well? The filter will only be applied to the region inside those clips. More specifically, the output of the filter on the PlatformView will be clipped by the clips.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should when we figure out how to filter a specific region inside the PlatformView.
We should have a follow up PR to support filter only a part of the PlatformView (at least a rect), which will fix flutter/flutter#50183
And the clip path should be added to the method in that PR.