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_set.h" | 5 #include "cc/resources/picture_layer_tiling_set.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "cc/resources/resource_provider.h" | 10 #include "cc/resources/resource_provider.h" |
11 #include "cc/test/fake_output_surface.h" | 11 #include "cc/test/fake_output_surface.h" |
12 #include "cc/test/fake_output_surface_client.h" | 12 #include "cc/test/fake_output_surface_client.h" |
13 #include "cc/test/fake_picture_layer_tiling_client.h" | 13 #include "cc/test/fake_picture_layer_tiling_client.h" |
14 #include "cc/test/test_shared_bitmap_manager.h" | 14 #include "cc/test/test_shared_bitmap_manager.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "ui/gfx/geometry/size_conversions.h" | 16 #include "ui/gfx/geometry/size_conversions.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 namespace { | 19 namespace { |
20 | 20 |
21 const size_t kMaxTilesForInterestArea = 128; | |
danakj
2014/12/02 21:58:37
kinda similar comment here.. these are somewhat me
| |
22 const float kSkewportTargetTimeInSeconds = 1.0f; | |
23 const int kSkewportExtrapolationLimitInContentPixels = 2000; | |
24 | |
21 TEST(PictureLayerTilingSetTest, NoResources) { | 25 TEST(PictureLayerTilingSetTest, NoResources) { |
22 FakePictureLayerTilingClient client; | 26 FakePictureLayerTilingClient client; |
23 gfx::Size layer_bounds(1000, 800); | 27 gfx::Size layer_bounds(1000, 800); |
24 auto set = PictureLayerTilingSet::Create(&client); | 28 auto set = PictureLayerTilingSet::Create( |
29 &client, kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, | |
30 kSkewportExtrapolationLimitInContentPixels); | |
25 client.SetTileSize(gfx::Size(256, 256)); | 31 client.SetTileSize(gfx::Size(256, 256)); |
26 | 32 |
27 set->AddTiling(1.0, layer_bounds); | 33 set->AddTiling(1.0, layer_bounds); |
28 set->AddTiling(1.5, layer_bounds); | 34 set->AddTiling(1.5, layer_bounds); |
29 set->AddTiling(2.0, layer_bounds); | 35 set->AddTiling(2.0, layer_bounds); |
30 | 36 |
31 float contents_scale = 2.0; | 37 float contents_scale = 2.0; |
32 gfx::Size content_bounds( | 38 gfx::Size content_bounds( |
33 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); | 39 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale))); |
34 gfx::Rect content_rect(content_bounds); | 40 gfx::Rect content_rect(content_bounds); |
(...skipping 17 matching lines...) Expand all Loading... | |
52 FakePictureLayerTilingClient client; | 58 FakePictureLayerTilingClient client; |
53 gfx::Size layer_bounds(10, 10); | 59 gfx::Size layer_bounds(10, 10); |
54 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0); | 60 PictureLayerTilingSet::TilingRange higher_than_high_res_range(0, 0); |
55 PictureLayerTilingSet::TilingRange high_res_range(0, 0); | 61 PictureLayerTilingSet::TilingRange high_res_range(0, 0); |
56 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0); | 62 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0); |
57 PictureLayerTilingSet::TilingRange low_res_range(0, 0); | 63 PictureLayerTilingSet::TilingRange low_res_range(0, 0); |
58 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0); | 64 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0); |
59 PictureLayerTiling* high_res_tiling; | 65 PictureLayerTiling* high_res_tiling; |
60 PictureLayerTiling* low_res_tiling; | 66 PictureLayerTiling* low_res_tiling; |
61 | 67 |
62 auto set = PictureLayerTilingSet::Create(&client); | 68 auto set = PictureLayerTilingSet::Create( |
69 &client, kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, | |
70 kSkewportExtrapolationLimitInContentPixels); | |
63 set->AddTiling(2.0, layer_bounds); | 71 set->AddTiling(2.0, layer_bounds); |
64 high_res_tiling = set->AddTiling(1.0, layer_bounds); | 72 high_res_tiling = set->AddTiling(1.0, layer_bounds); |
65 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 73 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
66 set->AddTiling(0.5, layer_bounds); | 74 set->AddTiling(0.5, layer_bounds); |
67 low_res_tiling = set->AddTiling(0.25, layer_bounds); | 75 low_res_tiling = set->AddTiling(0.25, layer_bounds); |
68 low_res_tiling->set_resolution(LOW_RESOLUTION); | 76 low_res_tiling->set_resolution(LOW_RESOLUTION); |
69 set->AddTiling(0.125, layer_bounds); | 77 set->AddTiling(0.125, layer_bounds); |
70 | 78 |
71 higher_than_high_res_range = | 79 higher_than_high_res_range = |
72 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 80 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
(...skipping 11 matching lines...) Expand all Loading... | |
84 | 92 |
85 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); | 93 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); |
86 EXPECT_EQ(3u, low_res_range.start); | 94 EXPECT_EQ(3u, low_res_range.start); |
87 EXPECT_EQ(4u, low_res_range.end); | 95 EXPECT_EQ(4u, low_res_range.end); |
88 | 96 |
89 lower_than_low_res_range = | 97 lower_than_low_res_range = |
90 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 98 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
91 EXPECT_EQ(4u, lower_than_low_res_range.start); | 99 EXPECT_EQ(4u, lower_than_low_res_range.start); |
92 EXPECT_EQ(5u, lower_than_low_res_range.end); | 100 EXPECT_EQ(5u, lower_than_low_res_range.end); |
93 | 101 |
94 auto set_without_low_res = PictureLayerTilingSet::Create(&client); | 102 auto set_without_low_res = PictureLayerTilingSet::Create( |
103 &client, kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, | |
104 kSkewportExtrapolationLimitInContentPixels); | |
95 set_without_low_res->AddTiling(2.0, layer_bounds); | 105 set_without_low_res->AddTiling(2.0, layer_bounds); |
96 high_res_tiling = set_without_low_res->AddTiling(1.0, layer_bounds); | 106 high_res_tiling = set_without_low_res->AddTiling(1.0, layer_bounds); |
97 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 107 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
98 set_without_low_res->AddTiling(0.5, layer_bounds); | 108 set_without_low_res->AddTiling(0.5, layer_bounds); |
99 set_without_low_res->AddTiling(0.25, layer_bounds); | 109 set_without_low_res->AddTiling(0.25, layer_bounds); |
100 | 110 |
101 higher_than_high_res_range = set_without_low_res->GetTilingRange( | 111 higher_than_high_res_range = set_without_low_res->GetTilingRange( |
102 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 112 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
103 EXPECT_EQ(0u, higher_than_high_res_range.start); | 113 EXPECT_EQ(0u, higher_than_high_res_range.start); |
104 EXPECT_EQ(1u, higher_than_high_res_range.end); | 114 EXPECT_EQ(1u, higher_than_high_res_range.end); |
105 | 115 |
106 high_res_range = | 116 high_res_range = |
107 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | 117 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); |
108 EXPECT_EQ(1u, high_res_range.start); | 118 EXPECT_EQ(1u, high_res_range.start); |
109 EXPECT_EQ(2u, high_res_range.end); | 119 EXPECT_EQ(2u, high_res_range.end); |
110 | 120 |
111 between_high_and_low_res_range = set_without_low_res->GetTilingRange( | 121 between_high_and_low_res_range = set_without_low_res->GetTilingRange( |
112 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | 122 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); |
113 EXPECT_EQ(2u, between_high_and_low_res_range.start); | 123 EXPECT_EQ(2u, between_high_and_low_res_range.start); |
114 EXPECT_EQ(4u, between_high_and_low_res_range.end); | 124 EXPECT_EQ(4u, between_high_and_low_res_range.end); |
115 | 125 |
116 low_res_range = | 126 low_res_range = |
117 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); | 127 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); |
118 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); | 128 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); |
119 | 129 |
120 lower_than_low_res_range = set_without_low_res->GetTilingRange( | 130 lower_than_low_res_range = set_without_low_res->GetTilingRange( |
121 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 131 PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
122 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); | 132 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); |
123 | 133 |
124 auto set_with_only_high_and_low_res = PictureLayerTilingSet::Create(&client); | 134 auto set_with_only_high_and_low_res = PictureLayerTilingSet::Create( |
135 &client, kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, | |
136 kSkewportExtrapolationLimitInContentPixels); | |
125 high_res_tiling = | 137 high_res_tiling = |
126 set_with_only_high_and_low_res->AddTiling(1.0, layer_bounds); | 138 set_with_only_high_and_low_res->AddTiling(1.0, layer_bounds); |
127 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 139 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
128 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, layer_bounds); | 140 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, layer_bounds); |
129 low_res_tiling->set_resolution(LOW_RESOLUTION); | 141 low_res_tiling->set_resolution(LOW_RESOLUTION); |
130 | 142 |
131 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( | 143 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( |
132 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 144 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
133 EXPECT_EQ(0u, | 145 EXPECT_EQ(0u, |
134 higher_than_high_res_range.end - higher_than_high_res_range.start); | 146 higher_than_high_res_range.end - higher_than_high_res_range.start); |
(...skipping 11 matching lines...) Expand all Loading... | |
146 | 158 |
147 low_res_range = set_with_only_high_and_low_res->GetTilingRange( | 159 low_res_range = set_with_only_high_and_low_res->GetTilingRange( |
148 PictureLayerTilingSet::LOW_RES); | 160 PictureLayerTilingSet::LOW_RES); |
149 EXPECT_EQ(1u, low_res_range.start); | 161 EXPECT_EQ(1u, low_res_range.start); |
150 EXPECT_EQ(2u, low_res_range.end); | 162 EXPECT_EQ(2u, low_res_range.end); |
151 | 163 |
152 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( | 164 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( |
153 PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 165 PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
154 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); | 166 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); |
155 | 167 |
156 auto set_with_only_high_res = PictureLayerTilingSet::Create(&client); | 168 auto set_with_only_high_res = PictureLayerTilingSet::Create( |
169 &client, kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, | |
170 kSkewportExtrapolationLimitInContentPixels); | |
157 high_res_tiling = set_with_only_high_res->AddTiling(1.0, layer_bounds); | 171 high_res_tiling = set_with_only_high_res->AddTiling(1.0, layer_bounds); |
158 high_res_tiling->set_resolution(HIGH_RESOLUTION); | 172 high_res_tiling->set_resolution(HIGH_RESOLUTION); |
159 | 173 |
160 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( | 174 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( |
161 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 175 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
162 EXPECT_EQ(0u, | 176 EXPECT_EQ(0u, |
163 higher_than_high_res_range.end - higher_than_high_res_range.start); | 177 higher_than_high_res_range.end - higher_than_high_res_range.start); |
164 | 178 |
165 high_res_range = | 179 high_res_range = |
166 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | 180 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 NULL, | 216 NULL, |
203 NULL, | 217 NULL, |
204 0, | 218 0, |
205 false, | 219 false, |
206 1); | 220 1); |
207 | 221 |
208 FakePictureLayerTilingClient client(resource_provider.get()); | 222 FakePictureLayerTilingClient client(resource_provider.get()); |
209 client.SetTileSize(gfx::Size(256, 256)); | 223 client.SetTileSize(gfx::Size(256, 256)); |
210 client.set_tree(PENDING_TREE); | 224 client.set_tree(PENDING_TREE); |
211 gfx::Size layer_bounds(1000, 800); | 225 gfx::Size layer_bounds(1000, 800); |
212 auto set = PictureLayerTilingSet::Create(&client); | 226 auto set = PictureLayerTilingSet::Create( |
227 &client, kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, | |
228 kSkewportExtrapolationLimitInContentPixels); | |
213 | 229 |
214 float scale = min_scale; | 230 float scale = min_scale; |
215 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { | 231 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { |
216 PictureLayerTiling* tiling = set->AddTiling(scale, layer_bounds); | 232 PictureLayerTiling* tiling = set->AddTiling(scale, layer_bounds); |
217 tiling->CreateAllTilesForTesting(); | 233 tiling->CreateAllTilesForTesting(); |
218 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 234 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
219 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 235 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
220 } | 236 } |
221 | 237 |
222 float max_contents_scale = scale; | 238 float max_contents_scale = scale; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 class PictureLayerTilingSetSyncTest : public testing::Test { | 297 class PictureLayerTilingSetSyncTest : public testing::Test { |
282 public: | 298 public: |
283 PictureLayerTilingSetSyncTest() | 299 PictureLayerTilingSetSyncTest() |
284 : tile_size_(gfx::Size(10, 10)), | 300 : tile_size_(gfx::Size(10, 10)), |
285 source_bounds_(gfx::Size(30, 20)), | 301 source_bounds_(gfx::Size(30, 20)), |
286 target_bounds_(gfx::Size(30, 30)) { | 302 target_bounds_(gfx::Size(30, 30)) { |
287 source_client_.SetTileSize(tile_size_); | 303 source_client_.SetTileSize(tile_size_); |
288 source_client_.set_tree(PENDING_TREE); | 304 source_client_.set_tree(PENDING_TREE); |
289 target_client_.SetTileSize(tile_size_); | 305 target_client_.SetTileSize(tile_size_); |
290 target_client_.set_tree(PENDING_TREE); | 306 target_client_.set_tree(PENDING_TREE); |
291 source_ = PictureLayerTilingSet::Create(&source_client_); | 307 source_ = PictureLayerTilingSet::Create( |
292 target_ = PictureLayerTilingSet::Create(&target_client_); | 308 &source_client_, kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, |
309 kSkewportExtrapolationLimitInContentPixels); | |
310 target_ = PictureLayerTilingSet::Create( | |
311 &target_client_, kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, | |
312 kSkewportExtrapolationLimitInContentPixels); | |
293 } | 313 } |
294 | 314 |
295 // Sync from source to target. | 315 // Sync from source to target. |
296 void SyncTilings(const gfx::Size& new_bounds, | 316 void SyncTilings(const gfx::Size& new_bounds, |
297 const Region& invalidation, | 317 const Region& invalidation, |
298 float minimum_scale) { | 318 float minimum_scale) { |
299 for (size_t i = 0; i < source_->num_tilings(); ++i) | 319 for (size_t i = 0; i < source_->num_tilings(); ++i) |
300 source_->tiling_at(i)->CreateAllTilesForTesting(); | 320 source_->tiling_at(i)->CreateAllTilesForTesting(); |
301 for (size_t i = 0; i < target_->num_tilings(); ++i) | 321 for (size_t i = 0; i < target_->num_tilings(); ++i) |
302 target_->tiling_at(i)->CreateAllTilesForTesting(); | 322 target_->tiling_at(i)->CreateAllTilesForTesting(); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 std::vector<Tile*> new_tiles = target_->tiling_at(0)->AllTilesForTesting(); | 566 std::vector<Tile*> new_tiles = target_->tiling_at(0)->AllTilesForTesting(); |
547 for (size_t i = 0; i < original_tiles.size(); ++i) { | 567 for (size_t i = 0; i < original_tiles.size(); ++i) { |
548 std::vector<Tile*>::iterator find = | 568 std::vector<Tile*>::iterator find = |
549 std::find(new_tiles.begin(), new_tiles.end(), original_tiles[i]); | 569 std::find(new_tiles.begin(), new_tiles.end(), original_tiles[i]); |
550 EXPECT_TRUE(find == new_tiles.end()); | 570 EXPECT_TRUE(find == new_tiles.end()); |
551 } | 571 } |
552 } | 572 } |
553 | 573 |
554 } // namespace | 574 } // namespace |
555 } // namespace cc | 575 } // namespace cc |
OLD | NEW |