-
Notifications
You must be signed in to change notification settings - Fork 6k
Layer state stack #35685
Layer state stack #35685
Changes from 14 commits
6a782c2
566f438
3d4450e
82f7d33
135737f
cc0de21
f1c4991
0a3818b
f5100ac
52fb6a7
396560f
52b885e
6c37393
b8b1f52
cd66334
98d76b9
68c0061
b75001a
c60bf8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,38 +47,16 @@ void BackdropFilterLayer::Preroll(PrerollContext* context, | |
| PrerollChildren(context, matrix, &child_paint_bounds); | ||
| child_paint_bounds.join(context->cull_rect); | ||
| set_paint_bounds(child_paint_bounds); | ||
| context->subtree_can_inherit_opacity = true; | ||
| context->rendering_state_flags = LayerStateStack::CALLER_CAN_APPLY_OPACITY; | ||
| } | ||
|
|
||
| void BackdropFilterLayer::Paint(PaintContext& context) const { | ||
| TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint"); | ||
| FML_DCHECK(needs_painting(context)); | ||
|
|
||
| AutoCachePaint save_paint(context); | ||
| save_paint.setBlendMode(blend_mode_); | ||
| if (context.leaf_nodes_builder) { | ||
| // Note that we perform a saveLayer directly on the | ||
| // leaf_nodes_builder here similar to how the SkCanvas | ||
| // path specifies the kLeafNodesCanvas below. | ||
| // See https:://flutter.dev/go/backdrop-filter-with-overlay-canvas | ||
| context.leaf_nodes_builder->saveLayer(&paint_bounds(), | ||
| save_paint.dl_paint(), filter_.get()); | ||
|
|
||
| PaintChildren(context); | ||
|
|
||
| context.leaf_nodes_builder->restore(); | ||
| } else { | ||
| auto sk_filter = filter_ ? filter_->skia_object() : nullptr; | ||
| Layer::AutoSaveLayer save = Layer::AutoSaveLayer::Create( | ||
| context, | ||
| SkCanvas::SaveLayerRec{&paint_bounds(), save_paint.sk_paint(), | ||
| sk_filter.get(), 0}, | ||
| // BackdropFilter should only happen on the leaf nodes canvas. | ||
| // See https:://flutter.dev/go/backdrop-filter-with-overlay-canvas | ||
| AutoSaveLayer::SaveMode::kLeafNodesCanvas); | ||
|
|
||
| PaintChildren(context); | ||
| } | ||
| auto save = context.state_stack.saveWithBackdropFilter(&paint_bounds(), | ||
|
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. If the parent node is OpacityLayer, here we need set the alpha of paint.
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. the test case is
Contributor
Author
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. Opacity inheritance is not really implemented yet - there is a skeleton of a concept for it, but it is not ready for review, just an inkling of where I'm headed. I'm still working out what is the best way to manage it with the new mechanism and what the API for layers will look like. |
||
| filter_, blend_mode_); | ||
| PaintChildren(context); | ||
| } | ||
|
|
||
| } // namespace flutter | ||
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.
Here, if mostly CF can commute with alpha, but if the CF is a MtrixCF and has specific alpha in the matrix it should not commute with alpha?