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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.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
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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 10331 matching lines...) Expand 10 before | Expand all | Expand 10 after
10342 host_impl_->CreatePendingTree(); 10342 host_impl_->CreatePendingTree();
10343 host_impl_->pending_tree()->set_source_frame_number(i + 1); 10343 host_impl_->pending_tree()->set_source_frame_number(i + 1);
10344 LayerImpl* content_layer = 10344 LayerImpl* content_layer =
10345 host_impl_->pending_tree()->OuterViewportScrollLayer()->children()[0]; 10345 host_impl_->pending_tree()->OuterViewportScrollLayer()->children()[0];
10346 // The scroll done on the active tree is undone on the pending tree. 10346 // The scroll done on the active tree is undone on the pending tree.
10347 gfx::Transform translate; 10347 gfx::Transform translate;
10348 translate.Translate(0, accumulated_scroll); 10348 translate.Translate(0, accumulated_scroll);
10349 content_layer->SetTransform(translate); 10349 content_layer->SetTransform(translate);
10350 10350
10351 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 10351 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
10352 LayerTreeImpl* active_tree = host_impl_->active_tree();
10352 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 10353 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
10353 LayerImpl* last_scrolled_layer = pending_tree->LayerById( 10354 ScrollNode* node = active_tree->property_trees()->scroll_tree.Node(
10354 host_impl_->active_tree()->LastScrolledLayerId()); 10355 active_tree->LastScrolledScrollNodeId());
10356 LayerImpl* last_scrolled_layer = pending_tree->LayerById(node->owner_id);
10355 10357
10356 // When building property trees from impl side, the builder uses the scroll 10358 // When building property trees from impl side, the builder uses the scroll
10357 // offset of layer_impl to initialize the scroll offset in scroll tree: 10359 // offset of layer_impl to initialize the scroll offset in scroll tree:
10358 // scroll_tree.synced_scroll_offset.PushFromMainThread( 10360 // scroll_tree.synced_scroll_offset.PushFromMainThread(
10359 // layer->CurrentScrollOffset()). 10361 // layer->CurrentScrollOffset()).
10360 // However, layer_impl does not store scroll_offset, so it is using scroll 10362 // However, layer_impl does not store scroll_offset, so it is using scroll
10361 // tree's scroll offset to initialize itself. Usually this approach works 10363 // tree's scroll offset to initialize itself. Usually this approach works
10362 // because this is a simple assignment. However if scroll_offset's pending 10364 // because this is a simple assignment. However if scroll_offset's pending
10363 // delta is not zero, the delta would be counted twice. 10365 // delta is not zero, the delta would be counted twice.
10364 // This hacking here is to restore the damaged scroll offset. 10366 // This hacking here is to restore the damaged scroll offset.
10365 gfx::ScrollOffset pending_base = 10367 gfx::ScrollOffset pending_base =
10366 pending_tree->property_trees() 10368 pending_tree->property_trees()
10367 ->scroll_tree.GetScrollOffsetBaseForTesting( 10369 ->scroll_tree.GetScrollOffsetBaseForTesting(
10368 last_scrolled_layer->id()); 10370 last_scrolled_layer->id());
10369 pending_tree->property_trees()->needs_rebuild = true; 10371 pending_tree->property_trees()->needs_rebuild = true;
10370 pending_tree->BuildPropertyTreesForTesting(); 10372 pending_tree->BuildPropertyTreesForTesting();
10371 pending_tree->property_trees() 10373 pending_tree->property_trees()
10372 ->scroll_tree.UpdateScrollOffsetBaseForTesting( 10374 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
10373 last_scrolled_layer->id(), pending_base); 10375 last_scrolled_layer->id(), pending_base);
10374 10376
10375 pending_tree->set_needs_update_draw_properties(); 10377 pending_tree->set_needs_update_draw_properties();
10376 pending_tree->UpdateDrawProperties(false); 10378 pending_tree->UpdateDrawProperties(false);
10377 float jitter = 10379 float jitter = LayerTreeHostCommon::CalculateFrameJitter(content_layer);
10378 LayerTreeHostCommon::CalculateFrameJitter(last_scrolled_layer);
10379 // There should not be any jitter measured till we hit the fixed point hits 10380 // There should not be any jitter measured till we hit the fixed point hits
10380 // threshold. 10381 // threshold.
10381 float expected_jitter = 10382 float expected_jitter =
10382 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10383 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10383 EXPECT_EQ(jitter, expected_jitter); 10384 EXPECT_EQ(jitter, expected_jitter);
10384 } 10385 }
10385 } 10386 }
10386 10387
10387 } // namespace 10388 } // namespace
10388 } // namespace cc 10389 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698