@@ -115,14 +115,14 @@ void SceneUpdateContext::CreateFrame(scenic::EntityNode& entity_node,
115115 SkAlpha opacity,
116116 const SkRect& paint_bounds,
117117 std::vector<Layer*> paint_layers) {
118+ // We don't need a shape if the frame is zero size.
118119 if (rrect.isEmpty ())
119120 return ;
120121
121122 // Frames always clip their children.
122123 SkRect shape_bounds = rrect.getBounds ();
123124 SetEntityNodeClipPlanes (entity_node, shape_bounds);
124125
125- // and possibly for its texture.
126126 // TODO(SCN-137): Need to be able to express the radii as vectors.
127127 scenic::ShapeNode shape_node (session_.get ());
128128 scenic::Rectangle shape (session_.get (), rrect.width (), rrect.height ());
@@ -140,7 +140,7 @@ void SceneUpdateContext::CreateFrame(scenic::EntityNode& entity_node,
140140 entity_node.AddChild (shape_node);
141141
142142 // Check whether a solid color will suffice.
143- if (paint_layers.empty () || shape_bounds. isEmpty () ) {
143+ if (paint_layers.empty ()) {
144144 SetMaterialColor (material, color, opacity);
145145 } else {
146146 // The final shape's color is material_color * texture_color. The passed in
@@ -182,6 +182,9 @@ void SceneUpdateContext::UpdateView(int64_t view_id,
182182 view_holder->UpdateScene (session_.get (), top_entity_->embedder_node (), offset,
183183 size, SkScalarRoundToInt (alphaf () * 255 ),
184184 hit_testable);
185+
186+ // Assume embedded views are 10 "layers" wide.
187+ next_elevation_ += 10 * kScenicZElevationBetweenLayers ;
185188}
186189
187190void SceneUpdateContext::CreateView (int64_t view_id,
@@ -286,13 +289,17 @@ SceneUpdateContext::Frame::Frame(SceneUpdateContext& context,
286289 opacity_(opacity),
287290 opacity_node_(context.session_.get()),
288291 paint_bounds_(SkRect::MakeEmpty()) {
289- entity_node (). SetLabel (label);
290- entity_node (). SetTranslation ( 0 . f , 0 . f ,
291- context. next_elevation_ - previous_elevation_);
292+ // Increment elevation trackers before calculating any local elevation.
293+ // |UpdateView| can modify context.next_elevation_, which is why it is
294+ // neccesary to track this addtional state.
292295 context.top_elevation_ += kScenicZElevationBetweenLayers ;
293296 context.next_elevation_ += kScenicZElevationBetweenLayers ;
294297
298+ float local_elevation = context.next_elevation_ - previous_elevation_;
299+ entity_node ().SetTranslation (0 .f , 0 .f , -local_elevation);
300+ entity_node ().SetLabel (label);
295301 entity_node ().AddChild (opacity_node_);
302+
296303 // Scenic currently lacks an API to enable rendering of alpha channel; alpha
297304 // channels are only rendered if there is a OpacityNode higher in the tree
298305 // with opacity != 1. For now, clamp to a infinitesimally smaller value than
@@ -301,11 +308,11 @@ SceneUpdateContext::Frame::Frame(SceneUpdateContext& context,
301308}
302309
303310SceneUpdateContext::Frame::~Frame () {
311+ context ().top_elevation_ = previous_elevation_;
312+
304313 // Add a part which represents the frame's geometry for clipping purposes
305314 context ().CreateFrame (entity_node (), rrect_, color_, opacity_, paint_bounds_,
306315 std::move (paint_layers_));
307-
308- context ().top_elevation_ = previous_elevation_;
309316}
310317
311318void SceneUpdateContext::Frame::AddPaintLayer (Layer* layer) {
0 commit comments