OLD | NEW |
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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "cc/content_layer.h" | 7 #include "cc/content_layer.h" |
8 #include "cc/layer.h" | 8 #include "cc/layer.h" |
9 #include "cc/layer_impl.h" | 9 #include "cc/layer_impl.h" |
10 #include "cc/layer_tree_impl.h" | 10 #include "cc/layer_tree_impl.h" |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 // Pretend like Javascript updated the scroll position itself with a | 530 // Pretend like Javascript updated the scroll position itself with a |
531 // change of main_thread_scroll. | 531 // change of main_thread_scroll. |
532 root->setScrollOffset(initial_scroll_ + main_thread_scroll_ + impl_thread_
scroll1_); | 532 root->setScrollOffset(initial_scroll_ + main_thread_scroll_ + impl_thread_
scroll1_); |
533 } | 533 } |
534 } | 534 } |
535 | 535 |
536 virtual bool canActivatePendingTree() OVERRIDE { | 536 virtual bool canActivatePendingTree() OVERRIDE { |
537 return can_activate_; | 537 return can_activate_; |
538 } | 538 } |
539 | 539 |
| 540 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 541 // We force a second draw here of the first commit before activating |
| 542 // the second commit. |
| 543 if (impl->activeTree()->source_frame_number() == 0) |
| 544 impl->setNeedsRedraw(); |
| 545 } |
| 546 |
540 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 547 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
541 ImplSidePaintingScrollTest::drawLayersOnThread(impl); | 548 ImplSidePaintingScrollTest::drawLayersOnThread(impl); |
542 | 549 |
543 LayerImpl* root = impl->rootLayer(); | 550 LayerImpl* root = impl->rootLayer(); |
544 root->setScrollable(true); | 551 root->setScrollable(true); |
545 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); | 552 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); |
546 | 553 |
547 LayerImpl* pending_root = | 554 LayerImpl* pending_root = |
548 impl->activeTree()->FindPendingTreeLayerById(root->id()); | 555 impl->activeTree()->FindPendingTreeLayerById(root->id()); |
549 | 556 |
550 switch (impl->activeTree()->source_frame_number()) { | 557 switch (impl->activeTree()->source_frame_number()) { |
551 case 0: | 558 case 0: |
552 if (!impl->pendingTree()) { | 559 if (!impl->pendingTree()) { |
553 can_activate_ = false; | 560 can_activate_ = false; |
554 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); | 561 EXPECT_VECTOR_EQ(root->scrollDelta(), gfx::Vector2d()); |
555 root->scrollBy(impl_thread_scroll1_); | 562 root->scrollBy(impl_thread_scroll1_); |
556 | 563 |
557 EXPECT_VECTOR_EQ(root->scrollOffset(), initial_scroll_); | 564 EXPECT_VECTOR_EQ(root->scrollOffset(), initial_scroll_); |
558 EXPECT_VECTOR_EQ(root->scrollDelta(), impl_thread_scroll1_); | 565 EXPECT_VECTOR_EQ(root->scrollDelta(), impl_thread_scroll1_); |
559 EXPECT_VECTOR_EQ(root->sentScrollDelta(), gfx::Vector2d()); | 566 EXPECT_VECTOR_EQ(root->sentScrollDelta(), gfx::Vector2d()); |
560 postSetNeedsCommitToMainThread(); | 567 postSetNeedsCommitToMainThread(); |
| 568 |
| 569 // commitCompleteOnThread will trigger this function again |
| 570 // and cause us to take the else clause. |
561 } else { | 571 } else { |
562 can_activate_ = true; | 572 can_activate_ = true; |
563 ASSERT_TRUE(pending_root); | 573 ASSERT_TRUE(pending_root); |
564 EXPECT_EQ(impl->pendingTree()->source_frame_number(), 1); | 574 EXPECT_EQ(impl->pendingTree()->source_frame_number(), 1); |
565 | 575 |
566 root->scrollBy(impl_thread_scroll2_); | 576 root->scrollBy(impl_thread_scroll2_); |
567 EXPECT_VECTOR_EQ(root->scrollOffset(), initial_scroll_); | 577 EXPECT_VECTOR_EQ(root->scrollOffset(), initial_scroll_); |
568 EXPECT_VECTOR_EQ(root->scrollDelta(), | 578 EXPECT_VECTOR_EQ(root->scrollDelta(), |
569 impl_thread_scroll1_ + impl_thread_scroll2_); | 579 impl_thread_scroll1_ + impl_thread_scroll2_); |
570 EXPECT_VECTOR_EQ(root->sentScrollDelta(), impl_thread_scroll1_); | 580 EXPECT_VECTOR_EQ(root->sentScrollDelta(), impl_thread_scroll1_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 gfx::Vector2d impl_thread_scroll1_; | 613 gfx::Vector2d impl_thread_scroll1_; |
604 gfx::Vector2d impl_thread_scroll2_; | 614 gfx::Vector2d impl_thread_scroll2_; |
605 int num_scrolls_; | 615 int num_scrolls_; |
606 bool can_activate_; | 616 bool can_activate_; |
607 }; | 617 }; |
608 | 618 |
609 MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestSimple); | 619 MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestSimple); |
610 | 620 |
611 } // namespace | 621 } // namespace |
612 } // namespace cc | 622 } // namespace cc |
OLD | NEW |