| 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 |
| 25 static gfx::Rect ViewportInLayerSpace( | 26 static gfx::Rect ViewportInLayerSpace( |
| 26 const gfx::Transform& transform, | 27 const gfx::Transform& transform, |
| 27 const gfx::Size& device_viewport) { | 28 const gfx::Size& device_viewport) { |
| 28 | 29 |
| 29 gfx::Transform inverse; | 30 gfx::Transform inverse; |
| 30 if (!transform.GetInverse(&inverse)) | 31 if (!transform.GetInverse(&inverse)) |
| 31 return gfx::Rect(); | 32 return gfx::Rect(); |
| 32 | 33 |
| 33 gfx::RectF viewport_in_layer_space = MathUtil::ProjectClippedRect( | 34 gfx::RectF viewport_in_layer_space = MathUtil::ProjectClippedRect( |
| 34 inverse, gfx::RectF(gfx::Point(0, 0), device_viewport)); | 35 inverse, gfx::RectF(gfx::Point(0, 0), device_viewport)); |
| 35 return ToEnclosingRect(viewport_in_layer_space); | 36 return ToEnclosingRect(viewport_in_layer_space); |
| 36 } | 37 } |
| 37 | 38 |
| 38 static void UpdateAllTilePriorities(PictureLayerTilingSet* set, | |
| 39 const gfx::Rect& visible_layer_rect, | |
| 40 float layer_contents_scale, | |
| 41 double current_frame_time_in_seconds) { | |
| 42 for (size_t i = 0; i < set->num_tilings(); ++i) { | |
| 43 set->tiling_at(i) | |
| 44 ->ComputeTilePriorityRects(visible_layer_rect, layer_contents_scale, | |
| 45 current_frame_time_in_seconds, Occlusion()); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 class TestablePictureLayerTiling : public PictureLayerTiling { | 39 class TestablePictureLayerTiling : public PictureLayerTiling { |
| 50 public: | 40 public: |
| 51 using PictureLayerTiling::SetLiveTilesRect; | 41 using PictureLayerTiling::SetLiveTilesRect; |
| 52 using PictureLayerTiling::TileAt; | 42 using PictureLayerTiling::TileAt; |
| 53 | 43 |
| 54 static scoped_ptr<TestablePictureLayerTiling> Create( | 44 static scoped_ptr<TestablePictureLayerTiling> Create( |
| 55 float contents_scale, | 45 float contents_scale, |
| 56 const gfx::Size& layer_bounds, | 46 scoped_refptr<RasterSource> raster_source, |
| 57 PictureLayerTilingClient* client, | 47 PictureLayerTilingClient* client, |
| 58 const LayerTreeSettings& settings) { | 48 const LayerTreeSettings& settings) { |
| 59 return make_scoped_ptr(new TestablePictureLayerTiling( | 49 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 60 contents_scale, layer_bounds, client, | 50 contents_scale, raster_source, client, |
| 61 settings.max_tiles_for_interest_area, | 51 settings.max_tiles_for_interest_area, |
| 62 settings.skewport_target_time_in_seconds, | 52 settings.skewport_target_time_in_seconds, |
| 63 settings.skewport_extrapolation_limit_in_content_pixels)); | 53 settings.skewport_extrapolation_limit_in_content_pixels)); |
| 64 } | 54 } |
| 65 | 55 |
| 66 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 56 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 67 | 57 |
| 68 using PictureLayerTiling::ComputeSkewport; | 58 using PictureLayerTiling::ComputeSkewport; |
| 69 using PictureLayerTiling::RemoveTileAt; | 59 using PictureLayerTiling::RemoveTileAt; |
| 70 | 60 |
| 71 protected: | 61 protected: |
| 72 TestablePictureLayerTiling(float contents_scale, | 62 TestablePictureLayerTiling(float contents_scale, |
| 73 const gfx::Size& layer_bounds, | 63 scoped_refptr<RasterSource> raster_source, |
| 74 PictureLayerTilingClient* client, | 64 PictureLayerTilingClient* client, |
| 75 size_t max_tiles_for_interest_area, | 65 size_t max_tiles_for_interest_area, |
| 76 float skewport_target_time, | 66 float skewport_target_time, |
| 77 int skewport_extrapolation_limit) | 67 int skewport_extrapolation_limit) |
| 78 : PictureLayerTiling(contents_scale, | 68 : PictureLayerTiling(contents_scale, |
| 79 layer_bounds, | 69 raster_source, |
| 80 client, | 70 client, |
| 81 max_tiles_for_interest_area, | 71 max_tiles_for_interest_area, |
| 82 skewport_target_time, | 72 skewport_target_time, |
| 83 skewport_extrapolation_limit) {} | 73 skewport_extrapolation_limit) {} |
| 84 }; | 74 }; |
| 85 | 75 |
| 86 class PictureLayerTilingIteratorTest : public testing::Test { | 76 class PictureLayerTilingIteratorTest : public testing::Test { |
| 87 public: | 77 public: |
| 88 PictureLayerTilingIteratorTest() {} | 78 PictureLayerTilingIteratorTest() {} |
| 89 virtual ~PictureLayerTilingIteratorTest() {} | 79 virtual ~PictureLayerTilingIteratorTest() {} |
| 90 | 80 |
| 91 void Initialize(const gfx::Size& tile_size, | 81 void Initialize(const gfx::Size& tile_size, |
| 92 float contents_scale, | 82 float contents_scale, |
| 93 const gfx::Size& layer_bounds) { | 83 const gfx::Size& layer_bounds) { |
| 94 client_.SetTileSize(tile_size); | 84 client_.SetTileSize(tile_size); |
| 95 client_.set_tree(PENDING_TREE); | 85 client_.set_tree(PENDING_TREE); |
| 96 tiling_ = TestablePictureLayerTiling::Create(contents_scale, layer_bounds, | 86 scoped_refptr<FakePicturePileImpl> pile = |
| 97 &client_, LayerTreeSettings()); | 87 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 88 tiling_ = TestablePictureLayerTiling::Create(contents_scale, pile, &client_, |
| 89 LayerTreeSettings()); |
| 98 } | 90 } |
| 99 | 91 |
| 100 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { | 92 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { |
| 101 tiling_->SetLiveTilesRect(live_tiles_rect); | 93 tiling_->SetLiveTilesRect(live_tiles_rect); |
| 102 | 94 |
| 103 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 95 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
| 104 for (std::vector<Tile*>::iterator iter = tiles.begin(); | 96 for (std::vector<Tile*>::iterator iter = tiles.begin(); |
| 105 iter != tiles.end(); | 97 iter != tiles.end(); |
| 106 ++iter) { | 98 ++iter) { |
| 107 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... |
| 199 // deletes tiles that intersect that invalidation. | 191 // deletes tiles that intersect that invalidation. |
| 200 gfx::Size tile_size(100, 100); | 192 gfx::Size tile_size(100, 100); |
| 201 gfx::Size original_layer_size(10, 10); | 193 gfx::Size original_layer_size(10, 10); |
| 202 Initialize(tile_size, 1.f, original_layer_size); | 194 Initialize(tile_size, 1.f, original_layer_size); |
| 203 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 195 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 204 | 196 |
| 205 // 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. |
| 206 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 198 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 207 | 199 |
| 208 // Stop creating tiles so that any invalidations are left as holes. | 200 // Stop creating tiles so that any invalidations are left as holes. |
| 209 client_.set_allow_create_tile(false); | 201 gfx::Size new_layer_size(200, 200); |
| 202 scoped_refptr<FakePicturePileImpl> pile = |
| 203 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(new_layer_size); |
| 210 | 204 |
| 211 Region invalidation = | 205 Region invalidation = |
| 212 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 206 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 213 tiling_->Resize(gfx::Size(200, 200)); | 207 tiling_->SetRasterSourceAndResize(pile); |
| 214 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 208 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 215 tiling_->Invalidate(invalidation); | 209 tiling_->Invalidate(invalidation); |
| 216 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 210 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| 217 } | 211 } |
| 218 | 212 |
| 219 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { | 213 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { |
| 220 // The tiling has three rows and columns. | 214 // The tiling has three rows and columns. |
| 221 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 250)); | 215 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 250)); |
| 222 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 216 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
| 223 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... |
| 259 EXPECT_TRUE(tiling_->TileAt(2, 2)); | 253 EXPECT_TRUE(tiling_->TileAt(2, 2)); |
| 260 EXPECT_TRUE(tiling_->TileAt(2, 3)); | 254 EXPECT_TRUE(tiling_->TileAt(2, 3)); |
| 261 EXPECT_TRUE(tiling_->TileAt(1, 3)); | 255 EXPECT_TRUE(tiling_->TileAt(1, 3)); |
| 262 EXPECT_TRUE(tiling_->TileAt(0, 3)); | 256 EXPECT_TRUE(tiling_->TileAt(0, 3)); |
| 263 | 257 |
| 264 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); | 258 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); |
| 265 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); | 259 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); |
| 266 | 260 |
| 267 // 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 |
| 268 // border pixels of the interior tiles. That row/column is removed. | 262 // border pixels of the interior tiles. That row/column is removed. |
| 269 tiling_->Resize(gfx::Size(right + 1, bottom + 1)); | 263 scoped_refptr<FakePicturePileImpl> pile = |
| 264 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 265 gfx::Size(right + 1, bottom + 1)); |
| 266 tiling_->SetRasterSourceAndResize(pile); |
| 270 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); | 267 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); |
| 271 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); | 268 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
| 272 | 269 |
| 273 // The live tiles rect was clamped to the pile size. | 270 // The live tiles rect was clamped to the pile size. |
| 274 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 271 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
| 275 | 272 |
| 276 // Since the row/column is gone, the tiles should be gone too. | 273 // Since the row/column is gone, the tiles should be gone too. |
| 277 EXPECT_FALSE(tiling_->TileAt(2, 0)); | 274 EXPECT_FALSE(tiling_->TileAt(2, 0)); |
| 278 EXPECT_FALSE(tiling_->TileAt(2, 1)); | 275 EXPECT_FALSE(tiling_->TileAt(2, 1)); |
| 279 EXPECT_FALSE(tiling_->TileAt(2, 2)); | 276 EXPECT_FALSE(tiling_->TileAt(2, 2)); |
| 280 EXPECT_FALSE(tiling_->TileAt(2, 3)); | 277 EXPECT_FALSE(tiling_->TileAt(2, 3)); |
| 281 EXPECT_FALSE(tiling_->TileAt(1, 3)); | 278 EXPECT_FALSE(tiling_->TileAt(1, 3)); |
| 282 EXPECT_FALSE(tiling_->TileAt(0, 3)); | 279 EXPECT_FALSE(tiling_->TileAt(0, 3)); |
| 283 | 280 |
| 284 // Growing outside the current right/bottom tiles border pixels should create | 281 // Growing outside the current right/bottom tiles border pixels should create |
| 285 // the tiles again, even though the live rect has not changed size. | 282 // the tiles again, even though the live rect has not changed size. |
| 286 tiling_->Resize(gfx::Size(right + 2, bottom + 2)); | 283 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 284 gfx::Size(right + 2, bottom + 2)); |
| 285 tiling_->SetRasterSourceAndResize(pile); |
| 287 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 286 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
| 288 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); | 287 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); |
| 289 | 288 |
| 290 // Not changed. | 289 // Not changed. |
| 291 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 290 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
| 292 | 291 |
| 293 // The last row/column tiles are inside the live tiles rect. | 292 // The last row/column tiles are inside the live tiles rect. |
| 294 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 293 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
| 295 tiling_->TilingDataForTesting().TileBounds(2, 0))); | 294 tiling_->TilingDataForTesting().TileBounds(2, 0))); |
| 296 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 295 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 // deletes tiles that intersect that invalidation. | 407 // deletes tiles that intersect that invalidation. |
| 409 gfx::Size tile_size(100, 100); | 408 gfx::Size tile_size(100, 100); |
| 410 gfx::Size original_layer_size(99, 99); | 409 gfx::Size original_layer_size(99, 99); |
| 411 Initialize(tile_size, 1.f, original_layer_size); | 410 Initialize(tile_size, 1.f, original_layer_size); |
| 412 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 411 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 413 | 412 |
| 414 // Tiling only has one tile, since its total size is less than one. | 413 // Tiling only has one tile, since its total size is less than one. |
| 415 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 414 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 416 | 415 |
| 417 // Stop creating tiles so that any invalidations are left as holes. | 416 // Stop creating tiles so that any invalidations are left as holes. |
| 418 client_.set_allow_create_tile(false); | 417 scoped_refptr<FakePicturePileImpl> pile = |
| 418 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize( |
| 419 gfx::Size(200, 200)); |
| 420 tiling_->SetRasterSourceAndResize(pile); |
| 419 | 421 |
| 420 Region invalidation = | 422 Region invalidation = |
| 421 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 423 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 422 tiling_->Resize(gfx::Size(200, 200)); | |
| 423 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 424 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 424 tiling_->Invalidate(invalidation); | 425 tiling_->Invalidate(invalidation); |
| 425 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 426 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| 426 | 427 |
| 427 // The original tile was the same size after resize, but it would include new | 428 // The original tile was the same size after resize, but it would include new |
| 428 // border pixels. | 429 // border pixels. |
| 429 EXPECT_EQ(gfx::Rect(original_layer_size), | 430 EXPECT_EQ(gfx::Rect(original_layer_size), |
| 430 tiling_->TilingDataForTesting().TileBounds(0, 0)); | 431 tiling_->TilingDataForTesting().TileBounds(0, 0)); |
| 431 } | 432 } |
| 432 | 433 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 528 |
| 528 // Partially covering content, but too large | 529 // Partially covering content, but too large |
| 529 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); | 530 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); |
| 530 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); | 531 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); |
| 531 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); | 532 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); |
| 532 } | 533 } |
| 533 | 534 |
| 534 TEST(PictureLayerTilingTest, SkewportLimits) { | 535 TEST(PictureLayerTilingTest, SkewportLimits) { |
| 535 FakePictureLayerTilingClient client; | 536 FakePictureLayerTilingClient client; |
| 536 client.set_tree(ACTIVE_TREE); | 537 client.set_tree(ACTIVE_TREE); |
| 537 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 538 | 538 |
| 539 gfx::Rect viewport(0, 0, 100, 100); | 539 gfx::Rect viewport(0, 0, 100, 100); |
| 540 gfx::Size layer_bounds(200, 200); | 540 gfx::Size layer_bounds(200, 200); |
| 541 | 541 |
| 542 client.SetTileSize(gfx::Size(100, 100)); | 542 client.SetTileSize(gfx::Size(100, 100)); |
| 543 LayerTreeSettings settings; | 543 LayerTreeSettings settings; |
| 544 settings.max_tiles_for_interest_area = 10000; | 544 settings.max_tiles_for_interest_area = 10000; |
| 545 settings.skewport_extrapolation_limit_in_content_pixels = 75; | 545 settings.skewport_extrapolation_limit_in_content_pixels = 75; |
| 546 tiling = | 546 |
| 547 TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, settings); | 547 scoped_refptr<FakePicturePileImpl> pile = |
| 548 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 549 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 550 TestablePictureLayerTiling::Create(1.0f, pile, &client, settings); |
| 548 | 551 |
| 549 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 552 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 550 | 553 |
| 551 // Move viewport down 50 pixels in 0.5 seconds. | 554 // Move viewport down 50 pixels in 0.5 seconds. |
| 552 gfx::Rect down_skewport = | 555 gfx::Rect down_skewport = |
| 553 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 556 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 554 | 557 |
| 555 EXPECT_EQ(0, down_skewport.x()); | 558 EXPECT_EQ(0, down_skewport.x()); |
| 556 EXPECT_EQ(50, down_skewport.y()); | 559 EXPECT_EQ(50, down_skewport.y()); |
| 557 EXPECT_EQ(100, down_skewport.width()); | 560 EXPECT_EQ(100, down_skewport.width()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 599 |
| 597 EXPECT_EQ(-575, big_expand_skewport.x()); | 600 EXPECT_EQ(-575, big_expand_skewport.x()); |
| 598 EXPECT_EQ(-575, big_expand_skewport.y()); | 601 EXPECT_EQ(-575, big_expand_skewport.y()); |
| 599 EXPECT_EQ(1650, big_expand_skewport.width()); | 602 EXPECT_EQ(1650, big_expand_skewport.width()); |
| 600 EXPECT_EQ(1650, big_expand_skewport.height()); | 603 EXPECT_EQ(1650, big_expand_skewport.height()); |
| 601 EXPECT_TRUE(big_expand_skewport.Contains(gfx::Rect(-500, -500, 1500, 1500))); | 604 EXPECT_TRUE(big_expand_skewport.Contains(gfx::Rect(-500, -500, 1500, 1500))); |
| 602 } | 605 } |
| 603 | 606 |
| 604 TEST(PictureLayerTilingTest, ComputeSkewport) { | 607 TEST(PictureLayerTilingTest, ComputeSkewport) { |
| 605 FakePictureLayerTilingClient client; | 608 FakePictureLayerTilingClient client; |
| 606 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 607 | 609 |
| 608 gfx::Rect viewport(0, 0, 100, 100); | 610 gfx::Rect viewport(0, 0, 100, 100); |
| 609 gfx::Size layer_bounds(200, 200); | 611 gfx::Size layer_bounds(200, 200); |
| 610 | 612 |
| 611 client.SetTileSize(gfx::Size(100, 100)); | 613 client.SetTileSize(gfx::Size(100, 100)); |
| 612 client.set_tree(ACTIVE_TREE); | 614 client.set_tree(ACTIVE_TREE); |
| 613 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, | 615 |
| 614 LayerTreeSettings()); | 616 scoped_refptr<FakePicturePileImpl> pile = |
| 617 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 618 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 619 TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 620 LayerTreeSettings()); |
| 615 | 621 |
| 616 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 622 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 617 | 623 |
| 618 // Move viewport down 50 pixels in 0.5 seconds. | 624 // Move viewport down 50 pixels in 0.5 seconds. |
| 619 gfx::Rect down_skewport = | 625 gfx::Rect down_skewport = |
| 620 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 626 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 621 | 627 |
| 622 EXPECT_EQ(0, down_skewport.x()); | 628 EXPECT_EQ(0, down_skewport.x()); |
| 623 EXPECT_EQ(50, down_skewport.y()); | 629 EXPECT_EQ(50, down_skewport.y()); |
| 624 EXPECT_EQ(100, down_skewport.width()); | 630 EXPECT_EQ(100, down_skewport.width()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 tiling->ComputeSkewport(1.2, gfx::Rect(-5, -5, 110, 110)); | 662 tiling->ComputeSkewport(1.2, gfx::Rect(-5, -5, 110, 110)); |
| 657 | 663 |
| 658 EXPECT_EQ(-30, expanded_skewport.x()); | 664 EXPECT_EQ(-30, expanded_skewport.x()); |
| 659 EXPECT_EQ(-30, expanded_skewport.y()); | 665 EXPECT_EQ(-30, expanded_skewport.y()); |
| 660 EXPECT_EQ(160, expanded_skewport.width()); | 666 EXPECT_EQ(160, expanded_skewport.width()); |
| 661 EXPECT_EQ(160, expanded_skewport.height()); | 667 EXPECT_EQ(160, expanded_skewport.height()); |
| 662 } | 668 } |
| 663 | 669 |
| 664 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { | 670 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
| 665 FakePictureLayerTilingClient client; | 671 FakePictureLayerTilingClient client; |
| 666 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 667 | 672 |
| 668 gfx::Rect viewport(0, 0, 100, 100); | 673 gfx::Rect viewport(0, 0, 100, 100); |
| 669 gfx::Size layer_bounds(1500, 1500); | 674 gfx::Size layer_bounds(1500, 1500); |
| 670 | 675 |
| 671 client.SetTileSize(gfx::Size(10, 10)); | 676 client.SetTileSize(gfx::Size(10, 10)); |
| 672 client.set_tree(ACTIVE_TREE); | 677 client.set_tree(ACTIVE_TREE); |
| 673 LayerTreeSettings settings; | 678 LayerTreeSettings settings; |
| 674 settings.max_tiles_for_interest_area = 10000; | 679 settings.max_tiles_for_interest_area = 10000; |
| 675 | 680 |
| 676 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 681 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
| 677 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 682 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
| 678 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 683 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
| 679 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 684 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
| 680 // tiling. | 685 // tiling. |
| 681 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client, | 686 scoped_refptr<FakePicturePileImpl> pile = |
| 682 settings); | 687 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 688 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 689 TestablePictureLayerTiling::Create(0.25f, pile, &client, settings); |
| 683 gfx::Rect viewport_in_content_space = | 690 gfx::Rect viewport_in_content_space = |
| 684 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); | 691 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); |
| 685 | 692 |
| 686 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 693 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 687 tiling->UpdateAllTilePrioritiesForTesting(); | 694 tiling->UpdateAllTilePrioritiesForTesting(); |
| 688 | 695 |
| 689 gfx::Rect soon_rect = viewport; | 696 gfx::Rect soon_rect = viewport; |
| 690 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 697 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 691 gfx::Rect soon_rect_in_content_space = | 698 gfx::Rect soon_rect_in_content_space = |
| 692 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); | 699 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 833 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 827 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); | 834 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); |
| 828 | 835 |
| 829 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 836 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 830 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); | 837 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
| 831 | 838 |
| 832 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 839 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
| 833 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); | 840 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
| 834 | 841 |
| 835 // Test additional scales. | 842 // Test additional scales. |
| 836 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client, | 843 tiling = TestablePictureLayerTiling::Create(0.2f, pile, &client, |
| 837 LayerTreeSettings()); | 844 LayerTreeSettings()); |
| 838 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); | 845 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); |
| 839 tiling->UpdateAllTilePrioritiesForTesting(); | 846 tiling->UpdateAllTilePrioritiesForTesting(); |
| 840 | 847 |
| 841 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 848 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 842 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); | 849 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); |
| 843 | 850 |
| 844 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 851 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 845 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); | 852 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); |
| 846 | 853 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 gfx::Rect in(40, 40, 0, 0); | 1084 gfx::Rect in(40, 40, 0, 0); |
| 1078 gfx::Rect bounds(0, 0, 10, 10); | 1085 gfx::Rect bounds(0, 0, 10, 10); |
| 1079 int64 target_area = 400 * 400; | 1086 int64 target_area = 400 * 400; |
| 1080 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 1087 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| 1081 in, target_area, bounds, NULL); | 1088 in, target_area, bounds, NULL); |
| 1082 EXPECT_TRUE(out.IsEmpty()); | 1089 EXPECT_TRUE(out.IsEmpty()); |
| 1083 } | 1090 } |
| 1084 | 1091 |
| 1085 TEST(PictureLayerTilingTest, TilingRasterTileIteratorStaticViewport) { | 1092 TEST(PictureLayerTilingTest, TilingRasterTileIteratorStaticViewport) { |
| 1086 FakePictureLayerTilingClient client; | 1093 FakePictureLayerTilingClient client; |
| 1087 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1088 | 1094 |
| 1089 gfx::Rect viewport(50, 50, 100, 100); | 1095 gfx::Rect viewport(50, 50, 100, 100); |
| 1090 gfx::Size layer_bounds(800, 800); | 1096 gfx::Size layer_bounds(800, 800); |
| 1091 | 1097 |
| 1092 gfx::Rect soon_rect = viewport; | 1098 gfx::Rect soon_rect = viewport; |
| 1093 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1099 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1094 | 1100 |
| 1095 client.SetTileSize(gfx::Size(30, 30)); | 1101 client.SetTileSize(gfx::Size(30, 30)); |
| 1096 client.set_tree(ACTIVE_TREE); | 1102 client.set_tree(ACTIVE_TREE); |
| 1097 LayerTreeSettings settings; | 1103 LayerTreeSettings settings; |
| 1098 settings.max_tiles_for_interest_area = 10000; | 1104 settings.max_tiles_for_interest_area = 10000; |
| 1099 | 1105 |
| 1100 tiling = | 1106 scoped_refptr<FakePicturePileImpl> pile = |
| 1101 TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, settings); | 1107 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1108 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1109 TestablePictureLayerTiling::Create(1.0f, pile, &client, settings); |
| 1102 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1110 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
| 1103 tiling->UpdateAllTilePrioritiesForTesting(); | 1111 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1104 | 1112 |
| 1105 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1113 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
| 1106 EXPECT_FALSE(empty_iterator); | 1114 EXPECT_FALSE(empty_iterator); |
| 1107 | 1115 |
| 1108 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1116 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1109 | 1117 |
| 1110 // Sanity check. | 1118 // Sanity check. |
| 1111 EXPECT_EQ(841u, all_tiles.size()); | 1119 EXPECT_EQ(841u, all_tiles.size()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1131 } | 1139 } |
| 1132 | 1140 |
| 1133 EXPECT_TRUE(it); | 1141 EXPECT_TRUE(it); |
| 1134 std::set<Tile*> unique_tiles; | 1142 std::set<Tile*> unique_tiles; |
| 1135 unique_tiles.insert(*it); | 1143 unique_tiles.insert(*it); |
| 1136 Tile* last_tile = *it; | 1144 Tile* last_tile = *it; |
| 1137 have_tiles[last_tile->priority(ACTIVE_TREE).priority_bin] = true; | 1145 have_tiles[last_tile->priority(ACTIVE_TREE).priority_bin] = true; |
| 1138 | 1146 |
| 1139 // On the second iteration, mark everything as ready to draw (solid color). | 1147 // On the second iteration, mark everything as ready to draw (solid color). |
| 1140 if (i == 1) { | 1148 if (i == 1) { |
| 1141 ManagedTileState::DrawInfo& draw_info = last_tile->draw_info(); | 1149 TileDrawInfo& draw_info = last_tile->draw_info(); |
| 1142 draw_info.SetSolidColorForTesting(SK_ColorRED); | 1150 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 1143 } | 1151 } |
| 1144 ++it; | 1152 ++it; |
| 1145 int eventually_bin_order_correct_count = 0; | 1153 int eventually_bin_order_correct_count = 0; |
| 1146 int eventually_bin_order_incorrect_count = 0; | 1154 int eventually_bin_order_incorrect_count = 0; |
| 1147 while (it) { | 1155 while (it) { |
| 1148 Tile* new_tile = *it; | 1156 Tile* new_tile = *it; |
| 1149 ++it; | 1157 ++it; |
| 1150 unique_tiles.insert(new_tile); | 1158 unique_tiles.insert(new_tile); |
| 1151 | 1159 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1167 EXPECT_EQ(TilePriority::SOON, new_priority.priority_bin); | 1175 EXPECT_EQ(TilePriority::SOON, new_priority.priority_bin); |
| 1168 } | 1176 } |
| 1169 } | 1177 } |
| 1170 have_tiles[new_priority.priority_bin] = true; | 1178 have_tiles[new_priority.priority_bin] = true; |
| 1171 | 1179 |
| 1172 last_tile = new_tile; | 1180 last_tile = new_tile; |
| 1173 | 1181 |
| 1174 // On the second iteration, mark everything as ready to draw (solid | 1182 // On the second iteration, mark everything as ready to draw (solid |
| 1175 // color). | 1183 // color). |
| 1176 if (i == 1) { | 1184 if (i == 1) { |
| 1177 ManagedTileState::DrawInfo& draw_info = last_tile->draw_info(); | 1185 TileDrawInfo& draw_info = last_tile->draw_info(); |
| 1178 draw_info.SetSolidColorForTesting(SK_ColorRED); | 1186 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 1179 } | 1187 } |
| 1180 } | 1188 } |
| 1181 | 1189 |
| 1182 EXPECT_GT(eventually_bin_order_correct_count, | 1190 EXPECT_GT(eventually_bin_order_correct_count, |
| 1183 eventually_bin_order_incorrect_count); | 1191 eventually_bin_order_incorrect_count); |
| 1184 | 1192 |
| 1185 // We should have now and eventually tiles, as well as soon tiles from | 1193 // We should have now and eventually tiles, as well as soon tiles from |
| 1186 // the border region. | 1194 // the border region. |
| 1187 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1195 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1188 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1196 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1189 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1197 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1190 | 1198 |
| 1191 EXPECT_EQ(unique_tiles.size(), all_tiles.size()); | 1199 EXPECT_EQ(unique_tiles.size(), all_tiles.size()); |
| 1192 } | 1200 } |
| 1193 } | 1201 } |
| 1194 | 1202 |
| 1195 TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) { | 1203 TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) { |
| 1196 FakePictureLayerTilingClient client; | 1204 FakePictureLayerTilingClient client; |
| 1197 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1198 | 1205 |
| 1199 gfx::Rect viewport(50, 0, 100, 100); | 1206 gfx::Rect viewport(50, 0, 100, 100); |
| 1200 gfx::Rect moved_viewport(50, 0, 100, 500); | 1207 gfx::Rect moved_viewport(50, 0, 100, 500); |
| 1201 gfx::Size layer_bounds(1000, 1000); | 1208 gfx::Size layer_bounds(1000, 1000); |
| 1202 | 1209 |
| 1203 client.SetTileSize(gfx::Size(30, 30)); | 1210 client.SetTileSize(gfx::Size(30, 30)); |
| 1204 client.set_tree(ACTIVE_TREE); | 1211 client.set_tree(ACTIVE_TREE); |
| 1205 LayerTreeSettings settings; | 1212 LayerTreeSettings settings; |
| 1206 settings.max_tiles_for_interest_area = 10000; | 1213 settings.max_tiles_for_interest_area = 10000; |
| 1207 | 1214 |
| 1208 tiling = | 1215 scoped_refptr<FakePicturePileImpl> pile = |
| 1209 TestablePictureLayerTiling::Create(1.f, layer_bounds, &client, settings); | 1216 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1217 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1218 TestablePictureLayerTiling::Create(1.f, pile, &client, settings); |
| 1210 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1219 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
| 1211 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); | 1220 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); |
| 1212 tiling->UpdateAllTilePrioritiesForTesting(); | 1221 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1213 | 1222 |
| 1214 gfx::Rect soon_rect = moved_viewport; | 1223 gfx::Rect soon_rect = moved_viewport; |
| 1215 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1224 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1216 | 1225 |
| 1217 // There are 3 bins in TilePriority. | 1226 // There are 3 bins in TilePriority. |
| 1218 bool have_tiles[3] = {}; | 1227 bool have_tiles[3] = {}; |
| 1219 Tile* last_tile = NULL; | 1228 Tile* last_tile = NULL; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 } | 1348 } |
| 1340 | 1349 |
| 1341 TEST_F(PictureLayerTilingIteratorTest, | 1350 TEST_F(PictureLayerTilingIteratorTest, |
| 1342 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1351 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
| 1343 gfx::Size layer_bounds(10000, 10000); | 1352 gfx::Size layer_bounds(10000, 10000); |
| 1344 client_.SetTileSize(gfx::Size(100, 100)); | 1353 client_.SetTileSize(gfx::Size(100, 100)); |
| 1345 client_.set_tree(PENDING_TREE); | 1354 client_.set_tree(PENDING_TREE); |
| 1346 LayerTreeSettings settings; | 1355 LayerTreeSettings settings; |
| 1347 settings.max_tiles_for_interest_area = 1; | 1356 settings.max_tiles_for_interest_area = 1; |
| 1348 | 1357 |
| 1349 tiling_ = | 1358 scoped_refptr<FakePicturePileImpl> pile = |
| 1350 TestablePictureLayerTiling::Create(1.f, layer_bounds, &client_, settings); | 1359 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1360 tiling_ = TestablePictureLayerTiling::Create(1.f, pile, &client_, settings); |
| 1351 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1361 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1352 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1362 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1353 | 1363 |
| 1354 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1364 gfx::Rect visible_rect(8000, 8000, 50, 50); |
| 1355 | 1365 |
| 1356 client_.set_tree(ACTIVE_TREE); | 1366 client_.set_tree(ACTIVE_TREE); |
| 1357 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect | 1367 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect |
| 1358 1.f, // current contents scale | 1368 1.f, // current contents scale |
| 1359 1.0, // current frame time | 1369 1.0, // current frame time |
| 1360 Occlusion()); | 1370 Occlusion()); |
| 1361 VerifyTiles(1.f, | 1371 VerifyTiles(1.f, |
| 1362 gfx::Rect(layer_bounds), | 1372 gfx::Rect(layer_bounds), |
| 1363 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); | 1373 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); |
| 1364 } | 1374 } |
| 1365 | 1375 |
| 1366 TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { | |
| 1367 gfx::Size layer_bounds(1099, 801); | |
| 1368 gfx::Size tile_size(100, 100); | |
| 1369 | |
| 1370 client_.SetTileSize(tile_size); | |
| 1371 client_.set_tree(PENDING_TREE); | |
| 1372 | |
| 1373 LayerTreeSettings defaults; | |
| 1374 auto active_set = PictureLayerTilingSet::Create( | |
| 1375 &client_, 10000, defaults.skewport_target_time_in_seconds, | |
| 1376 defaults.skewport_extrapolation_limit_in_content_pixels); | |
| 1377 | |
| 1378 active_set->AddTiling(1.f, layer_bounds); | |
| 1379 | |
| 1380 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | |
| 1381 base::Bind(&TileExists, false)); | |
| 1382 | |
| 1383 UpdateAllTilePriorities(active_set.get(), | |
| 1384 gfx::Rect(layer_bounds), // visible content rect | |
| 1385 1.f, // current contents scale | |
| 1386 1.0); // current frame time | |
| 1387 | |
| 1388 // The active tiling has tiles now. | |
| 1389 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | |
| 1390 base::Bind(&TileExists, true)); | |
| 1391 | |
| 1392 // Add the same tilings to the pending set. | |
| 1393 auto pending_set = PictureLayerTilingSet::Create( | |
| 1394 &client_, 10000, defaults.skewport_target_time_in_seconds, | |
| 1395 defaults.skewport_extrapolation_limit_in_content_pixels); | |
| 1396 Region invalidation; | |
| 1397 pending_set->SyncTilingsForTesting(*active_set, layer_bounds, invalidation, | |
| 1398 0.f, client_.raster_source()); | |
| 1399 | |
| 1400 // The pending tiling starts with no tiles. | |
| 1401 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | |
| 1402 base::Bind(&TileExists, false)); | |
| 1403 | |
| 1404 // ComputeTilePriorityRects on the pending tiling at the same frame time. The | |
| 1405 // pending tiling should get tiles. | |
| 1406 UpdateAllTilePriorities(pending_set.get(), | |
| 1407 gfx::Rect(layer_bounds), // visible content rect | |
| 1408 1.f, // current contents scale | |
| 1409 1.0); // current frame time | |
| 1410 | |
| 1411 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | |
| 1412 base::Bind(&TileExists, true)); | |
| 1413 } | |
| 1414 | |
| 1415 TEST(ComputeTilePriorityRectsTest, VisibleTiles) { | 1376 TEST(ComputeTilePriorityRectsTest, VisibleTiles) { |
| 1416 // The TilePriority of visible tiles should have zero distance_to_visible | 1377 // The TilePriority of visible tiles should have zero distance_to_visible |
| 1417 // and time_to_visible. | 1378 // and time_to_visible. |
| 1418 | |
| 1419 FakePictureLayerTilingClient client; | 1379 FakePictureLayerTilingClient client; |
| 1420 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1421 | 1380 |
| 1422 gfx::Size device_viewport(800, 600); | 1381 gfx::Size device_viewport(800, 600); |
| 1423 gfx::Size last_layer_bounds(200, 200); | 1382 gfx::Size last_layer_bounds(200, 200); |
| 1424 gfx::Size current_layer_bounds(200, 200); | 1383 gfx::Size current_layer_bounds(200, 200); |
| 1425 float current_layer_contents_scale = 1.f; | 1384 float current_layer_contents_scale = 1.f; |
| 1426 gfx::Transform current_screen_transform; | 1385 gfx::Transform current_screen_transform; |
| 1427 double current_frame_time_in_seconds = 1.0; | 1386 double current_frame_time_in_seconds = 1.0; |
| 1428 | 1387 |
| 1429 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1388 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1430 current_screen_transform, device_viewport); | 1389 current_screen_transform, device_viewport); |
| 1431 | 1390 |
| 1432 client.SetTileSize(gfx::Size(100, 100)); | 1391 client.SetTileSize(gfx::Size(100, 100)); |
| 1433 client.set_tree(ACTIVE_TREE); | 1392 client.set_tree(ACTIVE_TREE); |
| 1434 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1393 |
| 1435 current_layer_bounds, &client, | 1394 scoped_refptr<FakePicturePileImpl> pile = |
| 1436 LayerTreeSettings()); | 1395 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1396 current_layer_bounds); |
| 1397 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1398 TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1399 LayerTreeSettings()); |
| 1437 | 1400 |
| 1438 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1401 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1439 current_layer_contents_scale, | 1402 current_layer_contents_scale, |
| 1440 current_frame_time_in_seconds, Occlusion()); | 1403 current_frame_time_in_seconds, Occlusion()); |
| 1441 tiling->UpdateAllTilePrioritiesForTesting(); | 1404 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1442 | 1405 |
| 1443 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1406 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1444 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1407 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1445 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1408 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1446 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1409 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1458 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1421 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1459 | 1422 |
| 1460 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1423 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1461 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1424 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
| 1462 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1425 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1463 } | 1426 } |
| 1464 | 1427 |
| 1465 TEST(ComputeTilePriorityRectsTest, OffscreenTiles) { | 1428 TEST(ComputeTilePriorityRectsTest, OffscreenTiles) { |
| 1466 // The TilePriority of offscreen tiles (without movement) should have nonzero | 1429 // The TilePriority of offscreen tiles (without movement) should have nonzero |
| 1467 // distance_to_visible and infinite time_to_visible. | 1430 // distance_to_visible and infinite time_to_visible. |
| 1468 | |
| 1469 FakePictureLayerTilingClient client; | 1431 FakePictureLayerTilingClient client; |
| 1470 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1471 | 1432 |
| 1472 gfx::Size device_viewport(800, 600); | 1433 gfx::Size device_viewport(800, 600); |
| 1473 gfx::Size last_layer_bounds(200, 200); | 1434 gfx::Size last_layer_bounds(200, 200); |
| 1474 gfx::Size current_layer_bounds(200, 200); | 1435 gfx::Size current_layer_bounds(200, 200); |
| 1475 float current_layer_contents_scale = 1.f; | 1436 float current_layer_contents_scale = 1.f; |
| 1476 gfx::Transform last_screen_transform; | 1437 gfx::Transform last_screen_transform; |
| 1477 gfx::Transform current_screen_transform; | 1438 gfx::Transform current_screen_transform; |
| 1478 double current_frame_time_in_seconds = 1.0; | 1439 double current_frame_time_in_seconds = 1.0; |
| 1479 | 1440 |
| 1480 current_screen_transform.Translate(850, 0); | 1441 current_screen_transform.Translate(850, 0); |
| 1481 last_screen_transform = current_screen_transform; | 1442 last_screen_transform = current_screen_transform; |
| 1482 | 1443 |
| 1483 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1444 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1484 current_screen_transform, device_viewport); | 1445 current_screen_transform, device_viewport); |
| 1485 | 1446 |
| 1486 client.SetTileSize(gfx::Size(100, 100)); | 1447 client.SetTileSize(gfx::Size(100, 100)); |
| 1487 client.set_tree(ACTIVE_TREE); | 1448 client.set_tree(ACTIVE_TREE); |
| 1488 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1449 |
| 1489 current_layer_bounds, &client, | 1450 scoped_refptr<FakePicturePileImpl> pile = |
| 1490 LayerTreeSettings()); | 1451 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1452 current_layer_bounds); |
| 1453 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1454 TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1455 LayerTreeSettings()); |
| 1491 | 1456 |
| 1492 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1457 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1493 current_layer_contents_scale, | 1458 current_layer_contents_scale, |
| 1494 current_frame_time_in_seconds, Occlusion()); | 1459 current_frame_time_in_seconds, Occlusion()); |
| 1495 tiling->UpdateAllTilePrioritiesForTesting(); | 1460 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1496 | 1461 |
| 1497 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1462 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1498 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1463 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1499 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1464 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1500 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1465 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1522 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); | 1487 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); |
| 1523 | 1488 |
| 1524 left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 1489 left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
| 1525 right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1490 right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1526 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); | 1491 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); |
| 1527 } | 1492 } |
| 1528 | 1493 |
| 1529 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenLayer) { | 1494 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenLayer) { |
| 1530 // Sanity check that a layer with some tiles visible and others offscreen has | 1495 // Sanity check that a layer with some tiles visible and others offscreen has |
| 1531 // correct TilePriorities for each tile. | 1496 // correct TilePriorities for each tile. |
| 1532 | |
| 1533 FakePictureLayerTilingClient client; | 1497 FakePictureLayerTilingClient client; |
| 1534 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1535 | 1498 |
| 1536 gfx::Size device_viewport(800, 600); | 1499 gfx::Size device_viewport(800, 600); |
| 1537 gfx::Size last_layer_bounds(200, 200); | 1500 gfx::Size last_layer_bounds(200, 200); |
| 1538 gfx::Size current_layer_bounds(200, 200); | 1501 gfx::Size current_layer_bounds(200, 200); |
| 1539 float current_layer_contents_scale = 1.f; | 1502 float current_layer_contents_scale = 1.f; |
| 1540 gfx::Transform last_screen_transform; | 1503 gfx::Transform last_screen_transform; |
| 1541 gfx::Transform current_screen_transform; | 1504 gfx::Transform current_screen_transform; |
| 1542 double current_frame_time_in_seconds = 1.0; | 1505 double current_frame_time_in_seconds = 1.0; |
| 1543 | 1506 |
| 1544 current_screen_transform.Translate(705, 505); | 1507 current_screen_transform.Translate(705, 505); |
| 1545 last_screen_transform = current_screen_transform; | 1508 last_screen_transform = current_screen_transform; |
| 1546 | 1509 |
| 1547 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1510 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1548 current_screen_transform, device_viewport); | 1511 current_screen_transform, device_viewport); |
| 1549 | 1512 |
| 1550 client.SetTileSize(gfx::Size(100, 100)); | 1513 client.SetTileSize(gfx::Size(100, 100)); |
| 1551 client.set_tree(ACTIVE_TREE); | 1514 client.set_tree(ACTIVE_TREE); |
| 1552 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1515 |
| 1553 current_layer_bounds, &client, | 1516 scoped_refptr<FakePicturePileImpl> pile = |
| 1554 LayerTreeSettings()); | 1517 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1518 current_layer_bounds); |
| 1519 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1520 TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1521 LayerTreeSettings()); |
| 1555 | 1522 |
| 1556 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1523 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1557 current_layer_contents_scale, | 1524 current_layer_contents_scale, |
| 1558 current_frame_time_in_seconds, Occlusion()); | 1525 current_frame_time_in_seconds, Occlusion()); |
| 1559 tiling->UpdateAllTilePrioritiesForTesting(); | 1526 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1560 | 1527 |
| 1561 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1528 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1562 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1529 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1563 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1530 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1564 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1531 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1577 | 1544 |
| 1578 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1545 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1579 EXPECT_GT(priority.distance_to_visible, 0.f); | 1546 EXPECT_GT(priority.distance_to_visible, 0.f); |
| 1580 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1547 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 1581 } | 1548 } |
| 1582 | 1549 |
| 1583 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenRotatedLayer) { | 1550 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenRotatedLayer) { |
| 1584 // Each tile of a layer may be affected differently by a transform; Check | 1551 // Each tile of a layer may be affected differently by a transform; Check |
| 1585 // that ComputeTilePriorityRects correctly accounts for the transform between | 1552 // that ComputeTilePriorityRects correctly accounts for the transform between |
| 1586 // layer space and screen space. | 1553 // layer space and screen space. |
| 1587 | |
| 1588 FakePictureLayerTilingClient client; | 1554 FakePictureLayerTilingClient client; |
| 1589 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1590 | 1555 |
| 1591 gfx::Size device_viewport(800, 600); | 1556 gfx::Size device_viewport(800, 600); |
| 1592 gfx::Size last_layer_bounds(200, 200); | 1557 gfx::Size last_layer_bounds(200, 200); |
| 1593 gfx::Size current_layer_bounds(200, 200); | 1558 gfx::Size current_layer_bounds(200, 200); |
| 1594 float current_layer_contents_scale = 1.f; | 1559 float current_layer_contents_scale = 1.f; |
| 1595 gfx::Transform last_screen_transform; | 1560 gfx::Transform last_screen_transform; |
| 1596 gfx::Transform current_screen_transform; | 1561 gfx::Transform current_screen_transform; |
| 1597 double current_frame_time_in_seconds = 1.0; | 1562 double current_frame_time_in_seconds = 1.0; |
| 1598 | 1563 |
| 1599 // A diagonally rotated layer that is partially off the bottom of the screen. | 1564 // A diagonally rotated layer that is partially off the bottom of the screen. |
| 1600 // In this configuration, only the top-left tile would be visible. | 1565 // In this configuration, only the top-left tile would be visible. |
| 1601 current_screen_transform.Translate(600, 750); | 1566 current_screen_transform.Translate(600, 750); |
| 1602 current_screen_transform.RotateAboutZAxis(45); | 1567 current_screen_transform.RotateAboutZAxis(45); |
| 1603 last_screen_transform = current_screen_transform; | 1568 last_screen_transform = current_screen_transform; |
| 1604 | 1569 |
| 1605 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1570 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1606 current_screen_transform, device_viewport); | 1571 current_screen_transform, device_viewport); |
| 1607 | 1572 |
| 1608 client.SetTileSize(gfx::Size(100, 100)); | 1573 client.SetTileSize(gfx::Size(100, 100)); |
| 1609 client.set_tree(ACTIVE_TREE); | 1574 client.set_tree(ACTIVE_TREE); |
| 1610 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1575 |
| 1611 current_layer_bounds, &client, | 1576 scoped_refptr<FakePicturePileImpl> pile = |
| 1612 LayerTreeSettings()); | 1577 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1578 current_layer_bounds); |
| 1579 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1580 TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1581 LayerTreeSettings()); |
| 1613 | 1582 |
| 1614 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1583 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1615 current_layer_contents_scale, | 1584 current_layer_contents_scale, |
| 1616 current_frame_time_in_seconds, Occlusion()); | 1585 current_frame_time_in_seconds, Occlusion()); |
| 1617 tiling->UpdateAllTilePrioritiesForTesting(); | 1586 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1618 | 1587 |
| 1619 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1588 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1620 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1589 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1621 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1590 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1622 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1591 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1643 TilePriority top_right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1612 TilePriority top_right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
| 1644 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1613 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1645 EXPECT_GT(top_right.distance_to_visible, top_left.distance_to_visible); | 1614 EXPECT_GT(top_right.distance_to_visible, top_left.distance_to_visible); |
| 1646 | 1615 |
| 1647 EXPECT_EQ(bottom_right.distance_to_visible, top_right.distance_to_visible); | 1616 EXPECT_EQ(bottom_right.distance_to_visible, top_right.distance_to_visible); |
| 1648 } | 1617 } |
| 1649 | 1618 |
| 1650 TEST(ComputeTilePriorityRectsTest, PerspectiveLayer) { | 1619 TEST(ComputeTilePriorityRectsTest, PerspectiveLayer) { |
| 1651 // Perspective transforms need to take a different code path. | 1620 // Perspective transforms need to take a different code path. |
| 1652 // This test checks tile priorities of a perspective layer. | 1621 // This test checks tile priorities of a perspective layer. |
| 1653 | |
| 1654 FakePictureLayerTilingClient client; | 1622 FakePictureLayerTilingClient client; |
| 1655 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1656 | 1623 |
| 1657 gfx::Size device_viewport(800, 600); | 1624 gfx::Size device_viewport(800, 600); |
| 1658 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen. | 1625 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen. |
| 1659 gfx::Size last_layer_bounds(200, 200); | 1626 gfx::Size last_layer_bounds(200, 200); |
| 1660 gfx::Size current_layer_bounds(200, 200); | 1627 gfx::Size current_layer_bounds(200, 200); |
| 1661 float current_layer_contents_scale = 1.f; | 1628 float current_layer_contents_scale = 1.f; |
| 1662 gfx::Transform last_screen_transform; | 1629 gfx::Transform last_screen_transform; |
| 1663 gfx::Transform current_screen_transform; | 1630 gfx::Transform current_screen_transform; |
| 1664 double current_frame_time_in_seconds = 1.0; | 1631 double current_frame_time_in_seconds = 1.0; |
| 1665 | 1632 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1682 MathUtil::MapQuad(current_screen_transform, | 1649 MathUtil::MapQuad(current_screen_transform, |
| 1683 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), | 1650 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), |
| 1684 &clipped); | 1651 &clipped); |
| 1685 ASSERT_FALSE(clipped); | 1652 ASSERT_FALSE(clipped); |
| 1686 | 1653 |
| 1687 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1654 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1688 current_screen_transform, device_viewport); | 1655 current_screen_transform, device_viewport); |
| 1689 | 1656 |
| 1690 client.SetTileSize(gfx::Size(100, 100)); | 1657 client.SetTileSize(gfx::Size(100, 100)); |
| 1691 client.set_tree(ACTIVE_TREE); | 1658 client.set_tree(ACTIVE_TREE); |
| 1692 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1659 |
| 1693 current_layer_bounds, &client, | 1660 scoped_refptr<FakePicturePileImpl> pile = |
| 1694 LayerTreeSettings()); | 1661 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1662 current_layer_bounds); |
| 1663 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1664 TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1665 LayerTreeSettings()); |
| 1695 | 1666 |
| 1696 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1667 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1697 current_layer_contents_scale, | 1668 current_layer_contents_scale, |
| 1698 current_frame_time_in_seconds, Occlusion()); | 1669 current_frame_time_in_seconds, Occlusion()); |
| 1699 tiling->UpdateAllTilePrioritiesForTesting(); | 1670 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1700 | 1671 |
| 1701 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1672 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1702 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1673 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1703 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1674 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1704 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1675 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1730 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1701 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1731 | 1702 |
| 1732 EXPECT_GT(bottom_right.distance_to_visible, top_right.distance_to_visible); | 1703 EXPECT_GT(bottom_right.distance_to_visible, top_right.distance_to_visible); |
| 1733 | 1704 |
| 1734 EXPECT_GT(bottom_left.distance_to_visible, top_left.distance_to_visible); | 1705 EXPECT_GT(bottom_left.distance_to_visible, top_left.distance_to_visible); |
| 1735 } | 1706 } |
| 1736 | 1707 |
| 1737 TEST(ComputeTilePriorityRectsTest, PerspectiveLayerClippedByW) { | 1708 TEST(ComputeTilePriorityRectsTest, PerspectiveLayerClippedByW) { |
| 1738 // Perspective transforms need to take a different code path. | 1709 // Perspective transforms need to take a different code path. |
| 1739 // This test checks tile priorities of a perspective layer. | 1710 // This test checks tile priorities of a perspective layer. |
| 1740 | |
| 1741 FakePictureLayerTilingClient client; | 1711 FakePictureLayerTilingClient client; |
| 1742 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1743 | 1712 |
| 1744 gfx::Size device_viewport(800, 600); | 1713 gfx::Size device_viewport(800, 600); |
| 1745 gfx::Size last_layer_bounds(200, 200); | 1714 gfx::Size last_layer_bounds(200, 200); |
| 1746 gfx::Size current_layer_bounds(200, 200); | 1715 gfx::Size current_layer_bounds(200, 200); |
| 1747 float current_layer_contents_scale = 1.f; | 1716 float current_layer_contents_scale = 1.f; |
| 1748 gfx::Transform last_screen_transform; | 1717 gfx::Transform last_screen_transform; |
| 1749 gfx::Transform current_screen_transform; | 1718 gfx::Transform current_screen_transform; |
| 1750 double current_frame_time_in_seconds = 1.0; | 1719 double current_frame_time_in_seconds = 1.0; |
| 1751 | 1720 |
| 1752 // A 3d perspective layer rotated about its Y axis, translated to almost | 1721 // A 3d perspective layer rotated about its Y axis, translated to almost |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1774 MathUtil::MapQuad(current_screen_transform, | 1743 MathUtil::MapQuad(current_screen_transform, |
| 1775 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), | 1744 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), |
| 1776 &clipped); | 1745 &clipped); |
| 1777 ASSERT_FALSE(clipped); | 1746 ASSERT_FALSE(clipped); |
| 1778 | 1747 |
| 1779 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1748 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1780 current_screen_transform, device_viewport); | 1749 current_screen_transform, device_viewport); |
| 1781 | 1750 |
| 1782 client.SetTileSize(gfx::Size(100, 100)); | 1751 client.SetTileSize(gfx::Size(100, 100)); |
| 1783 client.set_tree(ACTIVE_TREE); | 1752 client.set_tree(ACTIVE_TREE); |
| 1784 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1753 |
| 1785 current_layer_bounds, &client, | 1754 scoped_refptr<FakePicturePileImpl> pile = |
| 1786 LayerTreeSettings()); | 1755 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1756 current_layer_bounds); |
| 1757 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1758 TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1759 LayerTreeSettings()); |
| 1787 | 1760 |
| 1788 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1761 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1789 current_layer_contents_scale, | 1762 current_layer_contents_scale, |
| 1790 current_frame_time_in_seconds, Occlusion()); | 1763 current_frame_time_in_seconds, Occlusion()); |
| 1791 tiling->UpdateAllTilePrioritiesForTesting(); | 1764 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1792 | 1765 |
| 1793 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1766 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1794 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1767 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1795 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1768 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1796 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1769 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1812 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1785 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 1813 | 1786 |
| 1814 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1787 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
| 1815 EXPECT_GT(priority.distance_to_visible, 0.f); | 1788 EXPECT_GT(priority.distance_to_visible, 0.f); |
| 1816 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1789 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
| 1817 } | 1790 } |
| 1818 | 1791 |
| 1819 TEST(ComputeTilePriorityRectsTest, BasicMotion) { | 1792 TEST(ComputeTilePriorityRectsTest, BasicMotion) { |
| 1820 // Test that time_to_visible is computed correctly when | 1793 // Test that time_to_visible is computed correctly when |
| 1821 // there is some motion. | 1794 // there is some motion. |
| 1822 | |
| 1823 FakePictureLayerTilingClient client; | 1795 FakePictureLayerTilingClient client; |
| 1824 scoped_ptr<TestablePictureLayerTiling> tiling; | |
| 1825 | 1796 |
| 1826 gfx::Size device_viewport(800, 600); | 1797 gfx::Size device_viewport(800, 600); |
| 1827 gfx::Rect visible_layer_rect(0, 0, 0, 0); | 1798 gfx::Rect visible_layer_rect(0, 0, 0, 0); |
| 1828 gfx::Size last_layer_bounds(200, 200); | 1799 gfx::Size last_layer_bounds(200, 200); |
| 1829 gfx::Size current_layer_bounds(200, 200); | 1800 gfx::Size current_layer_bounds(200, 200); |
| 1830 float last_layer_contents_scale = 1.f; | 1801 float last_layer_contents_scale = 1.f; |
| 1831 float current_layer_contents_scale = 1.f; | 1802 float current_layer_contents_scale = 1.f; |
| 1832 gfx::Transform last_screen_transform; | 1803 gfx::Transform last_screen_transform; |
| 1833 gfx::Transform current_screen_transform; | 1804 gfx::Transform current_screen_transform; |
| 1834 double last_frame_time_in_seconds = 1.0; | 1805 double last_frame_time_in_seconds = 1.0; |
| 1835 double current_frame_time_in_seconds = 2.0; | 1806 double current_frame_time_in_seconds = 2.0; |
| 1836 | 1807 |
| 1837 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1808 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
| 1838 current_screen_transform.Translate(1800, 0); | 1809 current_screen_transform.Translate(1800, 0); |
| 1839 last_screen_transform.Translate(2800, 0); | 1810 last_screen_transform.Translate(2800, 0); |
| 1840 | 1811 |
| 1841 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1812 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1842 current_screen_transform, device_viewport); | 1813 current_screen_transform, device_viewport); |
| 1843 | 1814 |
| 1844 client.SetTileSize(gfx::Size(100, 100)); | 1815 client.SetTileSize(gfx::Size(100, 100)); |
| 1845 client.set_tree(ACTIVE_TREE); | 1816 client.set_tree(ACTIVE_TREE); |
| 1846 LayerTreeSettings settings; | 1817 LayerTreeSettings settings; |
| 1847 settings.max_tiles_for_interest_area = 10000; | 1818 settings.max_tiles_for_interest_area = 10000; |
| 1848 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1819 |
| 1849 current_layer_bounds, &client, | 1820 scoped_refptr<FakePicturePileImpl> pile = |
| 1850 settings); | 1821 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1822 current_layer_bounds); |
| 1823 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1824 TestablePictureLayerTiling::Create(1.0f, pile, &client, settings); |
| 1851 | 1825 |
| 1852 // previous ("last") frame | 1826 // previous ("last") frame |
| 1853 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1827 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1854 last_layer_contents_scale, | 1828 last_layer_contents_scale, |
| 1855 last_frame_time_in_seconds, Occlusion()); | 1829 last_frame_time_in_seconds, Occlusion()); |
| 1856 | 1830 |
| 1857 // current frame | 1831 // current frame |
| 1858 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1832 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1859 current_layer_contents_scale, | 1833 current_layer_contents_scale, |
| 1860 current_frame_time_in_seconds, Occlusion()); | 1834 current_frame_time_in_seconds, Occlusion()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 current_screen_transform.Translate(400, 550); | 1887 current_screen_transform.Translate(400, 550); |
| 1914 current_screen_transform.RotateAboutZAxis(45); | 1888 current_screen_transform.RotateAboutZAxis(45); |
| 1915 | 1889 |
| 1916 last_screen_transform.Translate(400, 550); | 1890 last_screen_transform.Translate(400, 550); |
| 1917 | 1891 |
| 1918 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1892 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1919 current_screen_transform, device_viewport); | 1893 current_screen_transform, device_viewport); |
| 1920 | 1894 |
| 1921 client.SetTileSize(gfx::Size(100, 100)); | 1895 client.SetTileSize(gfx::Size(100, 100)); |
| 1922 client.set_tree(ACTIVE_TREE); | 1896 client.set_tree(ACTIVE_TREE); |
| 1923 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1897 |
| 1924 current_layer_bounds, &client, | 1898 scoped_refptr<FakePicturePileImpl> pile = |
| 1899 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1900 current_layer_bounds); |
| 1901 tiling = TestablePictureLayerTiling::Create(1.0f, pile, &client, |
| 1925 LayerTreeSettings()); | 1902 LayerTreeSettings()); |
| 1926 | 1903 |
| 1927 // previous ("last") frame | 1904 // previous ("last") frame |
| 1928 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1905 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1929 last_layer_contents_scale, | 1906 last_layer_contents_scale, |
| 1930 last_frame_time_in_seconds, Occlusion()); | 1907 last_frame_time_in_seconds, Occlusion()); |
| 1931 | 1908 |
| 1932 // current frame | 1909 // current frame |
| 1933 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1910 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1934 current_layer_contents_scale, | 1911 current_layer_contents_scale, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1958 // Setup: | 1935 // Setup: |
| 1959 // - Two tilings, one active one recycled with all tiles shared. | 1936 // - Two tilings, one active one recycled with all tiles shared. |
| 1960 // Procedure: | 1937 // Procedure: |
| 1961 // - Viewport moves somewhere far away and active tiling clears tiles. | 1938 // - Viewport moves somewhere far away and active tiling clears tiles. |
| 1962 // - Viewport moves back and a new active tiling tile is created. | 1939 // - Viewport moves back and a new active tiling tile is created. |
| 1963 // Result: | 1940 // Result: |
| 1964 // - Recycle tiling does _not_ have the tile in the same location (thus it | 1941 // - Recycle tiling does _not_ have the tile in the same location (thus it |
| 1965 // will be shared next time a pending tiling is created). | 1942 // will be shared next time a pending tiling is created). |
| 1966 | 1943 |
| 1967 FakePictureLayerTilingClient active_client; | 1944 FakePictureLayerTilingClient active_client; |
| 1968 scoped_ptr<TestablePictureLayerTiling> active_tiling; | |
| 1969 | 1945 |
| 1970 active_client.SetTileSize(gfx::Size(100, 100)); | 1946 active_client.SetTileSize(gfx::Size(100, 100)); |
| 1971 active_client.set_tree(ACTIVE_TREE); | 1947 active_client.set_tree(ACTIVE_TREE); |
| 1972 LayerTreeSettings settings; | 1948 LayerTreeSettings settings; |
| 1973 settings.max_tiles_for_interest_area = 10; | 1949 settings.max_tiles_for_interest_area = 10; |
| 1974 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1950 |
| 1975 gfx::Size(10000, 10000), | 1951 scoped_refptr<FakePicturePileImpl> pile = |
| 1976 &active_client, settings); | 1952 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1953 gfx::Size(10000, 10000)); |
| 1954 scoped_ptr<TestablePictureLayerTiling> active_tiling = |
| 1955 TestablePictureLayerTiling::Create(1.0f, pile, &active_client, settings); |
| 1977 // Create all tiles on this tiling. | 1956 // Create all tiles on this tiling. |
| 1978 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1957 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 1979 Occlusion()); | 1958 Occlusion()); |
| 1980 | 1959 |
| 1981 FakePictureLayerTilingClient recycle_client; | 1960 FakePictureLayerTilingClient recycle_client; |
| 1982 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1961 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 1983 recycle_client.set_tree(PENDING_TREE); | 1962 recycle_client.set_tree(PENDING_TREE); |
| 1984 recycle_client.set_twin_tiling(active_tiling.get()); | 1963 recycle_client.set_twin_tiling(active_tiling.get()); |
| 1985 | 1964 |
| 1986 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 1965 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1987 recycle_tiling = TestablePictureLayerTiling::Create( | 1966 gfx::Size(10000, 10000)); |
| 1988 1.0f, // contents_scale | 1967 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = |
| 1989 gfx::Size(10000, 10000), &recycle_client, settings); | 1968 TestablePictureLayerTiling::Create(1.0f, pile, &recycle_client, settings); |
| 1990 | 1969 |
| 1991 // Create all tiles on the second tiling. All tiles should be shared. | 1970 // Create all tiles on the second tiling. All tiles should be shared. |
| 1992 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1971 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 1993 1.0f, Occlusion()); | 1972 1.0f, Occlusion()); |
| 1994 | 1973 |
| 1995 // Set the second tiling as recycled. | 1974 // Set the second tiling as recycled. |
| 1996 active_client.set_twin_tiling(NULL); | 1975 active_client.set_twin_tiling(NULL); |
| 1997 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 1976 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
| 1998 recycle_client.set_twin_tiling(NULL); | 1977 recycle_client.set_twin_tiling(NULL); |
| 1999 | 1978 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2013 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, | 1992 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, |
| 2014 Occlusion()); | 1993 Occlusion()); |
| 2015 | 1994 |
| 2016 // Ensure that we now have a tile here on both tilings again. | 1995 // Ensure that we now have a tile here on both tilings again. |
| 2017 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1996 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 2018 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); | 1997 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
| 2019 } | 1998 } |
| 2020 | 1999 |
| 2021 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 2000 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
| 2022 FakePictureLayerTilingClient active_client; | 2001 FakePictureLayerTilingClient active_client; |
| 2023 scoped_ptr<TestablePictureLayerTiling> active_tiling; | |
| 2024 | |
| 2025 active_client.SetTileSize(gfx::Size(100, 100)); | 2002 active_client.SetTileSize(gfx::Size(100, 100)); |
| 2026 active_client.set_tree(ACTIVE_TREE); | 2003 active_client.set_tree(ACTIVE_TREE); |
| 2027 active_tiling = TestablePictureLayerTiling::Create( | 2004 |
| 2028 1.0f, // contents_scale | 2005 scoped_refptr<FakePicturePileImpl> pile = |
| 2029 gfx::Size(100, 100), &active_client, LayerTreeSettings()); | 2006 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 2007 gfx::Size(100, 100)); |
| 2008 scoped_ptr<TestablePictureLayerTiling> active_tiling = |
| 2009 TestablePictureLayerTiling::Create(1.0f, pile, &active_client, |
| 2010 LayerTreeSettings()); |
| 2030 // Create all tiles on this tiling. | 2011 // Create all tiles on this tiling. |
| 2031 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 2012 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 2032 Occlusion()); | 2013 Occlusion()); |
| 2033 | 2014 |
| 2034 FakePictureLayerTilingClient recycle_client; | 2015 FakePictureLayerTilingClient recycle_client; |
| 2035 recycle_client.SetTileSize(gfx::Size(100, 100)); | 2016 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 2036 recycle_client.set_tree(PENDING_TREE); | 2017 recycle_client.set_tree(PENDING_TREE); |
| 2037 recycle_client.set_twin_tiling(active_tiling.get()); | 2018 recycle_client.set_twin_tiling(active_tiling.get()); |
| 2038 | 2019 |
| 2039 LayerTreeSettings settings; | 2020 LayerTreeSettings settings; |
| 2040 settings.max_tiles_for_interest_area = 10; | 2021 settings.max_tiles_for_interest_area = 10; |
| 2041 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 2022 |
| 2042 recycle_tiling = TestablePictureLayerTiling::Create( | 2023 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 2043 1.0f, // contents_scale | 2024 gfx::Size(100, 100)); |
| 2044 gfx::Size(100, 100), &recycle_client, settings); | 2025 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = |
| 2026 TestablePictureLayerTiling::Create(1.0f, pile, &recycle_client, settings); |
| 2045 | 2027 |
| 2046 // Create all tiles on the recycle tiling. All tiles should be shared. | 2028 // Create all tiles on the recycle tiling. All tiles should be shared. |
| 2047 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 2029 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 2048 1.0f, Occlusion()); | 2030 1.0f, Occlusion()); |
| 2049 | 2031 |
| 2050 // Set the second tiling as recycled. | 2032 // Set the second tiling as recycled. |
| 2051 active_client.set_twin_tiling(NULL); | 2033 active_client.set_twin_tiling(NULL); |
| 2052 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2034 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
| 2053 recycle_client.set_twin_tiling(NULL); | 2035 recycle_client.set_twin_tiling(NULL); |
| 2054 | 2036 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2071 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 2053 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2072 EXPECT_EQ(4u, tiling_->AllRefTilesForTesting().size()); | 2054 EXPECT_EQ(4u, tiling_->AllRefTilesForTesting().size()); |
| 2073 | 2055 |
| 2074 client_.SetTileSize(gfx::Size(250, 200)); | 2056 client_.SetTileSize(gfx::Size(250, 200)); |
| 2075 client_.set_tree(PENDING_TREE); | 2057 client_.set_tree(PENDING_TREE); |
| 2076 | 2058 |
| 2077 // Tile size in the tiling should still be 150x100. | 2059 // Tile size in the tiling should still be 150x100. |
| 2078 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); | 2060 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 2079 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 2061 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2080 | 2062 |
| 2081 tiling_->Resize(gfx::Size(250, 150)); | 2063 // The layer's size isn't changed, but the tile size was. |
| 2064 scoped_refptr<FakePicturePileImpl> pile = |
| 2065 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 2066 gfx::Size(250, 150)); |
| 2067 tiling_->SetRasterSourceAndResize(pile); |
| 2082 | 2068 |
| 2083 // Tile size in the tiling should be resized to 250x200. | 2069 // Tile size in the tiling should be resized to 250x200. |
| 2084 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 2070 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 2085 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 2071 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2086 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 2072 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
| 2087 } | 2073 } |
| 2088 | 2074 |
| 2089 } // namespace | 2075 } // namespace |
| 2090 } // namespace cc | 2076 } // namespace cc |
| OLD | NEW |