A delegate that attempts to forward opacity from a save layer to child contents.
Currently this has a hardcoded limit of 3 entities in a pass, and cannot forward to child subpass delegates.
Definition at line 52 of file paint_pass_delegate.h.
bool impeller::OpacityPeepholePassDelegate::CanCollapseIntoParentPass |
( |
EntityPass * |
entity_pass | ) |
|
|
overridevirtual |
Whether or not this entity pass can be collapsed into the parent. If true, this method may modify the entities for the current pass.
Implements impeller::EntityPassDelegate.
Definition at line 72 of file paint_pass_delegate.cc.
76 if (entity_pass->GetBoundsLimitMightClipContent()) {
95 if (entity_pass->GetElementCount() > 3) {
102 bool all_can_accept =
true;
103 std::vector<Rect> all_coverages;
104 auto had_subpass = entity_pass->IterateUntilSubpass(
105 [&all_coverages, &all_can_accept](Entity& entity) {
106 const auto& contents = entity.GetContents();
107 if (!entity.CanInheritOpacity()) {
108 all_can_accept = false;
111 auto maybe_coverage = contents->GetCoverage(entity);
112 if (maybe_coverage.has_value()) {
113 auto coverage = maybe_coverage.value();
114 for (const auto& cv : all_coverages) {
115 if (cv.IntersectsWithRect(coverage)) {
116 all_can_accept = false;
120 all_coverages.push_back(coverage);
124 if (had_subpass || !all_can_accept) {
128 entity_pass->IterateUntilSubpass([&alpha](Entity& entity) {
129 entity.SetInheritedOpacity(alpha);
References impeller::Color::alpha, impeller::Entity::CanInheritOpacity(), impeller::Paint::color, impeller::Paint::color_filter, impeller::EntityPass::GetBoundsLimitMightClipContent(), impeller::Entity::GetContents(), impeller::EntityPass::GetElementCount(), impeller::Paint::image_filter, and impeller::EntityPass::IterateUntilSubpass().