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 "cc/debug/overdraw_metrics.h" | 10 #include "cc/debug/overdraw_metrics.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); | 222 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); |
223 } | 223 } |
224 | 224 |
225 TEST_F(TiledLayerTest, PushOccludedDirtyTiles) { | 225 TEST_F(TiledLayerTest, PushOccludedDirtyTiles) { |
226 scoped_refptr<FakeTiledLayer> layer = | 226 scoped_refptr<FakeTiledLayer> layer = |
227 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 227 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
228 scoped_ptr<FakeTiledLayerImpl> layer_impl = | 228 scoped_ptr<FakeTiledLayerImpl> layer_impl = |
229 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); | 229 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); |
230 TestOcclusionTracker occluded; | 230 TestOcclusionTracker occluded; |
231 occlusion_ = &occluded; | 231 occlusion_ = &occluded; |
232 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000), | 232 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); |
233 gfx::Size(1000, 1000)); | |
234 | 233 |
235 // The tile size is 100x100, so this invalidates and then paints two tiles. | 234 // The tile size is 100x100, so this invalidates and then paints two tiles. |
236 layer->SetBounds(gfx::Size(100, 200)); | 235 layer->SetBounds(gfx::Size(100, 200)); |
237 CalcDrawProps(layer); | 236 CalcDrawProps(layer); |
238 UpdateAndPush(layer, layer_impl); | 237 UpdateAndPush(layer, layer_impl); |
239 | 238 |
240 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); | 239 EXPECT_NEAR(occluded.overdraw_metrics()->pixels_uploaded_opaque(), 0, 1); |
241 EXPECT_NEAR( | 240 EXPECT_NEAR( |
242 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 20000, 1); | 241 occluded.overdraw_metrics()->pixels_uploaded_translucent(), 20000, 1); |
243 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 242 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // so the layer is considered small enough. | 571 // so the layer is considered small enough. |
573 bool run_out_of_memory[2] = { false, true }; | 572 bool run_out_of_memory[2] = { false, true }; |
574 for (int i = 0; i < 2; i++) { | 573 for (int i = 0; i < 2; i++) { |
575 // Create a layer with 5x5 tiles, with 4x4 size viewport. | 574 // Create a layer with 5x5 tiles, with 4x4 size viewport. |
576 int viewport_width = 4 * FakeTiledLayer::tile_size().width(); | 575 int viewport_width = 4 * FakeTiledLayer::tile_size().width(); |
577 int viewport_height = 4 * FakeTiledLayer::tile_size().width(); | 576 int viewport_height = 4 * FakeTiledLayer::tile_size().width(); |
578 int layer_width = 5 * FakeTiledLayer::tile_size().width(); | 577 int layer_width = 5 * FakeTiledLayer::tile_size().width(); |
579 int layer_height = 5 * FakeTiledLayer::tile_size().height(); | 578 int layer_height = 5 * FakeTiledLayer::tile_size().height(); |
580 int memory_for_layer = layer_width * layer_height * 4; | 579 int memory_for_layer = layer_width * layer_height * 4; |
581 layer_tree_host_->SetViewportSize( | 580 layer_tree_host_->SetViewportSize( |
582 gfx::Size(viewport_width, viewport_height), | |
583 gfx::Size(viewport_width, viewport_height)); | 581 gfx::Size(viewport_width, viewport_height)); |
584 | 582 |
585 // Use 10x5 tiles to run out of memory. | 583 // Use 10x5 tiles to run out of memory. |
586 if (run_out_of_memory[i]) | 584 if (run_out_of_memory[i]) |
587 layer_width *= 2; | 585 layer_width *= 2; |
588 | 586 |
589 resource_manager_->SetMaxMemoryLimitBytes(memory_for_layer); | 587 resource_manager_->SetMaxMemoryLimitBytes(memory_for_layer); |
590 | 588 |
591 scoped_refptr<FakeTiledLayer> layer = | 589 scoped_refptr<FakeTiledLayer> layer = |
592 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 590 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 root_layer->SetBounds(content_bounds); | 872 root_layer->SetBounds(content_bounds); |
875 root_layer->draw_properties().visible_content_rect = content_rect; | 873 root_layer->draw_properties().visible_content_rect = content_rect; |
876 root_layer->SetPosition(gfx::PointF(0, 0)); | 874 root_layer->SetPosition(gfx::PointF(0, 0)); |
877 child_layer->SetBounds(content_bounds); | 875 child_layer->SetBounds(content_bounds); |
878 child_layer->draw_properties().visible_content_rect = content_rect; | 876 child_layer->draw_properties().visible_content_rect = content_rect; |
879 child_layer->SetPosition(gfx::PointF(0, 0)); | 877 child_layer->SetPosition(gfx::PointF(0, 0)); |
880 root_layer->InvalidateContentRect(content_rect); | 878 root_layer->InvalidateContentRect(content_rect); |
881 child_layer->InvalidateContentRect(content_rect); | 879 child_layer->InvalidateContentRect(content_rect); |
882 | 880 |
883 layer_tree_host_->SetRootLayer(root_layer); | 881 layer_tree_host_->SetRootLayer(root_layer); |
884 layer_tree_host_->SetViewportSize(gfx::Size(300, 300), gfx::Size(300, 300)); | 882 layer_tree_host_->SetViewportSize(gfx::Size(300, 300)); |
885 | 883 |
886 layer_tree_host_->UpdateLayers(queue_.get(), memory_limit); | 884 layer_tree_host_->UpdateLayers(queue_.get(), memory_limit); |
887 | 885 |
888 // We'll skip the root layer. | 886 // We'll skip the root layer. |
889 EXPECT_TRUE(root_layer->SkipsDraw()); | 887 EXPECT_TRUE(root_layer->SkipsDraw()); |
890 EXPECT_FALSE(child_layer->SkipsDraw()); | 888 EXPECT_FALSE(child_layer->SkipsDraw()); |
891 | 889 |
892 layer_tree_host_->CommitComplete(); | 890 layer_tree_host_->CommitComplete(); |
893 | 891 |
894 // Remove the child layer. | 892 // Remove the child layer. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 gfx::Rect content_rect(content_bounds); | 942 gfx::Rect content_rect(content_bounds); |
945 | 943 |
946 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr( | 944 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr( |
947 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); | 945 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); |
948 layer->SetBounds(content_bounds); | 946 layer->SetBounds(content_bounds); |
949 layer->SetPosition(gfx::PointF(0, 0)); | 947 layer->SetPosition(gfx::PointF(0, 0)); |
950 layer->draw_properties().visible_content_rect = content_rect; | 948 layer->draw_properties().visible_content_rect = content_rect; |
951 layer->InvalidateContentRect(content_rect); | 949 layer->InvalidateContentRect(content_rect); |
952 | 950 |
953 layer_tree_host_->SetRootLayer(layer); | 951 layer_tree_host_->SetRootLayer(layer); |
954 layer_tree_host_->SetViewportSize(gfx::Size(300, 200), gfx::Size(300, 200)); | 952 layer_tree_host_->SetViewportSize(gfx::Size(300, 200)); |
955 | 953 |
956 // Full update of all 6 tiles. | 954 // Full update of all 6 tiles. |
957 layer_tree_host_->UpdateLayers(queue_.get(), | 955 layer_tree_host_->UpdateLayers(queue_.get(), |
958 std::numeric_limits<size_t>::max()); | 956 std::numeric_limits<size_t>::max()); |
959 { | 957 { |
960 scoped_ptr<FakeTiledLayerImpl> layer_impl = | 958 scoped_ptr<FakeTiledLayerImpl> layer_impl = |
961 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); | 959 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); |
962 EXPECT_EQ(6u, queue_->FullUploadSize()); | 960 EXPECT_EQ(6u, queue_->FullUploadSize()); |
963 EXPECT_EQ(0u, queue_->PartialUploadSize()); | 961 EXPECT_EQ(0u, queue_->PartialUploadSize()); |
964 UpdateTextures(); | 962 UpdateTextures(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 } | 1064 } |
1067 | 1065 |
1068 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { | 1066 TEST_F(TiledLayerTest, TilesPaintedWithOcclusion) { |
1069 scoped_refptr<FakeTiledLayer> layer = | 1067 scoped_refptr<FakeTiledLayer> layer = |
1070 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1068 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1071 TestOcclusionTracker occluded; | 1069 TestOcclusionTracker occluded; |
1072 occlusion_ = &occluded; | 1070 occlusion_ = &occluded; |
1073 | 1071 |
1074 // The tile size is 100x100. | 1072 // The tile size is 100x100. |
1075 | 1073 |
1076 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1074 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1077 layer->SetBounds(gfx::Size(600, 600)); | 1075 layer->SetBounds(gfx::Size(600, 600)); |
1078 CalcDrawProps(layer); | 1076 CalcDrawProps(layer); |
1079 | 1077 |
1080 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); | 1078 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); |
1081 layer->draw_properties().drawable_content_rect = | 1079 layer->draw_properties().drawable_content_rect = |
1082 gfx::Rect(layer->content_bounds()); | 1080 gfx::Rect(layer->content_bounds()); |
1083 layer->draw_properties().visible_content_rect = | 1081 layer->draw_properties().visible_content_rect = |
1084 gfx::Rect(layer->content_bounds()); | 1082 gfx::Rect(layer->content_bounds()); |
1085 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1083 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1086 | 1084 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 } | 1124 } |
1127 | 1125 |
1128 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { | 1126 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndVisiblityConstraints) { |
1129 scoped_refptr<FakeTiledLayer> layer = | 1127 scoped_refptr<FakeTiledLayer> layer = |
1130 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1128 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1131 TestOcclusionTracker occluded; | 1129 TestOcclusionTracker occluded; |
1132 occlusion_ = &occluded; | 1130 occlusion_ = &occluded; |
1133 | 1131 |
1134 // The tile size is 100x100. | 1132 // The tile size is 100x100. |
1135 | 1133 |
1136 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1134 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1137 layer->SetBounds(gfx::Size(600, 600)); | 1135 layer->SetBounds(gfx::Size(600, 600)); |
1138 CalcDrawProps(layer); | 1136 CalcDrawProps(layer); |
1139 | 1137 |
1140 // The partially occluded tiles (by the 150 occlusion height) are visible | 1138 // The partially occluded tiles (by the 150 occlusion height) are visible |
1141 // beyond the occlusion, so not culled. | 1139 // beyond the occlusion, so not culled. |
1142 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); | 1140 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 150)); |
1143 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); | 1141 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 360); |
1144 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360); | 1142 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 360); |
1145 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1143 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1146 | 1144 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 } | 1192 } |
1195 | 1193 |
1196 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { | 1194 TEST_F(TiledLayerTest, TilesNotPaintedWithoutInvalidation) { |
1197 scoped_refptr<FakeTiledLayer> layer = | 1195 scoped_refptr<FakeTiledLayer> layer = |
1198 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1196 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1199 TestOcclusionTracker occluded; | 1197 TestOcclusionTracker occluded; |
1200 occlusion_ = &occluded; | 1198 occlusion_ = &occluded; |
1201 | 1199 |
1202 // The tile size is 100x100. | 1200 // The tile size is 100x100. |
1203 | 1201 |
1204 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1202 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1205 layer->SetBounds(gfx::Size(600, 600)); | 1203 layer->SetBounds(gfx::Size(600, 600)); |
1206 CalcDrawProps(layer); | 1204 CalcDrawProps(layer); |
1207 | 1205 |
1208 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); | 1206 occluded.SetOcclusion(gfx::Rect(200, 200, 300, 100)); |
1209 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); | 1207 layer->draw_properties().drawable_content_rect = gfx::Rect(0, 0, 600, 600); |
1210 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600); | 1208 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 600, 600); |
1211 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); | 1209 layer->InvalidateContentRect(gfx::Rect(0, 0, 600, 600)); |
1212 layer->SetTexturePriorities(priority_calculator_); | 1210 layer->SetTexturePriorities(priority_calculator_); |
1213 resource_manager_->PrioritizeTextures(); | 1211 resource_manager_->PrioritizeTextures(); |
1214 layer->Update(queue_.get(), &occluded, NULL); | 1212 layer->Update(queue_.get(), &occluded, NULL); |
(...skipping 23 matching lines...) Expand all Loading... |
1238 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { | 1236 TEST_F(TiledLayerTest, TilesPaintedWithOcclusionAndTransforms) { |
1239 scoped_refptr<FakeTiledLayer> layer = | 1237 scoped_refptr<FakeTiledLayer> layer = |
1240 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1238 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1241 TestOcclusionTracker occluded; | 1239 TestOcclusionTracker occluded; |
1242 occlusion_ = &occluded; | 1240 occlusion_ = &occluded; |
1243 | 1241 |
1244 // The tile size is 100x100. | 1242 // The tile size is 100x100. |
1245 | 1243 |
1246 // This makes sure the painting works when the occluded region (in screen | 1244 // This makes sure the painting works when the occluded region (in screen |
1247 // space) is transformed differently than the layer. | 1245 // space) is transformed differently than the layer. |
1248 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1246 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1249 layer->SetBounds(gfx::Size(600, 600)); | 1247 layer->SetBounds(gfx::Size(600, 600)); |
1250 CalcDrawProps(layer); | 1248 CalcDrawProps(layer); |
1251 gfx::Transform screen_transform; | 1249 gfx::Transform screen_transform; |
1252 screen_transform.Scale(0.5, 0.5); | 1250 screen_transform.Scale(0.5, 0.5); |
1253 layer->draw_properties().screen_space_transform = screen_transform; | 1251 layer->draw_properties().screen_space_transform = screen_transform; |
1254 layer->draw_properties().target_space_transform = screen_transform; | 1252 layer->draw_properties().target_space_transform = screen_transform; |
1255 | 1253 |
1256 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 50)); | 1254 occluded.SetOcclusion(gfx::Rect(100, 100, 150, 50)); |
1257 layer->draw_properties().drawable_content_rect = | 1255 layer->draw_properties().drawable_content_rect = |
1258 gfx::Rect(layer->content_bounds()); | 1256 gfx::Rect(layer->content_bounds()); |
(...skipping 15 matching lines...) Expand all Loading... |
1274 scoped_refptr<FakeTiledLayer> layer = | 1272 scoped_refptr<FakeTiledLayer> layer = |
1275 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1273 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1276 TestOcclusionTracker occluded; | 1274 TestOcclusionTracker occluded; |
1277 occlusion_ = &occluded; | 1275 occlusion_ = &occluded; |
1278 | 1276 |
1279 // The tile size is 100x100. | 1277 // The tile size is 100x100. |
1280 | 1278 |
1281 // This makes sure the painting works when the content space is scaled to | 1279 // This makes sure the painting works when the content space is scaled to |
1282 // a different layer space. In this case tiles are scaled to be 200x200 | 1280 // a different layer space. In this case tiles are scaled to be 200x200 |
1283 // pixels, which means none should be occluded. | 1281 // pixels, which means none should be occluded. |
1284 layer_tree_host_->SetViewportSize(gfx::Size(600, 600), gfx::Size(600, 600)); | 1282 layer_tree_host_->SetViewportSize(gfx::Size(600, 600)); |
1285 layer->SetBounds(gfx::Size(600, 600)); | 1283 layer->SetBounds(gfx::Size(600, 600)); |
1286 layer->SetRasterScale(0.5); | 1284 layer->SetRasterScale(0.5); |
1287 CalcDrawProps(layer); | 1285 CalcDrawProps(layer); |
1288 EXPECT_FLOAT_EQ(layer->contents_scale_x(), layer->contents_scale_y()); | 1286 EXPECT_FLOAT_EQ(layer->contents_scale_x(), layer->contents_scale_y()); |
1289 gfx::Transform draw_transform; | 1287 gfx::Transform draw_transform; |
1290 double inv_scale_factor = 1 / layer->contents_scale_x(); | 1288 double inv_scale_factor = 1 / layer->contents_scale_x(); |
1291 draw_transform.Scale(inv_scale_factor, inv_scale_factor); | 1289 draw_transform.Scale(inv_scale_factor, inv_scale_factor); |
1292 layer->draw_properties().target_space_transform = draw_transform; | 1290 layer->draw_properties().target_space_transform = draw_transform; |
1293 layer->draw_properties().screen_space_transform = draw_transform; | 1291 layer->draw_properties().screen_space_transform = draw_transform; |
1294 | 1292 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 90000 + 80000 + 80000, | 1357 90000 + 80000 + 80000, |
1360 1); | 1358 1); |
1361 EXPECT_EQ(1 + 1, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1359 EXPECT_EQ(1 + 1, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1362 } | 1360 } |
1363 | 1361 |
1364 TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { | 1362 TEST_F(TiledLayerTest, VisibleContentOpaqueRegion) { |
1365 scoped_refptr<FakeTiledLayer> layer = | 1363 scoped_refptr<FakeTiledLayer> layer = |
1366 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1364 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1367 TestOcclusionTracker occluded; | 1365 TestOcclusionTracker occluded; |
1368 occlusion_ = &occluded; | 1366 occlusion_ = &occluded; |
1369 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000), | 1367 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); |
1370 gfx::Size(1000, 1000)); | |
1371 | 1368 |
1372 // The tile size is 100x100, so this invalidates and then paints two tiles in | 1369 // The tile size is 100x100, so this invalidates and then paints two tiles in |
1373 // various ways. | 1370 // various ways. |
1374 | 1371 |
1375 gfx::Rect opaque_paint_rect; | 1372 gfx::Rect opaque_paint_rect; |
1376 Region opaque_contents; | 1373 Region opaque_contents; |
1377 | 1374 |
1378 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 200); | 1375 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 200); |
1379 gfx::Rect visible_bounds = gfx::Rect(0, 0, 100, 150); | 1376 gfx::Rect visible_bounds = gfx::Rect(0, 0, 100, 150); |
1380 | 1377 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 20000 + 20000 - 17100 + 1 + 1, | 1472 20000 + 20000 - 17100 + 1 + 1, |
1476 1); | 1473 1); |
1477 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); | 1474 EXPECT_EQ(0, occluded.overdraw_metrics()->tiles_culled_for_upload()); |
1478 } | 1475 } |
1479 | 1476 |
1480 TEST_F(TiledLayerTest, Pixels_paintedMetrics) { | 1477 TEST_F(TiledLayerTest, Pixels_paintedMetrics) { |
1481 scoped_refptr<FakeTiledLayer> layer = | 1478 scoped_refptr<FakeTiledLayer> layer = |
1482 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1479 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1483 TestOcclusionTracker occluded; | 1480 TestOcclusionTracker occluded; |
1484 occlusion_ = &occluded; | 1481 occlusion_ = &occluded; |
1485 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000), | 1482 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); |
1486 gfx::Size(1000, 1000)); | |
1487 | 1483 |
1488 // The tile size is 100x100, so this invalidates and then paints two tiles in | 1484 // The tile size is 100x100, so this invalidates and then paints two tiles in |
1489 // various ways. | 1485 // various ways. |
1490 | 1486 |
1491 gfx::Rect opaque_paint_rect; | 1487 gfx::Rect opaque_paint_rect; |
1492 Region opaque_contents; | 1488 Region opaque_contents; |
1493 | 1489 |
1494 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 300); | 1490 gfx::Rect content_bounds = gfx::Rect(0, 0, 100, 300); |
1495 layer->SetBounds(content_bounds.size()); | 1491 layer->SetBounds(content_bounds.size()); |
1496 CalcDrawProps(layer); | 1492 CalcDrawProps(layer); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 child->draw_properties().visible_content_rect = child_rect; | 1564 child->draw_properties().visible_content_rect = child_rect; |
1569 child->draw_properties().drawable_content_rect = root_rect; | 1565 child->draw_properties().drawable_content_rect = root_rect; |
1570 | 1566 |
1571 child2->SetBounds(child2_rect.size()); | 1567 child2->SetBounds(child2_rect.size()); |
1572 child2->SetAnchorPoint(gfx::PointF()); | 1568 child2->SetAnchorPoint(gfx::PointF()); |
1573 child2->SetPosition(child2_rect.origin()); | 1569 child2->SetPosition(child2_rect.origin()); |
1574 child2->draw_properties().visible_content_rect = child2_rect; | 1570 child2->draw_properties().visible_content_rect = child2_rect; |
1575 child2->draw_properties().drawable_content_rect = root_rect; | 1571 child2->draw_properties().drawable_content_rect = root_rect; |
1576 | 1572 |
1577 layer_tree_host_->SetRootLayer(root); | 1573 layer_tree_host_->SetRootLayer(root); |
1578 layer_tree_host_->SetViewportSize(root_rect.size(), root_rect.size()); | 1574 layer_tree_host_->SetViewportSize(root_rect.size()); |
1579 | 1575 |
1580 // With a huge memory limit, all layers should update and push their textures. | 1576 // With a huge memory limit, all layers should update and push their textures. |
1581 root->InvalidateContentRect(root_rect); | 1577 root->InvalidateContentRect(root_rect); |
1582 child->InvalidateContentRect(child_rect); | 1578 child->InvalidateContentRect(child_rect); |
1583 child2->InvalidateContentRect(child2_rect); | 1579 child2->InvalidateContentRect(child2_rect); |
1584 layer_tree_host_->UpdateLayers(queue_.get(), | 1580 layer_tree_host_->UpdateLayers(queue_.get(), |
1585 std::numeric_limits<size_t>::max()); | 1581 std::numeric_limits<size_t>::max()); |
1586 { | 1582 { |
1587 UpdateTextures(); | 1583 UpdateTextures(); |
1588 EXPECT_EQ(6, root->fake_layer_updater()->update_count()); | 1584 EXPECT_EQ(6, root->fake_layer_updater()->update_count()); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 // Invalidate the entire layer in layer space. When painting, the rect given | 1795 // Invalidate the entire layer in layer space. When painting, the rect given |
1800 // to webkit should match the layer's bounds. | 1796 // to webkit should match the layer's bounds. |
1801 layer->SetNeedsDisplayRect(layer_rect); | 1797 layer->SetNeedsDisplayRect(layer_rect); |
1802 layer->Update(queue_.get(), 0, NULL); | 1798 layer->Update(queue_.get(), 0, NULL); |
1803 | 1799 |
1804 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1800 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
1805 } | 1801 } |
1806 | 1802 |
1807 } // namespace | 1803 } // namespace |
1808 } // namespace cc | 1804 } // namespace cc |
OLD | NEW |