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

Side by Side 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, 8 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 unified diff | 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')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 pending_tree_layer->draw_properties() 612 pending_tree_layer->draw_properties()
613 .screen_space_transform.To2dTranslation()) 613 .screen_space_transform.To2dTranslation())
614 .Length(); 614 .Length();
615 } 615 }
616 } 616 }
617 return 0.f; 617 return 0.f;
618 } 618 }
619 619
620 // A layer jitters if its screen space transform is same on two successive 620 // A layer jitters if its screen space transform is same on two successive
621 // commits, but has changed in between the commits. CalculateFrameJitter 621 // commits, but has changed in between the commits. CalculateFrameJitter
622 // computes the jitter in the entire frame. 622 // computes the jitter for the layer.
623 int LayerTreeHostCommon::CalculateFrameJitter(LayerImpl* layer) { 623 int LayerTreeHostCommon::CalculateFrameJitter(LayerImpl* layer) {
ajuma 2016/03/29 14:24:02 "CalculateLayerJitter" or "CalculateJitter"?
jaydasika 2016/03/29 15:57:24 Done.
624 if (!layer)
625 return 0.f;
626 float jitter = 0.f; 624 float jitter = 0.f;
627 layer->performance_properties().translation_from_last_frame = 0.f; 625 layer->performance_properties().translation_from_last_frame = 0.f;
628 layer->performance_properties().last_commit_screen_space_transform = 626 layer->performance_properties().last_commit_screen_space_transform =
629 layer->draw_properties().screen_space_transform; 627 layer->draw_properties().screen_space_transform;
630 628
631 if (!layer->visible_layer_rect().IsEmpty()) { 629 if (!layer->visible_layer_rect().IsEmpty()) {
632 if (layer->draw_properties().screen_space_transform.ApproximatelyEqual( 630 if (layer->draw_properties().screen_space_transform.ApproximatelyEqual(
633 layer->performance_properties() 631 layer->performance_properties()
634 .last_commit_screen_space_transform)) { 632 .last_commit_screen_space_transform)) {
635 float translation_from_last_commit = 633 float translation_from_last_commit =
636 TranslationFromActiveTreeLayerScreenSpaceTransform(layer); 634 TranslationFromActiveTreeLayerScreenSpaceTransform(layer);
637 if (translation_from_last_commit > 0.f) { 635 if (translation_from_last_commit > 0.f) {
638 layer->performance_properties().num_fixed_point_hits++; 636 layer->performance_properties().num_fixed_point_hits++;
639 layer->performance_properties().translation_from_last_frame = 637 layer->performance_properties().translation_from_last_frame =
640 translation_from_last_commit; 638 translation_from_last_commit;
641 if (layer->performance_properties().num_fixed_point_hits > 639 if (layer->performance_properties().num_fixed_point_hits >
642 layer->layer_tree_impl()->kFixedPointHitsThreshold) { 640 layer->layer_tree_impl()->kFixedPointHitsThreshold) {
643 // Jitter = Translation from fixed point * sqrt(Area of the layer). 641 // Jitter = Translation from fixed point * sqrt(Area of the layer).
644 // The square root of the area is used instead of the area to match 642 // The square root of the area is used instead of the area to match
645 // the dimensions of both terms on the rhs. 643 // the dimensions of both terms on the rhs.
646 jitter += translation_from_last_commit * 644 jitter += translation_from_last_commit *
647 sqrt(layer->visible_layer_rect().size().GetArea()); 645 sqrt(layer->visible_layer_rect().size().GetArea());
648 } 646 }
649 } else { 647 } else {
650 layer->performance_properties().num_fixed_point_hits = 0; 648 layer->performance_properties().num_fixed_point_hits = 0;
651 } 649 }
652 } 650 }
653 } 651 }
654 // Descendants of jittering layer will not contribute to unique jitter.
655 if (jitter > 0.f)
656 return jitter;
657
658 for (size_t i = 0; i < layer->children().size(); ++i) {
659 LayerImpl* child_layer =
660 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i);
661 jitter += CalculateFrameJitter(child_layer);
662 }
663 return jitter; 652 return jitter;
664 } 653 }
665 654
666 enum PropertyTreeOption { 655 enum PropertyTreeOption {
667 BUILD_PROPERTY_TREES_IF_NEEDED, 656 BUILD_PROPERTY_TREES_IF_NEEDED,
668 DONT_BUILD_PROPERTY_TREES 657 DONT_BUILD_PROPERTY_TREES
669 }; 658 };
670 659
671 void CalculateRenderTarget(LayerImpl* layer, 660 void CalculateRenderTarget(LayerImpl* layer,
672 PropertyTrees* property_trees, 661 PropertyTrees* property_trees,
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 CalculateDrawPropertiesInternal(inputs, DONT_BUILD_PROPERTY_TREES); 1066 CalculateDrawPropertiesInternal(inputs, DONT_BUILD_PROPERTY_TREES);
1078 1067
1079 if (CdpPerfTracingEnabled()) { 1068 if (CdpPerfTracingEnabled()) {
1080 LayerTreeImpl* layer_tree_impl = inputs->root_layer->layer_tree_impl(); 1069 LayerTreeImpl* layer_tree_impl = inputs->root_layer->layer_tree_impl();
1081 if (layer_tree_impl->IsPendingTree() && 1070 if (layer_tree_impl->IsPendingTree() &&
1082 layer_tree_impl->is_first_frame_after_commit()) { 1071 layer_tree_impl->is_first_frame_after_commit()) {
1083 LayerImpl* active_tree_root = 1072 LayerImpl* active_tree_root =
1084 layer_tree_impl->FindActiveTreeLayerById(inputs->root_layer->id()); 1073 layer_tree_impl->FindActiveTreeLayerById(inputs->root_layer->id());
1085 float jitter = 0.f; 1074 float jitter = 0.f;
1086 if (active_tree_root) { 1075 if (active_tree_root) {
1087 LayerImpl* last_scrolled_layer = layer_tree_impl->LayerById( 1076 std::unordered_set<int> jitter_nodes;
1088 active_tree_root->layer_tree_impl()->LastScrolledLayerId()); 1077 const int last_scrolled_scroll_node_id =
1089 jitter = CalculateFrameJitter(last_scrolled_layer); 1078 layer_tree_impl->LastScrolledScrollNodeId();
1079 for (auto* layer : *layer_tree_impl) {
1080 // Layers that have the same scroll tree index jitter together. So, it
1081 // 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.
1082 int scroll_tree_index = layer->scroll_tree_index();
1083 if (last_scrolled_scroll_node_id <= scroll_tree_index &&
1084 jitter_nodes.find(scroll_tree_index) == jitter_nodes.end()) {
1085 float layer_jitter = CalculateFrameJitter(layer);
1086 if (layer_jitter > 0.f) {
1087 jitter_nodes.insert(layer->scroll_tree_index());
1088 jitter += layer_jitter;
1089 }
1090 }
1091 }
1090 } 1092 }
1091 TRACE_EVENT_ASYNC_BEGIN1( 1093 TRACE_EVENT_ASYNC_BEGIN1(
1092 "cdp.perf", "jitter", 1094 "cdp.perf", "jitter",
1093 inputs->root_layer->layer_tree_impl()->source_frame_number(), "value", 1095 inputs->root_layer->layer_tree_impl()->source_frame_number(), "value",
1094 jitter); 1096 jitter);
1095 inputs->root_layer->layer_tree_impl()->set_is_first_frame_after_commit( 1097 inputs->root_layer->layer_tree_impl()->set_is_first_frame_after_commit(
1096 false); 1098 false);
1097 TRACE_EVENT_ASYNC_END1( 1099 TRACE_EVENT_ASYNC_END1(
1098 "cdp.perf", "jitter", 1100 "cdp.perf", "jitter",
1099 inputs->root_layer->layer_tree_impl()->source_frame_number(), "value", 1101 inputs->root_layer->layer_tree_impl()->source_frame_number(), "value",
1100 jitter); 1102 jitter);
1101 } 1103 }
1102 } 1104 }
1103 } 1105 }
1104 1106
1105 void LayerTreeHostCommon::CalculateDrawProperties( 1107 void LayerTreeHostCommon::CalculateDrawProperties(
1106 CalcDrawPropsImplInputsForTesting* inputs) { 1108 CalcDrawPropsImplInputsForTesting* inputs) {
1107 CalculateDrawPropertiesInternal(inputs, BUILD_PROPERTY_TREES_IF_NEEDED); 1109 CalculateDrawPropertiesInternal(inputs, BUILD_PROPERTY_TREES_IF_NEEDED);
1108 } 1110 }
1109 1111
1110 PropertyTrees* GetPropertyTrees(Layer* layer) { 1112 PropertyTrees* GetPropertyTrees(Layer* layer) {
1111 return layer->layer_tree_host()->property_trees(); 1113 return layer->layer_tree_host()->property_trees();
1112 } 1114 }
1113 1115
1114 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 1116 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
1115 return layer->layer_tree_impl()->property_trees(); 1117 return layer->layer_tree_impl()->property_trees();
1116 } 1118 }
1117 1119
1118 } // namespace cc 1120 } // namespace cc
OLDNEW
« 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