Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3239)

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 1840883002: cc : Calculate jitter without using layer hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | cc/trees/layer_tree_impl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common.cc
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 01875e93ba0e3b1c44aef386b9839e82749db29b..45cd672912331e698d7a5b5266e453b9c1ba548a 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -619,10 +619,8 @@ static float TranslationFromActiveTreeLayerScreenSpaceTransform(
// A layer jitters if its screen space transform is same on two successive
// commits, but has changed in between the commits. CalculateFrameJitter
-// computes the jitter in the entire frame.
+// computes the jitter for the layer.
int LayerTreeHostCommon::CalculateFrameJitter(LayerImpl* layer) {
ajuma 2016/03/29 14:24:02 "CalculateLayerJitter" or "CalculateJitter"?
jaydasika 2016/03/29 15:57:24 Done.
- if (!layer)
- return 0.f;
float jitter = 0.f;
layer->performance_properties().translation_from_last_frame = 0.f;
layer->performance_properties().last_commit_screen_space_transform =
@@ -651,15 +649,6 @@ int LayerTreeHostCommon::CalculateFrameJitter(LayerImpl* layer) {
}
}
}
- // Descendants of jittering layer will not contribute to unique jitter.
- if (jitter > 0.f)
- return jitter;
-
- for (size_t i = 0; i < layer->children().size(); ++i) {
- LayerImpl* child_layer =
- LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i);
- jitter += CalculateFrameJitter(child_layer);
- }
return jitter;
}
@@ -1084,9 +1073,22 @@ void LayerTreeHostCommon::CalculateDrawProperties(
layer_tree_impl->FindActiveTreeLayerById(inputs->root_layer->id());
float jitter = 0.f;
if (active_tree_root) {
- LayerImpl* last_scrolled_layer = layer_tree_impl->LayerById(
- active_tree_root->layer_tree_impl()->LastScrolledLayerId());
- jitter = CalculateFrameJitter(last_scrolled_layer);
+ std::unordered_set<int> jitter_nodes;
+ const int last_scrolled_scroll_node_id =
+ layer_tree_impl->LastScrolledScrollNodeId();
+ for (auto* layer : *layer_tree_impl) {
+ // Layers that have the same scroll tree index jitter together. So, it
+ // is enough to calculate jitter on one of these layers.
ajuma 2016/03/29 14:24:02 Please clarify this comment to say that once we've
jaydasika 2016/03/29 15:57:24 Done.
+ int scroll_tree_index = layer->scroll_tree_index();
+ if (last_scrolled_scroll_node_id <= scroll_tree_index &&
+ jitter_nodes.find(scroll_tree_index) == jitter_nodes.end()) {
+ float layer_jitter = CalculateFrameJitter(layer);
+ if (layer_jitter > 0.f) {
+ jitter_nodes.insert(layer->scroll_tree_index());
+ jitter += layer_jitter;
+ }
+ }
+ }
}
TRACE_EVENT_ASYNC_BEGIN1(
"cdp.perf", "jitter",
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | cc/trees/layer_tree_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698