From 950d4813b5c6806a01f0225da814f5cb300dd65b Mon Sep 17 00:00:00 2001 From: Michael Klimushyn Date: Thu, 20 Jun 2019 18:20:35 -0700 Subject: [PATCH] Clamp when overflowing z bounds (#9402) --- flow/scene_update_context.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/flow/scene_update_context.cc b/flow/scene_update_context.cc index 4f07edd43d..d1fe2a94fa 100644 --- a/flow/scene_update_context.cc +++ b/flow/scene_update_context.cc @@ -299,12 +299,18 @@ SceneUpdateContext::Frame::Frame(SceneUpdateContext& context, color_(color), paint_bounds_(SkRect::MakeEmpty()), layer_(layer) { + if (depth > -1 && world_elevation > depth) { + // TODO(mklim): Deal with bounds overflow more elegantly. We'd like to be + // able to have developers specify the behavior here to alternatives besides + // clamping, like normalization on some arbitrary curve. + + // Clamp the local z coordinate at our max bound. Take into account the + // parent z position here to fix clamping in cases where the child is + // overflowing because of its parents. + const float parent_elevation = world_elevation - local_elevation; + local_elevation = depth - parent_elevation; + } if (local_elevation != 0.0) { - if (depth > -1 && world_elevation >= depth) { - // TODO(mklim): Deal with bounds overflow correctly. - FML_LOG(ERROR) << "Elevation " << world_elevation << " is outside of " - << depth; - } entity_node().SetTranslation(0.f, 0.f, -local_elevation); } } -- GitLab