| 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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 static void UpdateAllTilePriorities(PictureLayerTilingSet* set, | 37 static void UpdateAllTilePriorities(PictureLayerTilingSet* set, |
| 38 WhichTree tree, | 38 WhichTree tree, |
| 39 const gfx::Rect& visible_layer_rect, | 39 const gfx::Rect& visible_layer_rect, |
| 40 float layer_contents_scale, | 40 float layer_contents_scale, |
| 41 double current_frame_time_in_seconds) { | 41 double current_frame_time_in_seconds) { |
| 42 for (size_t i = 0; i < set->num_tilings(); ++i) { | 42 for (size_t i = 0; i < set->num_tilings(); ++i) { |
| 43 set->tiling_at(i)->UpdateTilePriorities(tree, | 43 set->tiling_at(i)->UpdateTilePriorities(tree, |
| 44 visible_layer_rect, | 44 visible_layer_rect, |
| 45 layer_contents_scale, | 45 layer_contents_scale, |
| 46 current_frame_time_in_seconds, | 46 current_frame_time_in_seconds, |
| 47 NULL, | 47 Occlusion()); |
| 48 NULL, | |
| 49 gfx::Transform()); | |
| 50 } | 48 } |
| 51 } | 49 } |
| 52 | 50 |
| 53 class TestablePictureLayerTiling : public PictureLayerTiling { | 51 class TestablePictureLayerTiling : public PictureLayerTiling { |
| 54 public: | 52 public: |
| 55 using PictureLayerTiling::SetLiveTilesRect; | 53 using PictureLayerTiling::SetLiveTilesRect; |
| 56 using PictureLayerTiling::TileAt; | 54 using PictureLayerTiling::TileAt; |
| 57 | 55 |
| 58 static scoped_ptr<TestablePictureLayerTiling> Create( | 56 static scoped_ptr<TestablePictureLayerTiling> Create( |
| 59 float contents_scale, | 57 float contents_scale, |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 client.set_skewport_extrapolation_limit_in_content_pixels(75); | 531 client.set_skewport_extrapolation_limit_in_content_pixels(75); |
| 534 client.set_tree(ACTIVE_TREE); | 532 client.set_tree(ACTIVE_TREE); |
| 535 scoped_ptr<TestablePictureLayerTiling> tiling; | 533 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 536 | 534 |
| 537 gfx::Rect viewport(0, 0, 100, 100); | 535 gfx::Rect viewport(0, 0, 100, 100); |
| 538 gfx::Size layer_bounds(200, 200); | 536 gfx::Size layer_bounds(200, 200); |
| 539 | 537 |
| 540 client.SetTileSize(gfx::Size(100, 100)); | 538 client.SetTileSize(gfx::Size(100, 100)); |
| 541 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 539 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); |
| 542 | 540 |
| 543 tiling->UpdateTilePriorities( | 541 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.f, 1.0, Occlusion()); |
| 544 ACTIVE_TREE, viewport, 1.f, 1.0, NULL, NULL, gfx::Transform()); | |
| 545 | 542 |
| 546 // Move viewport down 50 pixels in 0.5 seconds. | 543 // Move viewport down 50 pixels in 0.5 seconds. |
| 547 gfx::Rect down_skewport = | 544 gfx::Rect down_skewport = |
| 548 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 545 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 549 | 546 |
| 550 EXPECT_EQ(0, down_skewport.x()); | 547 EXPECT_EQ(0, down_skewport.x()); |
| 551 EXPECT_EQ(50, down_skewport.y()); | 548 EXPECT_EQ(50, down_skewport.y()); |
| 552 EXPECT_EQ(100, down_skewport.width()); | 549 EXPECT_EQ(100, down_skewport.width()); |
| 553 EXPECT_EQ(175, down_skewport.height()); | 550 EXPECT_EQ(175, down_skewport.height()); |
| 554 EXPECT_TRUE(down_skewport.Contains(gfx::Rect(0, 50, 100, 100))); | 551 EXPECT_TRUE(down_skewport.Contains(gfx::Rect(0, 50, 100, 100))); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 FakePictureLayerTilingClient client; | 597 FakePictureLayerTilingClient client; |
| 601 scoped_ptr<TestablePictureLayerTiling> tiling; | 598 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 602 | 599 |
| 603 gfx::Rect viewport(0, 0, 100, 100); | 600 gfx::Rect viewport(0, 0, 100, 100); |
| 604 gfx::Size layer_bounds(200, 200); | 601 gfx::Size layer_bounds(200, 200); |
| 605 | 602 |
| 606 client.SetTileSize(gfx::Size(100, 100)); | 603 client.SetTileSize(gfx::Size(100, 100)); |
| 607 client.set_tree(ACTIVE_TREE); | 604 client.set_tree(ACTIVE_TREE); |
| 608 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 605 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); |
| 609 | 606 |
| 610 tiling->UpdateTilePriorities( | 607 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.f, 1.0, Occlusion()); |
| 611 ACTIVE_TREE, viewport, 1.f, 1.0, NULL, NULL, gfx::Transform()); | |
| 612 | 608 |
| 613 // Move viewport down 50 pixels in 0.5 seconds. | 609 // Move viewport down 50 pixels in 0.5 seconds. |
| 614 gfx::Rect down_skewport = | 610 gfx::Rect down_skewport = |
| 615 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 611 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 616 | 612 |
| 617 EXPECT_EQ(0, down_skewport.x()); | 613 EXPECT_EQ(0, down_skewport.x()); |
| 618 EXPECT_EQ(50, down_skewport.y()); | 614 EXPECT_EQ(50, down_skewport.y()); |
| 619 EXPECT_EQ(100, down_skewport.width()); | 615 EXPECT_EQ(100, down_skewport.width()); |
| 620 EXPECT_EQ(200, down_skewport.height()); | 616 EXPECT_EQ(200, down_skewport.height()); |
| 621 | 617 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 | 664 |
| 669 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 665 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
| 670 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 666 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
| 671 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 667 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
| 672 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 668 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
| 673 // tiling. | 669 // tiling. |
| 674 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client); | 670 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client); |
| 675 gfx::Rect viewport_in_content_space = | 671 gfx::Rect viewport_in_content_space = |
| 676 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); | 672 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); |
| 677 | 673 |
| 678 tiling->UpdateTilePriorities( | 674 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.f, 1.0, Occlusion()); |
| 679 ACTIVE_TREE, viewport, 1.f, 1.0, NULL, NULL, gfx::Transform()); | |
| 680 | 675 |
| 681 gfx::Rect soon_rect = viewport; | 676 gfx::Rect soon_rect = viewport; |
| 682 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 677 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 683 gfx::Rect soon_rect_in_content_space = | 678 gfx::Rect soon_rect_in_content_space = |
| 684 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); | 679 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); |
| 685 | 680 |
| 686 // Sanity checks. | 681 // Sanity checks. |
| 687 for (int i = 0; i < 47; ++i) { | 682 for (int i = 0; i < 47; ++i) { |
| 688 for (int j = 0; j < 47; ++j) { | 683 for (int j = 0; j < 47; ++j) { |
| 689 EXPECT_TRUE(tiling->TileAt(i, j)) << "i: " << i << " j: " << j; | 684 EXPECT_TRUE(tiling->TileAt(i, j)) << "i: " << i << " j: " << j; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 soon_rect = viewport; | 748 soon_rect = viewport; |
| 754 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 749 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 755 soon_rect_in_content_space = | 750 soon_rect_in_content_space = |
| 756 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); | 751 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); |
| 757 | 752 |
| 758 EXPECT_EQ(0, skewport.x()); | 753 EXPECT_EQ(0, skewport.x()); |
| 759 EXPECT_EQ(10, skewport.y()); | 754 EXPECT_EQ(10, skewport.y()); |
| 760 EXPECT_EQ(25, skewport.width()); | 755 EXPECT_EQ(25, skewport.width()); |
| 761 EXPECT_EQ(35, skewport.height()); | 756 EXPECT_EQ(35, skewport.height()); |
| 762 | 757 |
| 763 tiling->UpdateTilePriorities( | 758 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.f, 2.0, Occlusion()); |
| 764 ACTIVE_TREE, viewport, 1.f, 2.0, NULL, NULL, gfx::Transform()); | |
| 765 | 759 |
| 766 have_now = false; | 760 have_now = false; |
| 767 have_eventually = false; | 761 have_eventually = false; |
| 768 have_soon = false; | 762 have_soon = false; |
| 769 | 763 |
| 770 // Viewport moved, so we expect to find some NOW tiles, some SOON tiles and | 764 // Viewport moved, so we expect to find some NOW tiles, some SOON tiles and |
| 771 // some EVENTUALLY tiles. | 765 // some EVENTUALLY tiles. |
| 772 for (int i = 0; i < 47; ++i) { | 766 for (int i = 0; i < 47; ++i) { |
| 773 for (int j = 0; j < 47; ++j) { | 767 for (int j = 0; j < 47; ++j) { |
| 774 Tile* tile = tiling->TileAt(i, j); | 768 Tile* tile = tiling->TileAt(i, j); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 805 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 799 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 806 EXPECT_FLOAT_EQ(68.f, priority.distance_to_visible); | 800 EXPECT_FLOAT_EQ(68.f, priority.distance_to_visible); |
| 807 | 801 |
| 808 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 802 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 809 EXPECT_FLOAT_EQ(28.f, priority.distance_to_visible); | 803 EXPECT_FLOAT_EQ(28.f, priority.distance_to_visible); |
| 810 | 804 |
| 811 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 805 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
| 812 EXPECT_FLOAT_EQ(4.f, priority.distance_to_visible); | 806 EXPECT_FLOAT_EQ(4.f, priority.distance_to_visible); |
| 813 | 807 |
| 814 // Change the underlying layer scale. | 808 // Change the underlying layer scale. |
| 815 tiling->UpdateTilePriorities( | 809 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 2.0f, 3.0, Occlusion()); |
| 816 ACTIVE_TREE, viewport, 2.0f, 3.0, NULL, NULL, gfx::Transform()); | |
| 817 | 810 |
| 818 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 811 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 819 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); | 812 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); |
| 820 | 813 |
| 821 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 814 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 822 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); | 815 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
| 823 | 816 |
| 824 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 817 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
| 825 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); | 818 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
| 826 | 819 |
| 827 // Test additional scales. | 820 // Test additional scales. |
| 828 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client); | 821 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client); |
| 829 tiling->UpdateTilePriorities( | 822 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.0f, 4.0, Occlusion()); |
| 830 ACTIVE_TREE, viewport, 1.0f, 4.0, NULL, NULL, gfx::Transform()); | |
| 831 | 823 |
| 832 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 824 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 833 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); | 825 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); |
| 834 | 826 |
| 835 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 827 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 836 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); | 828 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); |
| 837 | 829 |
| 838 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 830 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
| 839 EXPECT_FLOAT_EQ(60.f, priority.distance_to_visible); | 831 EXPECT_FLOAT_EQ(60.f, priority.distance_to_visible); |
| 840 | 832 |
| 841 tiling->UpdateTilePriorities( | 833 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 0.5f, 5.0, Occlusion()); |
| 842 ACTIVE_TREE, viewport, 0.5f, 5.0, NULL, NULL, gfx::Transform()); | |
| 843 | 834 |
| 844 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 835 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 845 EXPECT_FLOAT_EQ(55.f, priority.distance_to_visible); | 836 EXPECT_FLOAT_EQ(55.f, priority.distance_to_visible); |
| 846 | 837 |
| 847 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 838 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 848 EXPECT_FLOAT_EQ(35.f, priority.distance_to_visible); | 839 EXPECT_FLOAT_EQ(35.f, priority.distance_to_visible); |
| 849 | 840 |
| 850 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 841 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
| 851 EXPECT_FLOAT_EQ(30.f, priority.distance_to_visible); | 842 EXPECT_FLOAT_EQ(30.f, priority.distance_to_visible); |
| 852 } | 843 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 gfx::Rect viewport(50, 50, 100, 100); | 1067 gfx::Rect viewport(50, 50, 100, 100); |
| 1077 gfx::Size layer_bounds(800, 800); | 1068 gfx::Size layer_bounds(800, 800); |
| 1078 | 1069 |
| 1079 gfx::Rect soon_rect = viewport; | 1070 gfx::Rect soon_rect = viewport; |
| 1080 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1071 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1081 | 1072 |
| 1082 client.SetTileSize(gfx::Size(30, 30)); | 1073 client.SetTileSize(gfx::Size(30, 30)); |
| 1083 client.set_tree(ACTIVE_TREE); | 1074 client.set_tree(ACTIVE_TREE); |
| 1084 | 1075 |
| 1085 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 1076 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); |
| 1086 tiling->UpdateTilePriorities( | 1077 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 1087 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); | |
| 1088 | 1078 |
| 1089 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1079 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
| 1090 EXPECT_FALSE(empty_iterator); | 1080 EXPECT_FALSE(empty_iterator); |
| 1091 | 1081 |
| 1092 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1082 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1093 | 1083 |
| 1094 // Sanity check. | 1084 // Sanity check. |
| 1095 EXPECT_EQ(841u, all_tiles.size()); | 1085 EXPECT_EQ(841u, all_tiles.size()); |
| 1096 | 1086 |
| 1097 // The explanation of each iteration is as follows: | 1087 // The explanation of each iteration is as follows: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 scoped_ptr<TestablePictureLayerTiling> tiling; | 1175 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 1186 | 1176 |
| 1187 gfx::Rect viewport(50, 0, 100, 100); | 1177 gfx::Rect viewport(50, 0, 100, 100); |
| 1188 gfx::Rect moved_viewport(50, 0, 100, 500); | 1178 gfx::Rect moved_viewport(50, 0, 100, 500); |
| 1189 gfx::Size layer_bounds(1000, 1000); | 1179 gfx::Size layer_bounds(1000, 1000); |
| 1190 | 1180 |
| 1191 client.SetTileSize(gfx::Size(30, 30)); | 1181 client.SetTileSize(gfx::Size(30, 30)); |
| 1192 client.set_tree(ACTIVE_TREE); | 1182 client.set_tree(ACTIVE_TREE); |
| 1193 | 1183 |
| 1194 tiling = TestablePictureLayerTiling::Create(1.f, layer_bounds, &client); | 1184 tiling = TestablePictureLayerTiling::Create(1.f, layer_bounds, &client); |
| 1185 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 1195 tiling->UpdateTilePriorities( | 1186 tiling->UpdateTilePriorities( |
| 1196 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); | 1187 ACTIVE_TREE, moved_viewport, 1.0f, 2.0, Occlusion()); |
| 1197 tiling->UpdateTilePriorities( | |
| 1198 ACTIVE_TREE, moved_viewport, 1.0f, 2.0, NULL, NULL, gfx::Transform()); | |
| 1199 | 1188 |
| 1200 gfx::Rect soon_rect = moved_viewport; | 1189 gfx::Rect soon_rect = moved_viewport; |
| 1201 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1190 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1202 | 1191 |
| 1203 // There are 3 bins in TilePriority. | 1192 // There are 3 bins in TilePriority. |
| 1204 bool have_tiles[3] = {}; | 1193 bool have_tiles[3] = {}; |
| 1205 Tile* last_tile = NULL; | 1194 Tile* last_tile = NULL; |
| 1206 int eventually_bin_order_correct_count = 0; | 1195 int eventually_bin_order_correct_count = 0; |
| 1207 int eventually_bin_order_incorrect_count = 0; | 1196 int eventually_bin_order_incorrect_count = 0; |
| 1208 for (PictureLayerTiling::TilingRasterTileIterator it(tiling.get(), | 1197 for (PictureLayerTiling::TilingRasterTileIterator it(tiling.get(), |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 FakePictureLayerTilingClient client(resource_provider.get()); | 1250 FakePictureLayerTilingClient client(resource_provider.get()); |
| 1262 scoped_ptr<TestablePictureLayerTiling> tiling; | 1251 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 1263 | 1252 |
| 1264 gfx::Rect viewport(50, 50, 100, 100); | 1253 gfx::Rect viewport(50, 50, 100, 100); |
| 1265 gfx::Size layer_bounds(2000, 2000); | 1254 gfx::Size layer_bounds(2000, 2000); |
| 1266 | 1255 |
| 1267 client.SetTileSize(gfx::Size(30, 30)); | 1256 client.SetTileSize(gfx::Size(30, 30)); |
| 1268 client.set_tree(ACTIVE_TREE); | 1257 client.set_tree(ACTIVE_TREE); |
| 1269 | 1258 |
| 1270 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 1259 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); |
| 1271 tiling->UpdateTilePriorities( | 1260 tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 1272 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); | |
| 1273 | 1261 |
| 1274 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1262 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
| 1275 EXPECT_FALSE(empty_iterator); | 1263 EXPECT_FALSE(empty_iterator); |
| 1276 | 1264 |
| 1277 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1265 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1278 | 1266 |
| 1279 PictureLayerTiling::TilingEvictionTileIterator it( | 1267 PictureLayerTiling::TilingEvictionTileIterator it( |
| 1280 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); | 1268 tiling.get(), SMOOTHNESS_TAKES_PRIORITY, PictureLayerTiling::NOW); |
| 1281 | 1269 |
| 1282 // Tiles don't have resources to evict. | 1270 // Tiles don't have resources to evict. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1328 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| 1341 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1329 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1342 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1330 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1343 | 1331 |
| 1344 client_.set_tree(ACTIVE_TREE); | 1332 client_.set_tree(ACTIVE_TREE); |
| 1345 tiling_->UpdateTilePriorities( | 1333 tiling_->UpdateTilePriorities( |
| 1346 ACTIVE_TREE, | 1334 ACTIVE_TREE, |
| 1347 gfx::Rect(layer_bounds), // visible content rect | 1335 gfx::Rect(layer_bounds), // visible content rect |
| 1348 1.f, // current contents scale | 1336 1.f, // current contents scale |
| 1349 1.0, // current frame time | 1337 1.0, // current frame time |
| 1350 NULL, // occlusion tracker | 1338 Occlusion()); |
| 1351 NULL, // render target | |
| 1352 gfx::Transform()); // draw transform | |
| 1353 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true)); | 1339 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true)); |
| 1354 | 1340 |
| 1355 // Make the viewport rect empty. All tiles are killed and become zombies. | 1341 // Make the viewport rect empty. All tiles are killed and become zombies. |
| 1356 tiling_->UpdateTilePriorities(ACTIVE_TREE, | 1342 tiling_->UpdateTilePriorities(ACTIVE_TREE, |
| 1357 gfx::Rect(), // visible content rect | 1343 gfx::Rect(), // visible content rect |
| 1358 1.f, // current contents scale | 1344 1.f, // current contents scale |
| 1359 2.0, // current frame time | 1345 2.0, // current frame time |
| 1360 NULL, // occlusion tracker | 1346 Occlusion()); |
| 1361 NULL, // render target | |
| 1362 gfx::Transform()); // draw transform | |
| 1363 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1347 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1364 } | 1348 } |
| 1365 | 1349 |
| 1366 TEST_F(PictureLayerTilingIteratorTest, TilesExistGiantViewport) { | 1350 TEST_F(PictureLayerTilingIteratorTest, TilesExistGiantViewport) { |
| 1367 gfx::Size layer_bounds(1099, 801); | 1351 gfx::Size layer_bounds(1099, 801); |
| 1368 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1352 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| 1369 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1353 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1370 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1354 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1371 | 1355 |
| 1372 gfx::Rect giant_rect(-10000000, -10000000, 1000000000, 1000000000); | 1356 gfx::Rect giant_rect(-10000000, -10000000, 1000000000, 1000000000); |
| 1373 | 1357 |
| 1374 client_.set_tree(ACTIVE_TREE); | 1358 client_.set_tree(ACTIVE_TREE); |
| 1375 tiling_->UpdateTilePriorities( | 1359 tiling_->UpdateTilePriorities( |
| 1376 ACTIVE_TREE, | 1360 ACTIVE_TREE, |
| 1377 gfx::Rect(layer_bounds), // visible content rect | 1361 gfx::Rect(layer_bounds), // visible content rect |
| 1378 1.f, // current contents scale | 1362 1.f, // current contents scale |
| 1379 1.0, // current frame time | 1363 1.0, // current frame time |
| 1380 NULL, // occlusion tracker | 1364 Occlusion()); |
| 1381 NULL, // render target | |
| 1382 gfx::Transform()); // draw transform | |
| 1383 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true)); | 1365 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true)); |
| 1384 | 1366 |
| 1385 // If the visible content rect is empty, it should still have live tiles. | 1367 // If the visible content rect is empty, it should still have live tiles. |
| 1386 tiling_->UpdateTilePriorities(ACTIVE_TREE, | 1368 tiling_->UpdateTilePriorities(ACTIVE_TREE, |
| 1387 giant_rect, // visible content rect | 1369 giant_rect, // visible content rect |
| 1388 1.f, // current contents scale | 1370 1.f, // current contents scale |
| 1389 2.0, // current frame time | 1371 2.0, // current frame time |
| 1390 NULL, // occlusion tracker | 1372 Occlusion()); |
| 1391 NULL, // render target | |
| 1392 gfx::Transform()); // draw transform | |
| 1393 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true)); | 1373 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true)); |
| 1394 } | 1374 } |
| 1395 | 1375 |
| 1396 TEST_F(PictureLayerTilingIteratorTest, TilesExistOutsideViewport) { | 1376 TEST_F(PictureLayerTilingIteratorTest, TilesExistOutsideViewport) { |
| 1397 gfx::Size layer_bounds(1099, 801); | 1377 gfx::Size layer_bounds(1099, 801); |
| 1398 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1378 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| 1399 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1379 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1400 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1380 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1401 | 1381 |
| 1402 // This rect does not intersect with the layer, as the layer is outside the | 1382 // This rect does not intersect with the layer, as the layer is outside the |
| 1403 // viewport. | 1383 // viewport. |
| 1404 gfx::Rect viewport_rect(1100, 0, 1000, 1000); | 1384 gfx::Rect viewport_rect(1100, 0, 1000, 1000); |
| 1405 EXPECT_FALSE(viewport_rect.Intersects(gfx::Rect(layer_bounds))); | 1385 EXPECT_FALSE(viewport_rect.Intersects(gfx::Rect(layer_bounds))); |
| 1406 | 1386 |
| 1407 client_.set_tree(ACTIVE_TREE); | 1387 client_.set_tree(ACTIVE_TREE); |
| 1408 tiling_->UpdateTilePriorities(ACTIVE_TREE, | 1388 tiling_->UpdateTilePriorities(ACTIVE_TREE, |
| 1409 viewport_rect, // visible content rect | 1389 viewport_rect, // visible content rect |
| 1410 1.f, // current contents scale | 1390 1.f, // current contents scale |
| 1411 1.0, // current frame time | 1391 1.0, // current frame time |
| 1412 NULL, // occlusion tracker | 1392 Occlusion()); |
| 1413 NULL, // render target | |
| 1414 gfx::Transform()); // draw transform | |
| 1415 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true)); | 1393 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true)); |
| 1416 } | 1394 } |
| 1417 | 1395 |
| 1418 static void TilesIntersectingRectExist(const gfx::Rect& rect, | 1396 static void TilesIntersectingRectExist(const gfx::Rect& rect, |
| 1419 bool intersect_exists, | 1397 bool intersect_exists, |
| 1420 Tile* tile, | 1398 Tile* tile, |
| 1421 const gfx::Rect& geometry_rect) { | 1399 const gfx::Rect& geometry_rect) { |
| 1422 bool intersects = rect.Intersects(geometry_rect); | 1400 bool intersects = rect.Intersects(geometry_rect); |
| 1423 bool expected_exists = intersect_exists ? intersects : !intersects; | 1401 bool expected_exists = intersect_exists ? intersects : !intersects; |
| 1424 EXPECT_EQ(expected_exists, tile != NULL) | 1402 EXPECT_EQ(expected_exists, tile != NULL) |
| 1425 << "Rects intersecting " << rect.ToString() << " should exist. " | 1403 << "Rects intersecting " << rect.ToString() << " should exist. " |
| 1426 << "Current tile rect is " << geometry_rect.ToString(); | 1404 << "Current tile rect is " << geometry_rect.ToString(); |
| 1427 } | 1405 } |
| 1428 | 1406 |
| 1429 TEST_F(PictureLayerTilingIteratorTest, | 1407 TEST_F(PictureLayerTilingIteratorTest, |
| 1430 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1408 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
| 1431 gfx::Size layer_bounds(10000, 10000); | 1409 gfx::Size layer_bounds(10000, 10000); |
| 1432 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1410 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| 1433 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1411 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1434 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1412 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1435 | 1413 |
| 1436 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1414 gfx::Rect visible_rect(8000, 8000, 50, 50); |
| 1437 | 1415 |
| 1438 client_.set_tree(ACTIVE_TREE); | 1416 client_.set_tree(ACTIVE_TREE); |
| 1439 set_max_tiles_for_interest_area(1); | 1417 set_max_tiles_for_interest_area(1); |
| 1440 tiling_->UpdateTilePriorities(ACTIVE_TREE, | 1418 tiling_->UpdateTilePriorities(ACTIVE_TREE, |
| 1441 visible_rect, // visible content rect | 1419 visible_rect, // visible content rect |
| 1442 1.f, // current contents scale | 1420 1.f, // current contents scale |
| 1443 1.0, // current frame time | 1421 1.0, // current frame time |
| 1444 NULL, // occlusion tracker | 1422 Occlusion()); |
| 1445 NULL, // render target | |
| 1446 gfx::Transform()); // draw transform | |
| 1447 VerifyTiles(1.f, | 1423 VerifyTiles(1.f, |
| 1448 gfx::Rect(layer_bounds), | 1424 gfx::Rect(layer_bounds), |
| 1449 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); | 1425 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); |
| 1450 } | 1426 } |
| 1451 | 1427 |
| 1452 static void CountExistingTiles(int *count, | 1428 static void CountExistingTiles(int *count, |
| 1453 Tile* tile, | 1429 Tile* tile, |
| 1454 const gfx::Rect& geometry_rect) { | 1430 const gfx::Rect& geometry_rect) { |
| 1455 if (tile != NULL) | 1431 if (tile != NULL) |
| 1456 ++(*count); | 1432 ++(*count); |
| 1457 } | 1433 } |
| 1458 | 1434 |
| 1459 TEST_F(PictureLayerTilingIteratorTest, | 1435 TEST_F(PictureLayerTilingIteratorTest, |
| 1460 TilesExistLargeViewportAndLayerWithLargeVisibleArea) { | 1436 TilesExistLargeViewportAndLayerWithLargeVisibleArea) { |
| 1461 gfx::Size layer_bounds(10000, 10000); | 1437 gfx::Size layer_bounds(10000, 10000); |
| 1462 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1438 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| 1463 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1439 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1464 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1440 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1465 | 1441 |
| 1466 client_.set_tree(ACTIVE_TREE); | 1442 client_.set_tree(ACTIVE_TREE); |
| 1467 set_max_tiles_for_interest_area(1); | 1443 set_max_tiles_for_interest_area(1); |
| 1468 tiling_->UpdateTilePriorities( | 1444 tiling_->UpdateTilePriorities( |
| 1469 ACTIVE_TREE, | 1445 ACTIVE_TREE, |
| 1470 gfx::Rect(layer_bounds), // visible content rect | 1446 gfx::Rect(layer_bounds), // visible content rect |
| 1471 1.f, // current contents scale | 1447 1.f, // current contents scale |
| 1472 1.0, // current frame time | 1448 1.0, // current frame time |
| 1473 NULL, // occlusion tracker | 1449 Occlusion()); |
| 1474 NULL, // render target | |
| 1475 gfx::Transform()); // draw transform | |
| 1476 | 1450 |
| 1477 int num_tiles = 0; | 1451 int num_tiles = 0; |
| 1478 VerifyTiles(1.f, | 1452 VerifyTiles(1.f, |
| 1479 gfx::Rect(layer_bounds), | 1453 gfx::Rect(layer_bounds), |
| 1480 base::Bind(&CountExistingTiles, &num_tiles)); | 1454 base::Bind(&CountExistingTiles, &num_tiles)); |
| 1481 // If we're making a rect the size of one tile, it can only overlap up to 4 | 1455 // If we're making a rect the size of one tile, it can only overlap up to 4 |
| 1482 // tiles depending on its position. | 1456 // tiles depending on its position. |
| 1483 EXPECT_LE(num_tiles, 4); | 1457 EXPECT_LE(num_tiles, 4); |
| 1484 VerifyTiles(1.f, gfx::Rect(), base::Bind(&TileExists, false)); | 1458 VerifyTiles(1.f, gfx::Rect(), base::Bind(&TileExists, false)); |
| 1485 } | 1459 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 client.SetTileSize(gfx::Size(100, 100)); | 1531 client.SetTileSize(gfx::Size(100, 100)); |
| 1558 client.set_tree(ACTIVE_TREE); | 1532 client.set_tree(ACTIVE_TREE); |
| 1559 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1533 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1560 current_layer_bounds, | 1534 current_layer_bounds, |
| 1561 &client); | 1535 &client); |
| 1562 | 1536 |
| 1563 tiling->UpdateTilePriorities(ACTIVE_TREE, | 1537 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 1564 viewport_in_layer_space, | 1538 viewport_in_layer_space, |
| 1565 current_layer_contents_scale, | 1539 current_layer_contents_scale, |
| 1566 current_frame_time_in_seconds, | 1540 current_frame_time_in_seconds, |
| 1567 NULL, // occlusion tracker | 1541 Occlusion()); |
| 1568 NULL, // render target | |
| 1569 gfx::Transform()); // draw transform | |
| 1570 | 1542 |
| 1571 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1543 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1572 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1544 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1573 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1545 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1574 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1546 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| 1575 | 1547 |
| 1576 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1548 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
| 1577 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1549 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| 1578 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1550 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1579 | 1551 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 client.SetTileSize(gfx::Size(100, 100)); | 1586 client.SetTileSize(gfx::Size(100, 100)); |
| 1615 client.set_tree(ACTIVE_TREE); | 1587 client.set_tree(ACTIVE_TREE); |
| 1616 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1588 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1617 current_layer_bounds, | 1589 current_layer_bounds, |
| 1618 &client); | 1590 &client); |
| 1619 | 1591 |
| 1620 tiling->UpdateTilePriorities(ACTIVE_TREE, | 1592 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 1621 viewport_in_layer_space, | 1593 viewport_in_layer_space, |
| 1622 current_layer_contents_scale, | 1594 current_layer_contents_scale, |
| 1623 current_frame_time_in_seconds, | 1595 current_frame_time_in_seconds, |
| 1624 NULL, // occlusion tracker | 1596 Occlusion()); |
| 1625 NULL, // render target | |
| 1626 gfx::Transform()); // draw transform | |
| 1627 | 1597 |
| 1628 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1598 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1629 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1599 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1630 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1600 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1631 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1601 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| 1632 | 1602 |
| 1633 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1603 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
| 1634 EXPECT_GT(priority.distance_to_visible, 0.f); | 1604 EXPECT_GT(priority.distance_to_visible, 0.f); |
| 1635 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1605 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 1636 | 1606 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 client.SetTileSize(gfx::Size(100, 100)); | 1651 client.SetTileSize(gfx::Size(100, 100)); |
| 1682 client.set_tree(ACTIVE_TREE); | 1652 client.set_tree(ACTIVE_TREE); |
| 1683 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1653 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1684 current_layer_bounds, | 1654 current_layer_bounds, |
| 1685 &client); | 1655 &client); |
| 1686 | 1656 |
| 1687 tiling->UpdateTilePriorities(ACTIVE_TREE, | 1657 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 1688 viewport_in_layer_space, | 1658 viewport_in_layer_space, |
| 1689 current_layer_contents_scale, | 1659 current_layer_contents_scale, |
| 1690 current_frame_time_in_seconds, | 1660 current_frame_time_in_seconds, |
| 1691 NULL, // occlusion tracker | 1661 Occlusion()); |
| 1692 NULL, // render target | |
| 1693 gfx::Transform()); // draw transform | |
| 1694 | 1662 |
| 1695 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1663 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1696 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1664 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1697 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1665 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1698 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1666 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| 1699 | 1667 |
| 1700 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1668 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
| 1701 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1669 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| 1702 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1670 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1703 | 1671 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1742 client.SetTileSize(gfx::Size(100, 100)); | 1710 client.SetTileSize(gfx::Size(100, 100)); |
| 1743 client.set_tree(ACTIVE_TREE); | 1711 client.set_tree(ACTIVE_TREE); |
| 1744 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1712 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1745 current_layer_bounds, | 1713 current_layer_bounds, |
| 1746 &client); | 1714 &client); |
| 1747 | 1715 |
| 1748 tiling->UpdateTilePriorities(ACTIVE_TREE, | 1716 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 1749 viewport_in_layer_space, | 1717 viewport_in_layer_space, |
| 1750 current_layer_contents_scale, | 1718 current_layer_contents_scale, |
| 1751 current_frame_time_in_seconds, | 1719 current_frame_time_in_seconds, |
| 1752 NULL, // occlusion tracker | 1720 Occlusion()); |
| 1753 NULL, // render target | |
| 1754 gfx::Transform()); // draw transform | |
| 1755 | 1721 |
| 1756 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1722 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1757 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1723 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1758 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1724 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1759 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1725 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| 1760 | 1726 |
| 1761 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1727 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
| 1762 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1728 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| 1763 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1729 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1764 | 1730 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 client.SetTileSize(gfx::Size(100, 100)); | 1793 client.SetTileSize(gfx::Size(100, 100)); |
| 1828 client.set_tree(ACTIVE_TREE); | 1794 client.set_tree(ACTIVE_TREE); |
| 1829 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1795 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1830 current_layer_bounds, | 1796 current_layer_bounds, |
| 1831 &client); | 1797 &client); |
| 1832 | 1798 |
| 1833 tiling->UpdateTilePriorities(ACTIVE_TREE, | 1799 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 1834 viewport_in_layer_space, | 1800 viewport_in_layer_space, |
| 1835 current_layer_contents_scale, | 1801 current_layer_contents_scale, |
| 1836 current_frame_time_in_seconds, | 1802 current_frame_time_in_seconds, |
| 1837 NULL, // occlusion tracker | 1803 Occlusion()); |
| 1838 NULL, // render target | |
| 1839 gfx::Transform()); // draw transform | |
| 1840 | 1804 |
| 1841 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1805 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1842 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1806 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1843 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1807 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1844 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1808 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| 1845 | 1809 |
| 1846 // All tiles will have a positive distance_to_visible | 1810 // All tiles will have a positive distance_to_visible |
| 1847 // and an infinite time_to_visible. | 1811 // and an infinite time_to_visible. |
| 1848 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1812 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
| 1849 EXPECT_FLOAT_EQ(priority.distance_to_visible, 0.f); | 1813 EXPECT_FLOAT_EQ(priority.distance_to_visible, 0.f); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 client.SetTileSize(gfx::Size(100, 100)); | 1886 client.SetTileSize(gfx::Size(100, 100)); |
| 1923 client.set_tree(ACTIVE_TREE); | 1887 client.set_tree(ACTIVE_TREE); |
| 1924 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1888 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1925 current_layer_bounds, | 1889 current_layer_bounds, |
| 1926 &client); | 1890 &client); |
| 1927 | 1891 |
| 1928 tiling->UpdateTilePriorities(ACTIVE_TREE, | 1892 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 1929 viewport_in_layer_space, | 1893 viewport_in_layer_space, |
| 1930 current_layer_contents_scale, | 1894 current_layer_contents_scale, |
| 1931 current_frame_time_in_seconds, | 1895 current_frame_time_in_seconds, |
| 1932 NULL, // occlusion tracker | 1896 Occlusion()); |
| 1933 NULL, // render target | |
| 1934 gfx::Transform()); // draw transform | |
| 1935 | 1897 |
| 1936 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1898 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1937 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1899 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1938 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1900 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1939 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1901 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| 1940 | 1902 |
| 1941 // Left-side tiles will be clipped by the transform, so we have to assume | 1903 // Left-side tiles will be clipped by the transform, so we have to assume |
| 1942 // they are visible just in case. | 1904 // they are visible just in case. |
| 1943 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1905 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
| 1944 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1906 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 client.set_tree(ACTIVE_TREE); | 1950 client.set_tree(ACTIVE_TREE); |
| 1989 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1951 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1990 current_layer_bounds, | 1952 current_layer_bounds, |
| 1991 &client); | 1953 &client); |
| 1992 | 1954 |
| 1993 // previous ("last") frame | 1955 // previous ("last") frame |
| 1994 tiling->UpdateTilePriorities(ACTIVE_TREE, | 1956 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 1995 viewport_in_layer_space, | 1957 viewport_in_layer_space, |
| 1996 last_layer_contents_scale, | 1958 last_layer_contents_scale, |
| 1997 last_frame_time_in_seconds, | 1959 last_frame_time_in_seconds, |
| 1998 NULL, // occlusion tracker | 1960 Occlusion()); |
| 1999 NULL, // render target | |
| 2000 gfx::Transform()); // draw transform | |
| 2001 | 1961 |
| 2002 // current frame | 1962 // current frame |
| 2003 tiling->UpdateTilePriorities(ACTIVE_TREE, | 1963 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 2004 viewport_in_layer_space, | 1964 viewport_in_layer_space, |
| 2005 current_layer_contents_scale, | 1965 current_layer_contents_scale, |
| 2006 current_frame_time_in_seconds, | 1966 current_frame_time_in_seconds, |
| 2007 NULL, // occlusion tracker | 1967 Occlusion()); |
| 2008 NULL, // render target | |
| 2009 gfx::Transform()); // draw transform | |
| 2010 | 1968 |
| 2011 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1969 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 2012 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1970 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 2013 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1971 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 2014 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1972 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| 2015 | 1973 |
| 2016 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1974 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
| 2017 EXPECT_GT(priority.distance_to_visible, 0.f); | 1975 EXPECT_GT(priority.distance_to_visible, 0.f); |
| 2018 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1976 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 2019 | 1977 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 client.set_tree(ACTIVE_TREE); | 2028 client.set_tree(ACTIVE_TREE); |
| 2071 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2029 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 2072 current_layer_bounds, | 2030 current_layer_bounds, |
| 2073 &client); | 2031 &client); |
| 2074 | 2032 |
| 2075 // previous ("last") frame | 2033 // previous ("last") frame |
| 2076 tiling->UpdateTilePriorities(ACTIVE_TREE, | 2034 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 2077 viewport_in_layer_space, | 2035 viewport_in_layer_space, |
| 2078 last_layer_contents_scale, | 2036 last_layer_contents_scale, |
| 2079 last_frame_time_in_seconds, | 2037 last_frame_time_in_seconds, |
| 2080 NULL, // occlusion tracker | 2038 Occlusion()); |
| 2081 NULL, // render target | |
| 2082 gfx::Transform()); // draw transform | |
| 2083 | 2039 |
| 2084 // current frame | 2040 // current frame |
| 2085 tiling->UpdateTilePriorities(ACTIVE_TREE, | 2041 tiling->UpdateTilePriorities(ACTIVE_TREE, |
| 2086 viewport_in_layer_space, | 2042 viewport_in_layer_space, |
| 2087 current_layer_contents_scale, | 2043 current_layer_contents_scale, |
| 2088 current_frame_time_in_seconds, | 2044 current_frame_time_in_seconds, |
| 2089 NULL, // occlusion tracker | 2045 Occlusion()); |
| 2090 NULL, // render target | |
| 2091 gfx::Transform()); // draw transform | |
| 2092 | 2046 |
| 2093 ASSERT_TRUE(tiling->TileAt(0, 0)); | 2047 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 2094 ASSERT_TRUE(tiling->TileAt(0, 1)); | 2048 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 2095 ASSERT_TRUE(tiling->TileAt(1, 0)); | 2049 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 2096 ASSERT_TRUE(tiling->TileAt(1, 1)); | 2050 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| 2097 | 2051 |
| 2098 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 2052 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
| 2099 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 2053 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| 2100 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2054 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 2101 | 2055 |
| 2102 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 2056 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
| 2103 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 2057 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| 2104 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2058 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 2105 | 2059 |
| 2106 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 2060 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
| 2107 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 2061 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| 2108 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2062 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 2109 } | 2063 } |
| 2110 | 2064 |
| 2111 TEST(PictureLayerTilingTest, ResetClearsPriorities) { | 2065 TEST(PictureLayerTilingTest, ResetClearsPriorities) { |
| 2112 FakePictureLayerTilingClient client; | 2066 FakePictureLayerTilingClient client; |
| 2113 scoped_ptr<TestablePictureLayerTiling> tiling; | 2067 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 2114 | 2068 |
| 2115 client.SetTileSize(gfx::Size(100, 100)); | 2069 client.SetTileSize(gfx::Size(100, 100)); |
| 2116 client.set_tree(ACTIVE_TREE); | 2070 client.set_tree(ACTIVE_TREE); |
| 2117 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2071 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 2118 gfx::Size(100, 100), | 2072 gfx::Size(100, 100), |
| 2119 &client); | 2073 &client); |
| 2120 tiling->UpdateTilePriorities(ACTIVE_TREE, | 2074 tiling->UpdateTilePriorities( |
| 2121 gfx::Rect(0, 0, 100, 100), | 2075 ACTIVE_TREE, gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, Occlusion()); |
| 2122 1.0f, | |
| 2123 1.0f, | |
| 2124 NULL, // occlusion tracker | |
| 2125 NULL, // render target | |
| 2126 gfx::Transform()); // draw transform | |
| 2127 | 2076 |
| 2128 std::vector<scoped_refptr<Tile> > tiles = tiling->AllRefTilesForTesting(); | 2077 std::vector<scoped_refptr<Tile> > tiles = tiling->AllRefTilesForTesting(); |
| 2129 ASSERT_GT(tiles.size(), 0u); | 2078 ASSERT_GT(tiles.size(), 0u); |
| 2130 for (std::vector<scoped_refptr<Tile> >::const_iterator it = tiles.begin(); | 2079 for (std::vector<scoped_refptr<Tile> >::const_iterator it = tiles.begin(); |
| 2131 it != tiles.end(); | 2080 it != tiles.end(); |
| 2132 ++it) { | 2081 ++it) { |
| 2133 EXPECT_NE(TilePriority(), (*it)->priority(ACTIVE_TREE)); | 2082 EXPECT_NE(TilePriority(), (*it)->priority(ACTIVE_TREE)); |
| 2134 } | 2083 } |
| 2135 | 2084 |
| 2136 tiling->Reset(); | 2085 tiling->Reset(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2156 FakePictureLayerTilingClient active_client; | 2105 FakePictureLayerTilingClient active_client; |
| 2157 scoped_ptr<TestablePictureLayerTiling> active_tiling; | 2106 scoped_ptr<TestablePictureLayerTiling> active_tiling; |
| 2158 | 2107 |
| 2159 active_client.SetTileSize(gfx::Size(100, 100)); | 2108 active_client.SetTileSize(gfx::Size(100, 100)); |
| 2160 active_client.set_tree(ACTIVE_TREE); | 2109 active_client.set_tree(ACTIVE_TREE); |
| 2161 active_client.set_max_tiles_for_interest_area(10); | 2110 active_client.set_max_tiles_for_interest_area(10); |
| 2162 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2111 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 2163 gfx::Size(10000, 10000), | 2112 gfx::Size(10000, 10000), |
| 2164 &active_client); | 2113 &active_client); |
| 2165 // Create all tiles on this tiling. | 2114 // Create all tiles on this tiling. |
| 2166 active_tiling->UpdateTilePriorities(ACTIVE_TREE, | 2115 active_tiling->UpdateTilePriorities( |
| 2167 gfx::Rect(0, 0, 100, 100), | 2116 ACTIVE_TREE, gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, Occlusion()); |
| 2168 1.0f, | |
| 2169 1.0f, | |
| 2170 NULL, // occlusion tracker | |
| 2171 NULL, // render target | |
| 2172 gfx::Transform()); // draw transform | |
| 2173 | 2117 |
| 2174 FakePictureLayerTilingClient recycle_client; | 2118 FakePictureLayerTilingClient recycle_client; |
| 2175 recycle_client.SetTileSize(gfx::Size(100, 100)); | 2119 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 2176 recycle_client.set_tree(PENDING_TREE); | 2120 recycle_client.set_tree(PENDING_TREE); |
| 2177 recycle_client.set_twin_tiling(active_tiling.get()); | 2121 recycle_client.set_twin_tiling(active_tiling.get()); |
| 2178 recycle_client.set_max_tiles_for_interest_area(10); | 2122 recycle_client.set_max_tiles_for_interest_area(10); |
| 2179 | 2123 |
| 2180 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 2124 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; |
| 2181 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2125 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 2182 gfx::Size(10000, 10000), | 2126 gfx::Size(10000, 10000), |
| 2183 &recycle_client); | 2127 &recycle_client); |
| 2184 | 2128 |
| 2185 // Create all tiles on the second tiling. All tiles should be shared. | 2129 // Create all tiles on the second tiling. All tiles should be shared. |
| 2186 recycle_tiling->UpdateTilePriorities(PENDING_TREE, | 2130 recycle_tiling->UpdateTilePriorities( |
| 2187 gfx::Rect(0, 0, 100, 100), | 2131 PENDING_TREE, gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, Occlusion()); |
| 2188 1.0f, | |
| 2189 1.0f, | |
| 2190 NULL, // occlusion tracker | |
| 2191 NULL, // render target | |
| 2192 gfx::Transform()); // draw transform | |
| 2193 | 2132 |
| 2194 // Set the second tiling as recycled. | 2133 // Set the second tiling as recycled. |
| 2195 active_client.set_twin_tiling(NULL); | 2134 active_client.set_twin_tiling(NULL); |
| 2196 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2135 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
| 2197 recycle_client.set_twin_tiling(NULL); | 2136 recycle_client.set_twin_tiling(NULL); |
| 2198 | 2137 |
| 2199 // Verify that tiles exist and are shared. | 2138 // Verify that tiles exist and are shared. |
| 2200 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2139 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2201 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); | 2140 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
| 2202 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); | 2141 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); |
| 2203 | 2142 |
| 2204 // Move the viewport far away from the (0, 0) tile. | 2143 // Move the viewport far away from the (0, 0) tile. |
| 2205 active_tiling->UpdateTilePriorities(ACTIVE_TREE, | 2144 active_tiling->UpdateTilePriorities( |
| 2206 gfx::Rect(9000, 9000, 100, 100), | 2145 ACTIVE_TREE, gfx::Rect(9000, 9000, 100, 100), 1.0f, 2.0, Occlusion()); |
| 2207 1.0f, | |
| 2208 2.0, | |
| 2209 NULL, // occlusion tracker | |
| 2210 NULL, // render target | |
| 2211 gfx::Transform()); // draw transform | |
| 2212 // Ensure the tile was deleted on both tilings. | 2146 // Ensure the tile was deleted on both tilings. |
| 2213 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 2147 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
| 2214 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2148 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
| 2215 | 2149 |
| 2216 // Move the viewport back to (0, 0) tile. | 2150 // Move the viewport back to (0, 0) tile. |
| 2217 active_tiling->UpdateTilePriorities(ACTIVE_TREE, | 2151 active_tiling->UpdateTilePriorities( |
| 2218 gfx::Rect(0, 0, 100, 100), | 2152 ACTIVE_TREE, gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, Occlusion()); |
| 2219 1.0f, | |
| 2220 3.0, | |
| 2221 NULL, // occlusion tracker | |
| 2222 NULL, // render target | |
| 2223 gfx::Transform()); // draw transform | |
| 2224 | 2153 |
| 2225 // Ensure that we now have a tile here, but the recycle tiling does not. | 2154 // Ensure that we now have a tile here, but the recycle tiling does not. |
| 2226 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2155 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2227 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2156 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
| 2228 } | 2157 } |
| 2229 | 2158 |
| 2230 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 2159 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
| 2231 FakePictureLayerTilingClient active_client; | 2160 FakePictureLayerTilingClient active_client; |
| 2232 scoped_ptr<TestablePictureLayerTiling> active_tiling; | 2161 scoped_ptr<TestablePictureLayerTiling> active_tiling; |
| 2233 | 2162 |
| 2234 active_client.SetTileSize(gfx::Size(100, 100)); | 2163 active_client.SetTileSize(gfx::Size(100, 100)); |
| 2235 active_client.set_tree(ACTIVE_TREE); | 2164 active_client.set_tree(ACTIVE_TREE); |
| 2236 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2165 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 2237 gfx::Size(100, 100), | 2166 gfx::Size(100, 100), |
| 2238 &active_client); | 2167 &active_client); |
| 2239 // Create all tiles on this tiling. | 2168 // Create all tiles on this tiling. |
| 2240 active_tiling->UpdateTilePriorities(ACTIVE_TREE, | 2169 active_tiling->UpdateTilePriorities( |
| 2241 gfx::Rect(0, 0, 100, 100), | 2170 ACTIVE_TREE, gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, Occlusion()); |
| 2242 1.0f, | |
| 2243 1.0f, | |
| 2244 NULL, // occlusion tracker | |
| 2245 NULL, // render target | |
| 2246 gfx::Transform()); // draw transform | |
| 2247 | 2171 |
| 2248 FakePictureLayerTilingClient recycle_client; | 2172 FakePictureLayerTilingClient recycle_client; |
| 2249 recycle_client.SetTileSize(gfx::Size(100, 100)); | 2173 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 2250 recycle_client.set_tree(PENDING_TREE); | 2174 recycle_client.set_tree(PENDING_TREE); |
| 2251 recycle_client.set_twin_tiling(active_tiling.get()); | 2175 recycle_client.set_twin_tiling(active_tiling.get()); |
| 2252 recycle_client.set_max_tiles_for_interest_area(10); | 2176 recycle_client.set_max_tiles_for_interest_area(10); |
| 2253 | 2177 |
| 2254 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 2178 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; |
| 2255 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2179 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 2256 gfx::Size(100, 100), | 2180 gfx::Size(100, 100), |
| 2257 &recycle_client); | 2181 &recycle_client); |
| 2258 | 2182 |
| 2259 // Create all tiles on the recycle tiling. All tiles should be shared. | 2183 // Create all tiles on the recycle tiling. All tiles should be shared. |
| 2260 recycle_tiling->UpdateTilePriorities(PENDING_TREE, | 2184 recycle_tiling->UpdateTilePriorities( |
| 2261 gfx::Rect(0, 0, 100, 100), | 2185 PENDING_TREE, gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, Occlusion()); |
| 2262 1.0f, | |
| 2263 1.0f, | |
| 2264 NULL, // occlusion tracker | |
| 2265 NULL, // render target | |
| 2266 gfx::Transform()); // draw transform | |
| 2267 | 2186 |
| 2268 // Set the second tiling as recycled. | 2187 // Set the second tiling as recycled. |
| 2269 active_client.set_twin_tiling(NULL); | 2188 active_client.set_twin_tiling(NULL); |
| 2270 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2189 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
| 2271 recycle_client.set_twin_tiling(NULL); | 2190 recycle_client.set_twin_tiling(NULL); |
| 2272 | 2191 |
| 2273 // Verify that tiles exist and are shared. | 2192 // Verify that tiles exist and are shared. |
| 2274 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2193 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2275 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); | 2194 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
| 2276 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); | 2195 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); |
| 2277 | 2196 |
| 2278 // Reset the active tiling. The recycle tiles should be released too. | 2197 // Reset the active tiling. The recycle tiles should be released too. |
| 2279 active_tiling->Reset(); | 2198 active_tiling->Reset(); |
| 2280 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 2199 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
| 2281 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2200 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
| 2282 } | 2201 } |
| 2283 | 2202 |
| 2284 } // namespace | 2203 } // namespace |
| 2285 } // namespace cc | 2204 } // namespace cc |
| OLD | NEW |