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 <limits> | 5 #include <limits> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/test/fake_display_list_raster_source.h" | |
9 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/fake_output_surface_client.h" | 11 #include "cc/test/fake_output_surface_client.h" |
11 #include "cc/test/fake_picture_layer_tiling_client.h" | 12 #include "cc/test/fake_picture_layer_tiling_client.h" |
12 #include "cc/test/fake_picture_pile_impl.h" | |
13 #include "cc/test/test_context_provider.h" | 13 #include "cc/test/test_context_provider.h" |
14 #include "cc/test/test_shared_bitmap_manager.h" | 14 #include "cc/test/test_shared_bitmap_manager.h" |
15 #include "cc/tiles/picture_layer_tiling.h" | 15 #include "cc/tiles/picture_layer_tiling.h" |
16 #include "cc/tiles/picture_layer_tiling_set.h" | 16 #include "cc/tiles/picture_layer_tiling_set.h" |
17 #include "cc/trees/layer_tree_settings.h" | 17 #include "cc/trees/layer_tree_settings.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/gfx/geometry/quad_f.h" | 19 #include "ui/gfx/geometry/quad_f.h" |
20 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
21 #include "ui/gfx/geometry/size_conversions.h" | 21 #include "ui/gfx/geometry/size_conversions.h" |
22 | 22 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 78 |
79 class PictureLayerTilingIteratorTest : public testing::Test { | 79 class PictureLayerTilingIteratorTest : public testing::Test { |
80 public: | 80 public: |
81 PictureLayerTilingIteratorTest() {} | 81 PictureLayerTilingIteratorTest() {} |
82 ~PictureLayerTilingIteratorTest() override {} | 82 ~PictureLayerTilingIteratorTest() override {} |
83 | 83 |
84 void Initialize(const gfx::Size& tile_size, | 84 void Initialize(const gfx::Size& tile_size, |
85 float contents_scale, | 85 float contents_scale, |
86 const gfx::Size& layer_bounds) { | 86 const gfx::Size& layer_bounds) { |
87 client_.SetTileSize(tile_size); | 87 client_.SetTileSize(tile_size); |
88 scoped_refptr<FakePicturePileImpl> pile = | 88 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
89 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 89 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
90 tiling_ = TestablePictureLayerTiling::Create( | 90 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, |
91 PENDING_TREE, contents_scale, pile, &client_, LayerTreeSettings()); | 91 raster_source, &client_, |
92 LayerTreeSettings()); | |
92 tiling_->set_resolution(HIGH_RESOLUTION); | 93 tiling_->set_resolution(HIGH_RESOLUTION); |
93 } | 94 } |
94 | 95 |
95 void InitializeActive(const gfx::Size& tile_size, | 96 void InitializeActive(const gfx::Size& tile_size, |
96 float contents_scale, | 97 float contents_scale, |
97 const gfx::Size& layer_bounds) { | 98 const gfx::Size& layer_bounds) { |
98 client_.SetTileSize(tile_size); | 99 client_.SetTileSize(tile_size); |
99 scoped_refptr<FakePicturePileImpl> pile = | 100 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
100 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 101 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
101 tiling_ = TestablePictureLayerTiling::Create( | 102 tiling_ = TestablePictureLayerTiling::Create(ACTIVE_TREE, contents_scale, |
102 ACTIVE_TREE, contents_scale, pile, &client_, LayerTreeSettings()); | 103 raster_source, &client_, |
104 LayerTreeSettings()); | |
103 tiling_->set_resolution(HIGH_RESOLUTION); | 105 tiling_->set_resolution(HIGH_RESOLUTION); |
104 } | 106 } |
105 | 107 |
106 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { | 108 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { |
107 tiling_->SetLiveTilesRect(live_tiles_rect); | 109 tiling_->SetLiveTilesRect(live_tiles_rect); |
108 | 110 |
109 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 111 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
110 for (std::vector<Tile*>::iterator iter = tiles.begin(); | 112 for (std::vector<Tile*>::iterator iter = tiles.begin(); |
111 iter != tiles.end(); | 113 iter != tiles.end(); |
112 ++iter) { | 114 ++iter) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 gfx::Size tile_size(100, 100); | 206 gfx::Size tile_size(100, 100); |
205 gfx::Size original_layer_size(10, 10); | 207 gfx::Size original_layer_size(10, 10); |
206 InitializeActive(tile_size, 1.f, original_layer_size); | 208 InitializeActive(tile_size, 1.f, original_layer_size); |
207 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 209 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
208 | 210 |
209 // Tiling only has one tile, since its total size is less than one. | 211 // Tiling only has one tile, since its total size is less than one. |
210 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 212 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
211 | 213 |
212 // Stop creating tiles so that any invalidations are left as holes. | 214 // Stop creating tiles so that any invalidations are left as holes. |
213 gfx::Size new_layer_size(200, 200); | 215 gfx::Size new_layer_size(200, 200); |
214 scoped_refptr<FakePicturePileImpl> pile = | 216 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
215 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(new_layer_size); | 217 FakeDisplayListRasterSource::CreatePartiallyFilled(new_layer_size, |
218 gfx::Rect()); | |
216 | 219 |
217 Region invalidation = | 220 Region invalidation = |
218 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 221 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
219 tiling_->SetRasterSourceAndResize(pile); | 222 tiling_->SetRasterSourceAndResize(raster_source); |
220 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 223 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
221 tiling_->Invalidate(invalidation); | 224 tiling_->Invalidate(invalidation); |
222 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 225 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
223 } | 226 } |
224 | 227 |
225 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { | 228 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { |
226 // The tiling has three rows and columns. | 229 // The tiling has three rows and columns. |
227 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 250)); | 230 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 250)); |
228 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 231 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
229 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); | 232 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 EXPECT_TRUE(tiling_->TileAt(2, 2)); | 268 EXPECT_TRUE(tiling_->TileAt(2, 2)); |
266 EXPECT_TRUE(tiling_->TileAt(2, 3)); | 269 EXPECT_TRUE(tiling_->TileAt(2, 3)); |
267 EXPECT_TRUE(tiling_->TileAt(1, 3)); | 270 EXPECT_TRUE(tiling_->TileAt(1, 3)); |
268 EXPECT_TRUE(tiling_->TileAt(0, 3)); | 271 EXPECT_TRUE(tiling_->TileAt(0, 3)); |
269 | 272 |
270 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); | 273 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); |
271 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); | 274 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); |
272 | 275 |
273 // Shrink the tiling so that the last tile row/column is entirely in the | 276 // Shrink the tiling so that the last tile row/column is entirely in the |
274 // border pixels of the interior tiles. That row/column is removed. | 277 // border pixels of the interior tiles. That row/column is removed. |
275 scoped_refptr<FakePicturePileImpl> pile = | 278 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
276 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 279 FakeDisplayListRasterSource::CreateFilled( |
277 gfx::Size(right + 1, bottom + 1)); | 280 gfx::Size(right + 1, bottom + 1)); |
278 tiling_->SetRasterSourceAndResize(pile); | 281 tiling_->SetRasterSourceAndResize(raster_source); |
279 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); | 282 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); |
280 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); | 283 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
281 | 284 |
282 // The live tiles rect was clamped to the pile size. | 285 // The live tiles rect was clamped to the raster source size. |
283 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 286 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
284 | 287 |
285 // Since the row/column is gone, the tiles should be gone too. | 288 // Since the row/column is gone, the tiles should be gone too. |
286 EXPECT_FALSE(tiling_->TileAt(2, 0)); | 289 EXPECT_FALSE(tiling_->TileAt(2, 0)); |
287 EXPECT_FALSE(tiling_->TileAt(2, 1)); | 290 EXPECT_FALSE(tiling_->TileAt(2, 1)); |
288 EXPECT_FALSE(tiling_->TileAt(2, 2)); | 291 EXPECT_FALSE(tiling_->TileAt(2, 2)); |
289 EXPECT_FALSE(tiling_->TileAt(2, 3)); | 292 EXPECT_FALSE(tiling_->TileAt(2, 3)); |
290 EXPECT_FALSE(tiling_->TileAt(1, 3)); | 293 EXPECT_FALSE(tiling_->TileAt(1, 3)); |
291 EXPECT_FALSE(tiling_->TileAt(0, 3)); | 294 EXPECT_FALSE(tiling_->TileAt(0, 3)); |
292 | 295 |
293 // Growing outside the current right/bottom tiles border pixels should create | 296 // Growing outside the current right/bottom tiles border pixels should create |
294 // the tiles again, even though the live rect has not changed size. | 297 // the tiles again, even though the live rect has not changed size. |
295 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 298 raster_source = FakeDisplayListRasterSource::CreateFilled( |
296 gfx::Size(right + 2, bottom + 2)); | 299 gfx::Size(right + 2, bottom + 2)); |
297 tiling_->SetRasterSourceAndResize(pile); | 300 tiling_->SetRasterSourceAndResize(raster_source); |
298 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 301 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
299 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); | 302 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); |
300 | 303 |
301 // Not changed. | 304 // Not changed. |
302 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 305 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
303 | 306 |
304 // The last row/column tiles are inside the live tiles rect. | 307 // The last row/column tiles are inside the live tiles rect. |
305 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 308 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
306 tiling_->TilingDataForTesting().TileBounds(2, 0))); | 309 tiling_->TilingDataForTesting().TileBounds(2, 0))); |
307 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 310 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 // deletes tiles that intersect that invalidation. | 422 // deletes tiles that intersect that invalidation. |
420 gfx::Size tile_size(100, 100); | 423 gfx::Size tile_size(100, 100); |
421 gfx::Size original_layer_size(99, 99); | 424 gfx::Size original_layer_size(99, 99); |
422 InitializeActive(tile_size, 1.f, original_layer_size); | 425 InitializeActive(tile_size, 1.f, original_layer_size); |
423 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 426 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
424 | 427 |
425 // Tiling only has one tile, since its total size is less than one. | 428 // Tiling only has one tile, since its total size is less than one. |
426 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 429 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
427 | 430 |
428 // Stop creating tiles so that any invalidations are left as holes. | 431 // Stop creating tiles so that any invalidations are left as holes. |
429 scoped_refptr<FakePicturePileImpl> pile = | 432 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
430 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize( | 433 FakeDisplayListRasterSource::CreatePartiallyFilled(gfx::Size(200, 200), |
431 gfx::Size(200, 200)); | 434 gfx::Rect()); |
432 tiling_->SetRasterSourceAndResize(pile); | 435 tiling_->SetRasterSourceAndResize(raster_source); |
433 | 436 |
434 Region invalidation = | 437 Region invalidation = |
435 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 438 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
436 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 439 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
437 tiling_->Invalidate(invalidation); | 440 tiling_->Invalidate(invalidation); |
438 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 441 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
439 | 442 |
440 // The original tile was the same size after resize, but it would include new | 443 // The original tile was the same size after resize, but it would include new |
441 // border pixels. | 444 // border pixels. |
442 EXPECT_EQ(gfx::Rect(original_layer_size), | 445 EXPECT_EQ(gfx::Rect(original_layer_size), |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 TEST(PictureLayerTilingTest, SkewportLimits) { | 550 TEST(PictureLayerTilingTest, SkewportLimits) { |
548 FakePictureLayerTilingClient client; | 551 FakePictureLayerTilingClient client; |
549 | 552 |
550 gfx::Rect viewport(0, 0, 100, 100); | 553 gfx::Rect viewport(0, 0, 100, 100); |
551 gfx::Size layer_bounds(200, 200); | 554 gfx::Size layer_bounds(200, 200); |
552 | 555 |
553 client.SetTileSize(gfx::Size(100, 100)); | 556 client.SetTileSize(gfx::Size(100, 100)); |
554 LayerTreeSettings settings; | 557 LayerTreeSettings settings; |
555 settings.skewport_extrapolation_limit_in_content_pixels = 75; | 558 settings.skewport_extrapolation_limit_in_content_pixels = 75; |
556 | 559 |
557 scoped_refptr<FakePicturePileImpl> pile = | 560 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
558 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 561 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
559 scoped_ptr<TestablePictureLayerTiling> tiling = | 562 scoped_ptr<TestablePictureLayerTiling> tiling = |
560 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 563 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
561 settings); | 564 &client, settings); |
562 | 565 |
563 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 566 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
564 | 567 |
565 // Move viewport down 50 pixels in 0.5 seconds. | 568 // Move viewport down 50 pixels in 0.5 seconds. |
566 gfx::Rect down_skewport = | 569 gfx::Rect down_skewport = |
567 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 570 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
568 | 571 |
569 EXPECT_EQ(0, down_skewport.x()); | 572 EXPECT_EQ(0, down_skewport.x()); |
570 EXPECT_EQ(50, down_skewport.y()); | 573 EXPECT_EQ(50, down_skewport.y()); |
571 EXPECT_EQ(100, down_skewport.width()); | 574 EXPECT_EQ(100, down_skewport.width()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 EXPECT_EQ(175, move_skewport_far.height()); | 634 EXPECT_EQ(175, move_skewport_far.height()); |
632 EXPECT_TRUE(move_skewport_far.Contains(gfx::Rect(0, 5000, 100, 100))); | 635 EXPECT_TRUE(move_skewport_far.Contains(gfx::Rect(0, 5000, 100, 100))); |
633 } | 636 } |
634 | 637 |
635 TEST(PictureLayerTilingTest, ComputeSkewportExtremeCases) { | 638 TEST(PictureLayerTilingTest, ComputeSkewportExtremeCases) { |
636 FakePictureLayerTilingClient client; | 639 FakePictureLayerTilingClient client; |
637 | 640 |
638 gfx::Size layer_bounds(200, 200); | 641 gfx::Size layer_bounds(200, 200); |
639 client.SetTileSize(gfx::Size(100, 100)); | 642 client.SetTileSize(gfx::Size(100, 100)); |
640 LayerTreeSettings settings; | 643 LayerTreeSettings settings; |
641 scoped_refptr<FakePicturePileImpl> pile = | 644 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
642 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 645 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
643 scoped_ptr<TestablePictureLayerTiling> tiling = | 646 scoped_ptr<TestablePictureLayerTiling> tiling = |
644 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 647 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
645 settings); | 648 &client, settings); |
646 | 649 |
647 gfx::Rect viewport1(-1918, 255860, 4010, 2356); | 650 gfx::Rect viewport1(-1918, 255860, 4010, 2356); |
648 gfx::Rect viewport2(-7088, -91738, 14212, 8350); | 651 gfx::Rect viewport2(-7088, -91738, 14212, 8350); |
649 gfx::Rect viewport3(-12730024, -158883296, 24607540, 14454512); | 652 gfx::Rect viewport3(-12730024, -158883296, 24607540, 14454512); |
650 double time = 1.0; | 653 double time = 1.0; |
651 tiling->ComputeTilePriorityRects(viewport1, 1.f, time, Occlusion()); | 654 tiling->ComputeTilePriorityRects(viewport1, 1.f, time, Occlusion()); |
652 time += 0.016; | 655 time += 0.016; |
653 EXPECT_TRUE(tiling->ComputeSkewport(time, viewport2).Contains(viewport2)); | 656 EXPECT_TRUE(tiling->ComputeSkewport(time, viewport2).Contains(viewport2)); |
654 tiling->ComputeTilePriorityRects(viewport2, 1.f, time, Occlusion()); | 657 tiling->ComputeTilePriorityRects(viewport2, 1.f, time, Occlusion()); |
655 time += 0.016; | 658 time += 0.016; |
656 EXPECT_TRUE(tiling->ComputeSkewport(time, viewport3).Contains(viewport3)); | 659 EXPECT_TRUE(tiling->ComputeSkewport(time, viewport3).Contains(viewport3)); |
657 } | 660 } |
658 | 661 |
659 TEST(PictureLayerTilingTest, ComputeSkewport) { | 662 TEST(PictureLayerTilingTest, ComputeSkewport) { |
660 FakePictureLayerTilingClient client; | 663 FakePictureLayerTilingClient client; |
661 | 664 |
662 gfx::Rect viewport(0, 0, 100, 100); | 665 gfx::Rect viewport(0, 0, 100, 100); |
663 gfx::Size layer_bounds(200, 200); | 666 gfx::Size layer_bounds(200, 200); |
664 | 667 |
665 client.SetTileSize(gfx::Size(100, 100)); | 668 client.SetTileSize(gfx::Size(100, 100)); |
666 | 669 |
667 scoped_refptr<FakePicturePileImpl> pile = | 670 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
668 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 671 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
669 scoped_ptr<TestablePictureLayerTiling> tiling = | 672 scoped_ptr<TestablePictureLayerTiling> tiling = |
670 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 673 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
671 LayerTreeSettings()); | 674 &client, LayerTreeSettings()); |
672 | 675 |
673 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 676 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
674 | 677 |
675 // Move viewport down 50 pixels in 0.5 seconds. | 678 // Move viewport down 50 pixels in 0.5 seconds. |
676 gfx::Rect down_skewport = | 679 gfx::Rect down_skewport = |
677 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 680 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
678 | 681 |
679 EXPECT_EQ(0, down_skewport.x()); | 682 EXPECT_EQ(0, down_skewport.x()); |
680 EXPECT_EQ(50, down_skewport.y()); | 683 EXPECT_EQ(50, down_skewport.y()); |
681 EXPECT_EQ(100, down_skewport.width()); | 684 EXPECT_EQ(100, down_skewport.width()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
719 } | 722 } |
720 | 723 |
721 TEST(PictureLayerTilingTest, SkewportThroughUpdateTilePriorities) { | 724 TEST(PictureLayerTilingTest, SkewportThroughUpdateTilePriorities) { |
722 FakePictureLayerTilingClient client; | 725 FakePictureLayerTilingClient client; |
723 | 726 |
724 gfx::Rect viewport(0, 0, 100, 100); | 727 gfx::Rect viewport(0, 0, 100, 100); |
725 gfx::Size layer_bounds(200, 200); | 728 gfx::Size layer_bounds(200, 200); |
726 | 729 |
727 client.SetTileSize(gfx::Size(100, 100)); | 730 client.SetTileSize(gfx::Size(100, 100)); |
728 | 731 |
729 scoped_refptr<FakePicturePileImpl> pile = | 732 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
730 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 733 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
731 scoped_ptr<TestablePictureLayerTiling> tiling = | 734 scoped_ptr<TestablePictureLayerTiling> tiling = |
732 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 735 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
733 LayerTreeSettings()); | 736 &client, LayerTreeSettings()); |
734 | 737 |
735 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 738 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
736 | 739 |
737 // Move viewport down 50 pixels in 0.5 seconds. | 740 // Move viewport down 50 pixels in 0.5 seconds. |
738 gfx::Rect viewport_50 = gfx::Rect(0, 50, 100, 100); | 741 gfx::Rect viewport_50 = gfx::Rect(0, 50, 100, 100); |
739 gfx::Rect skewport_50 = tiling->ComputeSkewport(1.5, viewport_50); | 742 gfx::Rect skewport_50 = tiling->ComputeSkewport(1.5, viewport_50); |
740 | 743 |
741 EXPECT_EQ(gfx::Rect(0, 50, 100, 200), skewport_50); | 744 EXPECT_EQ(gfx::Rect(0, 50, 100, 200), skewport_50); |
742 tiling->ComputeTilePriorityRects(viewport_50, 1.f, 1.5, Occlusion()); | 745 tiling->ComputeTilePriorityRects(viewport_50, 1.f, 1.5, Occlusion()); |
743 | 746 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 gfx::Size layer_bounds(1500, 1500); | 796 gfx::Size layer_bounds(1500, 1500); |
794 | 797 |
795 client.SetTileSize(gfx::Size(10, 10)); | 798 client.SetTileSize(gfx::Size(10, 10)); |
796 LayerTreeSettings settings; | 799 LayerTreeSettings settings; |
797 | 800 |
798 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 801 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
799 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 802 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
800 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 803 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
801 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 804 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
802 // tiling. | 805 // tiling. |
803 scoped_refptr<FakePicturePileImpl> pile = | 806 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
804 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 807 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
805 scoped_ptr<TestablePictureLayerTiling> tiling = | 808 scoped_ptr<TestablePictureLayerTiling> tiling = |
806 TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.25f, pile, &client, | 809 TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.25f, raster_source, |
807 settings); | 810 &client, settings); |
808 tiling->set_resolution(HIGH_RESOLUTION); | 811 tiling->set_resolution(HIGH_RESOLUTION); |
809 gfx::Rect viewport_in_content_space = | 812 gfx::Rect viewport_in_content_space = |
810 gfx::ScaleToEnclosedRect(viewport, 0.25f); | 813 gfx::ScaleToEnclosedRect(viewport, 0.25f); |
811 | 814 |
812 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 815 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
813 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 816 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
814 | 817 |
815 // Compute the soon border. | 818 // Compute the soon border. |
816 float inset = PictureLayerTiling::CalculateSoonBorderDistance( | 819 float inset = PictureLayerTiling::CalculateSoonBorderDistance( |
817 viewport_in_content_space, 1.0f / 0.25f); | 820 viewport_in_content_space, 1.0f / 0.25f); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
954 priority = prioritized_tiles[tiling->TileAt(5, 1)].priority(); | 957 priority = prioritized_tiles[tiling->TileAt(5, 1)].priority(); |
955 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); | 958 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); |
956 | 959 |
957 priority = prioritized_tiles[tiling->TileAt(2, 5)].priority(); | 960 priority = prioritized_tiles[tiling->TileAt(2, 5)].priority(); |
958 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); | 961 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
959 | 962 |
960 priority = prioritized_tiles[tiling->TileAt(3, 4)].priority(); | 963 priority = prioritized_tiles[tiling->TileAt(3, 4)].priority(); |
961 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); | 964 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
962 | 965 |
963 // Test additional scales. | 966 // Test additional scales. |
964 tiling = TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.2f, pile, &client, | 967 tiling = TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.2f, raster_source, |
965 LayerTreeSettings()); | 968 &client, LayerTreeSettings()); |
966 tiling->set_resolution(HIGH_RESOLUTION); | 969 tiling->set_resolution(HIGH_RESOLUTION); |
967 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); | 970 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); |
968 prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 971 prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
969 | 972 |
970 priority = prioritized_tiles[tiling->TileAt(5, 1)].priority(); | 973 priority = prioritized_tiles[tiling->TileAt(5, 1)].priority(); |
971 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); | 974 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); |
972 | 975 |
973 priority = prioritized_tiles[tiling->TileAt(2, 5)].priority(); | 976 priority = prioritized_tiles[tiling->TileAt(2, 5)].priority(); |
974 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); | 977 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); |
975 | 978 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1067 << "Current tile rect is " << geometry_rect.ToString(); | 1070 << "Current tile rect is " << geometry_rect.ToString(); |
1068 } | 1071 } |
1069 | 1072 |
1070 TEST_F(PictureLayerTilingIteratorTest, | 1073 TEST_F(PictureLayerTilingIteratorTest, |
1071 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1074 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
1072 gfx::Size layer_bounds(10000, 10000); | 1075 gfx::Size layer_bounds(10000, 10000); |
1073 client_.SetTileSize(gfx::Size(100, 100)); | 1076 client_.SetTileSize(gfx::Size(100, 100)); |
1074 LayerTreeSettings settings; | 1077 LayerTreeSettings settings; |
1075 settings.tiling_interest_area_padding = 1; | 1078 settings.tiling_interest_area_padding = 1; |
1076 | 1079 |
1077 scoped_refptr<FakePicturePileImpl> pile = | 1080 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1078 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 1081 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
1079 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, pile, | 1082 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, raster_source, |
1080 &client_, settings); | 1083 &client_, settings); |
1081 tiling_->set_resolution(HIGH_RESOLUTION); | 1084 tiling_->set_resolution(HIGH_RESOLUTION); |
1082 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1085 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
1083 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1086 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
1084 | 1087 |
1085 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1088 gfx::Rect visible_rect(8000, 8000, 50, 50); |
1086 | 1089 |
1087 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect | 1090 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect |
1088 1.f, // current contents scale | 1091 1.f, // current contents scale |
1089 1.0, // current frame time | 1092 1.0, // current frame time |
(...skipping 13 matching lines...) Expand all Loading... | |
1103 gfx::Size current_layer_bounds(200, 200); | 1106 gfx::Size current_layer_bounds(200, 200); |
1104 float current_layer_contents_scale = 1.f; | 1107 float current_layer_contents_scale = 1.f; |
1105 gfx::Transform current_screen_transform; | 1108 gfx::Transform current_screen_transform; |
1106 double current_frame_time_in_seconds = 1.0; | 1109 double current_frame_time_in_seconds = 1.0; |
1107 | 1110 |
1108 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1111 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1109 current_screen_transform, device_viewport); | 1112 current_screen_transform, device_viewport); |
1110 | 1113 |
1111 client.SetTileSize(gfx::Size(100, 100)); | 1114 client.SetTileSize(gfx::Size(100, 100)); |
1112 | 1115 |
1113 scoped_refptr<FakePicturePileImpl> pile = | 1116 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1114 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1117 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); |
1115 current_layer_bounds); | |
1116 scoped_ptr<TestablePictureLayerTiling> tiling = | 1118 scoped_ptr<TestablePictureLayerTiling> tiling = |
1117 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1119 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1118 LayerTreeSettings()); | 1120 &client, LayerTreeSettings()); |
1119 tiling->set_resolution(HIGH_RESOLUTION); | 1121 tiling->set_resolution(HIGH_RESOLUTION); |
1120 | 1122 |
1121 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1123 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1122 current_layer_contents_scale, | 1124 current_layer_contents_scale, |
1123 current_frame_time_in_seconds, Occlusion()); | 1125 current_frame_time_in_seconds, Occlusion()); |
1124 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1126 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
1125 | 1127 |
1126 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1128 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1127 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1129 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1128 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1130 ASSERT_TRUE(tiling->TileAt(1, 0)); |
(...skipping 30 matching lines...) Expand all Loading... | |
1159 double current_frame_time_in_seconds = 1.0; | 1161 double current_frame_time_in_seconds = 1.0; |
1160 | 1162 |
1161 current_screen_transform.Translate(850, 0); | 1163 current_screen_transform.Translate(850, 0); |
1162 last_screen_transform = current_screen_transform; | 1164 last_screen_transform = current_screen_transform; |
1163 | 1165 |
1164 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1166 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1165 current_screen_transform, device_viewport); | 1167 current_screen_transform, device_viewport); |
1166 | 1168 |
1167 client.SetTileSize(gfx::Size(100, 100)); | 1169 client.SetTileSize(gfx::Size(100, 100)); |
1168 | 1170 |
1169 scoped_refptr<FakePicturePileImpl> pile = | 1171 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1170 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1172 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); |
1171 current_layer_bounds); | |
1172 scoped_ptr<TestablePictureLayerTiling> tiling = | 1173 scoped_ptr<TestablePictureLayerTiling> tiling = |
1173 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1174 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1174 LayerTreeSettings()); | 1175 &client, LayerTreeSettings()); |
1175 tiling->set_resolution(HIGH_RESOLUTION); | 1176 tiling->set_resolution(HIGH_RESOLUTION); |
1176 | 1177 |
1177 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1178 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1178 current_layer_contents_scale, | 1179 current_layer_contents_scale, |
1179 current_frame_time_in_seconds, Occlusion()); | 1180 current_frame_time_in_seconds, Occlusion()); |
1180 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1181 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
1181 | 1182 |
1182 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1183 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1183 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1184 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1184 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1185 ASSERT_TRUE(tiling->TileAt(1, 0)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1225 double current_frame_time_in_seconds = 1.0; | 1226 double current_frame_time_in_seconds = 1.0; |
1226 | 1227 |
1227 current_screen_transform.Translate(705, 505); | 1228 current_screen_transform.Translate(705, 505); |
1228 last_screen_transform = current_screen_transform; | 1229 last_screen_transform = current_screen_transform; |
1229 | 1230 |
1230 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1231 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1231 current_screen_transform, device_viewport); | 1232 current_screen_transform, device_viewport); |
1232 | 1233 |
1233 client.SetTileSize(gfx::Size(100, 100)); | 1234 client.SetTileSize(gfx::Size(100, 100)); |
1234 | 1235 |
1235 scoped_refptr<FakePicturePileImpl> pile = | 1236 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1236 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1237 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); |
1237 current_layer_bounds); | |
1238 scoped_ptr<TestablePictureLayerTiling> tiling = | 1238 scoped_ptr<TestablePictureLayerTiling> tiling = |
1239 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1239 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1240 LayerTreeSettings()); | 1240 &client, LayerTreeSettings()); |
1241 tiling->set_resolution(HIGH_RESOLUTION); | 1241 tiling->set_resolution(HIGH_RESOLUTION); |
1242 | 1242 |
1243 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1243 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1244 current_layer_contents_scale, | 1244 current_layer_contents_scale, |
1245 current_frame_time_in_seconds, Occlusion()); | 1245 current_frame_time_in_seconds, Occlusion()); |
1246 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1246 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
1247 | 1247 |
1248 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1248 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1249 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1249 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1250 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1250 ASSERT_TRUE(tiling->TileAt(1, 0)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1285 // In this configuration, only the top-left tile would be visible. | 1285 // In this configuration, only the top-left tile would be visible. |
1286 current_screen_transform.Translate(600, 750); | 1286 current_screen_transform.Translate(600, 750); |
1287 current_screen_transform.RotateAboutZAxis(45); | 1287 current_screen_transform.RotateAboutZAxis(45); |
1288 last_screen_transform = current_screen_transform; | 1288 last_screen_transform = current_screen_transform; |
1289 | 1289 |
1290 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1290 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1291 current_screen_transform, device_viewport); | 1291 current_screen_transform, device_viewport); |
1292 | 1292 |
1293 client.SetTileSize(gfx::Size(100, 100)); | 1293 client.SetTileSize(gfx::Size(100, 100)); |
1294 | 1294 |
1295 scoped_refptr<FakePicturePileImpl> pile = | 1295 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1296 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1296 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); |
1297 current_layer_bounds); | |
1298 scoped_ptr<TestablePictureLayerTiling> tiling = | 1297 scoped_ptr<TestablePictureLayerTiling> tiling = |
1299 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1298 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1300 LayerTreeSettings()); | 1299 &client, LayerTreeSettings()); |
1301 tiling->set_resolution(HIGH_RESOLUTION); | 1300 tiling->set_resolution(HIGH_RESOLUTION); |
1302 | 1301 |
1303 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1302 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1304 current_layer_contents_scale, | 1303 current_layer_contents_scale, |
1305 current_frame_time_in_seconds, Occlusion()); | 1304 current_frame_time_in_seconds, Occlusion()); |
1306 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1305 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
1307 | 1306 |
1308 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1307 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1309 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1308 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1310 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1309 ASSERT_TRUE(tiling->TileAt(1, 0)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1370 MathUtil::MapQuad(current_screen_transform, | 1369 MathUtil::MapQuad(current_screen_transform, |
1371 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), | 1370 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), |
1372 &clipped); | 1371 &clipped); |
1373 ASSERT_FALSE(clipped); | 1372 ASSERT_FALSE(clipped); |
1374 | 1373 |
1375 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1374 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1376 current_screen_transform, device_viewport); | 1375 current_screen_transform, device_viewport); |
1377 | 1376 |
1378 client.SetTileSize(gfx::Size(100, 100)); | 1377 client.SetTileSize(gfx::Size(100, 100)); |
1379 | 1378 |
1380 scoped_refptr<FakePicturePileImpl> pile = | 1379 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1381 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1380 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); |
1382 current_layer_bounds); | |
1383 scoped_ptr<TestablePictureLayerTiling> tiling = | 1381 scoped_ptr<TestablePictureLayerTiling> tiling = |
1384 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1382 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1385 LayerTreeSettings()); | 1383 &client, LayerTreeSettings()); |
1386 tiling->set_resolution(HIGH_RESOLUTION); | 1384 tiling->set_resolution(HIGH_RESOLUTION); |
1387 | 1385 |
1388 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1386 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1389 current_layer_contents_scale, | 1387 current_layer_contents_scale, |
1390 current_frame_time_in_seconds, Occlusion()); | 1388 current_frame_time_in_seconds, Occlusion()); |
1391 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1389 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
1392 | 1390 |
1393 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1391 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1394 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1392 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1395 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1393 ASSERT_TRUE(tiling->TileAt(1, 0)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1465 MathUtil::MapQuad(current_screen_transform, | 1463 MathUtil::MapQuad(current_screen_transform, |
1466 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), | 1464 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), |
1467 &clipped); | 1465 &clipped); |
1468 ASSERT_FALSE(clipped); | 1466 ASSERT_FALSE(clipped); |
1469 | 1467 |
1470 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1468 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1471 current_screen_transform, device_viewport); | 1469 current_screen_transform, device_viewport); |
1472 | 1470 |
1473 client.SetTileSize(gfx::Size(100, 100)); | 1471 client.SetTileSize(gfx::Size(100, 100)); |
1474 | 1472 |
1475 scoped_refptr<FakePicturePileImpl> pile = | 1473 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1476 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1474 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); |
1477 current_layer_bounds); | |
1478 scoped_ptr<TestablePictureLayerTiling> tiling = | 1475 scoped_ptr<TestablePictureLayerTiling> tiling = |
1479 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1476 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1480 LayerTreeSettings()); | 1477 &client, LayerTreeSettings()); |
1481 tiling->set_resolution(HIGH_RESOLUTION); | 1478 tiling->set_resolution(HIGH_RESOLUTION); |
1482 | 1479 |
1483 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1480 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1484 current_layer_contents_scale, | 1481 current_layer_contents_scale, |
1485 current_frame_time_in_seconds, Occlusion()); | 1482 current_frame_time_in_seconds, Occlusion()); |
1486 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1483 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
1487 | 1484 |
1488 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1485 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1489 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1486 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1490 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1487 ASSERT_TRUE(tiling->TileAt(1, 0)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1530 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1527 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
1531 current_screen_transform.Translate(1800, 0); | 1528 current_screen_transform.Translate(1800, 0); |
1532 last_screen_transform.Translate(2800, 0); | 1529 last_screen_transform.Translate(2800, 0); |
1533 | 1530 |
1534 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1531 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1535 current_screen_transform, device_viewport); | 1532 current_screen_transform, device_viewport); |
1536 | 1533 |
1537 client.SetTileSize(gfx::Size(100, 100)); | 1534 client.SetTileSize(gfx::Size(100, 100)); |
1538 LayerTreeSettings settings; | 1535 LayerTreeSettings settings; |
1539 | 1536 |
1540 scoped_refptr<FakePicturePileImpl> pile = | 1537 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1541 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1538 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); |
1542 current_layer_bounds); | |
1543 scoped_ptr<TestablePictureLayerTiling> tiling = | 1539 scoped_ptr<TestablePictureLayerTiling> tiling = |
1544 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1540 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1545 settings); | 1541 &client, settings); |
1546 tiling->set_resolution(HIGH_RESOLUTION); | 1542 tiling->set_resolution(HIGH_RESOLUTION); |
1547 | 1543 |
1548 // previous ("last") frame | 1544 // previous ("last") frame |
1549 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1545 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1550 last_layer_contents_scale, | 1546 last_layer_contents_scale, |
1551 last_frame_time_in_seconds, Occlusion()); | 1547 last_frame_time_in_seconds, Occlusion()); |
1552 | 1548 |
1553 // current frame | 1549 // current frame |
1554 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1550 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1555 current_layer_contents_scale, | 1551 current_layer_contents_scale, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1609 current_screen_transform.Translate(400, 550); | 1605 current_screen_transform.Translate(400, 550); |
1610 current_screen_transform.RotateAboutZAxis(45); | 1606 current_screen_transform.RotateAboutZAxis(45); |
1611 | 1607 |
1612 last_screen_transform.Translate(400, 550); | 1608 last_screen_transform.Translate(400, 550); |
1613 | 1609 |
1614 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1610 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1615 current_screen_transform, device_viewport); | 1611 current_screen_transform, device_viewport); |
1616 | 1612 |
1617 client.SetTileSize(gfx::Size(100, 100)); | 1613 client.SetTileSize(gfx::Size(100, 100)); |
1618 | 1614 |
1619 scoped_refptr<FakePicturePileImpl> pile = | 1615 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1620 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1616 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); |
1621 current_layer_bounds); | 1617 tiling = TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1622 tiling = TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1618 &client, LayerTreeSettings()); |
1623 LayerTreeSettings()); | |
1624 tiling->set_resolution(HIGH_RESOLUTION); | 1619 tiling->set_resolution(HIGH_RESOLUTION); |
1625 | 1620 |
1626 // previous ("last") frame | 1621 // previous ("last") frame |
1627 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1622 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1628 last_layer_contents_scale, | 1623 last_layer_contents_scale, |
1629 last_frame_time_in_seconds, Occlusion()); | 1624 last_frame_time_in_seconds, Occlusion()); |
1630 | 1625 |
1631 // current frame | 1626 // current frame |
1632 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1627 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1633 current_layer_contents_scale, | 1628 current_layer_contents_scale, |
(...skipping 27 matching lines...) Expand all Loading... | |
1661 // - Viewport moves back and a new active tiling tile is created. | 1656 // - Viewport moves back and a new active tiling tile is created. |
1662 // Result: | 1657 // Result: |
1663 // - Recycle tiling does _not_ have the tile in the same location (thus it | 1658 // - Recycle tiling does _not_ have the tile in the same location (thus it |
1664 // will be shared next time a pending tiling is created). | 1659 // will be shared next time a pending tiling is created). |
1665 | 1660 |
1666 FakePictureLayerTilingClient active_client; | 1661 FakePictureLayerTilingClient active_client; |
1667 | 1662 |
1668 active_client.SetTileSize(gfx::Size(100, 100)); | 1663 active_client.SetTileSize(gfx::Size(100, 100)); |
1669 LayerTreeSettings settings; | 1664 LayerTreeSettings settings; |
1670 | 1665 |
1671 scoped_refptr<FakePicturePileImpl> pile = | 1666 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1672 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1667 FakeDisplayListRasterSource::CreateFilled(gfx::Size(10000, 10000)); |
1673 gfx::Size(10000, 10000)); | |
1674 scoped_ptr<TestablePictureLayerTiling> active_tiling = | 1668 scoped_ptr<TestablePictureLayerTiling> active_tiling = |
1675 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, | 1669 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1676 &active_client, settings); | 1670 &active_client, settings); |
1677 active_tiling->set_resolution(HIGH_RESOLUTION); | 1671 active_tiling->set_resolution(HIGH_RESOLUTION); |
1678 // Create all tiles on this tiling. | 1672 // Create all tiles on this tiling. |
1679 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1673 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
1680 Occlusion()); | 1674 Occlusion()); |
1681 | 1675 |
1682 FakePictureLayerTilingClient recycle_client; | 1676 FakePictureLayerTilingClient recycle_client; |
1683 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1677 recycle_client.SetTileSize(gfx::Size(100, 100)); |
1684 recycle_client.set_twin_tiling(active_tiling.get()); | 1678 recycle_client.set_twin_tiling(active_tiling.get()); |
1685 | 1679 |
1686 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1680 raster_source = |
1687 gfx::Size(10000, 10000)); | 1681 FakeDisplayListRasterSource::CreateFilled(gfx::Size(10000, 10000)); |
1688 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = | 1682 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = |
1689 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, pile, | 1683 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, raster_source, |
1690 &recycle_client, settings); | 1684 &recycle_client, settings); |
1691 recycle_tiling->set_resolution(HIGH_RESOLUTION); | 1685 recycle_tiling->set_resolution(HIGH_RESOLUTION); |
1692 | 1686 |
1693 // Create all tiles on the second tiling. All tiles should be shared. | 1687 // Create all tiles on the second tiling. All tiles should be shared. |
1694 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1688 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
1695 1.0f, Occlusion()); | 1689 1.0f, Occlusion()); |
1696 | 1690 |
1697 // Set the second tiling as recycled. | 1691 // Set the second tiling as recycled. |
1698 active_client.set_twin_tiling(NULL); | 1692 active_client.set_twin_tiling(NULL); |
1699 recycle_client.set_twin_tiling(NULL); | 1693 recycle_client.set_twin_tiling(NULL); |
(...skipping 14 matching lines...) Expand all Loading... | |
1714 | 1708 |
1715 // Ensure that we now have a tile here on both active. | 1709 // Ensure that we now have a tile here on both active. |
1716 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1710 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1717 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 1711 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
1718 } | 1712 } |
1719 | 1713 |
1720 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 1714 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
1721 FakePictureLayerTilingClient active_client; | 1715 FakePictureLayerTilingClient active_client; |
1722 active_client.SetTileSize(gfx::Size(100, 100)); | 1716 active_client.SetTileSize(gfx::Size(100, 100)); |
1723 | 1717 |
1724 scoped_refptr<FakePicturePileImpl> pile = | 1718 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1725 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1719 FakeDisplayListRasterSource::CreateFilled(gfx::Size(100, 100)); |
1726 gfx::Size(100, 100)); | |
1727 scoped_ptr<TestablePictureLayerTiling> active_tiling = | 1720 scoped_ptr<TestablePictureLayerTiling> active_tiling = |
1728 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, | 1721 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
1729 &active_client, LayerTreeSettings()); | 1722 &active_client, LayerTreeSettings()); |
1730 active_tiling->set_resolution(HIGH_RESOLUTION); | 1723 active_tiling->set_resolution(HIGH_RESOLUTION); |
1731 // Create all tiles on this tiling. | 1724 // Create all tiles on this tiling. |
1732 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1725 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
1733 Occlusion()); | 1726 Occlusion()); |
1734 | 1727 |
1735 FakePictureLayerTilingClient recycle_client; | 1728 FakePictureLayerTilingClient recycle_client; |
1736 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1729 recycle_client.SetTileSize(gfx::Size(100, 100)); |
1737 recycle_client.set_twin_tiling(active_tiling.get()); | 1730 recycle_client.set_twin_tiling(active_tiling.get()); |
1738 | 1731 |
1739 LayerTreeSettings settings; | 1732 LayerTreeSettings settings; |
1740 | 1733 |
1741 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1734 raster_source = |
1742 gfx::Size(100, 100)); | 1735 FakeDisplayListRasterSource::CreateFilled(gfx::Size(100, 100)); |
1743 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = | 1736 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = |
1744 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, pile, | 1737 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, raster_source, |
1745 &recycle_client, settings); | 1738 &recycle_client, settings); |
1746 recycle_tiling->set_resolution(HIGH_RESOLUTION); | 1739 recycle_tiling->set_resolution(HIGH_RESOLUTION); |
1747 | 1740 |
1748 // Create all tiles on the recycle tiling. All tiles should be shared. | 1741 // Create all tiles on the recycle tiling. All tiles should be shared. |
1749 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1742 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
1750 1.0f, Occlusion()); | 1743 1.0f, Occlusion()); |
1751 | 1744 |
1752 // Set the second tiling as recycled. | 1745 // Set the second tiling as recycled. |
1753 active_client.set_twin_tiling(NULL); | 1746 active_client.set_twin_tiling(NULL); |
1754 recycle_client.set_twin_tiling(NULL); | 1747 recycle_client.set_twin_tiling(NULL); |
(...skipping 15 matching lines...) Expand all Loading... | |
1770 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 1763 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
1771 EXPECT_EQ(4u, tiling_->AllTilesForTesting().size()); | 1764 EXPECT_EQ(4u, tiling_->AllTilesForTesting().size()); |
1772 | 1765 |
1773 client_.SetTileSize(gfx::Size(250, 200)); | 1766 client_.SetTileSize(gfx::Size(250, 200)); |
1774 | 1767 |
1775 // Tile size in the tiling should still be 150x100. | 1768 // Tile size in the tiling should still be 150x100. |
1776 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); | 1769 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); |
1777 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 1770 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
1778 | 1771 |
1779 // The layer's size isn't changed, but the tile size was. | 1772 // The layer's size isn't changed, but the tile size was. |
1780 scoped_refptr<FakePicturePileImpl> pile = | 1773 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1781 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1774 FakeDisplayListRasterSource::CreateFilled(gfx::Size(250, 150)); |
1782 gfx::Size(250, 150)); | 1775 tiling_->SetRasterSourceAndResize(raster_source); |
1783 tiling_->SetRasterSourceAndResize(pile); | |
1784 | 1776 |
1785 // Tile size in the tiling should be resized to 250x200. | 1777 // Tile size in the tiling should be resized to 250x200. |
1786 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 1778 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
1787 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 1779 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
1788 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); | 1780 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); |
1789 } | 1781 } |
1790 | 1782 |
1791 // This test runs into floating point issues because of big numbers. | 1783 // This test runs into floating point issues because of big numbers. |
1792 TEST_F(PictureLayerTilingIteratorTest, GiantRect) { | 1784 TEST_F(PictureLayerTilingIteratorTest, GiantRect) { |
1793 gfx::Size tile_size(256, 256); | 1785 gfx::Size tile_size(256, 256); |
1794 gfx::Size layer_size(33554432, 33554432); | 1786 gfx::Size layer_size(33554432, 33554432); |
1795 bool filled = false; | |
1796 float contents_scale = 1.f; | 1787 float contents_scale = 1.f; |
1797 | 1788 |
1798 client_.SetTileSize(tile_size); | 1789 client_.SetTileSize(tile_size); |
1799 scoped_refptr<FakePicturePileImpl> pile = FakePicturePileImpl::CreatePile( | 1790 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1800 tile_size, layer_size, gfx::Rect(), filled); | 1791 FakeDisplayListRasterSource::CreateFilled(layer_size); |
danakj
2015/09/22 21:52:15
before it was not filled (false), the test still w
vmpstr
2015/09/22 22:57:50
I don't think it matters whether it's filled or no
| |
1801 tiling_ = TestablePictureLayerTiling::Create( | 1792 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, |
1802 PENDING_TREE, contents_scale, pile, &client_, LayerTreeSettings()); | 1793 raster_source, &client_, |
1794 LayerTreeSettings()); | |
1803 | 1795 |
1804 gfx::Rect content_rect(25554432, 25554432, 950, 860); | 1796 gfx::Rect content_rect(25554432, 25554432, 950, 860); |
1805 VerifyTilesExactlyCoverRect(contents_scale, content_rect); | 1797 VerifyTilesExactlyCoverRect(contents_scale, content_rect); |
1806 } | 1798 } |
1807 | 1799 |
1808 } // namespace | 1800 } // namespace |
1809 } // namespace cc | 1801 } // namespace cc |
OLD | NEW |