-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fuchsia] Move physical shape layer compositing to Flutter #17005
[Fuchsia] Move physical shape layer compositing to Flutter #17005
Conversation
flow/scene_update_context.cc
Outdated
// if there is a OpacityNode higher in the tree with opacity != 1. For now, | ||
// clamp to a infinitesimally smaller value than 1, which does not cause visual | ||
// problems in practice. | ||
opacity_node_.SetOpacity(std::min(1 - FLT_EPSILON, opacity_ / 255.0f)); |
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.
add Scenic bug for API for marking surfaces as transparent
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.
flow/layers/physical_shape_layer.h
Outdated
@@ -37,11 +37,18 @@ class PhysicalShapeLayer : public ContainerLayer { | |||
|
|||
#if defined(OS_FUCHSIA) | |||
void UpdateScene(SceneUpdateContext& context) override; | |||
|
|||
void UpdateSceneChildren(SceneUpdateContext& context); |
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.
I just realized that UpdateSceneChildren
is protected
in other layers but public
in here. Shall we make them consistent as I don't see why this needs to be public. Also, it might be nice to add some documentation to these function declarations. Although we lack the documentation traditionally (just like tests), we're pushing for better documentations and tests for all new code.
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.
You can avoid overriding it entirely if you follow one of my suggestions above
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.
Removed the separate method and moved inline, which removed a member variable at the cost of a little extra duplication.
flow/scene_update_context.cc
Outdated
@@ -222,6 +222,9 @@ SceneUpdateContext::ExecutePaintTasks(CompositorContext::ScopedFrame& frame) { | |||
surfaces_to_submit.emplace_back(std::move(task.surface)); | |||
} | |||
paint_tasks_.clear(); | |||
alpha_ = 1.f; | |||
topmost_global_scenic_elevation_ = 10.f; |
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.
I curious where this 10.f
comes from, and whether it's configurable.
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.
will pull out to constant
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.
Done
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.
Nit: did you forget to use kScenicZElevationBetweenLayers
here? I saw that you've changed other places.
flow/scene_update_context.h
Outdated
|
||
float GetGlobalElevationForNextScenicLayer() { | ||
float elevation = topmost_global_scenic_elevation_; | ||
topmost_global_scenic_elevation_ += 10.f; |
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.
same for the 10.f
here.
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.
Done.
@@ -134,9 +134,9 @@ class VulkanSurface final | |||
// |EntityNode| associated with the retained surface instead of using the | |||
// retained surface directly. Hence Flutter can't modify the surface during | |||
// retained rendering. | |||
const scenic::EntityNode& GetRetainedNode() { | |||
scenic::EntityNode* GetRetainedNode() { |
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.
The comment of this method says that we want to prevent Flutter from modifying the surface. Is changing const scenic::EntityNode&
to scenic::EntityNode*
breaking that promise?
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. Updating comment.
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.
I think this will be good once we do the simplifications and write a screenshot test
flow/layers/physical_shape_layer.cc
Outdated
// PhysicalShapeLayers that appear above the embedded content will be turned | ||
// into their own Scenic layers. | ||
if (child_layer_exists_below_) { | ||
// Reset paint bounds, because shadows are not rendered in this case |
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.
Are you sure about this part? There is no comment (or changes at all for that matter) in Paint()
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.
Actually, after reading forward I'm even more sure. If you follow my other comment below in this function, you can remove this
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.
Look for "// TODO: Re-enable shadow drawing here." in Pain().
I think our offline discussion clarified why we need to do a check for child_layer_exists_below_; keeping it. Let me know if that wasn't the case.
flow/layers/physical_shape_layer.h
Outdated
#endif // defined(OS_FUCHSIA) | ||
|
||
float total_elevation() const { return total_elevation_; } | ||
|
||
private: | ||
#if defined(OS_FUCHSIA) | ||
float local_scenic_elevation_ = 0.0f; |
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.
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.
see comments above for child_layer_exists_below_
As far as children_need_system_compositing_ -- I think you are right, we can just get away with always calling UpdateSceneChildren in PhysicalShapeLayer::UpdateScene. I initially thought I needed it for correctness, but I think at this point it's just a tiny optimization. Getting rid of it will simplify things.
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.
flow/layers/physical_shape_layer.cc
Outdated
|
||
// Node: UpdateSceneChildren needs to be called here so that |frame| is still | ||
// in scope (and therefore alive) while UpdateSceneChildren is being called. | ||
if (children_need_system_compositing_) { |
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.
You shouldn't need this if, UpdateSceneChildren will check internally whether each child needs system compositing or not and skip over it if it doesnt
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.
+1 I concur (see comment above)
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.
Removed.
flow/layers/physical_shape_layer.cc
Outdated
|
||
void PhysicalShapeLayer::UpdateSceneChildren(SceneUpdateContext& context) { | ||
float scenic_elevation = context.scenic_elevation(); | ||
context.set_scenic_elevation(scenic_elevation + local_scenic_elevation_); |
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.
If you do this line in PhysicalShapeLayer::UpdateScene instead, you won't need to store local_scenic_elevation_
as a member variable.
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.
i moved this because UpdateSceneChildren is called in two different places and this removed some duplicated code. But I think I can put the elevation logic at the very top and very bottom of UpdateScene which would eliminate the duplication and need for a variable, at the cost of a slight reduction in understandability.
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.
Removed local_scenic_elevation_.
flow/layers/physical_shape_layer.h
Outdated
@@ -37,11 +37,18 @@ class PhysicalShapeLayer : public ContainerLayer { | |||
|
|||
#if defined(OS_FUCHSIA) | |||
void UpdateScene(SceneUpdateContext& context) override; | |||
|
|||
void UpdateSceneChildren(SceneUpdateContext& context); |
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.
You can avoid overriding it entirely if you follow one of my suggestions above
flow/layers/physical_shape_layer.h
Outdated
#endif // defined(OS_FUCHSIA) | ||
|
||
float total_elevation() const { return total_elevation_; } | ||
|
||
private: | ||
#if defined(OS_FUCHSIA) | ||
float local_scenic_elevation_ = 0.0f; |
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.
Actually, #1 is also unnecesary if following one of my suggestions above
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.
+1
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.
Done.
Ok, added tests (see latest CL), and I also addressed comments in the last CL as well. Hope that's ok, I haven't found a productive workflow for going back and modifying the previous CLs. See 9c629e4#diff-377431c448d255a96bd1943992182b3d and click "Load Diff" for the tests (not rendered by default since it's too big; file is fuchsia_layer_unittests.cc) |
9c629e4
to
11f9263
Compare
11f9263
to
0e03239
Compare
Thank you @mikejurka for adding the test! I wonder why all the presubmit tests are failing. Maybe you need to rebase against newest engine? I also couldn't find my comment regarding flutter/flutter#18320 although that issue showed that I referenced it from this PR... Anyway, it mostly looks good to me, and the only thing obvious to me is that you forget one more |
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.
Discussed with Mike offline about flutter/flutter#18320. This PR fixes that issue for PhysicalShapeLayer
, but we'll still have to fix that issue for other layers such as PerformanceOverlayerLayer
.
flow/scene_update_context.cc
Outdated
@@ -222,6 +222,9 @@ SceneUpdateContext::ExecutePaintTasks(CompositorContext::ScopedFrame& frame) { | |||
surfaces_to_submit.emplace_back(std::move(task.surface)); | |||
} | |||
paint_tasks_.clear(); | |||
alpha_ = 1.f; | |||
topmost_global_scenic_elevation_ = 10.f; |
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.
Nit: did you forget to use kScenicZElevationBetweenLayers
here? I saw that you've changed other places.
b1383a9
to
0792c63
Compare
Replaced the stray 10.f with kScenicZElevationBetweenLayers |
6f14029
to
80f08eb
Compare
…need to float above child views. In that case, they will still need to be pulled into separate Scenic nodes to be composited on top of the child view[s].
80f08eb
to
8b4aedc
Compare
Inspect commands going to Scenic and make sure they match what is expected. Also, restructure code to need less member variables, and other cleanups based on review feedback.
8b4aedc
to
4c1b195
Compare
I split the change up into smaller CLs. I haven't independently tested the sub-CLs, but just the full stack. No known issues at this time (the one issue I ran into today turned out to be a Scenic/Escher issue).