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

Side by Side Diff: cc/trees/layer_tree_host_unittest_scroll.cc

Issue 2661523003: cc: Merge LayerTree into the LayerTreeHost. (Closed)
Patch Set: auto Created 3 years, 10 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 | « cc/trees/layer_tree_host_unittest_proxy.cc ('k') | cc/trees/layer_tree_host_unittest_video.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 static ScrollTree* ScrollTreeForLayer(LayerImpl* layer_impl) { 67 static ScrollTree* ScrollTreeForLayer(LayerImpl* layer_impl) {
68 return &layer_impl->layer_tree_impl()->property_trees()->scroll_tree; 68 return &layer_impl->layer_tree_impl()->property_trees()->scroll_tree;
69 } 69 }
70 70
71 class LayerTreeHostScrollTest : public LayerTreeTest { 71 class LayerTreeHostScrollTest : public LayerTreeTest {
72 protected: 72 protected:
73 void SetupTree() override { 73 void SetupTree() override {
74 LayerTreeTest::SetupTree(); 74 LayerTreeTest::SetupTree();
75 Layer* root_layer = layer_tree()->root_layer(); 75 Layer* root_layer = layer_tree_host()->root_layer();
76 76
77 // Create an effective max_scroll_offset of (100, 100). 77 // Create an effective max_scroll_offset of (100, 100).
78 gfx::Size scroll_layer_bounds(root_layer->bounds().width() + 100, 78 gfx::Size scroll_layer_bounds(root_layer->bounds().width() + 100,
79 root_layer->bounds().height() + 100); 79 root_layer->bounds().height() + 100);
80 80
81 CreateVirtualViewportLayers(root_layer, root_layer->bounds(), 81 CreateVirtualViewportLayers(root_layer, root_layer->bounds(),
82 root_layer->bounds(), scroll_layer_bounds, 82 root_layer->bounds(), scroll_layer_bounds,
83 layer_tree_host()); 83 layer_tree_host());
84 } 84 }
85 }; 85 };
86 86
87 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest { 87 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest {
88 public: 88 public:
89 LayerTreeHostScrollTestScrollSimple() 89 LayerTreeHostScrollTestScrollSimple()
90 : initial_scroll_(10, 20), 90 : initial_scroll_(10, 20),
91 second_scroll_(40, 5), 91 second_scroll_(40, 5),
92 scroll_amount_(2, -1), 92 scroll_amount_(2, -1),
93 num_scrolls_(0) {} 93 num_scrolls_(0) {}
94 94
95 void BeginTest() override { 95 void BeginTest() override {
96 outer_viewport_container_layer_id_ = 96 outer_viewport_container_layer_id_ = layer_tree_host()
97 layer_tree()->outer_viewport_scroll_layer()->scroll_clip_layer()->id(); 97 ->outer_viewport_scroll_layer()
98 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset( 98 ->scroll_clip_layer()
99 ->id();
100 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
99 initial_scroll_); 101 initial_scroll_);
100 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback( 102 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback(
101 base::Bind(&LayerTreeHostScrollTestScrollSimple::DidScrollOuterViewport, 103 base::Bind(&LayerTreeHostScrollTestScrollSimple::DidScrollOuterViewport,
102 base::Unretained(this))); 104 base::Unretained(this)));
103 PostSetNeedsCommitToMainThread(); 105 PostSetNeedsCommitToMainThread();
104 } 106 }
105 107
106 void UpdateLayerTreeHost() override { 108 void UpdateLayerTreeHost() override {
107 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer(); 109 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
108 if (!layer_tree_host()->SourceFrameNumber()) { 110 if (!layer_tree_host()->SourceFrameNumber()) {
109 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); 111 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
110 } else { 112 } else {
111 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, 113 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_,
112 scroll_amount_), 114 scroll_amount_),
113 scroll_layer->scroll_offset()); 115 scroll_layer->scroll_offset());
114 116
115 // Pretend like Javascript updated the scroll position itself. 117 // Pretend like Javascript updated the scroll position itself.
116 scroll_layer->SetScrollOffset(second_scroll_); 118 scroll_layer->SetScrollOffset(second_scroll_);
117 } 119 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 161
160 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSimple); 162 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSimple);
161 163
162 class LayerTreeHostScrollTestScrollMultipleRedraw 164 class LayerTreeHostScrollTestScrollMultipleRedraw
163 : public LayerTreeHostScrollTest { 165 : public LayerTreeHostScrollTest {
164 public: 166 public:
165 LayerTreeHostScrollTestScrollMultipleRedraw() 167 LayerTreeHostScrollTestScrollMultipleRedraw()
166 : initial_scroll_(40, 10), scroll_amount_(-3, 17), num_scrolls_(0) {} 168 : initial_scroll_(40, 10), scroll_amount_(-3, 17), num_scrolls_(0) {}
167 169
168 void BeginTest() override { 170 void BeginTest() override {
169 scroll_layer_ = layer_tree()->outer_viewport_scroll_layer(); 171 scroll_layer_ = layer_tree_host()->outer_viewport_scroll_layer();
170 scroll_layer_->SetScrollOffset(initial_scroll_); 172 scroll_layer_->SetScrollOffset(initial_scroll_);
171 scroll_layer_->set_did_scroll_callback(base::Bind( 173 scroll_layer_->set_did_scroll_callback(base::Bind(
172 &LayerTreeHostScrollTestScrollMultipleRedraw::DidScrollOuterViewport, 174 &LayerTreeHostScrollTestScrollMultipleRedraw::DidScrollOuterViewport,
173 base::Unretained(this))); 175 base::Unretained(this)));
174 PostSetNeedsCommitToMainThread(); 176 PostSetNeedsCommitToMainThread();
175 } 177 }
176 178
177 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { 179 void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
178 switch (layer_tree_host()->SourceFrameNumber()) { 180 switch (layer_tree_host()->SourceFrameNumber()) {
179 case 0: 181 case 0:
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 second_main_scroll_(14, -3), 252 second_main_scroll_(14, -3),
251 impl_scale_(2.f), 253 impl_scale_(2.f),
252 num_will_begin_main_frames_(0), 254 num_will_begin_main_frames_(0),
253 num_did_begin_main_frames_(0), 255 num_did_begin_main_frames_(0),
254 num_will_commits_(0), 256 num_will_commits_(0),
255 num_did_commits_(0), 257 num_did_commits_(0),
256 num_impl_commits_(0), 258 num_impl_commits_(0),
257 num_impl_scrolls_(0) {} 259 num_impl_scrolls_(0) {}
258 260
259 void BeginTest() override { 261 void BeginTest() override {
260 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset( 262 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
261 initial_scroll_); 263 initial_scroll_);
262 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback( 264 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback(
263 base::Bind( 265 base::Bind(
264 &LayerTreeHostScrollTestScrollAbortedCommit::DidScrollOuterViewport, 266 &LayerTreeHostScrollTestScrollAbortedCommit::DidScrollOuterViewport,
265 base::Unretained(this))); 267 base::Unretained(this)));
266 PostSetNeedsCommitToMainThread(); 268 PostSetNeedsCommitToMainThread();
267 } 269 }
268 270
269 void SetupTree() override { 271 void SetupTree() override {
270 LayerTreeHostScrollTest::SetupTree(); 272 LayerTreeHostScrollTest::SetupTree();
271 273
272 gfx::Size scroll_layer_bounds(200, 200); 274 gfx::Size scroll_layer_bounds(200, 200);
273 layer_tree()->outer_viewport_scroll_layer()->SetBounds(scroll_layer_bounds); 275 layer_tree_host()->outer_viewport_scroll_layer()->SetBounds(
274 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); 276 scroll_layer_bounds);
277 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
275 } 278 }
276 279
277 void WillBeginMainFrame() override { 280 void WillBeginMainFrame() override {
278 num_will_begin_main_frames_++; 281 num_will_begin_main_frames_++;
279 Layer* root_scroll_layer = layer_tree()->outer_viewport_scroll_layer(); 282 Layer* root_scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
280 switch (num_will_begin_main_frames_) { 283 switch (num_will_begin_main_frames_) {
281 case 1: 284 case 1:
282 // This will not be aborted because of the initial prop changes. 285 // This will not be aborted because of the initial prop changes.
283 EXPECT_EQ(0, num_impl_scrolls_); 286 EXPECT_EQ(0, num_impl_scrolls_);
284 EXPECT_EQ(0, layer_tree_host()->SourceFrameNumber()); 287 EXPECT_EQ(0, layer_tree_host()->SourceFrameNumber());
285 EXPECT_VECTOR_EQ(initial_scroll_, root_scroll_layer->scroll_offset()); 288 EXPECT_VECTOR_EQ(initial_scroll_, root_scroll_layer->scroll_offset());
286 EXPECT_EQ(1.f, layer_tree()->page_scale_factor()); 289 EXPECT_EQ(1.f, layer_tree_host()->page_scale_factor());
287 break; 290 break;
288 case 2: 291 case 2:
289 // This commit will be aborted, and another commit will be 292 // This commit will be aborted, and another commit will be
290 // initiated from the redraw. 293 // initiated from the redraw.
291 EXPECT_EQ(1, num_impl_scrolls_); 294 EXPECT_EQ(1, num_impl_scrolls_);
292 EXPECT_EQ(1, layer_tree_host()->SourceFrameNumber()); 295 EXPECT_EQ(1, layer_tree_host()->SourceFrameNumber());
293 EXPECT_VECTOR_EQ( 296 EXPECT_VECTOR_EQ(
294 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_scroll_), 297 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_scroll_),
295 root_scroll_layer->scroll_offset()); 298 root_scroll_layer->scroll_offset());
296 EXPECT_EQ(impl_scale_, layer_tree()->page_scale_factor()); 299 EXPECT_EQ(impl_scale_, layer_tree_host()->page_scale_factor());
297 PostSetNeedsRedrawToMainThread(); 300 PostSetNeedsRedrawToMainThread();
298 break; 301 break;
299 case 3: 302 case 3:
300 // This commit will not be aborted because of the scroll change. 303 // This commit will not be aborted because of the scroll change.
301 EXPECT_EQ(2, num_impl_scrolls_); 304 EXPECT_EQ(2, num_impl_scrolls_);
302 // The source frame number still increases even with the abort. 305 // The source frame number still increases even with the abort.
303 EXPECT_EQ(2, layer_tree_host()->SourceFrameNumber()); 306 EXPECT_EQ(2, layer_tree_host()->SourceFrameNumber());
304 EXPECT_VECTOR_EQ( 307 EXPECT_VECTOR_EQ(
305 gfx::ScrollOffsetWithDelta(initial_scroll_, 308 gfx::ScrollOffsetWithDelta(initial_scroll_,
306 impl_scroll_ + impl_scroll_), 309 impl_scroll_ + impl_scroll_),
307 root_scroll_layer->scroll_offset()); 310 root_scroll_layer->scroll_offset());
308 EXPECT_EQ(impl_scale_ * impl_scale_, layer_tree()->page_scale_factor()); 311 EXPECT_EQ(impl_scale_ * impl_scale_,
312 layer_tree_host()->page_scale_factor());
309 root_scroll_layer->SetScrollOffset(gfx::ScrollOffsetWithDelta( 313 root_scroll_layer->SetScrollOffset(gfx::ScrollOffsetWithDelta(
310 root_scroll_layer->scroll_offset(), second_main_scroll_)); 314 root_scroll_layer->scroll_offset(), second_main_scroll_));
311 break; 315 break;
312 case 4: 316 case 4:
313 // This commit will also be aborted. 317 // This commit will also be aborted.
314 EXPECT_EQ(3, num_impl_scrolls_); 318 EXPECT_EQ(3, num_impl_scrolls_);
315 EXPECT_EQ(3, layer_tree_host()->SourceFrameNumber()); 319 EXPECT_EQ(3, layer_tree_host()->SourceFrameNumber());
316 gfx::Vector2dF delta = 320 gfx::Vector2dF delta =
317 impl_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_; 321 impl_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_;
318 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, delta), 322 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, delta),
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 }; 439 };
436 440
437 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommit); 441 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommit);
438 442
439 class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest { 443 class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest {
440 public: 444 public:
441 LayerTreeHostScrollTestFractionalScroll() : scroll_amount_(1.75, 0) {} 445 LayerTreeHostScrollTestFractionalScroll() : scroll_amount_(1.75, 0) {}
442 446
443 void SetupTree() override { 447 void SetupTree() override {
444 LayerTreeHostScrollTest::SetupTree(); 448 LayerTreeHostScrollTest::SetupTree();
445 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); 449 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
446 } 450 }
447 451
448 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 452 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
449 453
450 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 454 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
451 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 455 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
452 456
453 // Check that a fractional scroll delta is correctly accumulated over 457 // Check that a fractional scroll delta is correctly accumulated over
454 // multiple commits. 458 // multiple commits.
455 switch (impl->active_tree()->source_frame_number()) { 459 switch (impl->active_tree()->source_frame_number()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 }; 495 };
492 496
493 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll); 497 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll);
494 498
495 class LayerTreeHostScrollTestScrollSnapping : public LayerTreeHostScrollTest { 499 class LayerTreeHostScrollTestScrollSnapping : public LayerTreeHostScrollTest {
496 public: 500 public:
497 LayerTreeHostScrollTestScrollSnapping() : scroll_amount_(1.75, 0) {} 501 LayerTreeHostScrollTestScrollSnapping() : scroll_amount_(1.75, 0) {}
498 502
499 void SetupTree() override { 503 void SetupTree() override {
500 LayerTreeHostScrollTest::SetupTree(); 504 LayerTreeHostScrollTest::SetupTree();
501 layer_tree() 505 layer_tree_host()
502 ->outer_viewport_scroll_layer() 506 ->outer_viewport_scroll_layer()
503 ->scroll_clip_layer() 507 ->scroll_clip_layer()
504 ->SetForceRenderSurfaceForTesting(true); 508 ->SetForceRenderSurfaceForTesting(true);
505 gfx::Transform translate; 509 gfx::Transform translate;
506 translate.Translate(0.25f, 0.f); 510 translate.Translate(0.25f, 0.f);
507 layer_tree() 511 layer_tree_host()
508 ->outer_viewport_scroll_layer() 512 ->outer_viewport_scroll_layer()
509 ->scroll_clip_layer() 513 ->scroll_clip_layer()
510 ->SetTransform(translate); 514 ->SetTransform(translate);
511 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.1f, 100.f); 515 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.1f, 100.f);
512 } 516 }
513 517
514 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 518 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
515 519
516 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 520 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
517 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 521 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
518 gfx::Transform translate; 522 gfx::Transform translate;
519 523
520 // Check that screen space transform of the scrollable layer is correctly 524 // Check that screen space transform of the scrollable layer is correctly
521 // snapped to integers. 525 // snapped to integers.
(...skipping 29 matching lines...) Expand all
551 555
552 class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest { 556 class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
553 public: 557 public:
554 LayerTreeHostScrollTestCaseWithChild() 558 LayerTreeHostScrollTestCaseWithChild()
555 : initial_offset_(10, 20), 559 : initial_offset_(10, 20),
556 javascript_scroll_(40, 5), 560 javascript_scroll_(40, 5),
557 scroll_amount_(2, -1), 561 scroll_amount_(2, -1),
558 num_scrolls_(0) {} 562 num_scrolls_(0) {}
559 563
560 void SetupTree() override { 564 void SetupTree() override {
561 layer_tree()->SetDeviceScaleFactor(device_scale_factor_); 565 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_);
562 566
563 scoped_refptr<Layer> root_layer = Layer::Create(); 567 scoped_refptr<Layer> root_layer = Layer::Create();
564 root_layer->SetBounds(gfx::Size(10, 10)); 568 root_layer->SetBounds(gfx::Size(10, 10));
565 569
566 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); 570 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
567 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); 571 root_scroll_layer_->SetBounds(gfx::Size(110, 110));
568 root_scroll_layer_->SetPosition(gfx::PointF()); 572 root_scroll_layer_->SetPosition(gfx::PointF());
569 root_scroll_layer_->SetIsDrawable(true); 573 root_scroll_layer_->SetIsDrawable(true);
570 574
571 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_, 575 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_,
(...skipping 10 matching lines...) Expand all
582 // Scrolls on the child layer will happen at 5, 5. If they are treated 586 // Scrolls on the child layer will happen at 5, 5. If they are treated
583 // like device pixels, and device scale factor is 2, then they will 587 // like device pixels, and device scale factor is 2, then they will
584 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. 588 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer.
585 child_layer_->SetPosition(gfx::PointF(5.f, 5.f)); 589 child_layer_->SetPosition(gfx::PointF(5.f, 5.f));
586 } else { 590 } else {
587 // Adjust the child layer horizontally so that scrolls will never hit it. 591 // Adjust the child layer horizontally so that scrolls will never hit it.
588 child_layer_->SetPosition(gfx::PointF(60.f, 5.f)); 592 child_layer_->SetPosition(gfx::PointF(60.f, 5.f));
589 } 593 }
590 594
591 scoped_refptr<Layer> outer_container_layer = 595 scoped_refptr<Layer> outer_container_layer =
592 layer_tree()->outer_viewport_scroll_layer()->parent(); 596 layer_tree_host()->outer_viewport_scroll_layer()->parent();
593 597
594 child_layer_->SetIsDrawable(true); 598 child_layer_->SetIsDrawable(true);
595 child_layer_->SetScrollClipLayerId(outer_container_layer->id()); 599 child_layer_->SetScrollClipLayerId(outer_container_layer->id());
596 child_layer_->SetBounds(root_scroll_layer_->bounds()); 600 child_layer_->SetBounds(root_scroll_layer_->bounds());
597 root_scroll_layer_->AddChild(child_layer_); 601 root_scroll_layer_->AddChild(child_layer_);
598 602
599 if (scroll_child_layer_) { 603 if (scroll_child_layer_) {
600 expected_scroll_layer_ = child_layer_; 604 expected_scroll_layer_ = child_layer_;
601 expected_no_scroll_layer_ = root_scroll_layer_; 605 expected_no_scroll_layer_ = root_scroll_layer_;
602 } else { 606 } else {
603 expected_scroll_layer_ = root_scroll_layer_; 607 expected_scroll_layer_ = root_scroll_layer_;
604 expected_no_scroll_layer_ = child_layer_; 608 expected_no_scroll_layer_ = child_layer_;
605 } 609 }
606 610
607 expected_scroll_layer_->SetScrollOffset(initial_offset_); 611 expected_scroll_layer_->SetScrollOffset(initial_offset_);
608 612
609 layer_tree()->SetRootLayer(root_layer); 613 layer_tree_host()->SetRootLayer(root_layer);
610 LayerTreeTest::SetupTree(); 614 LayerTreeTest::SetupTree();
611 fake_content_layer_client_.set_bounds(root_layer->bounds()); 615 fake_content_layer_client_.set_bounds(root_layer->bounds());
612 616
613 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback( 617 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback(
614 base::Bind( 618 base::Bind(
615 &LayerTreeHostScrollTestCaseWithChild::DidScrollOuterViewport, 619 &LayerTreeHostScrollTestCaseWithChild::DidScrollOuterViewport,
616 base::Unretained(this))); 620 base::Unretained(this)));
617 } 621 }
618 622
619 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 623 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
620 624
621 void WillCommit() override { 625 void WillCommit() override {
622 // Keep the test committing (otherwise the early out for no update 626 // Keep the test committing (otherwise the early out for no update
623 // will stall the test). 627 // will stall the test).
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 public: 820 public:
817 LayerTreeHostScrollTestSimple() 821 LayerTreeHostScrollTestSimple()
818 : initial_scroll_(10, 20), 822 : initial_scroll_(10, 20),
819 main_thread_scroll_(40, 5), 823 main_thread_scroll_(40, 5),
820 impl_thread_scroll1_(2, -1), 824 impl_thread_scroll1_(2, -1),
821 impl_thread_scroll2_(-3, 10), 825 impl_thread_scroll2_(-3, 10),
822 num_scrolls_(0) {} 826 num_scrolls_(0) {}
823 827
824 void SetupTree() override { 828 void SetupTree() override {
825 LayerTreeHostScrollTest::SetupTree(); 829 LayerTreeHostScrollTest::SetupTree();
826 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); 830 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
827 } 831 }
828 832
829 void BeginTest() override { 833 void BeginTest() override {
830 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset( 834 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
831 initial_scroll_); 835 initial_scroll_);
832 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback( 836 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback(
833 base::Bind(&LayerTreeHostScrollTestSimple::DidScrollOuterViewport, 837 base::Bind(&LayerTreeHostScrollTestSimple::DidScrollOuterViewport,
834 base::Unretained(this))); 838 base::Unretained(this)));
835 PostSetNeedsCommitToMainThread(); 839 PostSetNeedsCommitToMainThread();
836 } 840 }
837 841
838 void UpdateLayerTreeHost() override { 842 void UpdateLayerTreeHost() override {
839 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer(); 843 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
840 if (!layer_tree_host()->SourceFrameNumber()) { 844 if (!layer_tree_host()->SourceFrameNumber()) {
841 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); 845 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
842 } else { 846 } else {
843 EXPECT_VECTOR_EQ( 847 EXPECT_VECTOR_EQ(
844 scroll_layer->scroll_offset(), 848 scroll_layer->scroll_offset(),
845 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_thread_scroll1_)); 849 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_thread_scroll1_));
846 850
847 // Pretend like Javascript updated the scroll position itself with a 851 // Pretend like Javascript updated the scroll position itself with a
848 // change of main_thread_scroll. 852 // change of main_thread_scroll.
849 scroll_layer->SetScrollOffset( 853 scroll_layer->SetScrollOffset(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 // beginning a commit and finishing a commit (aka scroll deltas not 942 // beginning a commit and finishing a commit (aka scroll deltas not
939 // included in sent scroll delta) still apply to layers that don't 943 // included in sent scroll delta) still apply to layers that don't
940 // push properties. 944 // push properties.
941 class LayerTreeHostScrollTestImplOnlyScroll : public LayerTreeHostScrollTest { 945 class LayerTreeHostScrollTestImplOnlyScroll : public LayerTreeHostScrollTest {
942 public: 946 public:
943 LayerTreeHostScrollTestImplOnlyScroll() 947 LayerTreeHostScrollTestImplOnlyScroll()
944 : initial_scroll_(20, 10), impl_thread_scroll_(-2, 3), impl_scale_(2.f) {} 948 : initial_scroll_(20, 10), impl_thread_scroll_(-2, 3), impl_scale_(2.f) {}
945 949
946 void SetupTree() override { 950 void SetupTree() override {
947 LayerTreeHostScrollTest::SetupTree(); 951 LayerTreeHostScrollTest::SetupTree();
948 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); 952 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
949 } 953 }
950 954
951 void BeginTest() override { 955 void BeginTest() override {
952 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset( 956 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
953 initial_scroll_); 957 initial_scroll_);
954 PostSetNeedsCommitToMainThread(); 958 PostSetNeedsCommitToMainThread();
955 } 959 }
956 960
957 void WillCommit() override { 961 void WillCommit() override {
958 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer(); 962 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
959 switch (layer_tree_host()->SourceFrameNumber()) { 963 switch (layer_tree_host()->SourceFrameNumber()) {
960 case 0: 964 case 0:
961 EXPECT_TRUE( 965 EXPECT_TRUE(
962 scroll_layer->GetLayerTree()->LayerNeedsPushPropertiesForTesting( 966 scroll_layer->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
963 scroll_layer)); 967 scroll_layer));
964 break; 968 break;
965 case 1: 969 case 1:
966 // Even if this layer doesn't need push properties, it should 970 // Even if this layer doesn't need push properties, it should
967 // still pick up scrolls that happen on the active layer during 971 // still pick up scrolls that happen on the active layer during
968 // commit. 972 // commit.
969 EXPECT_FALSE( 973 EXPECT_FALSE(
970 scroll_layer->GetLayerTree()->LayerNeedsPushPropertiesForTesting( 974 scroll_layer->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
971 scroll_layer)); 975 scroll_layer));
972 break; 976 break;
973 } 977 }
974 } 978 }
975 979
976 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { 980 void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
977 // Scroll after the 2nd commit has started. 981 // Scroll after the 2nd commit has started.
978 if (impl->active_tree()->source_frame_number() == 0) { 982 if (impl->active_tree()->source_frame_number() == 0) {
979 LayerImpl* active_root = impl->active_tree()->root_layer_for_testing(); 983 LayerImpl* active_root = impl->active_tree()->root_layer_for_testing();
980 LayerImpl* active_scroll_layer = impl->OuterViewportScrollLayer(); 984 LayerImpl* active_scroll_layer = impl->OuterViewportScrollLayer();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1082
1079 // This tests scrolling on the impl side which is only possible with a thread. 1083 // This tests scrolling on the impl side which is only possible with a thread.
1080 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplOnlyScroll); 1084 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplOnlyScroll);
1081 1085
1082 class LayerTreeHostScrollTestScrollZeroMaxScrollOffset 1086 class LayerTreeHostScrollTestScrollZeroMaxScrollOffset
1083 : public LayerTreeHostScrollTest { 1087 : public LayerTreeHostScrollTest {
1084 public: 1088 public:
1085 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {} 1089 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {}
1086 1090
1087 void BeginTest() override { 1091 void BeginTest() override {
1088 outer_viewport_container_layer_id_ = 1092 outer_viewport_container_layer_id_ = layer_tree_host()
1089 layer_tree()->outer_viewport_scroll_layer()->scroll_clip_layer()->id(); 1093 ->outer_viewport_scroll_layer()
1094 ->scroll_clip_layer()
1095 ->id();
1090 PostSetNeedsCommitToMainThread(); 1096 PostSetNeedsCommitToMainThread();
1091 } 1097 }
1092 1098
1093 void UpdateLayerTreeHost() override { 1099 void UpdateLayerTreeHost() override {
1094 Layer* root = layer_tree()->root_layer(); 1100 Layer* root = layer_tree_host()->root_layer();
1095 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer(); 1101 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
1096 switch (layer_tree_host()->SourceFrameNumber()) { 1102 switch (layer_tree_host()->SourceFrameNumber()) {
1097 case 0: 1103 case 0:
1098 scroll_layer->SetScrollClipLayerId(outer_viewport_container_layer_id_); 1104 scroll_layer->SetScrollClipLayerId(outer_viewport_container_layer_id_);
1099 // Set max_scroll_offset = (100, 100). 1105 // Set max_scroll_offset = (100, 100).
1100 scroll_layer->SetBounds(gfx::Size(root->bounds().width() + 100, 1106 scroll_layer->SetBounds(gfx::Size(root->bounds().width() + 100,
1101 root->bounds().height() + 100)); 1107 root->bounds().height() + 100));
1102 break; 1108 break;
1103 case 1: 1109 case 1:
1104 // Set max_scroll_offset = (0, 0). 1110 // Set max_scroll_offset = (0, 0).
1105 scroll_layer->SetBounds(root->bounds()); 1111 scroll_layer->SetBounds(root->bounds());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 1160
1155 class LayerTreeHostScrollTestScrollNonDrawnLayer 1161 class LayerTreeHostScrollTestScrollNonDrawnLayer
1156 : public LayerTreeHostScrollTest { 1162 : public LayerTreeHostScrollTest {
1157 public: 1163 public:
1158 LayerTreeHostScrollTestScrollNonDrawnLayer() {} 1164 LayerTreeHostScrollTestScrollNonDrawnLayer() {}
1159 1165
1160 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1166 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1161 1167
1162 void SetupTree() override { 1168 void SetupTree() override {
1163 LayerTreeHostScrollTest::SetupTree(); 1169 LayerTreeHostScrollTest::SetupTree();
1164 layer_tree()->outer_viewport_scroll_layer()->SetIsDrawable(false); 1170 layer_tree_host()->outer_viewport_scroll_layer()->SetIsDrawable(false);
1165 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset( 1171 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
1166 gfx::ScrollOffset(20.f, 20.f)); 1172 gfx::ScrollOffset(20.f, 20.f));
1167 layer_tree()->outer_viewport_scroll_layer()->SetNonFastScrollableRegion( 1173 layer_tree_host()
1168 gfx::Rect(20, 20, 20, 20)); 1174 ->outer_viewport_scroll_layer()
1175 ->SetNonFastScrollableRegion(gfx::Rect(20, 20, 20, 20));
1169 } 1176 }
1170 1177
1171 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1178 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1172 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 1179 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
1173 1180
1174 ScrollTree& scroll_tree = 1181 ScrollTree& scroll_tree =
1175 impl->active_tree()->property_trees()->scroll_tree; 1182 impl->active_tree()->property_trees()->scroll_tree;
1176 ScrollNode* scroll_node = 1183 ScrollNode* scroll_node =
1177 scroll_tree.Node(scroll_layer->scroll_tree_index()); 1184 scroll_tree.Node(scroll_layer->scroll_tree_index());
1178 1185
(...skipping 24 matching lines...) Expand all
1203 1210
1204 class LayerTreeHostScrollTestImplScrollUnderMainThreadScrollingParent 1211 class LayerTreeHostScrollTestImplScrollUnderMainThreadScrollingParent
1205 : public LayerTreeHostScrollTest { 1212 : public LayerTreeHostScrollTest {
1206 public: 1213 public:
1207 LayerTreeHostScrollTestImplScrollUnderMainThreadScrollingParent() {} 1214 LayerTreeHostScrollTestImplScrollUnderMainThreadScrollingParent() {}
1208 1215
1209 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1216 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1210 1217
1211 void SetupTree() override { 1218 void SetupTree() override {
1212 LayerTreeHostScrollTest::SetupTree(); 1219 LayerTreeHostScrollTest::SetupTree();
1213 layer_tree()->inner_viewport_scroll_layer()->AddMainThreadScrollingReasons( 1220 layer_tree_host()
1214 MainThreadScrollingReason::kNonFastScrollableRegion); 1221 ->inner_viewport_scroll_layer()
1222 ->AddMainThreadScrollingReasons(
1223 MainThreadScrollingReason::kNonFastScrollableRegion);
1215 } 1224 }
1216 1225
1217 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1226 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1218 LayerImpl* inner_scroll_layer = impl->InnerViewportScrollLayer(); 1227 LayerImpl* inner_scroll_layer = impl->InnerViewportScrollLayer();
1219 LayerImpl* outer_scroll_layer = impl->OuterViewportScrollLayer(); 1228 LayerImpl* outer_scroll_layer = impl->OuterViewportScrollLayer();
1220 1229
1221 ScrollTree& scroll_tree = 1230 ScrollTree& scroll_tree =
1222 impl->active_tree()->property_trees()->scroll_tree; 1231 impl->active_tree()->property_trees()->scroll_tree;
1223 ScrollNode* inner_scroll_node = 1232 ScrollNode* inner_scroll_node =
1224 scroll_tree.Node(inner_scroll_layer->scroll_tree_index()); 1233 scroll_tree.Node(inner_scroll_layer->scroll_tree_index());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 } 1354 }
1346 1355
1347 class LayerTreeHostScrollTestLayerStructureChange 1356 class LayerTreeHostScrollTestLayerStructureChange
1348 : public LayerTreeHostScrollTest { 1357 : public LayerTreeHostScrollTest {
1349 public: 1358 public:
1350 LayerTreeHostScrollTestLayerStructureChange() 1359 LayerTreeHostScrollTestLayerStructureChange()
1351 : scroll_destroy_whole_tree_(false) {} 1360 : scroll_destroy_whole_tree_(false) {}
1352 1361
1353 void SetupTree() override { 1362 void SetupTree() override {
1354 LayerTreeTest::SetupTree(); 1363 LayerTreeTest::SetupTree();
1355 Layer* root_layer = layer_tree()->root_layer(); 1364 Layer* root_layer = layer_tree_host()->root_layer();
1356 root_layer->SetBounds(gfx::Size(10, 10)); 1365 root_layer->SetBounds(gfx::Size(10, 10));
1357 1366
1358 CreateVirtualViewportLayers(root_layer, root_layer->bounds(), 1367 CreateVirtualViewportLayers(root_layer, root_layer->bounds(),
1359 root_layer->bounds(), root_layer->bounds(), 1368 root_layer->bounds(), root_layer->bounds(),
1360 layer_tree_host()); 1369 layer_tree_host());
1361 1370
1362 Layer* outer_scroll_layer = layer_tree()->outer_viewport_scroll_layer(); 1371 Layer* outer_scroll_layer =
1372 layer_tree_host()->outer_viewport_scroll_layer();
1363 1373
1364 Layer* root_scroll_layer = 1374 Layer* root_scroll_layer =
1365 CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_); 1375 CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_);
1366 Layer* sibling_scroll_layer = 1376 Layer* sibling_scroll_layer =
1367 CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_); 1377 CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_);
1368 Layer* child_scroll_layer = 1378 Layer* child_scroll_layer =
1369 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); 1379 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_);
1370 root_scroll_layer_id_ = root_scroll_layer->id(); 1380 root_scroll_layer_id_ = root_scroll_layer->id();
1371 sibling_scroll_layer_id_ = sibling_scroll_layer->id(); 1381 sibling_scroll_layer_id_ = sibling_scroll_layer->id();
1372 child_scroll_layer_id_ = child_scroll_layer->id(); 1382 child_scroll_layer_id_ = child_scroll_layer->id();
(...skipping 19 matching lines...) Expand all
1392 case 1: 1402 case 1:
1393 EndTest(); 1403 EndTest();
1394 break; 1404 break;
1395 } 1405 }
1396 } 1406 }
1397 1407
1398 void AfterTest() override {} 1408 void AfterTest() override {}
1399 1409
1400 virtual void DidScroll(Layer* layer) { 1410 virtual void DidScroll(Layer* layer) {
1401 if (scroll_destroy_whole_tree_) { 1411 if (scroll_destroy_whole_tree_) {
1402 layer_tree()->RegisterViewportLayers(NULL, NULL, NULL, NULL); 1412 layer_tree_host()->RegisterViewportLayers(NULL, NULL, NULL, NULL);
1403 layer_tree()->SetRootLayer(NULL); 1413 layer_tree_host()->SetRootLayer(NULL);
1404 EndTest(); 1414 EndTest();
1405 return; 1415 return;
1406 } 1416 }
1407 layer->RemoveFromParent(); 1417 layer->RemoveFromParent();
1408 } 1418 }
1409 1419
1410 protected: 1420 protected:
1411 class FakeLayerScrollClient { 1421 class FakeLayerScrollClient {
1412 public: 1422 public:
1413 void DidScroll() { 1423 void DidScroll() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 third_scroll_(20, 10), 1482 third_scroll_(20, 10),
1473 scroll_amount_(2, -1), 1483 scroll_amount_(2, -1),
1474 num_commits_(0), 1484 num_commits_(0),
1475 num_scrolls_(0) {} 1485 num_scrolls_(0) {}
1476 1486
1477 void InitializeSettings(LayerTreeSettings* settings) override { 1487 void InitializeSettings(LayerTreeSettings* settings) override {
1478 settings->main_frame_before_activation_enabled = true; 1488 settings->main_frame_before_activation_enabled = true;
1479 } 1489 }
1480 1490
1481 void BeginTest() override { 1491 void BeginTest() override {
1482 outer_viewport_container_layer_id_ = 1492 outer_viewport_container_layer_id_ = layer_tree_host()
1483 layer_tree()->outer_viewport_scroll_layer()->scroll_clip_layer()->id(); 1493 ->outer_viewport_scroll_layer()
1484 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset( 1494 ->scroll_clip_layer()
1495 ->id();
1496 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
1485 initial_scroll_); 1497 initial_scroll_);
1486 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback( 1498 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback(
1487 base::Bind(&LayerTreeHostScrollTestScrollMFBA::DidScrollOuterViewport, 1499 base::Bind(&LayerTreeHostScrollTestScrollMFBA::DidScrollOuterViewport,
1488 base::Unretained(this))); 1500 base::Unretained(this)));
1489 PostSetNeedsCommitToMainThread(); 1501 PostSetNeedsCommitToMainThread();
1490 } 1502 }
1491 1503
1492 void ReadyToCommitOnThread(LayerTreeHostImpl* impl) override { 1504 void ReadyToCommitOnThread(LayerTreeHostImpl* impl) override {
1493 switch (num_commits_) { 1505 switch (num_commits_) {
1494 case 1: 1506 case 1:
1495 // Ask for commit here because activation (and draw) will be blocked. 1507 // Ask for commit here because activation (and draw) will be blocked.
1496 impl->SetNeedsCommit(); 1508 impl->SetNeedsCommit();
1497 // Block activation after second commit until third commit is ready. 1509 // Block activation after second commit until third commit is ready.
1498 impl->BlockNotifyReadyToActivateForTesting(true); 1510 impl->BlockNotifyReadyToActivateForTesting(true);
1499 break; 1511 break;
1500 case 2: 1512 case 2:
1501 // Unblock activation after third commit is ready. 1513 // Unblock activation after third commit is ready.
1502 impl->BlockNotifyReadyToActivateForTesting(false); 1514 impl->BlockNotifyReadyToActivateForTesting(false);
1503 break; 1515 break;
1504 } 1516 }
1505 num_commits_++; 1517 num_commits_++;
1506 } 1518 }
1507 1519
1508 void UpdateLayerTreeHost() override { 1520 void UpdateLayerTreeHost() override {
1509 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer(); 1521 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
1510 switch (layer_tree_host()->SourceFrameNumber()) { 1522 switch (layer_tree_host()->SourceFrameNumber()) {
1511 case 0: 1523 case 0:
1512 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); 1524 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
1513 break; 1525 break;
1514 case 1: 1526 case 1:
1515 EXPECT_VECTOR_EQ( 1527 EXPECT_VECTOR_EQ(
1516 gfx::ScrollOffsetWithDelta(initial_scroll_, scroll_amount_), 1528 gfx::ScrollOffsetWithDelta(initial_scroll_, scroll_amount_),
1517 scroll_layer->scroll_offset()); 1529 scroll_layer->scroll_offset());
1518 // Pretend like Javascript updated the scroll position itself. 1530 // Pretend like Javascript updated the scroll position itself.
1519 scroll_layer->SetScrollOffset(second_scroll_); 1531 scroll_layer->SetScrollOffset(second_scroll_);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 num_impl_commits_(0), 1615 num_impl_commits_(0),
1604 num_aborted_commits_(0), 1616 num_aborted_commits_(0),
1605 num_impl_scrolls_(0), 1617 num_impl_scrolls_(0),
1606 num_draws_(0) {} 1618 num_draws_(0) {}
1607 1619
1608 void InitializeSettings(LayerTreeSettings* settings) override { 1620 void InitializeSettings(LayerTreeSettings* settings) override {
1609 settings->main_frame_before_activation_enabled = true; 1621 settings->main_frame_before_activation_enabled = true;
1610 } 1622 }
1611 1623
1612 void BeginTest() override { 1624 void BeginTest() override {
1613 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset( 1625 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
1614 initial_scroll_); 1626 initial_scroll_);
1615 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback( 1627 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback(
1616 base::Bind(&LayerTreeHostScrollTestScrollAbortedCommitMFBA:: 1628 base::Bind(&LayerTreeHostScrollTestScrollAbortedCommitMFBA::
1617 DidScrollOuterViewport, 1629 DidScrollOuterViewport,
1618 base::Unretained(this))); 1630 base::Unretained(this)));
1619 PostSetNeedsCommitToMainThread(); 1631 PostSetNeedsCommitToMainThread();
1620 } 1632 }
1621 1633
1622 void SetupTree() override { 1634 void SetupTree() override {
1623 LayerTreeHostScrollTest::SetupTree(); 1635 LayerTreeHostScrollTest::SetupTree();
1624 1636
1625 gfx::Size scroll_layer_bounds(200, 200); 1637 gfx::Size scroll_layer_bounds(200, 200);
1626 layer_tree()->outer_viewport_scroll_layer()->SetBounds(scroll_layer_bounds); 1638 layer_tree_host()->outer_viewport_scroll_layer()->SetBounds(
1627 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); 1639 scroll_layer_bounds);
1640 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
1628 } 1641 }
1629 1642
1630 void WillBeginMainFrame() override { 1643 void WillBeginMainFrame() override {
1631 num_will_begin_main_frames_++; 1644 num_will_begin_main_frames_++;
1632 Layer* root_scroll_layer = layer_tree()->outer_viewport_scroll_layer(); 1645 Layer* root_scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
1633 switch (num_will_begin_main_frames_) { 1646 switch (num_will_begin_main_frames_) {
1634 case 1: 1647 case 1:
1635 // This will not be aborted because of the initial prop changes. 1648 // This will not be aborted because of the initial prop changes.
1636 EXPECT_EQ(0, num_impl_scrolls_); 1649 EXPECT_EQ(0, num_impl_scrolls_);
1637 EXPECT_EQ(0, layer_tree_host()->SourceFrameNumber()); 1650 EXPECT_EQ(0, layer_tree_host()->SourceFrameNumber());
1638 EXPECT_VECTOR_EQ(initial_scroll_, root_scroll_layer->scroll_offset()); 1651 EXPECT_VECTOR_EQ(initial_scroll_, root_scroll_layer->scroll_offset());
1639 break; 1652 break;
1640 case 2: 1653 case 2:
1641 // This commit will not be aborted because of the scroll change. 1654 // This commit will not be aborted because of the scroll change.
1642 EXPECT_EQ(1, num_impl_scrolls_); 1655 EXPECT_EQ(1, num_impl_scrolls_);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 float scale, 1879 float scale,
1867 float top_controls_delta) override { 1880 float top_controls_delta) override {
1868 DCHECK_NE(0, num_begin_main_frames_main_thread_) 1881 DCHECK_NE(0, num_begin_main_frames_main_thread_)
1869 << "The first BeginMainFrame has no deltas to report"; 1882 << "The first BeginMainFrame has no deltas to report";
1870 DCHECK_LT(num_begin_main_frames_main_thread_, 5); 1883 DCHECK_LT(num_begin_main_frames_main_thread_, 5);
1871 1884
1872 gfx::Vector2dF expected_elastic_overscroll = 1885 gfx::Vector2dF expected_elastic_overscroll =
1873 elastic_overscroll_test_cases_[num_begin_main_frames_main_thread_]; 1886 elastic_overscroll_test_cases_[num_begin_main_frames_main_thread_];
1874 current_elastic_overscroll_ += elastic_overscroll_delta; 1887 current_elastic_overscroll_ += elastic_overscroll_delta;
1875 EXPECT_EQ(expected_elastic_overscroll, current_elastic_overscroll_); 1888 EXPECT_EQ(expected_elastic_overscroll, current_elastic_overscroll_);
1876 EXPECT_EQ(expected_elastic_overscroll, layer_tree()->elastic_overscroll()); 1889 EXPECT_EQ(expected_elastic_overscroll,
1890 layer_tree_host()->elastic_overscroll());
1877 } 1891 }
1878 1892
1879 void WillBeginMainFrame() override { num_begin_main_frames_main_thread_++; } 1893 void WillBeginMainFrame() override { num_begin_main_frames_main_thread_++; }
1880 1894
1881 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, 1895 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
1882 CommitEarlyOutReason reason) override { 1896 CommitEarlyOutReason reason) override {
1883 VerifyBeginMainFrameResultOnImplThread(host_impl, true); 1897 VerifyBeginMainFrameResultOnImplThread(host_impl, true);
1884 } 1898 }
1885 1899
1886 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 1900 void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 2003
1990 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestElasticOverscroll); 2004 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestElasticOverscroll);
1991 2005
1992 class LayerTreeHostScrollTestPropertyTreeUpdate 2006 class LayerTreeHostScrollTestPropertyTreeUpdate
1993 : public LayerTreeHostScrollTest { 2007 : public LayerTreeHostScrollTest {
1994 public: 2008 public:
1995 LayerTreeHostScrollTestPropertyTreeUpdate() 2009 LayerTreeHostScrollTestPropertyTreeUpdate()
1996 : initial_scroll_(10, 20), second_scroll_(0, 0) {} 2010 : initial_scroll_(10, 20), second_scroll_(0, 0) {}
1997 2011
1998 void BeginTest() override { 2012 void BeginTest() override {
1999 layer_tree()->inner_viewport_scroll_layer()->SetScrollOffset( 2013 layer_tree_host()->inner_viewport_scroll_layer()->SetScrollOffset(
2000 initial_scroll_); 2014 initial_scroll_);
2001 layer_tree()->inner_viewport_scroll_layer()->SetBounds(gfx::Size(100, 100)); 2015 layer_tree_host()->inner_viewport_scroll_layer()->SetBounds(
2016 gfx::Size(100, 100));
2002 PostSetNeedsCommitToMainThread(); 2017 PostSetNeedsCommitToMainThread();
2003 } 2018 }
2004 2019
2005 void UpdateLayerTreeHost() override { 2020 void UpdateLayerTreeHost() override {
2006 Layer* scroll_layer = layer_tree()->inner_viewport_scroll_layer(); 2021 Layer* scroll_layer = layer_tree_host()->inner_viewport_scroll_layer();
2007 if (layer_tree_host()->SourceFrameNumber() == 0) { 2022 if (layer_tree_host()->SourceFrameNumber() == 0) {
2008 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); 2023 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
2009 } else { 2024 } else {
2010 EXPECT_VECTOR_EQ( 2025 EXPECT_VECTOR_EQ(
2011 gfx::ScrollOffsetWithDelta(initial_scroll_, scroll_amount_), 2026 gfx::ScrollOffsetWithDelta(initial_scroll_, scroll_amount_),
2012 scroll_layer->scroll_offset()); 2027 scroll_layer->scroll_offset());
2013 scroll_layer->SetScrollOffset(second_scroll_); 2028 scroll_layer->SetScrollOffset(second_scroll_);
2014 scroll_layer->SetOpacity(0.5f); 2029 scroll_layer->SetOpacity(0.5f);
2015 } 2030 }
2016 } 2031 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 private: 2066 private:
2052 gfx::ScrollOffset initial_scroll_; 2067 gfx::ScrollOffset initial_scroll_;
2053 gfx::ScrollOffset second_scroll_; 2068 gfx::ScrollOffset second_scroll_;
2054 gfx::Vector2dF scroll_amount_; 2069 gfx::Vector2dF scroll_amount_;
2055 }; 2070 };
2056 2071
2057 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostScrollTestPropertyTreeUpdate); 2072 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostScrollTestPropertyTreeUpdate);
2058 2073
2059 } // namespace 2074 } // namespace
2060 } // namespace cc 2075 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_proxy.cc ('k') | cc/trees/layer_tree_host_unittest_video.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698