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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 | 681 |
682 virtual void AfterTest() OVERRIDE { | 682 virtual void AfterTest() OVERRIDE { |
683 EXPECT_EQ(3, did_swaps_); | 683 EXPECT_EQ(3, did_swaps_); |
684 } | 684 } |
685 | 685 |
686 int did_swaps_; | 686 int did_swaps_; |
687 }; | 687 }; |
688 | 688 |
689 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); | 689 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); |
690 | 690 |
691 class LayerTreeHostDamageTestVisibleTilesStillTriggerDraws | |
692 : public LayerTreeHostDamageTest { | |
693 | |
694 virtual void BeginTest() OVERRIDE { | |
695 if (!settings_.impl_side_painting) { | |
696 EndTest(); | |
697 return; | |
698 } | |
699 PostSetNeedsCommitToMainThread(); | |
700 } | |
701 | |
702 virtual void SetupTree() OVERRIDE { | |
703 root_ = FakeContentLayer::Create(&client_); | |
danakj
2013/09/07 01:00:15
If you're testing impl paint only, do you want Fak
epenner
2013/09/07 01:55:18
Done.
| |
704 root_->SetBounds(gfx::Size(500, 500)); | |
705 layer_tree_host()->SetRootLayer(root_); | |
706 LayerTreeHostDamageTest::SetupTree(); | |
707 | |
708 swap_count_ = 0; | |
709 prepare_to_draw_count_ = 0; | |
710 update_visible_tile_count_ = 0; | |
711 } | |
712 | |
713 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | |
714 LayerTreeHostImpl::FrameData* frame_data, | |
715 bool result) OVERRIDE { | |
716 EXPECT_TRUE(result); | |
717 prepare_to_draw_count_++; | |
718 switch (prepare_to_draw_count_) { | |
719 case 1: | |
720 // Detect that we have an incomplete tile, during the first frame. | |
721 // The first frame should have damage. | |
722 frame_data->contains_incomplete_tile = true; | |
723 DCHECK(!frame_data->has_no_damage); | |
724 break; | |
725 case 2: | |
726 // Make a no-damage frame. We early out and can't detect | |
727 // incomplete tiles, even if they still exist. | |
728 frame_data->contains_incomplete_tile = false; | |
729 frame_data->has_no_damage = true; | |
730 break; | |
731 case 3: | |
732 // Trigger the last swap for the completed tile. | |
733 frame_data->contains_incomplete_tile = false; | |
734 frame_data->has_no_damage = false; | |
735 EndTest(); | |
736 break; | |
737 default: | |
738 NOTREACHED(); | |
739 break; | |
740 } | |
741 | |
742 return result; | |
743 } | |
744 | |
745 virtual void UpdateVisibleTilesOnThread( | |
746 LayerTreeHostImpl* host_impl) OVERRIDE { | |
747 // Simulate creating some visible tiles (that trigger prepare-to-draws). | |
748 // The first we make into a no-damage-frame during prepare-to-draw (see | |
749 // above). This is to ensure we still get UpdateVisibleTiles calls after | |
750 // a no-damage or aborted frame. | |
751 update_visible_tile_count_++; | |
752 switch (update_visible_tile_count_) { | |
753 case 3: | |
754 case 6: | |
755 host_impl->DidInitializeVisibleTile(); | |
756 break; | |
757 case 7: | |
758 NOTREACHED(); | |
759 break; | |
760 } | |
761 } | |
762 | |
763 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | |
764 bool didSwap) OVERRIDE { | |
765 if (!didSwap) | |
766 return; | |
767 ++swap_count_; | |
768 } | |
769 | |
770 virtual void AfterTest() OVERRIDE { | |
771 if (!settings_.impl_side_painting) | |
772 return; | |
773 // We should keep getting update-visible-tiles calls | |
774 // until we report there are no more incomplete-tiles. | |
775 EXPECT_EQ(update_visible_tile_count_, 6); | |
776 // First frame, plus two triggered by DidInitializeVisibleTile() | |
777 EXPECT_EQ(prepare_to_draw_count_, 3); | |
778 // First swap, plus final swap (contained damage). | |
779 EXPECT_EQ(swap_count_, 2); | |
780 } | |
781 | |
782 FakeContentLayerClient client_; | |
783 scoped_refptr<FakeContentLayer> root_; | |
danakj
2013/09/07 01:00:15
This can be a local in SetupTree, it's not used el
epenner
2013/09/07 01:55:18
Done.
| |
784 int swap_count_; | |
785 int prepare_to_draw_count_; | |
786 int update_visible_tile_count_; | |
787 }; | |
788 | |
789 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); | |
790 | |
691 } // namespace | 791 } // namespace |
692 } // namespace cc | 792 } // namespace cc |
OLD | NEW |