OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 2804 matching lines...) Loading... |
2815 | 2815 |
2816 // Low-res tiles should not be enough. | 2816 // Low-res tiles should not be enough. |
2817 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2817 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2818 | 2818 |
2819 // Initialize remaining tiles. | 2819 // Initialize remaining tiles. |
2820 pending_layer_->SetAllTilesReady(); | 2820 pending_layer_->SetAllTilesReady(); |
2821 | 2821 |
2822 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2822 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2823 } | 2823 } |
2824 | 2824 |
2825 TEST_F(PictureLayerImplTest, HighResReadyToDrawNotEnoughToActivate) { | 2825 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { |
2826 gfx::Size tile_size(100, 100); | 2826 gfx::Size tile_size(100, 100); |
2827 gfx::Size layer_bounds(1000, 1000); | 2827 gfx::Size layer_bounds(1000, 1000); |
2828 | 2828 |
2829 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 2829 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
2830 | 2830 |
2831 // Make sure some tiles are not shared. | 2831 // Make sure some tiles are not shared. |
2832 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 2832 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); |
2833 | 2833 |
2834 CreateHighLowResAndSetAllTilesVisible(); | 2834 CreateHighLowResAndSetAllTilesVisible(); |
2835 active_layer_->SetAllTilesReady(); | 2835 active_layer_->SetAllTilesReady(); |
2836 pending_layer_->MarkVisibleResourcesAsRequired(); | 2836 pending_layer_->MarkVisibleResourcesAsRequired(); |
2837 | 2837 |
2838 // All pending layer tiles required are not ready. | 2838 // All pending layer tiles required are not ready. |
2839 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2839 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2840 | 2840 |
2841 // Initialize all high-res tiles. | 2841 // Initialize all high-res tiles. |
2842 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 2842 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
2843 | 2843 |
2844 // High-res tiles should not be enough. | 2844 // High-res tiles should be enough, since they cover everything visible. |
2845 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | |
2846 | |
2847 // Initialize remaining tiles. | |
2848 pending_layer_->SetAllTilesReady(); | |
2849 | |
2850 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 2845 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
2851 } | 2846 } |
2852 | 2847 |
| 2848 TEST_F(PictureLayerImplTest, |
| 2849 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { |
| 2850 gfx::Size tile_size(100, 100); |
| 2851 gfx::Size layer_bounds(1000, 1000); |
| 2852 |
| 2853 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
| 2854 |
| 2855 // Make sure some tiles are not shared. |
| 2856 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); |
| 2857 |
| 2858 CreateHighLowResAndSetAllTilesVisible(); |
| 2859 |
| 2860 // Initialize all high-res tiles in the active layer. |
| 2861 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 2862 // And all the low-res tiles in the pending layer. |
| 2863 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
| 2864 |
| 2865 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 2866 |
| 2867 // The unshared high-res tiles are not ready, so we cannot activate. |
| 2868 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| 2869 |
| 2870 // When the unshared pending high-res tiles are ready, we can activate. |
| 2871 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 2872 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| 2873 } |
| 2874 |
| 2875 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { |
| 2876 gfx::Size tile_size(100, 100); |
| 2877 gfx::Size layer_bounds(1000, 1000); |
| 2878 |
| 2879 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
| 2880 |
| 2881 // Make sure some tiles are not shared. |
| 2882 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); |
| 2883 |
| 2884 CreateHighLowResAndSetAllTilesVisible(); |
| 2885 |
| 2886 // Initialize all high-res tiles in the active layer. |
| 2887 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
| 2888 |
| 2889 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 2890 |
| 2891 // The unshared high-res tiles are not ready, so we cannot activate. |
| 2892 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| 2893 |
| 2894 // When the unshared pending high-res tiles are ready, we can activate. |
| 2895 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
| 2896 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
| 2897 } |
| 2898 |
2853 class NoLowResTilingsSettings : public ImplSidePaintingSettings { | 2899 class NoLowResTilingsSettings : public ImplSidePaintingSettings { |
2854 public: | 2900 public: |
2855 NoLowResTilingsSettings() { create_low_res_tiling = false; } | 2901 NoLowResTilingsSettings() { create_low_res_tiling = false; } |
2856 }; | 2902 }; |
2857 | 2903 |
2858 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { | 2904 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { |
2859 public: | 2905 public: |
2860 NoLowResPictureLayerImplTest() | 2906 NoLowResPictureLayerImplTest() |
2861 : PictureLayerImplTest(NoLowResTilingsSettings()) {} | 2907 : PictureLayerImplTest(NoLowResTilingsSettings()) {} |
2862 }; | 2908 }; |
(...skipping 1212 matching lines...) Loading... |
4075 ActivateTree(); | 4121 ActivateTree(); |
4076 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer()); | 4122 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer()); |
4077 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer()); | 4123 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer()); |
4078 | 4124 |
4079 host_impl_.ResetRecycleTreeForTesting(); | 4125 host_impl_.ResetRecycleTreeForTesting(); |
4080 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); | 4126 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); |
4081 } | 4127 } |
4082 | 4128 |
4083 } // namespace | 4129 } // namespace |
4084 } // namespace cc | 4130 } // namespace cc |
OLD | NEW |