| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
| 12 #include "cc/test/fake_display_list_raster_source.h" | |
| 13 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
| 14 #include "cc/test/fake_output_surface_client.h" | 13 #include "cc/test/fake_output_surface_client.h" |
| 15 #include "cc/test/fake_picture_layer_tiling_client.h" | 14 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 15 #include "cc/test/fake_raster_source.h" |
| 16 #include "cc/test/test_context_provider.h" | 16 #include "cc/test/test_context_provider.h" |
| 17 #include "cc/test/test_shared_bitmap_manager.h" | 17 #include "cc/test/test_shared_bitmap_manager.h" |
| 18 #include "cc/tiles/picture_layer_tiling.h" | 18 #include "cc/tiles/picture_layer_tiling.h" |
| 19 #include "cc/tiles/picture_layer_tiling_set.h" | 19 #include "cc/tiles/picture_layer_tiling_set.h" |
| 20 #include "cc/trees/layer_tree_settings.h" | 20 #include "cc/trees/layer_tree_settings.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/gfx/geometry/quad_f.h" | 22 #include "ui/gfx/geometry/quad_f.h" |
| 23 #include "ui/gfx/geometry/rect_conversions.h" | 23 #include "ui/gfx/geometry/rect_conversions.h" |
| 24 #include "ui/gfx/geometry/size_conversions.h" | 24 #include "ui/gfx/geometry/size_conversions.h" |
| 25 | 25 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 class TestablePictureLayerTiling : public PictureLayerTiling { | 41 class TestablePictureLayerTiling : public PictureLayerTiling { |
| 42 public: | 42 public: |
| 43 using PictureLayerTiling::SetLiveTilesRect; | 43 using PictureLayerTiling::SetLiveTilesRect; |
| 44 using PictureLayerTiling::TileAt; | 44 using PictureLayerTiling::TileAt; |
| 45 | 45 |
| 46 static scoped_ptr<TestablePictureLayerTiling> Create( | 46 static scoped_ptr<TestablePictureLayerTiling> Create( |
| 47 WhichTree tree, | 47 WhichTree tree, |
| 48 float contents_scale, | 48 float contents_scale, |
| 49 scoped_refptr<DisplayListRasterSource> raster_source, | 49 scoped_refptr<RasterSource> raster_source, |
| 50 PictureLayerTilingClient* client, | 50 PictureLayerTilingClient* client, |
| 51 const LayerTreeSettings& settings) { | 51 const LayerTreeSettings& settings) { |
| 52 return make_scoped_ptr(new TestablePictureLayerTiling( | 52 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 53 tree, contents_scale, raster_source, client, | 53 tree, contents_scale, raster_source, client, |
| 54 settings.tiling_interest_area_padding, | 54 settings.tiling_interest_area_padding, |
| 55 settings.skewport_target_time_in_seconds, | 55 settings.skewport_target_time_in_seconds, |
| 56 settings.skewport_extrapolation_limit_in_content_pixels)); | 56 settings.skewport_extrapolation_limit_in_content_pixels)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 59 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 60 | 60 |
| 61 using PictureLayerTiling::ComputeSkewport; | 61 using PictureLayerTiling::ComputeSkewport; |
| 62 using PictureLayerTiling::RemoveTileAt; | 62 using PictureLayerTiling::RemoveTileAt; |
| 63 using PictureLayerTiling::RemoveTilesInRegion; | 63 using PictureLayerTiling::RemoveTilesInRegion; |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 TestablePictureLayerTiling( | 66 TestablePictureLayerTiling(WhichTree tree, |
| 67 WhichTree tree, | 67 float contents_scale, |
| 68 float contents_scale, | 68 scoped_refptr<RasterSource> raster_source, |
| 69 scoped_refptr<DisplayListRasterSource> raster_source, | 69 PictureLayerTilingClient* client, |
| 70 PictureLayerTilingClient* client, | 70 size_t tiling_interest_area_padding, |
| 71 size_t tiling_interest_area_padding, | 71 float skewport_target_time, |
| 72 float skewport_target_time, | 72 int skewport_extrapolation_limit) |
| 73 int skewport_extrapolation_limit) | |
| 74 : PictureLayerTiling(tree, | 73 : PictureLayerTiling(tree, |
| 75 contents_scale, | 74 contents_scale, |
| 76 raster_source, | 75 raster_source, |
| 77 client, | 76 client, |
| 78 tiling_interest_area_padding, | 77 tiling_interest_area_padding, |
| 79 skewport_target_time, | 78 skewport_target_time, |
| 80 skewport_extrapolation_limit) {} | 79 skewport_extrapolation_limit) {} |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 class PictureLayerTilingIteratorTest : public testing::Test { | 82 class PictureLayerTilingIteratorTest : public testing::Test { |
| 84 public: | 83 public: |
| 85 PictureLayerTilingIteratorTest() {} | 84 PictureLayerTilingIteratorTest() {} |
| 86 ~PictureLayerTilingIteratorTest() override {} | 85 ~PictureLayerTilingIteratorTest() override {} |
| 87 | 86 |
| 88 void Initialize(const gfx::Size& tile_size, | 87 void Initialize(const gfx::Size& tile_size, |
| 89 float contents_scale, | 88 float contents_scale, |
| 90 const gfx::Size& layer_bounds) { | 89 const gfx::Size& layer_bounds) { |
| 91 client_.SetTileSize(tile_size); | 90 client_.SetTileSize(tile_size); |
| 92 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 91 scoped_refptr<FakeRasterSource> raster_source = |
| 93 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 92 FakeRasterSource::CreateFilled(layer_bounds); |
| 94 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, | 93 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, |
| 95 raster_source, &client_, | 94 raster_source, &client_, |
| 96 LayerTreeSettings()); | 95 LayerTreeSettings()); |
| 97 tiling_->set_resolution(HIGH_RESOLUTION); | 96 tiling_->set_resolution(HIGH_RESOLUTION); |
| 98 } | 97 } |
| 99 | 98 |
| 100 void InitializeActive(const gfx::Size& tile_size, | 99 void InitializeActive(const gfx::Size& tile_size, |
| 101 float contents_scale, | 100 float contents_scale, |
| 102 const gfx::Size& layer_bounds) { | 101 const gfx::Size& layer_bounds) { |
| 103 client_.SetTileSize(tile_size); | 102 client_.SetTileSize(tile_size); |
| 104 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 103 scoped_refptr<FakeRasterSource> raster_source = |
| 105 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 104 FakeRasterSource::CreateFilled(layer_bounds); |
| 106 tiling_ = TestablePictureLayerTiling::Create(ACTIVE_TREE, contents_scale, | 105 tiling_ = TestablePictureLayerTiling::Create(ACTIVE_TREE, contents_scale, |
| 107 raster_source, &client_, | 106 raster_source, &client_, |
| 108 LayerTreeSettings()); | 107 LayerTreeSettings()); |
| 109 tiling_->set_resolution(HIGH_RESOLUTION); | 108 tiling_->set_resolution(HIGH_RESOLUTION); |
| 110 } | 109 } |
| 111 | 110 |
| 112 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { | 111 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { |
| 113 tiling_->SetLiveTilesRect(live_tiles_rect); | 112 tiling_->SetLiveTilesRect(live_tiles_rect); |
| 114 | 113 |
| 115 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 114 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 gfx::Size tile_size(100, 100); | 209 gfx::Size tile_size(100, 100); |
| 211 gfx::Size original_layer_size(10, 10); | 210 gfx::Size original_layer_size(10, 10); |
| 212 InitializeActive(tile_size, 1.f, original_layer_size); | 211 InitializeActive(tile_size, 1.f, original_layer_size); |
| 213 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 212 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 214 | 213 |
| 215 // Tiling only has one tile, since its total size is less than one. | 214 // Tiling only has one tile, since its total size is less than one. |
| 216 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 215 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 217 | 216 |
| 218 // Stop creating tiles so that any invalidations are left as holes. | 217 // Stop creating tiles so that any invalidations are left as holes. |
| 219 gfx::Size new_layer_size(200, 200); | 218 gfx::Size new_layer_size(200, 200); |
| 220 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 219 scoped_refptr<FakeRasterSource> raster_source = |
| 221 FakeDisplayListRasterSource::CreatePartiallyFilled(new_layer_size, | 220 FakeRasterSource::CreatePartiallyFilled(new_layer_size, gfx::Rect()); |
| 222 gfx::Rect()); | |
| 223 | 221 |
| 224 Region invalidation = | 222 Region invalidation = |
| 225 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 223 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 226 tiling_->SetRasterSourceAndResize(raster_source); | 224 tiling_->SetRasterSourceAndResize(raster_source); |
| 227 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 225 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 228 tiling_->Invalidate(invalidation); | 226 tiling_->Invalidate(invalidation); |
| 229 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 227 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| 230 } | 228 } |
| 231 | 229 |
| 232 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { | 230 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 EXPECT_TRUE(tiling_->TileAt(2, 2)); | 270 EXPECT_TRUE(tiling_->TileAt(2, 2)); |
| 273 EXPECT_TRUE(tiling_->TileAt(2, 3)); | 271 EXPECT_TRUE(tiling_->TileAt(2, 3)); |
| 274 EXPECT_TRUE(tiling_->TileAt(1, 3)); | 272 EXPECT_TRUE(tiling_->TileAt(1, 3)); |
| 275 EXPECT_TRUE(tiling_->TileAt(0, 3)); | 273 EXPECT_TRUE(tiling_->TileAt(0, 3)); |
| 276 | 274 |
| 277 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); | 275 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); |
| 278 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); | 276 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); |
| 279 | 277 |
| 280 // Shrink the tiling so that the last tile row/column is entirely in the | 278 // Shrink the tiling so that the last tile row/column is entirely in the |
| 281 // border pixels of the interior tiles. That row/column is removed. | 279 // border pixels of the interior tiles. That row/column is removed. |
| 282 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 280 scoped_refptr<FakeRasterSource> raster_source = |
| 283 FakeDisplayListRasterSource::CreateFilled( | 281 FakeRasterSource::CreateFilled(gfx::Size(right + 1, bottom + 1)); |
| 284 gfx::Size(right + 1, bottom + 1)); | |
| 285 tiling_->SetRasterSourceAndResize(raster_source); | 282 tiling_->SetRasterSourceAndResize(raster_source); |
| 286 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); | 283 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); |
| 287 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); | 284 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
| 288 | 285 |
| 289 // The live tiles rect was clamped to the raster source size. | 286 // The live tiles rect was clamped to the raster source size. |
| 290 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 287 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
| 291 | 288 |
| 292 // Since the row/column is gone, the tiles should be gone too. | 289 // Since the row/column is gone, the tiles should be gone too. |
| 293 EXPECT_FALSE(tiling_->TileAt(2, 0)); | 290 EXPECT_FALSE(tiling_->TileAt(2, 0)); |
| 294 EXPECT_FALSE(tiling_->TileAt(2, 1)); | 291 EXPECT_FALSE(tiling_->TileAt(2, 1)); |
| 295 EXPECT_FALSE(tiling_->TileAt(2, 2)); | 292 EXPECT_FALSE(tiling_->TileAt(2, 2)); |
| 296 EXPECT_FALSE(tiling_->TileAt(2, 3)); | 293 EXPECT_FALSE(tiling_->TileAt(2, 3)); |
| 297 EXPECT_FALSE(tiling_->TileAt(1, 3)); | 294 EXPECT_FALSE(tiling_->TileAt(1, 3)); |
| 298 EXPECT_FALSE(tiling_->TileAt(0, 3)); | 295 EXPECT_FALSE(tiling_->TileAt(0, 3)); |
| 299 | 296 |
| 300 // Growing outside the current right/bottom tiles border pixels should create | 297 // Growing outside the current right/bottom tiles border pixels should create |
| 301 // the tiles again, even though the live rect has not changed size. | 298 // the tiles again, even though the live rect has not changed size. |
| 302 raster_source = FakeDisplayListRasterSource::CreateFilled( | 299 raster_source = |
| 303 gfx::Size(right + 2, bottom + 2)); | 300 FakeRasterSource::CreateFilled(gfx::Size(right + 2, bottom + 2)); |
| 304 tiling_->SetRasterSourceAndResize(raster_source); | 301 tiling_->SetRasterSourceAndResize(raster_source); |
| 305 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 302 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
| 306 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); | 303 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); |
| 307 | 304 |
| 308 // Not changed. | 305 // Not changed. |
| 309 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 306 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
| 310 | 307 |
| 311 // The last row/column tiles are inside the live tiles rect. | 308 // The last row/column tiles are inside the live tiles rect. |
| 312 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 309 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
| 313 tiling_->TilingDataForTesting().TileBounds(2, 0))); | 310 tiling_->TilingDataForTesting().TileBounds(2, 0))); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // deletes tiles that intersect that invalidation. | 423 // deletes tiles that intersect that invalidation. |
| 427 gfx::Size tile_size(100, 100); | 424 gfx::Size tile_size(100, 100); |
| 428 gfx::Size original_layer_size(99, 99); | 425 gfx::Size original_layer_size(99, 99); |
| 429 InitializeActive(tile_size, 1.f, original_layer_size); | 426 InitializeActive(tile_size, 1.f, original_layer_size); |
| 430 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 427 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 431 | 428 |
| 432 // Tiling only has one tile, since its total size is less than one. | 429 // Tiling only has one tile, since its total size is less than one. |
| 433 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 430 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 434 | 431 |
| 435 // Stop creating tiles so that any invalidations are left as holes. | 432 // Stop creating tiles so that any invalidations are left as holes. |
| 436 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 433 scoped_refptr<FakeRasterSource> raster_source = |
| 437 FakeDisplayListRasterSource::CreatePartiallyFilled(gfx::Size(200, 200), | 434 FakeRasterSource::CreatePartiallyFilled(gfx::Size(200, 200), gfx::Rect()); |
| 438 gfx::Rect()); | |
| 439 tiling_->SetRasterSourceAndResize(raster_source); | 435 tiling_->SetRasterSourceAndResize(raster_source); |
| 440 | 436 |
| 441 Region invalidation = | 437 Region invalidation = |
| 442 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 438 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 443 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 439 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 444 tiling_->Invalidate(invalidation); | 440 tiling_->Invalidate(invalidation); |
| 445 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 441 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| 446 | 442 |
| 447 // 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 |
| 448 // border pixels. | 444 // border pixels. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 TEST(PictureLayerTilingTest, SkewportLimits) { | 574 TEST(PictureLayerTilingTest, SkewportLimits) { |
| 579 FakePictureLayerTilingClient client; | 575 FakePictureLayerTilingClient client; |
| 580 | 576 |
| 581 gfx::Rect viewport(0, 0, 100, 100); | 577 gfx::Rect viewport(0, 0, 100, 100); |
| 582 gfx::Size layer_bounds(200, 200); | 578 gfx::Size layer_bounds(200, 200); |
| 583 | 579 |
| 584 client.SetTileSize(gfx::Size(100, 100)); | 580 client.SetTileSize(gfx::Size(100, 100)); |
| 585 LayerTreeSettings settings; | 581 LayerTreeSettings settings; |
| 586 settings.skewport_extrapolation_limit_in_content_pixels = 75; | 582 settings.skewport_extrapolation_limit_in_content_pixels = 75; |
| 587 | 583 |
| 588 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 584 scoped_refptr<FakeRasterSource> raster_source = |
| 589 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 585 FakeRasterSource::CreateFilled(layer_bounds); |
| 590 scoped_ptr<TestablePictureLayerTiling> tiling = | 586 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 591 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 587 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 592 &client, settings); | 588 &client, settings); |
| 593 | 589 |
| 594 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 590 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 595 | 591 |
| 596 // Move viewport down 50 pixels in 0.5 seconds. | 592 // Move viewport down 50 pixels in 0.5 seconds. |
| 597 gfx::Rect down_skewport = | 593 gfx::Rect down_skewport = |
| 598 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 594 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 599 | 595 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 EXPECT_EQ(175, move_skewport_far.height()); | 658 EXPECT_EQ(175, move_skewport_far.height()); |
| 663 EXPECT_TRUE(move_skewport_far.Contains(gfx::Rect(0, 5000, 100, 100))); | 659 EXPECT_TRUE(move_skewport_far.Contains(gfx::Rect(0, 5000, 100, 100))); |
| 664 } | 660 } |
| 665 | 661 |
| 666 TEST(PictureLayerTilingTest, ComputeSkewportExtremeCases) { | 662 TEST(PictureLayerTilingTest, ComputeSkewportExtremeCases) { |
| 667 FakePictureLayerTilingClient client; | 663 FakePictureLayerTilingClient client; |
| 668 | 664 |
| 669 gfx::Size layer_bounds(200, 200); | 665 gfx::Size layer_bounds(200, 200); |
| 670 client.SetTileSize(gfx::Size(100, 100)); | 666 client.SetTileSize(gfx::Size(100, 100)); |
| 671 LayerTreeSettings settings; | 667 LayerTreeSettings settings; |
| 672 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 668 scoped_refptr<FakeRasterSource> raster_source = |
| 673 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 669 FakeRasterSource::CreateFilled(layer_bounds); |
| 674 scoped_ptr<TestablePictureLayerTiling> tiling = | 670 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 675 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 671 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 676 &client, settings); | 672 &client, settings); |
| 677 | 673 |
| 678 gfx::Rect viewport1(-1918, 255860, 4010, 2356); | 674 gfx::Rect viewport1(-1918, 255860, 4010, 2356); |
| 679 gfx::Rect viewport2(-7088, -91738, 14212, 8350); | 675 gfx::Rect viewport2(-7088, -91738, 14212, 8350); |
| 680 gfx::Rect viewport3(-12730024, -158883296, 24607540, 14454512); | 676 gfx::Rect viewport3(-12730024, -158883296, 24607540, 14454512); |
| 681 double time = 1.0; | 677 double time = 1.0; |
| 682 tiling->ComputeTilePriorityRects(viewport1, 1.f, time, Occlusion()); | 678 tiling->ComputeTilePriorityRects(viewport1, 1.f, time, Occlusion()); |
| 683 time += 0.016; | 679 time += 0.016; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 695 } | 691 } |
| 696 | 692 |
| 697 TEST(PictureLayerTilingTest, ComputeSkewport) { | 693 TEST(PictureLayerTilingTest, ComputeSkewport) { |
| 698 FakePictureLayerTilingClient client; | 694 FakePictureLayerTilingClient client; |
| 699 | 695 |
| 700 gfx::Rect viewport(0, 0, 100, 100); | 696 gfx::Rect viewport(0, 0, 100, 100); |
| 701 gfx::Size layer_bounds(200, 200); | 697 gfx::Size layer_bounds(200, 200); |
| 702 | 698 |
| 703 client.SetTileSize(gfx::Size(100, 100)); | 699 client.SetTileSize(gfx::Size(100, 100)); |
| 704 | 700 |
| 705 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 701 scoped_refptr<FakeRasterSource> raster_source = |
| 706 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 702 FakeRasterSource::CreateFilled(layer_bounds); |
| 707 scoped_ptr<TestablePictureLayerTiling> tiling = | 703 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 708 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 704 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 709 &client, LayerTreeSettings()); | 705 &client, LayerTreeSettings()); |
| 710 | 706 |
| 711 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 707 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 712 | 708 |
| 713 // Move viewport down 50 pixels in 0.5 seconds. | 709 // Move viewport down 50 pixels in 0.5 seconds. |
| 714 gfx::Rect down_skewport = | 710 gfx::Rect down_skewport = |
| 715 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 711 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 716 | 712 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 } | 753 } |
| 758 | 754 |
| 759 TEST(PictureLayerTilingTest, SkewportThroughUpdateTilePriorities) { | 755 TEST(PictureLayerTilingTest, SkewportThroughUpdateTilePriorities) { |
| 760 FakePictureLayerTilingClient client; | 756 FakePictureLayerTilingClient client; |
| 761 | 757 |
| 762 gfx::Rect viewport(0, 0, 100, 100); | 758 gfx::Rect viewport(0, 0, 100, 100); |
| 763 gfx::Size layer_bounds(200, 200); | 759 gfx::Size layer_bounds(200, 200); |
| 764 | 760 |
| 765 client.SetTileSize(gfx::Size(100, 100)); | 761 client.SetTileSize(gfx::Size(100, 100)); |
| 766 | 762 |
| 767 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 763 scoped_refptr<FakeRasterSource> raster_source = |
| 768 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 764 FakeRasterSource::CreateFilled(layer_bounds); |
| 769 scoped_ptr<TestablePictureLayerTiling> tiling = | 765 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 770 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 766 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 771 &client, LayerTreeSettings()); | 767 &client, LayerTreeSettings()); |
| 772 | 768 |
| 773 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 769 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 774 | 770 |
| 775 // Move viewport down 50 pixels in 0.5 seconds. | 771 // Move viewport down 50 pixels in 0.5 seconds. |
| 776 gfx::Rect viewport_50 = gfx::Rect(0, 50, 100, 100); | 772 gfx::Rect viewport_50 = gfx::Rect(0, 50, 100, 100); |
| 777 gfx::Rect skewport_50 = tiling->ComputeSkewport(1.5, viewport_50); | 773 gfx::Rect skewport_50 = tiling->ComputeSkewport(1.5, viewport_50); |
| 778 | 774 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 gfx::Size layer_bounds(1500, 1500); | 827 gfx::Size layer_bounds(1500, 1500); |
| 832 | 828 |
| 833 client.SetTileSize(gfx::Size(10, 10)); | 829 client.SetTileSize(gfx::Size(10, 10)); |
| 834 LayerTreeSettings settings; | 830 LayerTreeSettings settings; |
| 835 | 831 |
| 836 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 832 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
| 837 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 833 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
| 838 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 834 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
| 839 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 835 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
| 840 // tiling. | 836 // tiling. |
| 841 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 837 scoped_refptr<FakeRasterSource> raster_source = |
| 842 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 838 FakeRasterSource::CreateFilled(layer_bounds); |
| 843 scoped_ptr<TestablePictureLayerTiling> tiling = | 839 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 844 TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.25f, raster_source, | 840 TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.25f, raster_source, |
| 845 &client, settings); | 841 &client, settings); |
| 846 tiling->set_resolution(HIGH_RESOLUTION); | 842 tiling->set_resolution(HIGH_RESOLUTION); |
| 847 gfx::Rect viewport_in_content_space = | 843 gfx::Rect viewport_in_content_space = |
| 848 gfx::ScaleToEnclosedRect(viewport, 0.25f); | 844 gfx::ScaleToEnclosedRect(viewport, 0.25f); |
| 849 | 845 |
| 850 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 846 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 851 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 847 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 852 | 848 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 << "Current tile rect is " << geometry_rect.ToString(); | 1101 << "Current tile rect is " << geometry_rect.ToString(); |
| 1106 } | 1102 } |
| 1107 | 1103 |
| 1108 TEST_F(PictureLayerTilingIteratorTest, | 1104 TEST_F(PictureLayerTilingIteratorTest, |
| 1109 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1105 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
| 1110 gfx::Size layer_bounds(10000, 10000); | 1106 gfx::Size layer_bounds(10000, 10000); |
| 1111 client_.SetTileSize(gfx::Size(100, 100)); | 1107 client_.SetTileSize(gfx::Size(100, 100)); |
| 1112 LayerTreeSettings settings; | 1108 LayerTreeSettings settings; |
| 1113 settings.tiling_interest_area_padding = 1; | 1109 settings.tiling_interest_area_padding = 1; |
| 1114 | 1110 |
| 1115 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1111 scoped_refptr<FakeRasterSource> raster_source = |
| 1116 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 1112 FakeRasterSource::CreateFilled(layer_bounds); |
| 1117 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, raster_source, | 1113 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, raster_source, |
| 1118 &client_, settings); | 1114 &client_, settings); |
| 1119 tiling_->set_resolution(HIGH_RESOLUTION); | 1115 tiling_->set_resolution(HIGH_RESOLUTION); |
| 1120 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1116 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1121 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1117 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1122 | 1118 |
| 1123 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1119 gfx::Rect visible_rect(8000, 8000, 50, 50); |
| 1124 | 1120 |
| 1125 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect | 1121 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect |
| 1126 1.f, // current contents scale | 1122 1.f, // current contents scale |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1141 gfx::Size current_layer_bounds(200, 200); | 1137 gfx::Size current_layer_bounds(200, 200); |
| 1142 float current_layer_contents_scale = 1.f; | 1138 float current_layer_contents_scale = 1.f; |
| 1143 gfx::Transform current_screen_transform; | 1139 gfx::Transform current_screen_transform; |
| 1144 double current_frame_time_in_seconds = 1.0; | 1140 double current_frame_time_in_seconds = 1.0; |
| 1145 | 1141 |
| 1146 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1142 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1147 current_screen_transform, device_viewport); | 1143 current_screen_transform, device_viewport); |
| 1148 | 1144 |
| 1149 client.SetTileSize(gfx::Size(100, 100)); | 1145 client.SetTileSize(gfx::Size(100, 100)); |
| 1150 | 1146 |
| 1151 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1147 scoped_refptr<FakeRasterSource> raster_source = |
| 1152 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); | 1148 FakeRasterSource::CreateFilled(current_layer_bounds); |
| 1153 scoped_ptr<TestablePictureLayerTiling> tiling = | 1149 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1154 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1150 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1155 &client, LayerTreeSettings()); | 1151 &client, LayerTreeSettings()); |
| 1156 tiling->set_resolution(HIGH_RESOLUTION); | 1152 tiling->set_resolution(HIGH_RESOLUTION); |
| 1157 | 1153 |
| 1158 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1154 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1159 current_layer_contents_scale, | 1155 current_layer_contents_scale, |
| 1160 current_frame_time_in_seconds, Occlusion()); | 1156 current_frame_time_in_seconds, Occlusion()); |
| 1161 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1157 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 1162 | 1158 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 double current_frame_time_in_seconds = 1.0; | 1192 double current_frame_time_in_seconds = 1.0; |
| 1197 | 1193 |
| 1198 current_screen_transform.Translate(850, 0); | 1194 current_screen_transform.Translate(850, 0); |
| 1199 last_screen_transform = current_screen_transform; | 1195 last_screen_transform = current_screen_transform; |
| 1200 | 1196 |
| 1201 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1197 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1202 current_screen_transform, device_viewport); | 1198 current_screen_transform, device_viewport); |
| 1203 | 1199 |
| 1204 client.SetTileSize(gfx::Size(100, 100)); | 1200 client.SetTileSize(gfx::Size(100, 100)); |
| 1205 | 1201 |
| 1206 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1202 scoped_refptr<FakeRasterSource> raster_source = |
| 1207 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); | 1203 FakeRasterSource::CreateFilled(current_layer_bounds); |
| 1208 scoped_ptr<TestablePictureLayerTiling> tiling = | 1204 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1209 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1205 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1210 &client, LayerTreeSettings()); | 1206 &client, LayerTreeSettings()); |
| 1211 tiling->set_resolution(HIGH_RESOLUTION); | 1207 tiling->set_resolution(HIGH_RESOLUTION); |
| 1212 | 1208 |
| 1213 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1209 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1214 current_layer_contents_scale, | 1210 current_layer_contents_scale, |
| 1215 current_frame_time_in_seconds, Occlusion()); | 1211 current_frame_time_in_seconds, Occlusion()); |
| 1216 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1212 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 1217 | 1213 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 double current_frame_time_in_seconds = 1.0; | 1257 double current_frame_time_in_seconds = 1.0; |
| 1262 | 1258 |
| 1263 current_screen_transform.Translate(705, 505); | 1259 current_screen_transform.Translate(705, 505); |
| 1264 last_screen_transform = current_screen_transform; | 1260 last_screen_transform = current_screen_transform; |
| 1265 | 1261 |
| 1266 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1262 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1267 current_screen_transform, device_viewport); | 1263 current_screen_transform, device_viewport); |
| 1268 | 1264 |
| 1269 client.SetTileSize(gfx::Size(100, 100)); | 1265 client.SetTileSize(gfx::Size(100, 100)); |
| 1270 | 1266 |
| 1271 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1267 scoped_refptr<FakeRasterSource> raster_source = |
| 1272 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); | 1268 FakeRasterSource::CreateFilled(current_layer_bounds); |
| 1273 scoped_ptr<TestablePictureLayerTiling> tiling = | 1269 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1274 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1270 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1275 &client, LayerTreeSettings()); | 1271 &client, LayerTreeSettings()); |
| 1276 tiling->set_resolution(HIGH_RESOLUTION); | 1272 tiling->set_resolution(HIGH_RESOLUTION); |
| 1277 | 1273 |
| 1278 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1274 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1279 current_layer_contents_scale, | 1275 current_layer_contents_scale, |
| 1280 current_frame_time_in_seconds, Occlusion()); | 1276 current_frame_time_in_seconds, Occlusion()); |
| 1281 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1277 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 1282 | 1278 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 // In this configuration, only the top-left tile would be visible. | 1316 // In this configuration, only the top-left tile would be visible. |
| 1321 current_screen_transform.Translate(600, 750); | 1317 current_screen_transform.Translate(600, 750); |
| 1322 current_screen_transform.RotateAboutZAxis(45); | 1318 current_screen_transform.RotateAboutZAxis(45); |
| 1323 last_screen_transform = current_screen_transform; | 1319 last_screen_transform = current_screen_transform; |
| 1324 | 1320 |
| 1325 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1321 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1326 current_screen_transform, device_viewport); | 1322 current_screen_transform, device_viewport); |
| 1327 | 1323 |
| 1328 client.SetTileSize(gfx::Size(100, 100)); | 1324 client.SetTileSize(gfx::Size(100, 100)); |
| 1329 | 1325 |
| 1330 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1326 scoped_refptr<FakeRasterSource> raster_source = |
| 1331 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); | 1327 FakeRasterSource::CreateFilled(current_layer_bounds); |
| 1332 scoped_ptr<TestablePictureLayerTiling> tiling = | 1328 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1333 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1329 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1334 &client, LayerTreeSettings()); | 1330 &client, LayerTreeSettings()); |
| 1335 tiling->set_resolution(HIGH_RESOLUTION); | 1331 tiling->set_resolution(HIGH_RESOLUTION); |
| 1336 | 1332 |
| 1337 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1333 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1338 current_layer_contents_scale, | 1334 current_layer_contents_scale, |
| 1339 current_frame_time_in_seconds, Occlusion()); | 1335 current_frame_time_in_seconds, Occlusion()); |
| 1340 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1336 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 1341 | 1337 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 MathUtil::MapQuad(current_screen_transform, | 1400 MathUtil::MapQuad(current_screen_transform, |
| 1405 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), | 1401 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), |
| 1406 &clipped); | 1402 &clipped); |
| 1407 ASSERT_FALSE(clipped); | 1403 ASSERT_FALSE(clipped); |
| 1408 | 1404 |
| 1409 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1405 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1410 current_screen_transform, device_viewport); | 1406 current_screen_transform, device_viewport); |
| 1411 | 1407 |
| 1412 client.SetTileSize(gfx::Size(100, 100)); | 1408 client.SetTileSize(gfx::Size(100, 100)); |
| 1413 | 1409 |
| 1414 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1410 scoped_refptr<FakeRasterSource> raster_source = |
| 1415 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); | 1411 FakeRasterSource::CreateFilled(current_layer_bounds); |
| 1416 scoped_ptr<TestablePictureLayerTiling> tiling = | 1412 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1417 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1413 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1418 &client, LayerTreeSettings()); | 1414 &client, LayerTreeSettings()); |
| 1419 tiling->set_resolution(HIGH_RESOLUTION); | 1415 tiling->set_resolution(HIGH_RESOLUTION); |
| 1420 | 1416 |
| 1421 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1417 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1422 current_layer_contents_scale, | 1418 current_layer_contents_scale, |
| 1423 current_frame_time_in_seconds, Occlusion()); | 1419 current_frame_time_in_seconds, Occlusion()); |
| 1424 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1420 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 1425 | 1421 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 MathUtil::MapQuad(current_screen_transform, | 1494 MathUtil::MapQuad(current_screen_transform, |
| 1499 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), | 1495 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), |
| 1500 &clipped); | 1496 &clipped); |
| 1501 ASSERT_FALSE(clipped); | 1497 ASSERT_FALSE(clipped); |
| 1502 | 1498 |
| 1503 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1499 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1504 current_screen_transform, device_viewport); | 1500 current_screen_transform, device_viewport); |
| 1505 | 1501 |
| 1506 client.SetTileSize(gfx::Size(100, 100)); | 1502 client.SetTileSize(gfx::Size(100, 100)); |
| 1507 | 1503 |
| 1508 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1504 scoped_refptr<FakeRasterSource> raster_source = |
| 1509 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); | 1505 FakeRasterSource::CreateFilled(current_layer_bounds); |
| 1510 scoped_ptr<TestablePictureLayerTiling> tiling = | 1506 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1511 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1507 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1512 &client, LayerTreeSettings()); | 1508 &client, LayerTreeSettings()); |
| 1513 tiling->set_resolution(HIGH_RESOLUTION); | 1509 tiling->set_resolution(HIGH_RESOLUTION); |
| 1514 | 1510 |
| 1515 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1511 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1516 current_layer_contents_scale, | 1512 current_layer_contents_scale, |
| 1517 current_frame_time_in_seconds, Occlusion()); | 1513 current_frame_time_in_seconds, Occlusion()); |
| 1518 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 1514 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 1519 | 1515 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1558 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
| 1563 current_screen_transform.Translate(1800, 0); | 1559 current_screen_transform.Translate(1800, 0); |
| 1564 last_screen_transform.Translate(2800, 0); | 1560 last_screen_transform.Translate(2800, 0); |
| 1565 | 1561 |
| 1566 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1562 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1567 current_screen_transform, device_viewport); | 1563 current_screen_transform, device_viewport); |
| 1568 | 1564 |
| 1569 client.SetTileSize(gfx::Size(100, 100)); | 1565 client.SetTileSize(gfx::Size(100, 100)); |
| 1570 LayerTreeSettings settings; | 1566 LayerTreeSettings settings; |
| 1571 | 1567 |
| 1572 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1568 scoped_refptr<FakeRasterSource> raster_source = |
| 1573 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); | 1569 FakeRasterSource::CreateFilled(current_layer_bounds); |
| 1574 scoped_ptr<TestablePictureLayerTiling> tiling = | 1570 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1575 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1571 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1576 &client, settings); | 1572 &client, settings); |
| 1577 tiling->set_resolution(HIGH_RESOLUTION); | 1573 tiling->set_resolution(HIGH_RESOLUTION); |
| 1578 | 1574 |
| 1579 // previous ("last") frame | 1575 // previous ("last") frame |
| 1580 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1576 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1581 last_layer_contents_scale, | 1577 last_layer_contents_scale, |
| 1582 last_frame_time_in_seconds, Occlusion()); | 1578 last_frame_time_in_seconds, Occlusion()); |
| 1583 | 1579 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 current_screen_transform.Translate(400, 550); | 1636 current_screen_transform.Translate(400, 550); |
| 1641 current_screen_transform.RotateAboutZAxis(45); | 1637 current_screen_transform.RotateAboutZAxis(45); |
| 1642 | 1638 |
| 1643 last_screen_transform.Translate(400, 550); | 1639 last_screen_transform.Translate(400, 550); |
| 1644 | 1640 |
| 1645 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1641 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1646 current_screen_transform, device_viewport); | 1642 current_screen_transform, device_viewport); |
| 1647 | 1643 |
| 1648 client.SetTileSize(gfx::Size(100, 100)); | 1644 client.SetTileSize(gfx::Size(100, 100)); |
| 1649 | 1645 |
| 1650 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1646 scoped_refptr<FakeRasterSource> raster_source = |
| 1651 FakeDisplayListRasterSource::CreateFilled(current_layer_bounds); | 1647 FakeRasterSource::CreateFilled(current_layer_bounds); |
| 1652 tiling = TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1648 tiling = TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1653 &client, LayerTreeSettings()); | 1649 &client, LayerTreeSettings()); |
| 1654 tiling->set_resolution(HIGH_RESOLUTION); | 1650 tiling->set_resolution(HIGH_RESOLUTION); |
| 1655 | 1651 |
| 1656 // previous ("last") frame | 1652 // previous ("last") frame |
| 1657 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1653 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1658 last_layer_contents_scale, | 1654 last_layer_contents_scale, |
| 1659 last_frame_time_in_seconds, Occlusion()); | 1655 last_frame_time_in_seconds, Occlusion()); |
| 1660 | 1656 |
| 1661 // current frame | 1657 // current frame |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1691 // - Viewport moves back and a new active tiling tile is created. | 1687 // - Viewport moves back and a new active tiling tile is created. |
| 1692 // Result: | 1688 // Result: |
| 1693 // - Recycle tiling does _not_ have the tile in the same location (thus it | 1689 // - Recycle tiling does _not_ have the tile in the same location (thus it |
| 1694 // will be shared next time a pending tiling is created). | 1690 // will be shared next time a pending tiling is created). |
| 1695 | 1691 |
| 1696 FakePictureLayerTilingClient active_client; | 1692 FakePictureLayerTilingClient active_client; |
| 1697 | 1693 |
| 1698 active_client.SetTileSize(gfx::Size(100, 100)); | 1694 active_client.SetTileSize(gfx::Size(100, 100)); |
| 1699 LayerTreeSettings settings; | 1695 LayerTreeSettings settings; |
| 1700 | 1696 |
| 1701 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1697 scoped_refptr<FakeRasterSource> raster_source = |
| 1702 FakeDisplayListRasterSource::CreateFilled(gfx::Size(10000, 10000)); | 1698 FakeRasterSource::CreateFilled(gfx::Size(10000, 10000)); |
| 1703 scoped_ptr<TestablePictureLayerTiling> active_tiling = | 1699 scoped_ptr<TestablePictureLayerTiling> active_tiling = |
| 1704 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1700 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1705 &active_client, settings); | 1701 &active_client, settings); |
| 1706 active_tiling->set_resolution(HIGH_RESOLUTION); | 1702 active_tiling->set_resolution(HIGH_RESOLUTION); |
| 1707 // Create all tiles on this tiling. | 1703 // Create all tiles on this tiling. |
| 1708 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1704 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 1709 Occlusion()); | 1705 Occlusion()); |
| 1710 | 1706 |
| 1711 FakePictureLayerTilingClient recycle_client; | 1707 FakePictureLayerTilingClient recycle_client; |
| 1712 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1708 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 1713 recycle_client.set_twin_tiling(active_tiling.get()); | 1709 recycle_client.set_twin_tiling(active_tiling.get()); |
| 1714 | 1710 |
| 1715 raster_source = | 1711 raster_source = FakeRasterSource::CreateFilled(gfx::Size(10000, 10000)); |
| 1716 FakeDisplayListRasterSource::CreateFilled(gfx::Size(10000, 10000)); | |
| 1717 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = | 1712 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = |
| 1718 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, raster_source, | 1713 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, raster_source, |
| 1719 &recycle_client, settings); | 1714 &recycle_client, settings); |
| 1720 recycle_tiling->set_resolution(HIGH_RESOLUTION); | 1715 recycle_tiling->set_resolution(HIGH_RESOLUTION); |
| 1721 | 1716 |
| 1722 // Create all tiles on the second tiling. All tiles should be shared. | 1717 // Create all tiles on the second tiling. All tiles should be shared. |
| 1723 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1718 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 1724 1.0f, Occlusion()); | 1719 1.0f, Occlusion()); |
| 1725 | 1720 |
| 1726 // Set the second tiling as recycled. | 1721 // Set the second tiling as recycled. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1743 | 1738 |
| 1744 // Ensure that we now have a tile here on both active. | 1739 // Ensure that we now have a tile here on both active. |
| 1745 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1740 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 1746 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 1741 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
| 1747 } | 1742 } |
| 1748 | 1743 |
| 1749 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 1744 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
| 1750 FakePictureLayerTilingClient active_client; | 1745 FakePictureLayerTilingClient active_client; |
| 1751 active_client.SetTileSize(gfx::Size(100, 100)); | 1746 active_client.SetTileSize(gfx::Size(100, 100)); |
| 1752 | 1747 |
| 1753 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1748 scoped_refptr<FakeRasterSource> raster_source = |
| 1754 FakeDisplayListRasterSource::CreateFilled(gfx::Size(100, 100)); | 1749 FakeRasterSource::CreateFilled(gfx::Size(100, 100)); |
| 1755 scoped_ptr<TestablePictureLayerTiling> active_tiling = | 1750 scoped_ptr<TestablePictureLayerTiling> active_tiling = |
| 1756 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, | 1751 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, raster_source, |
| 1757 &active_client, LayerTreeSettings()); | 1752 &active_client, LayerTreeSettings()); |
| 1758 active_tiling->set_resolution(HIGH_RESOLUTION); | 1753 active_tiling->set_resolution(HIGH_RESOLUTION); |
| 1759 // Create all tiles on this tiling. | 1754 // Create all tiles on this tiling. |
| 1760 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1755 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 1761 Occlusion()); | 1756 Occlusion()); |
| 1762 | 1757 |
| 1763 FakePictureLayerTilingClient recycle_client; | 1758 FakePictureLayerTilingClient recycle_client; |
| 1764 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1759 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 1765 recycle_client.set_twin_tiling(active_tiling.get()); | 1760 recycle_client.set_twin_tiling(active_tiling.get()); |
| 1766 | 1761 |
| 1767 LayerTreeSettings settings; | 1762 LayerTreeSettings settings; |
| 1768 | 1763 |
| 1769 raster_source = | 1764 raster_source = FakeRasterSource::CreateFilled(gfx::Size(100, 100)); |
| 1770 FakeDisplayListRasterSource::CreateFilled(gfx::Size(100, 100)); | |
| 1771 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = | 1765 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = |
| 1772 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, raster_source, | 1766 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, raster_source, |
| 1773 &recycle_client, settings); | 1767 &recycle_client, settings); |
| 1774 recycle_tiling->set_resolution(HIGH_RESOLUTION); | 1768 recycle_tiling->set_resolution(HIGH_RESOLUTION); |
| 1775 | 1769 |
| 1776 // Create all tiles on the recycle tiling. All tiles should be shared. | 1770 // Create all tiles on the recycle tiling. All tiles should be shared. |
| 1777 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1771 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 1778 1.0f, Occlusion()); | 1772 1.0f, Occlusion()); |
| 1779 | 1773 |
| 1780 // Set the second tiling as recycled. | 1774 // Set the second tiling as recycled. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1798 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 1792 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 1799 EXPECT_EQ(4u, tiling_->AllTilesForTesting().size()); | 1793 EXPECT_EQ(4u, tiling_->AllTilesForTesting().size()); |
| 1800 | 1794 |
| 1801 client_.SetTileSize(gfx::Size(250, 200)); | 1795 client_.SetTileSize(gfx::Size(250, 200)); |
| 1802 | 1796 |
| 1803 // Tile size in the tiling should still be 150x100. | 1797 // Tile size in the tiling should still be 150x100. |
| 1804 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); | 1798 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 1805 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 1799 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 1806 | 1800 |
| 1807 // The layer's size isn't changed, but the tile size was. | 1801 // The layer's size isn't changed, but the tile size was. |
| 1808 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1802 scoped_refptr<FakeRasterSource> raster_source = |
| 1809 FakeDisplayListRasterSource::CreateFilled(gfx::Size(250, 150)); | 1803 FakeRasterSource::CreateFilled(gfx::Size(250, 150)); |
| 1810 tiling_->SetRasterSourceAndResize(raster_source); | 1804 tiling_->SetRasterSourceAndResize(raster_source); |
| 1811 | 1805 |
| 1812 // Tile size in the tiling should be resized to 250x200. | 1806 // Tile size in the tiling should be resized to 250x200. |
| 1813 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 1807 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 1814 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 1808 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 1815 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); | 1809 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); |
| 1816 } | 1810 } |
| 1817 | 1811 |
| 1818 // This test runs into floating point issues because of big numbers. | 1812 // This test runs into floating point issues because of big numbers. |
| 1819 TEST_F(PictureLayerTilingIteratorTest, GiantRect) { | 1813 TEST_F(PictureLayerTilingIteratorTest, GiantRect) { |
| 1820 gfx::Size tile_size(256, 256); | 1814 gfx::Size tile_size(256, 256); |
| 1821 gfx::Size layer_size(33554432, 33554432); | 1815 gfx::Size layer_size(33554432, 33554432); |
| 1822 float contents_scale = 1.f; | 1816 float contents_scale = 1.f; |
| 1823 | 1817 |
| 1824 client_.SetTileSize(tile_size); | 1818 client_.SetTileSize(tile_size); |
| 1825 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1819 scoped_refptr<FakeRasterSource> raster_source = |
| 1826 FakeDisplayListRasterSource::CreateEmpty(layer_size); | 1820 FakeRasterSource::CreateEmpty(layer_size); |
| 1827 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, | 1821 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, |
| 1828 raster_source, &client_, | 1822 raster_source, &client_, |
| 1829 LayerTreeSettings()); | 1823 LayerTreeSettings()); |
| 1830 | 1824 |
| 1831 gfx::Rect content_rect(25554432, 25554432, 950, 860); | 1825 gfx::Rect content_rect(25554432, 25554432, 950, 860); |
| 1832 VerifyTilesExactlyCoverRect(contents_scale, content_rect); | 1826 VerifyTilesExactlyCoverRect(contents_scale, content_rect); |
| 1833 } | 1827 } |
| 1834 | 1828 |
| 1835 } // namespace | 1829 } // namespace |
| 1836 } // namespace cc | 1830 } // namespace cc |
| OLD | NEW |