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
[Impeller] Incorporate filters in subpass coverage. #45778
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -110,12 +110,39 @@ std::optional<Rect> EntityPass::GetElementsCoverage( | |
if (auto entity = std::get_if<Entity>(&element)) { | ||
coverage = entity->GetCoverage(); | ||
|
||
// When the coverage limit is std::nullopt, that means there is no limit, | ||
// as opposed to empty coverage. | ||
if (coverage.has_value() && coverage_limit.has_value()) { | ||
coverage = coverage->Intersection(coverage_limit.value()); | ||
const auto* filter = entity->GetContents()->AsFilter(); | ||
if (!filter || filter->IsTranslationOnly()) { | ||
coverage = coverage->Intersection(coverage_limit.value()); | ||
} | ||
} | ||
} else if (auto subpass = | ||
} else if (auto subpass_ptr = | ||
std::get_if<std::unique_ptr<EntityPass>>(&element)) { | ||
coverage = GetSubpassCoverage(*subpass->get(), coverage_limit); | ||
auto& subpass = *subpass_ptr->get(); | ||
|
||
std::optional<Rect> unfiltered_coverage = | ||
GetSubpassCoverage(subpass, std::nullopt); | ||
if (!unfiltered_coverage.has_value()) { | ||
continue; | ||
} | ||
|
||
std::shared_ptr<FilterContents> image_filter = | ||
subpass.delegate_->WithImageFilter(*unfiltered_coverage, | ||
subpass.xformation_); | ||
if (image_filter) { | ||
Entity subpass_entity; | ||
subpass_entity.SetTransformation(subpass.xformation_); | ||
coverage = image_filter->GetCoverage(subpass_entity); | ||
} else { | ||
coverage = unfiltered_coverage; | ||
} | ||
|
||
if (coverage.has_value() && coverage_limit.has_value() && | ||
(!image_filter || image_filter->IsTranslationOnly())) { | ||
coverage = coverage->Intersection(coverage_limit.value()); | ||
} | ||
} else { | ||
FML_UNREACHABLE(); | ||
} | ||
|
@@ -135,6 +162,16 @@ std::optional<Rect> EntityPass::GetElementsCoverage( | |
std::optional<Rect> EntityPass::GetSubpassCoverage( | ||
const EntityPass& subpass, | ||
std::optional<Rect> coverage_limit) const { | ||
std::shared_ptr<FilterContents> image_filter = | ||
subpass.delegate_->WithImageFilter(Rect(), subpass.xformation_); | ||
|
||
// If the filter graph transforms the basis of the subpass, then its space | ||
// has deviated too much from the parent pass to safely intersect with the | ||
// pass coverage limit. | ||
coverage_limit = | ||
(image_filter && image_filter->IsTranslationOnly() ? std::nullopt | ||
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. Should this be 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. Yeah |
||
: coverage_limit); | ||
|
||
auto entities_coverage = subpass.GetElementsCoverage(coverage_limit); | ||
// The entities don't cover anything. There is nothing to do. | ||
if (!entities_coverage.has_value()) { | ||
|
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
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.
Dry by comment on an unrelated item: Instead of booleans for absorb_opacity and is_subpass, I'd rather have a typed enum with AbsorbOpacity::kYes and AbsorbOpacity::kNo and the like.
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.
Added an issue about this: flutter/flutter#134681