OLD | NEW |
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/layers/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 impl_task_runner); | 87 impl_task_runner); |
88 } | 88 } |
89 | 89 |
90 bool output_surface_created_; | 90 bool output_surface_created_; |
91 base::RunLoop run_loop_; | 91 base::RunLoop run_loop_; |
92 }; | 92 }; |
93 | 93 |
94 class TiledLayerTest : public testing::Test { | 94 class TiledLayerTest : public testing::Test { |
95 public: | 95 public: |
96 TiledLayerTest() | 96 TiledLayerTest() |
97 : proxy_(NULL), | 97 : proxy_(nullptr), |
98 output_surface_(FakeOutputSurface::Create3d()), | 98 output_surface_(FakeOutputSurface::Create3d()), |
99 queue_(make_scoped_ptr(new ResourceUpdateQueue)), | 99 queue_(make_scoped_ptr(new ResourceUpdateQueue)), |
100 impl_thread_("ImplThread"), | 100 impl_thread_("ImplThread"), |
101 fake_layer_tree_host_client_(FakeLayerTreeHostClient::DIRECT_3D), | 101 fake_layer_tree_host_client_(FakeLayerTreeHostClient::DIRECT_3D), |
102 occlusion_(NULL) { | 102 occlusion_(nullptr) { |
103 settings_.max_partial_texture_updates = std::numeric_limits<size_t>::max(); | 103 settings_.max_partial_texture_updates = std::numeric_limits<size_t>::max(); |
104 settings_.layer_transforms_should_scale_layer_contents = true; | 104 settings_.layer_transforms_should_scale_layer_contents = true; |
105 } | 105 } |
106 | 106 |
107 virtual void SetUp() { | 107 virtual void SetUp() { |
108 impl_thread_.Start(); | 108 impl_thread_.Start(); |
109 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 109 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
110 layer_tree_host_ = SynchronousOutputSurfaceLayerTreeHost::Create( | 110 layer_tree_host_ = SynchronousOutputSurfaceLayerTreeHost::Create( |
111 &fake_layer_tree_host_client_, | 111 &fake_layer_tree_host_client_, |
112 shared_bitmap_manager_.get(), | 112 shared_bitmap_manager_.get(), |
113 settings_, | 113 settings_, |
114 impl_thread_.message_loop_proxy()); | 114 impl_thread_.message_loop_proxy()); |
115 fake_layer_tree_host_client_.SetLayerTreeHost(layer_tree_host_.get()); | 115 fake_layer_tree_host_client_.SetLayerTreeHost(layer_tree_host_.get()); |
116 proxy_ = layer_tree_host_->proxy(); | 116 proxy_ = layer_tree_host_->proxy(); |
117 resource_manager_ = PrioritizedResourceManager::Create(proxy_); | 117 resource_manager_ = PrioritizedResourceManager::Create(proxy_); |
118 layer_tree_host_->SetLayerTreeHostClientReady(); | 118 layer_tree_host_->SetLayerTreeHostClientReady(); |
119 CHECK(layer_tree_host_->EnsureOutputSurfaceCreated()); | 119 CHECK(layer_tree_host_->EnsureOutputSurfaceCreated()); |
120 layer_tree_host_->SetRootLayer(Layer::Create()); | 120 layer_tree_host_->SetRootLayer(Layer::Create()); |
121 | 121 |
122 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 122 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
123 | 123 |
124 DebugScopedSetImplThreadAndMainThreadBlocked | 124 DebugScopedSetImplThreadAndMainThreadBlocked |
125 impl_thread_and_main_thread_blocked(proxy_); | 125 impl_thread_and_main_thread_blocked(proxy_); |
126 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 126 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
127 shared_bitmap_manager_.get(), | 127 shared_bitmap_manager_.get(), |
128 NULL, | 128 nullptr, |
129 0, | 129 0, |
130 false, | 130 false, |
131 1, | 131 1, |
132 false); | 132 false); |
133 host_impl_ = make_scoped_ptr( | 133 host_impl_ = make_scoped_ptr( |
134 new FakeLayerTreeHostImpl(proxy_, shared_bitmap_manager_.get())); | 134 new FakeLayerTreeHostImpl(proxy_, shared_bitmap_manager_.get())); |
135 } | 135 } |
136 | 136 |
137 virtual ~TiledLayerTest() { | 137 virtual ~TiledLayerTest() { |
138 ResourceManagerClearAllMemory(resource_manager_.get(), | 138 ResourceManagerClearAllMemory(resource_manager_.get(), |
(...skipping 15 matching lines...) Expand all Loading... |
154 resource_manager->ReduceMemory(resource_provider); | 154 resource_manager->ReduceMemory(resource_provider); |
155 } | 155 } |
156 resource_manager->UnlinkAndClearEvictedBackings(); | 156 resource_manager->UnlinkAndClearEvictedBackings(); |
157 } | 157 } |
158 | 158 |
159 void UpdateTextures() { | 159 void UpdateTextures() { |
160 DebugScopedSetImplThreadAndMainThreadBlocked | 160 DebugScopedSetImplThreadAndMainThreadBlocked |
161 impl_thread_and_main_thread_blocked(proxy_); | 161 impl_thread_and_main_thread_blocked(proxy_); |
162 DCHECK(queue_); | 162 DCHECK(queue_); |
163 scoped_ptr<ResourceUpdateController> update_controller = | 163 scoped_ptr<ResourceUpdateController> update_controller = |
164 ResourceUpdateController::Create(NULL, | 164 ResourceUpdateController::Create(nullptr, |
165 proxy_->ImplThreadTaskRunner(), | 165 proxy_->ImplThreadTaskRunner(), |
166 queue_.Pass(), | 166 queue_.Pass(), |
167 resource_provider_.get()); | 167 resource_provider_.get()); |
168 update_controller->Finalize(); | 168 update_controller->Finalize(); |
169 queue_ = make_scoped_ptr(new ResourceUpdateQueue); | 169 queue_ = make_scoped_ptr(new ResourceUpdateQueue); |
170 } | 170 } |
171 | 171 |
172 void LayerPushPropertiesTo(FakeTiledLayer* layer, | 172 void LayerPushPropertiesTo(FakeTiledLayer* layer, |
173 FakeTiledLayerImpl* layer_impl) { | 173 FakeTiledLayerImpl* layer_impl) { |
174 DebugScopedSetImplThreadAndMainThreadBlocked | 174 DebugScopedSetImplThreadAndMainThreadBlocked |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 // Pretend the layer is animating. | 715 // Pretend the layer is animating. |
716 layer->draw_properties().target_space_transform_is_animating = true; | 716 layer->draw_properties().target_space_transform_is_animating = true; |
717 layer->draw_properties().visible_content_rect = visible_rect; | 717 layer->draw_properties().visible_content_rect = visible_rect; |
718 layer->SetLayerTreeHost(layer_tree_host_.get()); | 718 layer->SetLayerTreeHost(layer_tree_host_.get()); |
719 | 719 |
720 // The layer should paint its entire contents on the first paint | 720 // The layer should paint its entire contents on the first paint |
721 // if it is close to the viewport size and has the available memory. | 721 // if it is close to the viewport size and has the available memory. |
722 layer->SetTexturePriorities(priority_calculator_); | 722 layer->SetTexturePriorities(priority_calculator_); |
723 resource_manager_->PrioritizeTextures(); | 723 resource_manager_->PrioritizeTextures(); |
724 layer->SavePaintProperties(); | 724 layer->SavePaintProperties(); |
725 layer->Update(queue_.get(), NULL); | 725 layer->Update(queue_.get(), nullptr); |
726 UpdateTextures(); | 726 UpdateTextures(); |
727 LayerPushPropertiesTo(layer.get(), layer_impl.get()); | 727 LayerPushPropertiesTo(layer.get(), layer_impl.get()); |
728 | 728 |
729 // We should have all the tiles for the small animated layer. | 729 // We should have all the tiles for the small animated layer. |
730 // We should still have the visible tiles when we didn't | 730 // We should still have the visible tiles when we didn't |
731 // have enough memory for all the tiles. | 731 // have enough memory for all the tiles. |
732 if (!run_out_of_memory[i]) { | 732 if (!run_out_of_memory[i]) { |
733 for (int i = 0; i < 5; ++i) { | 733 for (int i = 0; i < 5; ++i) { |
734 for (int j = 0; j < 5; ++j) | 734 for (int j = 0; j < 5; ++j) |
735 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(i, j)); | 735 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(i, j)); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 layer->draw_properties().contents_scale_y = 1.25f; | 903 layer->draw_properties().contents_scale_y = 1.25f; |
904 | 904 |
905 // On first update, the update_rect includes all tiles, even beyond the | 905 // On first update, the update_rect includes all tiles, even beyond the |
906 // boundaries of the layer. | 906 // boundaries of the layer. |
907 // However, it should still be in layer space, not content space. | 907 // However, it should still be in layer space, not content space. |
908 layer->InvalidateContentRect(content_bounds); | 908 layer->InvalidateContentRect(content_bounds); |
909 | 909 |
910 layer->SetTexturePriorities(priority_calculator_); | 910 layer->SetTexturePriorities(priority_calculator_); |
911 resource_manager_->PrioritizeTextures(); | 911 resource_manager_->PrioritizeTextures(); |
912 layer->SavePaintProperties(); | 912 layer->SavePaintProperties(); |
913 layer->Update(queue_.get(), NULL); | 913 layer->Update(queue_.get(), nullptr); |
914 | 914 |
915 // Update rect is 200x300 (tile size of 100x100). Scaled this gives 400x240. | 915 // Update rect is 200x300 (tile size of 100x100). Scaled this gives 400x240. |
916 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 400, 240), layer->update_rect()); | 916 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 400, 240), layer->update_rect()); |
917 UpdateTextures(); | 917 UpdateTextures(); |
918 | 918 |
919 // After the tiles are updated once, another invalidate only needs to update | 919 // After the tiles are updated once, another invalidate only needs to update |
920 // the bounds of the layer. | 920 // the bounds of the layer. |
921 layer->SetTexturePriorities(priority_calculator_); | 921 layer->SetTexturePriorities(priority_calculator_); |
922 resource_manager_->PrioritizeTextures(); | 922 resource_manager_->PrioritizeTextures(); |
923 layer->InvalidateContentRect(content_bounds); | 923 layer->InvalidateContentRect(content_bounds); |
924 layer->SavePaintProperties(); | 924 layer->SavePaintProperties(); |
925 layer->Update(queue_.get(), NULL); | 925 layer->Update(queue_.get(), nullptr); |
926 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layer_bounds), layer->update_rect()); | 926 EXPECT_FLOAT_RECT_EQ(gfx::RectF(layer_bounds), layer->update_rect()); |
927 UpdateTextures(); | 927 UpdateTextures(); |
928 | 928 |
929 // Partial re-paint should also be represented by the update rect in layer | 929 // Partial re-paint should also be represented by the update rect in layer |
930 // space, not content space. | 930 // space, not content space. |
931 gfx::Rect partial_damage(30, 100, 10, 10); | 931 gfx::Rect partial_damage(30, 100, 10, 10); |
932 layer->InvalidateContentRect(partial_damage); | 932 layer->InvalidateContentRect(partial_damage); |
933 layer->SetTexturePriorities(priority_calculator_); | 933 layer->SetTexturePriorities(priority_calculator_); |
934 resource_manager_->PrioritizeTextures(); | 934 resource_manager_->PrioritizeTextures(); |
935 layer->SavePaintProperties(); | 935 layer->SavePaintProperties(); |
936 layer->Update(queue_.get(), NULL); | 936 layer->Update(queue_.get(), nullptr); |
937 EXPECT_FLOAT_RECT_EQ(gfx::RectF(60, 80, 20, 8), layer->update_rect()); | 937 EXPECT_FLOAT_RECT_EQ(gfx::RectF(60, 80, 20, 8), layer->update_rect()); |
938 } | 938 } |
939 | 939 |
940 TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { | 940 TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { |
941 scoped_refptr<FakeTiledLayer> layer = | 941 scoped_refptr<FakeTiledLayer> layer = |
942 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 942 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
943 scoped_ptr<FakeTiledLayerImpl> layer_impl = | 943 scoped_ptr<FakeTiledLayerImpl> layer_impl = |
944 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); | 944 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); |
945 RenderSurfaceLayerList render_surface_layer_list; | 945 RenderSurfaceLayerList render_surface_layer_list; |
946 | 946 |
947 layer_tree_host_->root_layer()->AddChild(layer); | 947 layer_tree_host_->root_layer()->AddChild(layer); |
948 | 948 |
949 // Create a layer with one tile. | 949 // Create a layer with one tile. |
950 layer->SetBounds(gfx::Size(100, 100)); | 950 layer->SetBounds(gfx::Size(100, 100)); |
951 CalcDrawProps(&render_surface_layer_list); | 951 CalcDrawProps(&render_surface_layer_list); |
952 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 952 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
953 layer->Update(queue_.get(), NULL); | 953 layer->Update(queue_.get(), nullptr); |
954 UpdateTextures(); | 954 UpdateTextures(); |
955 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), | 955 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), |
956 layer->last_needs_display_rect()); | 956 layer->last_needs_display_rect()); |
957 | 957 |
958 // Push the tiles to the impl side and check that there is exactly one. | 958 // Push the tiles to the impl side and check that there is exactly one. |
959 layer->SetTexturePriorities(priority_calculator_); | 959 layer->SetTexturePriorities(priority_calculator_); |
960 resource_manager_->PrioritizeTextures(); | 960 resource_manager_->PrioritizeTextures(); |
961 layer->SavePaintProperties(); | 961 layer->SavePaintProperties(); |
962 layer->Update(queue_.get(), NULL); | 962 layer->Update(queue_.get(), nullptr); |
963 UpdateTextures(); | 963 UpdateTextures(); |
964 LayerPushPropertiesTo(layer.get(), layer_impl.get()); | 964 LayerPushPropertiesTo(layer.get(), layer_impl.get()); |
965 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); | 965 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); |
966 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); | 966 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); |
967 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 0)); | 967 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 0)); |
968 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 1)); | 968 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(1, 1)); |
969 | 969 |
970 layer->SetNeedsDisplayRect(gfx::Rect()); | 970 layer->SetNeedsDisplayRect(gfx::Rect()); |
971 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->last_needs_display_rect()); | 971 EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->last_needs_display_rect()); |
972 | 972 |
973 // Change the contents scale. | 973 // Change the contents scale. |
974 layer->UpdateContentsScale(2.f); | 974 layer->UpdateContentsScale(2.f); |
975 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200); | 975 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 200, 200); |
976 | 976 |
977 // The impl side should get 2x2 tiles now. | 977 // The impl side should get 2x2 tiles now. |
978 layer->SetTexturePriorities(priority_calculator_); | 978 layer->SetTexturePriorities(priority_calculator_); |
979 resource_manager_->PrioritizeTextures(); | 979 resource_manager_->PrioritizeTextures(); |
980 layer->SavePaintProperties(); | 980 layer->SavePaintProperties(); |
981 layer->Update(queue_.get(), NULL); | 981 layer->Update(queue_.get(), nullptr); |
982 UpdateTextures(); | 982 UpdateTextures(); |
983 LayerPushPropertiesTo(layer.get(), layer_impl.get()); | 983 LayerPushPropertiesTo(layer.get(), layer_impl.get()); |
984 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); | 984 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); |
985 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); | 985 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 1)); |
986 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 0)); | 986 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 0)); |
987 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 1)); | 987 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(1, 1)); |
988 | 988 |
989 // Verify that changing the contents scale caused invalidation, and | 989 // Verify that changing the contents scale caused invalidation, and |
990 // that the layer-space rectangle requiring painting is not scaled. | 990 // that the layer-space rectangle requiring painting is not scaled. |
991 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), | 991 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 layer_tree_host_->CommitComplete(); | 1041 layer_tree_host_->CommitComplete(); |
1042 | 1042 |
1043 // Remove the child layer. | 1043 // Remove the child layer. |
1044 root_layer->RemoveAllChildren(); | 1044 root_layer->RemoveAllChildren(); |
1045 | 1045 |
1046 layer_tree_host_->UpdateLayers(queue_.get()); | 1046 layer_tree_host_->UpdateLayers(queue_.get()); |
1047 EXPECT_FALSE(root_layer->SkipsDraw()); | 1047 EXPECT_FALSE(root_layer->SkipsDraw()); |
1048 | 1048 |
1049 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), | 1049 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), |
1050 resource_provider_.get()); | 1050 resource_provider_.get()); |
1051 layer_tree_host_->SetRootLayer(NULL); | 1051 layer_tree_host_->SetRootLayer(nullptr); |
1052 } | 1052 } |
1053 | 1053 |
1054 TEST_F(TiledLayerTest, ResizeToSmaller) { | 1054 TEST_F(TiledLayerTest, ResizeToSmaller) { |
1055 scoped_refptr<FakeTiledLayer> layer = | 1055 scoped_refptr<FakeTiledLayer> layer = |
1056 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1056 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1057 | 1057 |
1058 layer_tree_host_->root_layer()->AddChild(layer); | 1058 layer_tree_host_->root_layer()->AddChild(layer); |
1059 | 1059 |
1060 layer->SetBounds(gfx::Size(700, 700)); | 1060 layer->SetBounds(gfx::Size(700, 700)); |
1061 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); | 1061 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); |
1062 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700)); | 1062 layer->InvalidateContentRect(gfx::Rect(0, 0, 700, 700)); |
1063 | 1063 |
1064 layer->SetTexturePriorities(priority_calculator_); | 1064 layer->SetTexturePriorities(priority_calculator_); |
1065 resource_manager_->PrioritizeTextures(); | 1065 resource_manager_->PrioritizeTextures(); |
1066 layer->SavePaintProperties(); | 1066 layer->SavePaintProperties(); |
1067 layer->Update(queue_.get(), NULL); | 1067 layer->Update(queue_.get(), nullptr); |
1068 | 1068 |
1069 layer->SetBounds(gfx::Size(200, 200)); | 1069 layer->SetBounds(gfx::Size(200, 200)); |
1070 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); | 1070 layer->InvalidateContentRect(gfx::Rect(0, 0, 200, 200)); |
1071 } | 1071 } |
1072 | 1072 |
1073 TEST_F(TiledLayerTest, HugeLayerUpdateCrash) { | 1073 TEST_F(TiledLayerTest, HugeLayerUpdateCrash) { |
1074 scoped_refptr<FakeTiledLayer> layer = | 1074 scoped_refptr<FakeTiledLayer> layer = |
1075 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1075 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1076 | 1076 |
1077 layer_tree_host_->root_layer()->AddChild(layer); | 1077 layer_tree_host_->root_layer()->AddChild(layer); |
1078 | 1078 |
1079 int size = 1 << 30; | 1079 int size = 1 << 30; |
1080 layer->SetBounds(gfx::Size(size, size)); | 1080 layer->SetBounds(gfx::Size(size, size)); |
1081 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); | 1081 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 700, 700); |
1082 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size)); | 1082 layer->InvalidateContentRect(gfx::Rect(0, 0, size, size)); |
1083 | 1083 |
1084 // Ensure no crash for bounds where size * size would overflow an int. | 1084 // Ensure no crash for bounds where size * size would overflow an int. |
1085 layer->SetTexturePriorities(priority_calculator_); | 1085 layer->SetTexturePriorities(priority_calculator_); |
1086 resource_manager_->PrioritizeTextures(); | 1086 resource_manager_->PrioritizeTextures(); |
1087 layer->SavePaintProperties(); | 1087 layer->SavePaintProperties(); |
1088 layer->Update(queue_.get(), NULL); | 1088 layer->Update(queue_.get(), nullptr); |
1089 } | 1089 } |
1090 | 1090 |
1091 class TiledLayerPartialUpdateTest : public TiledLayerTest { | 1091 class TiledLayerPartialUpdateTest : public TiledLayerTest { |
1092 public: | 1092 public: |
1093 TiledLayerPartialUpdateTest() { settings_.max_partial_texture_updates = 4; } | 1093 TiledLayerPartialUpdateTest() { settings_.max_partial_texture_updates = 4; } |
1094 }; | 1094 }; |
1095 | 1095 |
1096 TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) { | 1096 TEST_F(TiledLayerPartialUpdateTest, PartialUpdates) { |
1097 // Create one 300 x 200 tiled layer with 3 x 2 tiles. | 1097 // Create one 300 x 200 tiled layer with 3 x 2 tiles. |
1098 gfx::Size content_bounds(300, 200); | 1098 gfx::Size content_bounds(300, 200); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 UpdateTextures(); | 1191 UpdateTextures(); |
1192 EXPECT_EQ(4, layer->fake_layer_updater()->update_count()); | 1192 EXPECT_EQ(4, layer->fake_layer_updater()->update_count()); |
1193 EXPECT_FALSE(queue_->HasMoreUpdates()); | 1193 EXPECT_FALSE(queue_->HasMoreUpdates()); |
1194 layer->fake_layer_updater()->ClearUpdateCount(); | 1194 layer->fake_layer_updater()->ClearUpdateCount(); |
1195 LayerPushPropertiesTo(layer.get(), layer_impl.get()); | 1195 LayerPushPropertiesTo(layer.get(), layer_impl.get()); |
1196 } | 1196 } |
1197 layer_tree_host_->CommitComplete(); | 1197 layer_tree_host_->CommitComplete(); |
1198 | 1198 |
1199 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), | 1199 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), |
1200 resource_provider_.get()); | 1200 resource_provider_.get()); |
1201 layer_tree_host_->SetRootLayer(NULL); | 1201 layer_tree_host_->SetRootLayer(nullptr); |
1202 } | 1202 } |
1203 | 1203 |
1204 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { | 1204 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { |
1205 scoped_refptr<FakeTiledLayer> layer = | 1205 scoped_refptr<FakeTiledLayer> layer = |
1206 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1206 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1207 RenderSurfaceLayerList render_surface_layer_list; | 1207 RenderSurfaceLayerList render_surface_layer_list; |
1208 | 1208 |
1209 layer_tree_host_->root_layer()->AddChild(layer); | 1209 layer_tree_host_->root_layer()->AddChild(layer); |
1210 | 1210 |
1211 // The tile size is 100x100, so this invalidates and then paints two tiles. | 1211 // The tile size is 100x100, so this invalidates and then paints two tiles. |
1212 layer->SetBounds(gfx::Size(100, 200)); | 1212 layer->SetBounds(gfx::Size(100, 200)); |
1213 CalcDrawProps(&render_surface_layer_list); | 1213 CalcDrawProps(&render_surface_layer_list); |
1214 | 1214 |
1215 layer->SetTexturePriorities(priority_calculator_); | 1215 layer->SetTexturePriorities(priority_calculator_); |
1216 resource_manager_->PrioritizeTextures(); | 1216 resource_manager_->PrioritizeTextures(); |
1217 layer->SavePaintProperties(); | 1217 layer->SavePaintProperties(); |
1218 layer->Update(queue_.get(), NULL); | 1218 layer->Update(queue_.get(), nullptr); |
1219 EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); | 1219 EXPECT_EQ(2, layer->fake_layer_updater()->update_count()); |
1220 } | 1220 } |
1221 | 1221 |
1222 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { | 1222 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { |
1223 scoped_refptr<FakeTiledLayer> layer = | 1223 scoped_refptr<FakeTiledLayer> layer = |
1224 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1224 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1225 RenderSurfaceLayerList render_surface_layer_list; | 1225 RenderSurfaceLayerList render_surface_layer_list; |
1226 TestOcclusionTracker occluded; | 1226 TestOcclusionTracker occluded; |
1227 occlusion_ = &occluded; | 1227 occlusion_ = &occluded; |
1228 | 1228 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 for (unsigned j = 0; j < 2; ++j) | 1632 for (unsigned j = 0; j < 2; ++j) |
1633 EXPECT_FALSE(root_impl->HasResourceIdForTileAt(i, j)); | 1633 EXPECT_FALSE(root_impl->HasResourceIdForTileAt(i, j)); |
1634 EXPECT_FALSE(child_impl->HasResourceIdForTileAt(i, 0)); | 1634 EXPECT_FALSE(child_impl->HasResourceIdForTileAt(i, 0)); |
1635 EXPECT_FALSE(child2_impl->HasResourceIdForTileAt(i, 0)); | 1635 EXPECT_FALSE(child2_impl->HasResourceIdForTileAt(i, 0)); |
1636 } | 1636 } |
1637 } | 1637 } |
1638 layer_tree_host_->CommitComplete(); | 1638 layer_tree_host_->CommitComplete(); |
1639 | 1639 |
1640 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), | 1640 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), |
1641 resource_provider_.get()); | 1641 resource_provider_.get()); |
1642 layer_tree_host_->SetRootLayer(NULL); | 1642 layer_tree_host_->SetRootLayer(nullptr); |
1643 } | 1643 } |
1644 | 1644 |
1645 class TrackingLayerPainter : public LayerPainter { | 1645 class TrackingLayerPainter : public LayerPainter { |
1646 public: | 1646 public: |
1647 static scoped_ptr<TrackingLayerPainter> Create() { | 1647 static scoped_ptr<TrackingLayerPainter> Create() { |
1648 return make_scoped_ptr(new TrackingLayerPainter()); | 1648 return make_scoped_ptr(new TrackingLayerPainter()); |
1649 } | 1649 } |
1650 | 1650 |
1651 virtual void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) override { | 1651 virtual void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) override { |
1652 painted_rect_ = content_rect; | 1652 painted_rect_ = content_rect; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 gfx::Rect content_rect(0, 0, 45, 47); | 1698 gfx::Rect content_rect(0, 0, 45, 47); |
1699 EXPECT_EQ(content_rect.size(), layer->content_bounds()); | 1699 EXPECT_EQ(content_rect.size(), layer->content_bounds()); |
1700 layer->draw_properties().visible_content_rect = content_rect; | 1700 layer->draw_properties().visible_content_rect = content_rect; |
1701 layer->draw_properties().drawable_content_rect = content_rect; | 1701 layer->draw_properties().drawable_content_rect = content_rect; |
1702 | 1702 |
1703 layer->SetTexturePriorities(priority_calculator_); | 1703 layer->SetTexturePriorities(priority_calculator_); |
1704 resource_manager_->PrioritizeTextures(); | 1704 resource_manager_->PrioritizeTextures(); |
1705 layer->SavePaintProperties(); | 1705 layer->SavePaintProperties(); |
1706 | 1706 |
1707 // Update the whole tile. | 1707 // Update the whole tile. |
1708 layer->Update(queue_.get(), NULL); | 1708 layer->Update(queue_.get(), nullptr); |
1709 layer->tracking_layer_painter()->ResetPaintedRect(); | 1709 layer->tracking_layer_painter()->ResetPaintedRect(); |
1710 | 1710 |
1711 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); | 1711 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); |
1712 UpdateTextures(); | 1712 UpdateTextures(); |
1713 | 1713 |
1714 // Invalidate the entire layer in content space. When painting, the rect given | 1714 // Invalidate the entire layer in content space. When painting, the rect given |
1715 // to webkit should match the layer's bounds. | 1715 // to webkit should match the layer's bounds. |
1716 layer->InvalidateContentRect(content_rect); | 1716 layer->InvalidateContentRect(content_rect); |
1717 layer->Update(queue_.get(), NULL); | 1717 layer->Update(queue_.get(), nullptr); |
1718 | 1718 |
1719 // Rounding leads to an extra pixel. | 1719 // Rounding leads to an extra pixel. |
1720 gfx::Rect expanded_layer_rect(layer_rect); | 1720 gfx::Rect expanded_layer_rect(layer_rect); |
1721 expanded_layer_rect.set_height(32); | 1721 expanded_layer_rect.set_height(32); |
1722 EXPECT_RECT_EQ(expanded_layer_rect, | 1722 EXPECT_RECT_EQ(expanded_layer_rect, |
1723 layer->tracking_layer_painter()->PaintedRect()); | 1723 layer->tracking_layer_painter()->PaintedRect()); |
1724 } | 1724 } |
1725 | 1725 |
1726 TEST_F(TiledLayerTest, | 1726 TEST_F(TiledLayerTest, |
1727 NonIntegerContentsScaleIsNotDistortedDuringInvalidation) { | 1727 NonIntegerContentsScaleIsNotDistortedDuringInvalidation) { |
1728 scoped_refptr<UpdateTrackingTiledLayer> layer = | 1728 scoped_refptr<UpdateTrackingTiledLayer> layer = |
1729 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); | 1729 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); |
1730 | 1730 |
1731 layer_tree_host_->root_layer()->AddChild(layer); | 1731 layer_tree_host_->root_layer()->AddChild(layer); |
1732 | 1732 |
1733 gfx::Rect layer_rect(0, 0, 30, 31); | 1733 gfx::Rect layer_rect(0, 0, 30, 31); |
1734 layer->SetPosition(layer_rect.origin()); | 1734 layer->SetPosition(layer_rect.origin()); |
1735 layer->SetBounds(layer_rect.size()); | 1735 layer->SetBounds(layer_rect.size()); |
1736 layer->UpdateContentsScale(1.3f); | 1736 layer->UpdateContentsScale(1.3f); |
1737 | 1737 |
1738 gfx::Rect content_rect(layer->content_bounds()); | 1738 gfx::Rect content_rect(layer->content_bounds()); |
1739 layer->draw_properties().visible_content_rect = content_rect; | 1739 layer->draw_properties().visible_content_rect = content_rect; |
1740 layer->draw_properties().drawable_content_rect = content_rect; | 1740 layer->draw_properties().drawable_content_rect = content_rect; |
1741 | 1741 |
1742 layer->SetTexturePriorities(priority_calculator_); | 1742 layer->SetTexturePriorities(priority_calculator_); |
1743 resource_manager_->PrioritizeTextures(); | 1743 resource_manager_->PrioritizeTextures(); |
1744 layer->SavePaintProperties(); | 1744 layer->SavePaintProperties(); |
1745 | 1745 |
1746 // Update the whole tile. | 1746 // Update the whole tile. |
1747 layer->Update(queue_.get(), NULL); | 1747 layer->Update(queue_.get(), nullptr); |
1748 layer->tracking_layer_painter()->ResetPaintedRect(); | 1748 layer->tracking_layer_painter()->ResetPaintedRect(); |
1749 | 1749 |
1750 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); | 1750 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); |
1751 UpdateTextures(); | 1751 UpdateTextures(); |
1752 | 1752 |
1753 // Invalidate the entire layer in layer space. When painting, the rect given | 1753 // Invalidate the entire layer in layer space. When painting, the rect given |
1754 // to webkit should match the layer's bounds. | 1754 // to webkit should match the layer's bounds. |
1755 layer->SetNeedsDisplayRect(layer_rect); | 1755 layer->SetNeedsDisplayRect(layer_rect); |
1756 layer->Update(queue_.get(), NULL); | 1756 layer->Update(queue_.get(), nullptr); |
1757 | 1757 |
1758 // Rounding leads to an extra pixel. | 1758 // Rounding leads to an extra pixel. |
1759 gfx::Rect expanded_layer_rect(layer_rect); | 1759 gfx::Rect expanded_layer_rect(layer_rect); |
1760 expanded_layer_rect.set_height(32); | 1760 expanded_layer_rect.set_height(32); |
1761 EXPECT_RECT_EQ(expanded_layer_rect, | 1761 EXPECT_RECT_EQ(expanded_layer_rect, |
1762 layer->tracking_layer_painter()->PaintedRect()); | 1762 layer->tracking_layer_painter()->PaintedRect()); |
1763 } | 1763 } |
1764 | 1764 |
1765 } // namespace | 1765 } // namespace |
1766 } // namespace cc | 1766 } // namespace cc |
OLD | NEW |