| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| 11 #include "cc/resources/picture_layer_tiling_set.h" | 11 #include "cc/resources/picture_layer_tiling_set.h" |
| 12 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
| 13 #include "cc/test/fake_output_surface_client.h" | 13 #include "cc/test/fake_output_surface_client.h" |
| 14 #include "cc/test/fake_picture_layer_tiling_client.h" | 14 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 15 #include "cc/test/fake_picture_pile_impl.h" |
| 15 #include "cc/test/test_context_provider.h" | 16 #include "cc/test/test_context_provider.h" |
| 16 #include "cc/test/test_shared_bitmap_manager.h" | 17 #include "cc/test/test_shared_bitmap_manager.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "ui/gfx/geometry/quad_f.h" | 19 #include "ui/gfx/geometry/quad_f.h" |
| 19 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
| 20 #include "ui/gfx/geometry/size_conversions.h" | 21 #include "ui/gfx/geometry/size_conversions.h" |
| 21 | 22 |
| 22 namespace cc { | 23 namespace cc { |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 return ToEnclosingRect(viewport_in_layer_space); | 36 return ToEnclosingRect(viewport_in_layer_space); |
| 36 } | 37 } |
| 37 | 38 |
| 38 class TestablePictureLayerTiling : public PictureLayerTiling { | 39 class TestablePictureLayerTiling : public PictureLayerTiling { |
| 39 public: | 40 public: |
| 40 using PictureLayerTiling::SetLiveTilesRect; | 41 using PictureLayerTiling::SetLiveTilesRect; |
| 41 using PictureLayerTiling::TileAt; | 42 using PictureLayerTiling::TileAt; |
| 42 | 43 |
| 43 static scoped_ptr<TestablePictureLayerTiling> Create( | 44 static scoped_ptr<TestablePictureLayerTiling> Create( |
| 44 float contents_scale, | 45 float contents_scale, |
| 45 const gfx::Size& layer_bounds, | 46 scoped_refptr<RasterSource> raster_source, |
| 46 PictureLayerTilingClient* client, | 47 PictureLayerTilingClient* client, |
| 47 const LayerTreeSettings& settings) { | 48 const LayerTreeSettings& settings) { |
| 48 return make_scoped_ptr(new TestablePictureLayerTiling( | 49 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 49 contents_scale, layer_bounds, client, | 50 contents_scale, raster_source, client, |
| 50 settings.max_tiles_for_interest_area, | 51 settings.max_tiles_for_interest_area, |
| 51 settings.skewport_target_time_in_seconds, | 52 settings.skewport_target_time_in_seconds, |
| 52 settings.skewport_extrapolation_limit_in_content_pixels)); | 53 settings.skewport_extrapolation_limit_in_content_pixels)); |
| 53 } | 54 } |
| 54 | 55 |
| 55 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 56 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 56 | 57 |
| 57 using PictureLayerTiling::ComputeSkewport; | 58 using PictureLayerTiling::ComputeSkewport; |
| 58 using PictureLayerTiling::RemoveTileAt; | 59 using PictureLayerTiling::RemoveTileAt; |
| 59 | 60 |
| 60 protected: | 61 protected: |
| 61 TestablePictureLayerTiling(float contents_scale, | 62 TestablePictureLayerTiling(float contents_scale, |
| 62 const gfx::Size& layer_bounds, | 63 scoped_refptr<RasterSource> raster_source, |
| 63 PictureLayerTilingClient* client, | 64 PictureLayerTilingClient* client, |
| 64 size_t max_tiles_for_interest_area, | 65 size_t max_tiles_for_interest_area, |
| 65 float skewport_target_time, | 66 float skewport_target_time, |
| 66 int skewport_extrapolation_limit) | 67 int skewport_extrapolation_limit) |
| 67 : PictureLayerTiling(contents_scale, | 68 : PictureLayerTiling(contents_scale, |
| 68 layer_bounds, | 69 raster_source, |
| 69 client, | 70 client, |
| 70 max_tiles_for_interest_area, | 71 max_tiles_for_interest_area, |
| 71 skewport_target_time, | 72 skewport_target_time, |
| 72 skewport_extrapolation_limit) {} | 73 skewport_extrapolation_limit) {} |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 class PictureLayerTilingIteratorTest : public testing::Test { | 76 class PictureLayerTilingIteratorTest : public testing::Test { |
| 76 public: | 77 public: |
| 77 PictureLayerTilingIteratorTest() {} | 78 PictureLayerTilingIteratorTest() {} |
| 78 virtual ~PictureLayerTilingIteratorTest() {} | 79 virtual ~PictureLayerTilingIteratorTest() {} |
| 79 | 80 |
| 80 void Initialize(const gfx::Size& tile_size, | 81 void Initialize(const gfx::Size& tile_size, |
| 81 float contents_scale, | 82 float contents_scale, |
| 82 const gfx::Size& layer_bounds) { | 83 const gfx::Size& layer_bounds) { |
| 83 client_.SetTileSize(tile_size); | 84 client_.SetTileSize(tile_size); |
| 84 client_.set_tree(PENDING_TREE); | 85 client_.set_tree(PENDING_TREE); |
| 85 tiling_ = TestablePictureLayerTiling::Create(contents_scale, layer_bounds, | 86 auto pile = |
| 86 &client_, LayerTreeSettings()); | 87 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 88 tiling_ = TestablePictureLayerTiling::Create(contents_scale, pile, &client_, |
| 89 LayerTreeSettings()); |
| 87 } | 90 } |
| 88 | 91 |
| 89 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { | 92 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { |
| 90 tiling_->SetLiveTilesRect(live_tiles_rect); | 93 tiling_->SetLiveTilesRect(live_tiles_rect); |
| 91 | 94 |
| 92 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 95 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
| 93 for (std::vector<Tile*>::iterator iter = tiles.begin(); | 96 for (std::vector<Tile*>::iterator iter = tiles.begin(); |
| 94 iter != tiles.end(); | 97 iter != tiles.end(); |
| 95 ++iter) { | 98 ++iter) { |
| 96 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); | 99 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // deletes tiles that intersect that invalidation. | 191 // deletes tiles that intersect that invalidation. |
| 189 gfx::Size tile_size(100, 100); | 192 gfx::Size tile_size(100, 100); |
| 190 gfx::Size original_layer_size(10, 10); | 193 gfx::Size original_layer_size(10, 10); |
| 191 Initialize(tile_size, 1.f, original_layer_size); | 194 Initialize(tile_size, 1.f, original_layer_size); |
| 192 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 195 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 193 | 196 |
| 194 // Tiling only has one tile, since its total size is less than one. | 197 // Tiling only has one tile, since its total size is less than one. |
| 195 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 198 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 196 | 199 |
| 197 // Stop creating tiles so that any invalidations are left as holes. | 200 // Stop creating tiles so that any invalidations are left as holes. |
| 198 client_.set_allow_create_tile(false); | 201 gfx::Size new_layer_size(200, 200); |
| 202 auto pile = |
| 203 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(new_layer_size); |
| 199 | 204 |
| 200 Region invalidation = | 205 Region invalidation = |
| 201 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 206 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 202 tiling_->Resize(gfx::Size(200, 200)); | 207 tiling_->SetRasterSourceAndResize(pile); |
| 203 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 208 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 204 tiling_->Invalidate(invalidation); | 209 tiling_->Invalidate(invalidation); |
| 205 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 210 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| 206 } | 211 } |
| 207 | 212 |
| 208 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { | 213 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { |
| 209 // The tiling has three rows and columns. | 214 // The tiling has three rows and columns. |
| 210 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 250)); | 215 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 250)); |
| 211 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 216 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
| 212 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); | 217 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 EXPECT_TRUE(tiling_->TileAt(2, 2)); | 253 EXPECT_TRUE(tiling_->TileAt(2, 2)); |
| 249 EXPECT_TRUE(tiling_->TileAt(2, 3)); | 254 EXPECT_TRUE(tiling_->TileAt(2, 3)); |
| 250 EXPECT_TRUE(tiling_->TileAt(1, 3)); | 255 EXPECT_TRUE(tiling_->TileAt(1, 3)); |
| 251 EXPECT_TRUE(tiling_->TileAt(0, 3)); | 256 EXPECT_TRUE(tiling_->TileAt(0, 3)); |
| 252 | 257 |
| 253 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); | 258 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); |
| 254 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); | 259 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); |
| 255 | 260 |
| 256 // Shrink the tiling so that the last tile row/column is entirely in the | 261 // Shrink the tiling so that the last tile row/column is entirely in the |
| 257 // border pixels of the interior tiles. That row/column is removed. | 262 // border pixels of the interior tiles. That row/column is removed. |
| 258 tiling_->Resize(gfx::Size(right + 1, bottom + 1)); | 263 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 264 gfx::Size(right + 1, bottom + 1)); |
| 265 tiling_->SetRasterSourceAndResize(pile); |
| 259 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); | 266 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); |
| 260 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); | 267 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
| 261 | 268 |
| 262 // The live tiles rect was clamped to the pile size. | 269 // The live tiles rect was clamped to the pile size. |
| 263 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 270 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
| 264 | 271 |
| 265 // Since the row/column is gone, the tiles should be gone too. | 272 // Since the row/column is gone, the tiles should be gone too. |
| 266 EXPECT_FALSE(tiling_->TileAt(2, 0)); | 273 EXPECT_FALSE(tiling_->TileAt(2, 0)); |
| 267 EXPECT_FALSE(tiling_->TileAt(2, 1)); | 274 EXPECT_FALSE(tiling_->TileAt(2, 1)); |
| 268 EXPECT_FALSE(tiling_->TileAt(2, 2)); | 275 EXPECT_FALSE(tiling_->TileAt(2, 2)); |
| 269 EXPECT_FALSE(tiling_->TileAt(2, 3)); | 276 EXPECT_FALSE(tiling_->TileAt(2, 3)); |
| 270 EXPECT_FALSE(tiling_->TileAt(1, 3)); | 277 EXPECT_FALSE(tiling_->TileAt(1, 3)); |
| 271 EXPECT_FALSE(tiling_->TileAt(0, 3)); | 278 EXPECT_FALSE(tiling_->TileAt(0, 3)); |
| 272 | 279 |
| 273 // Growing outside the current right/bottom tiles border pixels should create | 280 // Growing outside the current right/bottom tiles border pixels should create |
| 274 // the tiles again, even though the live rect has not changed size. | 281 // the tiles again, even though the live rect has not changed size. |
| 275 tiling_->Resize(gfx::Size(right + 2, bottom + 2)); | 282 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 283 gfx::Size(right + 2, bottom + 2)); |
| 284 tiling_->SetRasterSourceAndResize(pile); |
| 276 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 285 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
| 277 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); | 286 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); |
| 278 | 287 |
| 279 // Not changed. | 288 // Not changed. |
| 280 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 289 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
| 281 | 290 |
| 282 // The last row/column tiles are inside the live tiles rect. | 291 // The last row/column tiles are inside the live tiles rect. |
| 283 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 292 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
| 284 tiling_->TilingDataForTesting().TileBounds(2, 0))); | 293 tiling_->TilingDataForTesting().TileBounds(2, 0))); |
| 285 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 294 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // deletes tiles that intersect that invalidation. | 406 // deletes tiles that intersect that invalidation. |
| 398 gfx::Size tile_size(100, 100); | 407 gfx::Size tile_size(100, 100); |
| 399 gfx::Size original_layer_size(99, 99); | 408 gfx::Size original_layer_size(99, 99); |
| 400 Initialize(tile_size, 1.f, original_layer_size); | 409 Initialize(tile_size, 1.f, original_layer_size); |
| 401 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 410 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 402 | 411 |
| 403 // Tiling only has one tile, since its total size is less than one. | 412 // Tiling only has one tile, since its total size is less than one. |
| 404 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 413 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 405 | 414 |
| 406 // Stop creating tiles so that any invalidations are left as holes. | 415 // Stop creating tiles so that any invalidations are left as holes. |
| 407 client_.set_allow_create_tile(false); | 416 auto pile = FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize( |
| 417 gfx::Size(200, 200)); |
| 418 tiling_->SetRasterSourceAndResize(pile); |
| 408 | 419 |
| 409 Region invalidation = | 420 Region invalidation = |
| 410 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 421 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 411 tiling_->Resize(gfx::Size(200, 200)); | |
| 412 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 422 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 413 tiling_->Invalidate(invalidation); | 423 tiling_->Invalidate(invalidation); |
| 414 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 424 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| 415 | 425 |
| 416 // The original tile was the same size after resize, but it would include new | 426 // The original tile was the same size after resize, but it would include new |
| 417 // border pixels. | 427 // border pixels. |
| 418 EXPECT_EQ(gfx::Rect(original_layer_size), | 428 EXPECT_EQ(gfx::Rect(original_layer_size), |
| 419 tiling_->TilingDataForTesting().TileBounds(0, 0)); | 429 tiling_->TilingDataForTesting().TileBounds(0, 0)); |
| 420 } | 430 } |
| 421 | 431 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 526 |
| 517 // Partially covering content, but too large | 527 // Partially covering content, but too large |
| 518 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); | 528 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); |
| 519 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); | 529 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); |
| 520 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); | 530 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); |
| 521 } | 531 } |
| 522 | 532 |
| 523 TEST(PictureLayerTilingTest, SkewportLimits) { | 533 TEST(PictureLayerTilingTest, SkewportLimits) { |
| 524 FakePictureLayerTilingClient client; | 534 FakePictureLayerTilingClient client; |
| 525 client.set_tree(ACTIVE_TREE); | 535 client.set_tree(ACTIVE_TREE); |
| 526 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 527 | 536 |
| 528 gfx::Rect viewport(0, 0, 100, 100); | 537 gfx::Rect viewport(0, 0, 100, 100); |
| 529 gfx::Size layer_bounds(200, 200); | 538 gfx::Size layer_bounds(200, 200); |
| 530 | 539 |
| 531 client.SetTileSize(gfx::Size(100, 100)); | 540 client.SetTileSize(gfx::Size(100, 100)); |
| 532 LayerTreeSettings settings; | 541 LayerTreeSettings settings; |
| 533 settings.max_tiles_for_interest_area = 10000; | 542 settings.max_tiles_for_interest_area = 10000; |
| 534 settings.skewport_extrapolation_limit_in_content_pixels = 75; | 543 settings.skewport_extrapolation_limit_in_content_pixels = 75; |
| 535 tiling = | 544 |
| 536 TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, settings); | 545 auto pile = |
| 546 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 547 auto tiling = |
| 548 TestablePictureLayerTiling::Create(1.0f, pile, &client, settings); |
| 537 | 549 |
| 538 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 550 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 539 | 551 |
| 540 // Move viewport down 50 pixels in 0.5 seconds. | 552 // Move viewport down 50 pixels in 0.5 seconds. |
| 541 gfx::Rect down_skewport = | 553 gfx::Rect down_skewport = |
| 542 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 554 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 543 | 555 |
| 544 EXPECT_EQ(0, down_skewport.x()); | 556 EXPECT_EQ(0, down_skewport.x()); |
| 545 EXPECT_EQ(50, down_skewport.y()); | 557 EXPECT_EQ(50, down_skewport.y()); |
| 546 EXPECT_EQ(100, down_skewport.width()); | 558 EXPECT_EQ(100, down_skewport.width()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 | 597 |
| 586 EXPECT_EQ(-575, big_expand_skewport.x()); | 598 EXPECT_EQ(-575, big_expand_skewport.x()); |
| 587 EXPECT_EQ(-575, big_expand_skewport.y()); | 599 EXPECT_EQ(-575, big_expand_skewport.y()); |
| 588 EXPECT_EQ(1650, big_expand_skewport.width()); | 600 EXPECT_EQ(1650, big_expand_skewport.width()); |
| 589 EXPECT_EQ(1650, big_expand_skewport.height()); | 601 EXPECT_EQ(1650, big_expand_skewport.height()); |
| 590 EXPECT_TRUE(big_expand_skewport.Contains(gfx::Rect(-500, -500, 1500, 1500))); | 602 EXPECT_TRUE(big_expand_skewport.Contains(gfx::Rect(-500, -500, 1500, 1500))); |
| 591 } | 603 } |
| 592 | 604 |
| 593 TEST(PictureLayerTilingTest, ComputeSkewport) { | 605 TEST(PictureLayerTilingTest, ComputeSkewport) { |
| 594 FakePictureLayerTilingClient client; | 606 FakePictureLayerTilingClient client; |
| 595 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 596 | 607 |
| 597 gfx::Rect viewport(0, 0, 100, 100); | 608 gfx::Rect viewport(0, 0, 100, 100); |
| 598 gfx::Size layer_bounds(200, 200); | 609 gfx::Size layer_bounds(200, 200); |
| 599 | 610 |
| 600 client.SetTileSize(gfx::Size(100, 100)); | 611 client.SetTileSize(gfx::Size(100, 100)); |
| 601 client.set_tree(ACTIVE_TREE); | 612 client.set_tree(ACTIVE_TREE); |
| 602 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, | 613 |
| 603 LayerTreeSettings()); | 614 auto pile = |
| 615 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 616 auto tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 617 LayerTreeSettings()); |
| 604 | 618 |
| 605 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 619 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 606 | 620 |
| 607 // Move viewport down 50 pixels in 0.5 seconds. | 621 // Move viewport down 50 pixels in 0.5 seconds. |
| 608 gfx::Rect down_skewport = | 622 gfx::Rect down_skewport = |
| 609 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 623 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 610 | 624 |
| 611 EXPECT_EQ(0, down_skewport.x()); | 625 EXPECT_EQ(0, down_skewport.x()); |
| 612 EXPECT_EQ(50, down_skewport.y()); | 626 EXPECT_EQ(50, down_skewport.y()); |
| 613 EXPECT_EQ(100, down_skewport.width()); | 627 EXPECT_EQ(100, down_skewport.width()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 tiling->ComputeSkewport(1.2, gfx::Rect(-5, -5, 110, 110)); | 659 tiling->ComputeSkewport(1.2, gfx::Rect(-5, -5, 110, 110)); |
| 646 | 660 |
| 647 EXPECT_EQ(-30, expanded_skewport.x()); | 661 EXPECT_EQ(-30, expanded_skewport.x()); |
| 648 EXPECT_EQ(-30, expanded_skewport.y()); | 662 EXPECT_EQ(-30, expanded_skewport.y()); |
| 649 EXPECT_EQ(160, expanded_skewport.width()); | 663 EXPECT_EQ(160, expanded_skewport.width()); |
| 650 EXPECT_EQ(160, expanded_skewport.height()); | 664 EXPECT_EQ(160, expanded_skewport.height()); |
| 651 } | 665 } |
| 652 | 666 |
| 653 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { | 667 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
| 654 FakePictureLayerTilingClient client; | 668 FakePictureLayerTilingClient client; |
| 655 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 656 | 669 |
| 657 gfx::Rect viewport(0, 0, 100, 100); | 670 gfx::Rect viewport(0, 0, 100, 100); |
| 658 gfx::Size layer_bounds(1500, 1500); | 671 gfx::Size layer_bounds(1500, 1500); |
| 659 | 672 |
| 660 client.SetTileSize(gfx::Size(10, 10)); | 673 client.SetTileSize(gfx::Size(10, 10)); |
| 661 client.set_tree(ACTIVE_TREE); | 674 client.set_tree(ACTIVE_TREE); |
| 662 LayerTreeSettings settings; | 675 LayerTreeSettings settings; |
| 663 settings.max_tiles_for_interest_area = 10000; | 676 settings.max_tiles_for_interest_area = 10000; |
| 664 | 677 |
| 665 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 678 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
| 666 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 679 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
| 667 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 680 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
| 668 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 681 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
| 669 // tiling. | 682 // tiling. |
| 670 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client, | 683 auto pile = |
| 671 settings); | 684 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 685 auto tiling = |
| 686 TestablePictureLayerTiling::Create(0.25f, pile, &client, settings); |
| 672 gfx::Rect viewport_in_content_space = | 687 gfx::Rect viewport_in_content_space = |
| 673 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); | 688 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); |
| 674 | 689 |
| 675 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 690 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 676 tiling->UpdateAllTilePrioritiesForTesting(); | 691 tiling->UpdateAllTilePrioritiesForTesting(); |
| 677 | 692 |
| 678 gfx::Rect soon_rect = viewport; | 693 gfx::Rect soon_rect = viewport; |
| 679 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 694 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 680 gfx::Rect soon_rect_in_content_space = | 695 gfx::Rect soon_rect_in_content_space = |
| 681 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); | 696 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 830 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 816 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); | 831 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); |
| 817 | 832 |
| 818 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 833 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 819 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); | 834 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
| 820 | 835 |
| 821 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 836 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
| 822 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); | 837 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
| 823 | 838 |
| 824 // Test additional scales. | 839 // Test additional scales. |
| 825 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client, | 840 tiling = TestablePictureLayerTiling::Create(0.2f, pile, &client, |
| 826 LayerTreeSettings()); | 841 LayerTreeSettings()); |
| 827 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); | 842 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); |
| 828 tiling->UpdateAllTilePrioritiesForTesting(); | 843 tiling->UpdateAllTilePrioritiesForTesting(); |
| 829 | 844 |
| 830 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 845 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 831 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); | 846 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); |
| 832 | 847 |
| 833 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 848 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 834 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); | 849 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); |
| 835 | 850 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 gfx::Rect in(40, 40, 0, 0); | 1081 gfx::Rect in(40, 40, 0, 0); |
| 1067 gfx::Rect bounds(0, 0, 10, 10); | 1082 gfx::Rect bounds(0, 0, 10, 10); |
| 1068 int64 target_area = 400 * 400; | 1083 int64 target_area = 400 * 400; |
| 1069 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 1084 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| 1070 in, target_area, bounds, NULL); | 1085 in, target_area, bounds, NULL); |
| 1071 EXPECT_TRUE(out.IsEmpty()); | 1086 EXPECT_TRUE(out.IsEmpty()); |
| 1072 } | 1087 } |
| 1073 | 1088 |
| 1074 TEST(PictureLayerTilingTest, TilingRasterTileIteratorStaticViewport) { | 1089 TEST(PictureLayerTilingTest, TilingRasterTileIteratorStaticViewport) { |
| 1075 FakePictureLayerTilingClient client; | 1090 FakePictureLayerTilingClient client; |
| 1076 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1077 | 1091 |
| 1078 gfx::Rect viewport(50, 50, 100, 100); | 1092 gfx::Rect viewport(50, 50, 100, 100); |
| 1079 gfx::Size layer_bounds(800, 800); | 1093 gfx::Size layer_bounds(800, 800); |
| 1080 | 1094 |
| 1081 gfx::Rect soon_rect = viewport; | 1095 gfx::Rect soon_rect = viewport; |
| 1082 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1096 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1083 | 1097 |
| 1084 client.SetTileSize(gfx::Size(30, 30)); | 1098 client.SetTileSize(gfx::Size(30, 30)); |
| 1085 client.set_tree(ACTIVE_TREE); | 1099 client.set_tree(ACTIVE_TREE); |
| 1086 LayerTreeSettings settings; | 1100 LayerTreeSettings settings; |
| 1087 settings.max_tiles_for_interest_area = 10000; | 1101 settings.max_tiles_for_interest_area = 10000; |
| 1088 | 1102 |
| 1089 tiling = | 1103 auto pile = |
| 1090 TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, settings); | 1104 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1105 auto tiling = |
| 1106 TestablePictureLayerTiling::Create(1.0f, pile, &client, settings); |
| 1091 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1107 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
| 1092 tiling->UpdateAllTilePrioritiesForTesting(); | 1108 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1093 | 1109 |
| 1094 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1110 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
| 1095 EXPECT_FALSE(empty_iterator); | 1111 EXPECT_FALSE(empty_iterator); |
| 1096 | 1112 |
| 1097 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1113 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1098 | 1114 |
| 1099 // Sanity check. | 1115 // Sanity check. |
| 1100 EXPECT_EQ(841u, all_tiles.size()); | 1116 EXPECT_EQ(841u, all_tiles.size()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1192 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1177 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1193 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1178 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1194 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1179 | 1195 |
| 1180 EXPECT_EQ(unique_tiles.size(), all_tiles.size()); | 1196 EXPECT_EQ(unique_tiles.size(), all_tiles.size()); |
| 1181 } | 1197 } |
| 1182 } | 1198 } |
| 1183 | 1199 |
| 1184 TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) { | 1200 TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) { |
| 1185 FakePictureLayerTilingClient client; | 1201 FakePictureLayerTilingClient client; |
| 1186 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1187 | 1202 |
| 1188 gfx::Rect viewport(50, 0, 100, 100); | 1203 gfx::Rect viewport(50, 0, 100, 100); |
| 1189 gfx::Rect moved_viewport(50, 0, 100, 500); | 1204 gfx::Rect moved_viewport(50, 0, 100, 500); |
| 1190 gfx::Size layer_bounds(1000, 1000); | 1205 gfx::Size layer_bounds(1000, 1000); |
| 1191 | 1206 |
| 1192 client.SetTileSize(gfx::Size(30, 30)); | 1207 client.SetTileSize(gfx::Size(30, 30)); |
| 1193 client.set_tree(ACTIVE_TREE); | 1208 client.set_tree(ACTIVE_TREE); |
| 1194 LayerTreeSettings settings; | 1209 LayerTreeSettings settings; |
| 1195 settings.max_tiles_for_interest_area = 10000; | 1210 settings.max_tiles_for_interest_area = 10000; |
| 1196 | 1211 |
| 1197 tiling = | 1212 auto pile = |
| 1198 TestablePictureLayerTiling::Create(1.f, layer_bounds, &client, settings); | 1213 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1214 auto tiling = |
| 1215 TestablePictureLayerTiling::Create(1.f, pile, &client, settings); |
| 1199 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1216 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
| 1200 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); | 1217 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); |
| 1201 tiling->UpdateAllTilePrioritiesForTesting(); | 1218 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1202 | 1219 |
| 1203 gfx::Rect soon_rect = moved_viewport; | 1220 gfx::Rect soon_rect = moved_viewport; |
| 1204 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1221 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1205 | 1222 |
| 1206 // There are 3 bins in TilePriority. | 1223 // There are 3 bins in TilePriority. |
| 1207 bool have_tiles[3] = {}; | 1224 bool have_tiles[3] = {}; |
| 1208 Tile* last_tile = NULL; | 1225 Tile* last_tile = NULL; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 } | 1345 } |
| 1329 | 1346 |
| 1330 TEST_F(PictureLayerTilingIteratorTest, | 1347 TEST_F(PictureLayerTilingIteratorTest, |
| 1331 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1348 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
| 1332 gfx::Size layer_bounds(10000, 10000); | 1349 gfx::Size layer_bounds(10000, 10000); |
| 1333 client_.SetTileSize(gfx::Size(100, 100)); | 1350 client_.SetTileSize(gfx::Size(100, 100)); |
| 1334 client_.set_tree(PENDING_TREE); | 1351 client_.set_tree(PENDING_TREE); |
| 1335 LayerTreeSettings settings; | 1352 LayerTreeSettings settings; |
| 1336 settings.max_tiles_for_interest_area = 1; | 1353 settings.max_tiles_for_interest_area = 1; |
| 1337 | 1354 |
| 1338 tiling_ = | 1355 auto pile = |
| 1339 TestablePictureLayerTiling::Create(1.f, layer_bounds, &client_, settings); | 1356 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1357 tiling_ = TestablePictureLayerTiling::Create(1.f, pile, &client_, settings); |
| 1340 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1358 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1341 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1359 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1342 | 1360 |
| 1343 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1361 gfx::Rect visible_rect(8000, 8000, 50, 50); |
| 1344 | 1362 |
| 1345 client_.set_tree(ACTIVE_TREE); | 1363 client_.set_tree(ACTIVE_TREE); |
| 1346 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect | 1364 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect |
| 1347 1.f, // current contents scale | 1365 1.f, // current contents scale |
| 1348 1.0, // current frame time | 1366 1.0, // current frame time |
| 1349 Occlusion()); | 1367 Occlusion()); |
| 1350 VerifyTiles(1.f, | 1368 VerifyTiles(1.f, |
| 1351 gfx::Rect(layer_bounds), | 1369 gfx::Rect(layer_bounds), |
| 1352 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); | 1370 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); |
| 1353 } | 1371 } |
| 1354 | 1372 |
| 1355 TEST(ComputeTilePriorityRectsTest, VisibleTiles) { | 1373 TEST(ComputeTilePriorityRectsTest, VisibleTiles) { |
| 1356 // The TilePriority of visible tiles should have zero distance_to_visible | 1374 // The TilePriority of visible tiles should have zero distance_to_visible |
| 1357 // and time_to_visible. | 1375 // and time_to_visible. |
| 1358 | |
| 1359 FakePictureLayerTilingClient client; | 1376 FakePictureLayerTilingClient client; |
| 1360 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1361 | 1377 |
| 1362 gfx::Size device_viewport(800, 600); | 1378 gfx::Size device_viewport(800, 600); |
| 1363 gfx::Size last_layer_bounds(200, 200); | 1379 gfx::Size last_layer_bounds(200, 200); |
| 1364 gfx::Size current_layer_bounds(200, 200); | 1380 gfx::Size current_layer_bounds(200, 200); |
| 1365 float current_layer_contents_scale = 1.f; | 1381 float current_layer_contents_scale = 1.f; |
| 1366 gfx::Transform current_screen_transform; | 1382 gfx::Transform current_screen_transform; |
| 1367 double current_frame_time_in_seconds = 1.0; | 1383 double current_frame_time_in_seconds = 1.0; |
| 1368 | 1384 |
| 1369 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1385 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1370 current_screen_transform, device_viewport); | 1386 current_screen_transform, device_viewport); |
| 1371 | 1387 |
| 1372 client.SetTileSize(gfx::Size(100, 100)); | 1388 client.SetTileSize(gfx::Size(100, 100)); |
| 1373 client.set_tree(ACTIVE_TREE); | 1389 client.set_tree(ACTIVE_TREE); |
| 1374 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1390 |
| 1375 current_layer_bounds, &client, | 1391 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1376 LayerTreeSettings()); | 1392 current_layer_bounds); |
| 1393 auto tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1394 LayerTreeSettings()); |
| 1377 | 1395 |
| 1378 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1396 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1379 current_layer_contents_scale, | 1397 current_layer_contents_scale, |
| 1380 current_frame_time_in_seconds, Occlusion()); | 1398 current_frame_time_in_seconds, Occlusion()); |
| 1381 tiling->UpdateAllTilePrioritiesForTesting(); | 1399 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1382 | 1400 |
| 1383 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1401 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1384 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1402 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1385 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1403 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1386 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1404 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1398 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1416 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1399 | 1417 |
| 1400 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1418 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1401 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1419 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| 1402 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1420 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1403 } | 1421 } |
| 1404 | 1422 |
| 1405 TEST(ComputeTilePriorityRectsTest, OffscreenTiles) { | 1423 TEST(ComputeTilePriorityRectsTest, OffscreenTiles) { |
| 1406 // The TilePriority of offscreen tiles (without movement) should have nonzero | 1424 // The TilePriority of offscreen tiles (without movement) should have nonzero |
| 1407 // distance_to_visible and infinite time_to_visible. | 1425 // distance_to_visible and infinite time_to_visible. |
| 1408 | |
| 1409 FakePictureLayerTilingClient client; | 1426 FakePictureLayerTilingClient client; |
| 1410 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1411 | 1427 |
| 1412 gfx::Size device_viewport(800, 600); | 1428 gfx::Size device_viewport(800, 600); |
| 1413 gfx::Size last_layer_bounds(200, 200); | 1429 gfx::Size last_layer_bounds(200, 200); |
| 1414 gfx::Size current_layer_bounds(200, 200); | 1430 gfx::Size current_layer_bounds(200, 200); |
| 1415 float current_layer_contents_scale = 1.f; | 1431 float current_layer_contents_scale = 1.f; |
| 1416 gfx::Transform last_screen_transform; | 1432 gfx::Transform last_screen_transform; |
| 1417 gfx::Transform current_screen_transform; | 1433 gfx::Transform current_screen_transform; |
| 1418 double current_frame_time_in_seconds = 1.0; | 1434 double current_frame_time_in_seconds = 1.0; |
| 1419 | 1435 |
| 1420 current_screen_transform.Translate(850, 0); | 1436 current_screen_transform.Translate(850, 0); |
| 1421 last_screen_transform = current_screen_transform; | 1437 last_screen_transform = current_screen_transform; |
| 1422 | 1438 |
| 1423 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1439 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1424 current_screen_transform, device_viewport); | 1440 current_screen_transform, device_viewport); |
| 1425 | 1441 |
| 1426 client.SetTileSize(gfx::Size(100, 100)); | 1442 client.SetTileSize(gfx::Size(100, 100)); |
| 1427 client.set_tree(ACTIVE_TREE); | 1443 client.set_tree(ACTIVE_TREE); |
| 1428 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1444 |
| 1429 current_layer_bounds, &client, | 1445 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1430 LayerTreeSettings()); | 1446 current_layer_bounds); |
| 1447 auto tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1448 LayerTreeSettings()); |
| 1431 | 1449 |
| 1432 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1450 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1433 current_layer_contents_scale, | 1451 current_layer_contents_scale, |
| 1434 current_frame_time_in_seconds, Occlusion()); | 1452 current_frame_time_in_seconds, Occlusion()); |
| 1435 tiling->UpdateAllTilePrioritiesForTesting(); | 1453 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1436 | 1454 |
| 1437 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1455 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1438 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1456 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1439 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1457 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1440 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1458 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1462 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); | 1480 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); |
| 1463 | 1481 |
| 1464 left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 1482 left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
| 1465 right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1483 right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1466 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); | 1484 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); |
| 1467 } | 1485 } |
| 1468 | 1486 |
| 1469 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenLayer) { | 1487 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenLayer) { |
| 1470 // Sanity check that a layer with some tiles visible and others offscreen has | 1488 // Sanity check that a layer with some tiles visible and others offscreen has |
| 1471 // correct TilePriorities for each tile. | 1489 // correct TilePriorities for each tile. |
| 1472 | |
| 1473 FakePictureLayerTilingClient client; | 1490 FakePictureLayerTilingClient client; |
| 1474 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1475 | 1491 |
| 1476 gfx::Size device_viewport(800, 600); | 1492 gfx::Size device_viewport(800, 600); |
| 1477 gfx::Size last_layer_bounds(200, 200); | 1493 gfx::Size last_layer_bounds(200, 200); |
| 1478 gfx::Size current_layer_bounds(200, 200); | 1494 gfx::Size current_layer_bounds(200, 200); |
| 1479 float current_layer_contents_scale = 1.f; | 1495 float current_layer_contents_scale = 1.f; |
| 1480 gfx::Transform last_screen_transform; | 1496 gfx::Transform last_screen_transform; |
| 1481 gfx::Transform current_screen_transform; | 1497 gfx::Transform current_screen_transform; |
| 1482 double current_frame_time_in_seconds = 1.0; | 1498 double current_frame_time_in_seconds = 1.0; |
| 1483 | 1499 |
| 1484 current_screen_transform.Translate(705, 505); | 1500 current_screen_transform.Translate(705, 505); |
| 1485 last_screen_transform = current_screen_transform; | 1501 last_screen_transform = current_screen_transform; |
| 1486 | 1502 |
| 1487 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1503 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1488 current_screen_transform, device_viewport); | 1504 current_screen_transform, device_viewport); |
| 1489 | 1505 |
| 1490 client.SetTileSize(gfx::Size(100, 100)); | 1506 client.SetTileSize(gfx::Size(100, 100)); |
| 1491 client.set_tree(ACTIVE_TREE); | 1507 client.set_tree(ACTIVE_TREE); |
| 1492 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1508 |
| 1493 current_layer_bounds, &client, | 1509 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1494 LayerTreeSettings()); | 1510 current_layer_bounds); |
| 1511 auto tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1512 LayerTreeSettings()); |
| 1495 | 1513 |
| 1496 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1514 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1497 current_layer_contents_scale, | 1515 current_layer_contents_scale, |
| 1498 current_frame_time_in_seconds, Occlusion()); | 1516 current_frame_time_in_seconds, Occlusion()); |
| 1499 tiling->UpdateAllTilePrioritiesForTesting(); | 1517 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1500 | 1518 |
| 1501 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1519 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1502 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1520 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1503 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1521 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1504 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1522 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1517 | 1535 |
| 1518 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1536 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1519 EXPECT_GT(priority.distance_to_visible, 0.f); | 1537 EXPECT_GT(priority.distance_to_visible, 0.f); |
| 1520 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1538 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 1521 } | 1539 } |
| 1522 | 1540 |
| 1523 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenRotatedLayer) { | 1541 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenRotatedLayer) { |
| 1524 // Each tile of a layer may be affected differently by a transform; Check | 1542 // Each tile of a layer may be affected differently by a transform; Check |
| 1525 // that ComputeTilePriorityRects correctly accounts for the transform between | 1543 // that ComputeTilePriorityRects correctly accounts for the transform between |
| 1526 // layer space and screen space. | 1544 // layer space and screen space. |
| 1527 | |
| 1528 FakePictureLayerTilingClient client; | 1545 FakePictureLayerTilingClient client; |
| 1529 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1530 | 1546 |
| 1531 gfx::Size device_viewport(800, 600); | 1547 gfx::Size device_viewport(800, 600); |
| 1532 gfx::Size last_layer_bounds(200, 200); | 1548 gfx::Size last_layer_bounds(200, 200); |
| 1533 gfx::Size current_layer_bounds(200, 200); | 1549 gfx::Size current_layer_bounds(200, 200); |
| 1534 float current_layer_contents_scale = 1.f; | 1550 float current_layer_contents_scale = 1.f; |
| 1535 gfx::Transform last_screen_transform; | 1551 gfx::Transform last_screen_transform; |
| 1536 gfx::Transform current_screen_transform; | 1552 gfx::Transform current_screen_transform; |
| 1537 double current_frame_time_in_seconds = 1.0; | 1553 double current_frame_time_in_seconds = 1.0; |
| 1538 | 1554 |
| 1539 // A diagonally rotated layer that is partially off the bottom of the screen. | 1555 // A diagonally rotated layer that is partially off the bottom of the screen. |
| 1540 // In this configuration, only the top-left tile would be visible. | 1556 // In this configuration, only the top-left tile would be visible. |
| 1541 current_screen_transform.Translate(600, 750); | 1557 current_screen_transform.Translate(600, 750); |
| 1542 current_screen_transform.RotateAboutZAxis(45); | 1558 current_screen_transform.RotateAboutZAxis(45); |
| 1543 last_screen_transform = current_screen_transform; | 1559 last_screen_transform = current_screen_transform; |
| 1544 | 1560 |
| 1545 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1561 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1546 current_screen_transform, device_viewport); | 1562 current_screen_transform, device_viewport); |
| 1547 | 1563 |
| 1548 client.SetTileSize(gfx::Size(100, 100)); | 1564 client.SetTileSize(gfx::Size(100, 100)); |
| 1549 client.set_tree(ACTIVE_TREE); | 1565 client.set_tree(ACTIVE_TREE); |
| 1550 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1566 |
| 1551 current_layer_bounds, &client, | 1567 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1552 LayerTreeSettings()); | 1568 current_layer_bounds); |
| 1569 auto tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1570 LayerTreeSettings()); |
| 1553 | 1571 |
| 1554 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1572 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1555 current_layer_contents_scale, | 1573 current_layer_contents_scale, |
| 1556 current_frame_time_in_seconds, Occlusion()); | 1574 current_frame_time_in_seconds, Occlusion()); |
| 1557 tiling->UpdateAllTilePrioritiesForTesting(); | 1575 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1558 | 1576 |
| 1559 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1577 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1560 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1578 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1561 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1579 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1562 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1580 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1583 TilePriority top_right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1601 TilePriority top_right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
| 1584 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1602 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1585 EXPECT_GT(top_right.distance_to_visible, top_left.distance_to_visible); | 1603 EXPECT_GT(top_right.distance_to_visible, top_left.distance_to_visible); |
| 1586 | 1604 |
| 1587 EXPECT_EQ(bottom_right.distance_to_visible, top_right.distance_to_visible); | 1605 EXPECT_EQ(bottom_right.distance_to_visible, top_right.distance_to_visible); |
| 1588 } | 1606 } |
| 1589 | 1607 |
| 1590 TEST(ComputeTilePriorityRectsTest, PerspectiveLayer) { | 1608 TEST(ComputeTilePriorityRectsTest, PerspectiveLayer) { |
| 1591 // Perspective transforms need to take a different code path. | 1609 // Perspective transforms need to take a different code path. |
| 1592 // This test checks tile priorities of a perspective layer. | 1610 // This test checks tile priorities of a perspective layer. |
| 1593 | |
| 1594 FakePictureLayerTilingClient client; | 1611 FakePictureLayerTilingClient client; |
| 1595 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1596 | 1612 |
| 1597 gfx::Size device_viewport(800, 600); | 1613 gfx::Size device_viewport(800, 600); |
| 1598 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen. | 1614 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen. |
| 1599 gfx::Size last_layer_bounds(200, 200); | 1615 gfx::Size last_layer_bounds(200, 200); |
| 1600 gfx::Size current_layer_bounds(200, 200); | 1616 gfx::Size current_layer_bounds(200, 200); |
| 1601 float current_layer_contents_scale = 1.f; | 1617 float current_layer_contents_scale = 1.f; |
| 1602 gfx::Transform last_screen_transform; | 1618 gfx::Transform last_screen_transform; |
| 1603 gfx::Transform current_screen_transform; | 1619 gfx::Transform current_screen_transform; |
| 1604 double current_frame_time_in_seconds = 1.0; | 1620 double current_frame_time_in_seconds = 1.0; |
| 1605 | 1621 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1622 MathUtil::MapQuad(current_screen_transform, | 1638 MathUtil::MapQuad(current_screen_transform, |
| 1623 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), | 1639 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), |
| 1624 &clipped); | 1640 &clipped); |
| 1625 ASSERT_FALSE(clipped); | 1641 ASSERT_FALSE(clipped); |
| 1626 | 1642 |
| 1627 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1643 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1628 current_screen_transform, device_viewport); | 1644 current_screen_transform, device_viewport); |
| 1629 | 1645 |
| 1630 client.SetTileSize(gfx::Size(100, 100)); | 1646 client.SetTileSize(gfx::Size(100, 100)); |
| 1631 client.set_tree(ACTIVE_TREE); | 1647 client.set_tree(ACTIVE_TREE); |
| 1632 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1648 |
| 1633 current_layer_bounds, &client, | 1649 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1634 LayerTreeSettings()); | 1650 current_layer_bounds); |
| 1651 auto tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1652 LayerTreeSettings()); |
| 1635 | 1653 |
| 1636 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1654 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1637 current_layer_contents_scale, | 1655 current_layer_contents_scale, |
| 1638 current_frame_time_in_seconds, Occlusion()); | 1656 current_frame_time_in_seconds, Occlusion()); |
| 1639 tiling->UpdateAllTilePrioritiesForTesting(); | 1657 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1640 | 1658 |
| 1641 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1659 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1642 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1660 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1643 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1661 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1644 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1662 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1670 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1688 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1671 | 1689 |
| 1672 EXPECT_GT(bottom_right.distance_to_visible, top_right.distance_to_visible); | 1690 EXPECT_GT(bottom_right.distance_to_visible, top_right.distance_to_visible); |
| 1673 | 1691 |
| 1674 EXPECT_GT(bottom_left.distance_to_visible, top_left.distance_to_visible); | 1692 EXPECT_GT(bottom_left.distance_to_visible, top_left.distance_to_visible); |
| 1675 } | 1693 } |
| 1676 | 1694 |
| 1677 TEST(ComputeTilePriorityRectsTest, PerspectiveLayerClippedByW) { | 1695 TEST(ComputeTilePriorityRectsTest, PerspectiveLayerClippedByW) { |
| 1678 // Perspective transforms need to take a different code path. | 1696 // Perspective transforms need to take a different code path. |
| 1679 // This test checks tile priorities of a perspective layer. | 1697 // This test checks tile priorities of a perspective layer. |
| 1680 | |
| 1681 FakePictureLayerTilingClient client; | 1698 FakePictureLayerTilingClient client; |
| 1682 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1683 | 1699 |
| 1684 gfx::Size device_viewport(800, 600); | 1700 gfx::Size device_viewport(800, 600); |
| 1685 gfx::Size last_layer_bounds(200, 200); | 1701 gfx::Size last_layer_bounds(200, 200); |
| 1686 gfx::Size current_layer_bounds(200, 200); | 1702 gfx::Size current_layer_bounds(200, 200); |
| 1687 float current_layer_contents_scale = 1.f; | 1703 float current_layer_contents_scale = 1.f; |
| 1688 gfx::Transform last_screen_transform; | 1704 gfx::Transform last_screen_transform; |
| 1689 gfx::Transform current_screen_transform; | 1705 gfx::Transform current_screen_transform; |
| 1690 double current_frame_time_in_seconds = 1.0; | 1706 double current_frame_time_in_seconds = 1.0; |
| 1691 | 1707 |
| 1692 // A 3d perspective layer rotated about its Y axis, translated to almost | 1708 // A 3d perspective layer rotated about its Y axis, translated to almost |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1714 MathUtil::MapQuad(current_screen_transform, | 1730 MathUtil::MapQuad(current_screen_transform, |
| 1715 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), | 1731 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), |
| 1716 &clipped); | 1732 &clipped); |
| 1717 ASSERT_FALSE(clipped); | 1733 ASSERT_FALSE(clipped); |
| 1718 | 1734 |
| 1719 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1735 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1720 current_screen_transform, device_viewport); | 1736 current_screen_transform, device_viewport); |
| 1721 | 1737 |
| 1722 client.SetTileSize(gfx::Size(100, 100)); | 1738 client.SetTileSize(gfx::Size(100, 100)); |
| 1723 client.set_tree(ACTIVE_TREE); | 1739 client.set_tree(ACTIVE_TREE); |
| 1724 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1740 |
| 1725 current_layer_bounds, &client, | 1741 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1726 LayerTreeSettings()); | 1742 current_layer_bounds); |
| 1743 auto tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1744 LayerTreeSettings()); |
| 1727 | 1745 |
| 1728 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1746 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1729 current_layer_contents_scale, | 1747 current_layer_contents_scale, |
| 1730 current_frame_time_in_seconds, Occlusion()); | 1748 current_frame_time_in_seconds, Occlusion()); |
| 1731 tiling->UpdateAllTilePrioritiesForTesting(); | 1749 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1732 | 1750 |
| 1733 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1751 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1734 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1752 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1735 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1753 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1736 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1754 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1752 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1770 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1753 | 1771 |
| 1754 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1772 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1755 EXPECT_GT(priority.distance_to_visible, 0.f); | 1773 EXPECT_GT(priority.distance_to_visible, 0.f); |
| 1756 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1774 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 1757 } | 1775 } |
| 1758 | 1776 |
| 1759 TEST(ComputeTilePriorityRectsTest, BasicMotion) { | 1777 TEST(ComputeTilePriorityRectsTest, BasicMotion) { |
| 1760 // Test that time_to_visible is computed correctly when | 1778 // Test that time_to_visible is computed correctly when |
| 1761 // there is some motion. | 1779 // there is some motion. |
| 1762 | |
| 1763 FakePictureLayerTilingClient client; | 1780 FakePictureLayerTilingClient client; |
| 1764 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1765 | 1781 |
| 1766 gfx::Size device_viewport(800, 600); | 1782 gfx::Size device_viewport(800, 600); |
| 1767 gfx::Rect visible_layer_rect(0, 0, 0, 0); | 1783 gfx::Rect visible_layer_rect(0, 0, 0, 0); |
| 1768 gfx::Size last_layer_bounds(200, 200); | 1784 gfx::Size last_layer_bounds(200, 200); |
| 1769 gfx::Size current_layer_bounds(200, 200); | 1785 gfx::Size current_layer_bounds(200, 200); |
| 1770 float last_layer_contents_scale = 1.f; | 1786 float last_layer_contents_scale = 1.f; |
| 1771 float current_layer_contents_scale = 1.f; | 1787 float current_layer_contents_scale = 1.f; |
| 1772 gfx::Transform last_screen_transform; | 1788 gfx::Transform last_screen_transform; |
| 1773 gfx::Transform current_screen_transform; | 1789 gfx::Transform current_screen_transform; |
| 1774 double last_frame_time_in_seconds = 1.0; | 1790 double last_frame_time_in_seconds = 1.0; |
| 1775 double current_frame_time_in_seconds = 2.0; | 1791 double current_frame_time_in_seconds = 2.0; |
| 1776 | 1792 |
| 1777 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1793 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
| 1778 current_screen_transform.Translate(1800, 0); | 1794 current_screen_transform.Translate(1800, 0); |
| 1779 last_screen_transform.Translate(2800, 0); | 1795 last_screen_transform.Translate(2800, 0); |
| 1780 | 1796 |
| 1781 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1797 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1782 current_screen_transform, device_viewport); | 1798 current_screen_transform, device_viewport); |
| 1783 | 1799 |
| 1784 client.SetTileSize(gfx::Size(100, 100)); | 1800 client.SetTileSize(gfx::Size(100, 100)); |
| 1785 client.set_tree(ACTIVE_TREE); | 1801 client.set_tree(ACTIVE_TREE); |
| 1786 LayerTreeSettings settings; | 1802 LayerTreeSettings settings; |
| 1787 settings.max_tiles_for_interest_area = 10000; | 1803 settings.max_tiles_for_interest_area = 10000; |
| 1788 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1804 |
| 1789 current_layer_bounds, &client, | 1805 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1790 settings); | 1806 current_layer_bounds); |
| 1807 auto tiling = |
| 1808 TestablePictureLayerTiling::Create(1.0f, pile, &client, settings); |
| 1791 | 1809 |
| 1792 // previous ("last") frame | 1810 // previous ("last") frame |
| 1793 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1811 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1794 last_layer_contents_scale, | 1812 last_layer_contents_scale, |
| 1795 last_frame_time_in_seconds, Occlusion()); | 1813 last_frame_time_in_seconds, Occlusion()); |
| 1796 | 1814 |
| 1797 // current frame | 1815 // current frame |
| 1798 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1816 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1799 current_layer_contents_scale, | 1817 current_layer_contents_scale, |
| 1800 current_frame_time_in_seconds, Occlusion()); | 1818 current_frame_time_in_seconds, Occlusion()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 current_screen_transform.Translate(400, 550); | 1871 current_screen_transform.Translate(400, 550); |
| 1854 current_screen_transform.RotateAboutZAxis(45); | 1872 current_screen_transform.RotateAboutZAxis(45); |
| 1855 | 1873 |
| 1856 last_screen_transform.Translate(400, 550); | 1874 last_screen_transform.Translate(400, 550); |
| 1857 | 1875 |
| 1858 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1876 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1859 current_screen_transform, device_viewport); | 1877 current_screen_transform, device_viewport); |
| 1860 | 1878 |
| 1861 client.SetTileSize(gfx::Size(100, 100)); | 1879 client.SetTileSize(gfx::Size(100, 100)); |
| 1862 client.set_tree(ACTIVE_TREE); | 1880 client.set_tree(ACTIVE_TREE); |
| 1863 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1881 |
| 1864 current_layer_bounds, &client, | 1882 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1883 current_layer_bounds); |
| 1884 tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1865 LayerTreeSettings()); | 1885 LayerTreeSettings()); |
| 1866 | 1886 |
| 1867 // previous ("last") frame | 1887 // previous ("last") frame |
| 1868 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1888 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1869 last_layer_contents_scale, | 1889 last_layer_contents_scale, |
| 1870 last_frame_time_in_seconds, Occlusion()); | 1890 last_frame_time_in_seconds, Occlusion()); |
| 1871 | 1891 |
| 1872 // current frame | 1892 // current frame |
| 1873 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1893 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1874 current_layer_contents_scale, | 1894 current_layer_contents_scale, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1898 // Setup: | 1918 // Setup: |
| 1899 // - Two tilings, one active one recycled with all tiles shared. | 1919 // - Two tilings, one active one recycled with all tiles shared. |
| 1900 // Procedure: | 1920 // Procedure: |
| 1901 // - Viewport moves somewhere far away and active tiling clears tiles. | 1921 // - Viewport moves somewhere far away and active tiling clears tiles. |
| 1902 // - Viewport moves back and a new active tiling tile is created. | 1922 // - Viewport moves back and a new active tiling tile is created. |
| 1903 // Result: | 1923 // Result: |
| 1904 // - Recycle tiling does _not_ have the tile in the same location (thus it | 1924 // - Recycle tiling does _not_ have the tile in the same location (thus it |
| 1905 // will be shared next time a pending tiling is created). | 1925 // will be shared next time a pending tiling is created). |
| 1906 | 1926 |
| 1907 FakePictureLayerTilingClient active_client; | 1927 FakePictureLayerTilingClient active_client; |
| 1908 scoped_ptr<TestablePictureLayerTiling> active_tiling; | |
| 1909 | 1928 |
| 1910 active_client.SetTileSize(gfx::Size(100, 100)); | 1929 active_client.SetTileSize(gfx::Size(100, 100)); |
| 1911 active_client.set_tree(ACTIVE_TREE); | 1930 active_client.set_tree(ACTIVE_TREE); |
| 1912 LayerTreeSettings settings; | 1931 LayerTreeSettings settings; |
| 1913 settings.max_tiles_for_interest_area = 10; | 1932 settings.max_tiles_for_interest_area = 10; |
| 1914 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1933 |
| 1915 gfx::Size(10000, 10000), | 1934 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1916 &active_client, settings); | 1935 gfx::Size(10000, 10000)); |
| 1936 auto active_tiling = |
| 1937 TestablePictureLayerTiling::Create(1.0f, pile, &active_client, settings); |
| 1917 // Create all tiles on this tiling. | 1938 // Create all tiles on this tiling. |
| 1918 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1939 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 1919 Occlusion()); | 1940 Occlusion()); |
| 1920 | 1941 |
| 1921 FakePictureLayerTilingClient recycle_client; | 1942 FakePictureLayerTilingClient recycle_client; |
| 1922 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1943 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 1923 recycle_client.set_tree(PENDING_TREE); | 1944 recycle_client.set_tree(PENDING_TREE); |
| 1924 recycle_client.set_twin_tiling(active_tiling.get()); | 1945 recycle_client.set_twin_tiling(active_tiling.get()); |
| 1925 | 1946 |
| 1926 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 1947 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1927 recycle_tiling = TestablePictureLayerTiling::Create( | 1948 gfx::Size(10000, 10000)); |
| 1928 1.0f, // contents_scale | 1949 auto recycle_tiling = |
| 1929 gfx::Size(10000, 10000), &recycle_client, settings); | 1950 TestablePictureLayerTiling::Create(1.0f, pile, &recycle_client, settings); |
| 1930 | 1951 |
| 1931 // Create all tiles on the second tiling. All tiles should be shared. | 1952 // Create all tiles on the second tiling. All tiles should be shared. |
| 1932 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1953 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 1933 1.0f, Occlusion()); | 1954 1.0f, Occlusion()); |
| 1934 | 1955 |
| 1935 // Set the second tiling as recycled. | 1956 // Set the second tiling as recycled. |
| 1936 active_client.set_twin_tiling(NULL); | 1957 active_client.set_twin_tiling(NULL); |
| 1937 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 1958 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
| 1938 recycle_client.set_twin_tiling(NULL); | 1959 recycle_client.set_twin_tiling(NULL); |
| 1939 | 1960 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1953 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, | 1974 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, |
| 1954 Occlusion()); | 1975 Occlusion()); |
| 1955 | 1976 |
| 1956 // Ensure that we now have a tile here on both tilings again. | 1977 // Ensure that we now have a tile here on both tilings again. |
| 1957 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1978 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 1958 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); | 1979 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
| 1959 } | 1980 } |
| 1960 | 1981 |
| 1961 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 1982 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
| 1962 FakePictureLayerTilingClient active_client; | 1983 FakePictureLayerTilingClient active_client; |
| 1963 scoped_ptr<TestablePictureLayerTiling> active_tiling; | |
| 1964 | |
| 1965 active_client.SetTileSize(gfx::Size(100, 100)); | 1984 active_client.SetTileSize(gfx::Size(100, 100)); |
| 1966 active_client.set_tree(ACTIVE_TREE); | 1985 active_client.set_tree(ACTIVE_TREE); |
| 1967 active_tiling = TestablePictureLayerTiling::Create( | 1986 |
| 1968 1.0f, // contents_scale | 1987 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1969 gfx::Size(100, 100), &active_client, LayerTreeSettings()); | 1988 gfx::Size(100, 100)); |
| 1989 auto active_tiling = TestablePictureLayerTiling::Create( |
| 1990 1.0f, pile, &active_client, LayerTreeSettings()); |
| 1970 // Create all tiles on this tiling. | 1991 // Create all tiles on this tiling. |
| 1971 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1992 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 1972 Occlusion()); | 1993 Occlusion()); |
| 1973 | 1994 |
| 1974 FakePictureLayerTilingClient recycle_client; | 1995 FakePictureLayerTilingClient recycle_client; |
| 1975 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1996 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 1976 recycle_client.set_tree(PENDING_TREE); | 1997 recycle_client.set_tree(PENDING_TREE); |
| 1977 recycle_client.set_twin_tiling(active_tiling.get()); | 1998 recycle_client.set_twin_tiling(active_tiling.get()); |
| 1978 | 1999 |
| 1979 LayerTreeSettings settings; | 2000 LayerTreeSettings settings; |
| 1980 settings.max_tiles_for_interest_area = 10; | 2001 settings.max_tiles_for_interest_area = 10; |
| 1981 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 2002 |
| 1982 recycle_tiling = TestablePictureLayerTiling::Create( | 2003 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1983 1.0f, // contents_scale | 2004 gfx::Size(100, 100)); |
| 1984 gfx::Size(100, 100), &recycle_client, settings); | 2005 auto recycle_tiling = |
| 2006 TestablePictureLayerTiling::Create(1.0f, pile, &recycle_client, settings); |
| 1985 | 2007 |
| 1986 // Create all tiles on the recycle tiling. All tiles should be shared. | 2008 // Create all tiles on the recycle tiling. All tiles should be shared. |
| 1987 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 2009 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 1988 1.0f, Occlusion()); | 2010 1.0f, Occlusion()); |
| 1989 | 2011 |
| 1990 // Set the second tiling as recycled. | 2012 // Set the second tiling as recycled. |
| 1991 active_client.set_twin_tiling(NULL); | 2013 active_client.set_twin_tiling(NULL); |
| 1992 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2014 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
| 1993 recycle_client.set_twin_tiling(NULL); | 2015 recycle_client.set_twin_tiling(NULL); |
| 1994 | 2016 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2011 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 2033 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2012 EXPECT_EQ(4u, tiling_->AllRefTilesForTesting().size()); | 2034 EXPECT_EQ(4u, tiling_->AllRefTilesForTesting().size()); |
| 2013 | 2035 |
| 2014 client_.SetTileSize(gfx::Size(250, 200)); | 2036 client_.SetTileSize(gfx::Size(250, 200)); |
| 2015 client_.set_tree(PENDING_TREE); | 2037 client_.set_tree(PENDING_TREE); |
| 2016 | 2038 |
| 2017 // Tile size in the tiling should still be 150x100. | 2039 // Tile size in the tiling should still be 150x100. |
| 2018 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); | 2040 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 2019 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 2041 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2020 | 2042 |
| 2021 tiling_->Resize(gfx::Size(250, 150)); | 2043 // The layer's size isn't changed, but the tile size was. |
| 2044 auto pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 2045 gfx::Size(250, 150)); |
| 2046 tiling_->SetRasterSourceAndResize(pile); |
| 2022 | 2047 |
| 2023 // Tile size in the tiling should be resized to 250x200. | 2048 // Tile size in the tiling should be resized to 250x200. |
| 2024 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 2049 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 2025 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 2050 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2026 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 2051 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
| 2027 } | 2052 } |
| 2028 | 2053 |
| 2029 } // namespace | 2054 } // namespace |
| 2030 } // namespace cc | 2055 } // namespace cc |
| OLD | NEW |