Commit 995cbcd0 authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

Misc de-jelly fixes.

Fixes two small issues:
- Padding of visible layer region did not consider page scale.
- New layers may jitter as we won't de-jelly them for 1 frame. We now
  use a reasonable default.

Bug: 995965
Change-Id: Ib2ad58eab9b393b691e586e8649672c1d4323864
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1861096Reviewed-by: default avatarenne <enne@chromium.org>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705781}
parent f394f4be
...@@ -54,6 +54,17 @@ void DeJellyState::AdvanceFrame(LayerTreeImpl* layer_tree_impl) { ...@@ -54,6 +54,17 @@ void DeJellyState::AdvanceFrame(LayerTreeImpl* layer_tree_impl) {
return; return;
} }
// Compute the fallback movement of a scrolling element based purely on the
// scroll offset of the currently scrolling node.
float previous_scroll_offset = scroll_offset_;
scroll_offset_ = layer_tree_impl->property_trees()
->transform_tree.Node(scroll_transform_node_)
->scroll_offset.y();
fallback_delta_y_ = scroll_offset_ - previous_scroll_offset;
gfx::Vector3dF vector(0, fallback_delta_y_, 0);
new_scroll_node_transform_->TransformVector(&vector);
fallback_delta_y_ = vector.y();
// Don't attempt de-jelly while the omnibox is transitioning in or out. There // Don't attempt de-jelly while the omnibox is transitioning in or out. There
// is no correct way to handle this. // is no correct way to handle this.
float top_controls_shown_ratio = float top_controls_shown_ratio =
...@@ -115,17 +126,20 @@ void DeJellyState::UpdateSharedQuadState(LayerTreeImpl* layer_tree_impl, ...@@ -115,17 +126,20 @@ void DeJellyState::UpdateSharedQuadState(LayerTreeImpl* layer_tree_impl,
// Get the previous transform (if any). // Get the previous transform (if any).
const auto& found = previous_transforms_.find(transform_id); const auto& found = previous_transforms_.find(transform_id);
float delta_y = 0.0f;
if (found == previous_transforms_.end()) { if (found == previous_transforms_.end()) {
return; delta_y = fallback_delta_y_;
} else {
// Calculate the delta of point (0, 0) from the previous frame.
gfx::Transform previous_transform = found->second;
gfx::PointF new_point(0, 0);
transform.TransformPoint(&new_point);
gfx::PointF old_point(0, 0);
previous_transform.TransformPoint(&old_point);
delta_y = old_point.y() - new_point.y();
} }
// Calculate the delta of point (0, 0) from the previous frame.
gfx::Transform previous_transform = found->second;
gfx::PointF new_point(0, 0);
transform.TransformPoint(&new_point);
gfx::PointF old_point(0, 0);
previous_transform.TransformPoint(&old_point);
float delta_y = old_point.y() - new_point.y();
if (delta_y == 0.0f) { if (delta_y == 0.0f) {
return; return;
} }
......
...@@ -41,6 +41,9 @@ class CC_EXPORT DeJellyState { ...@@ -41,6 +41,9 @@ class CC_EXPORT DeJellyState {
private: private:
bool should_de_jelly_ = false; bool should_de_jelly_ = false;
int scroll_transform_node_ = 0; int scroll_transform_node_ = 0;
float scroll_offset_ = 0;
float fallback_delta_y_ = 0;
base::Optional<gfx::Transform> new_scroll_node_transform_; base::Optional<gfx::Transform> new_scroll_node_transform_;
std::map<int, gfx::Transform> previous_transforms_; std::map<int, gfx::Transform> previous_transforms_;
std::map<int, gfx::Transform> new_transforms_; std::map<int, gfx::Transform> new_transforms_;
......
...@@ -642,7 +642,11 @@ gfx::Rect LayerVisibleRect(PropertyTrees* property_trees, LayerImpl* layer) { ...@@ -642,7 +642,11 @@ gfx::Rect LayerVisibleRect(PropertyTrees* property_trees, LayerImpl* layer) {
gfx::Rect visible_rect = ToEnclosingClipRect(clip_in_layer_space); gfx::Rect visible_rect = ToEnclosingClipRect(clip_in_layer_space);
if (layer->layer_tree_impl()->settings().allow_de_jelly_effect) { if (layer->layer_tree_impl()->settings().allow_de_jelly_effect) {
visible_rect.Inset(0.0f, -viz::MaxDeJellyHeight()); float padding_amount = viz::MaxDeJellyHeight();
if (layer->IsAffectedByPageScale()) {
padding_amount /= layer->layer_tree_impl()->current_page_scale_factor();
}
visible_rect.Inset(0.0f, -padding_amount);
} }
visible_rect.Intersect(layer_content_rect); visible_rect.Intersect(layer_content_rect);
return visible_rect; return visible_rect;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment