| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 animating_transform_to_screen); | 184 animating_transform_to_screen); |
| 185 layer->UpdateTiles(); | 185 layer->UpdateTiles(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource( | 188 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource( |
| 189 const PictureLayerTiling* tiling, | 189 const PictureLayerTiling* tiling, |
| 190 RasterSource* raster_source) { | 190 RasterSource* raster_source) { |
| 191 auto prioritized_tiles = | 191 auto prioritized_tiles = |
| 192 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 192 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 193 for (PictureLayerTiling::CoverageIterator iter( | 193 for (PictureLayerTiling::CoverageIterator iter( |
| 194 tiling, tiling->contents_scale(), | 194 tiling, tiling->contents_scale_key(), |
| 195 gfx::Rect(tiling->tiling_size())); | 195 gfx::Rect(tiling->tiling_size())); |
| 196 iter; ++iter) { | 196 iter; ++iter) { |
| 197 EXPECT_TRUE(*iter); | 197 EXPECT_TRUE(*iter); |
| 198 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source()); | 198 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source()); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 void SetContentsScaleOnBothLayers(float contents_scale, | 202 void SetContentsScaleOnBothLayers(float contents_scale, |
| 203 float device_scale_factor, | 203 float device_scale_factor, |
| 204 float page_scale_factor, | 204 float page_scale_factor, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 316 |
| 317 // Verify the viewport rect for tile priority is used in picture layer tiling. | 317 // Verify the viewport rect for tile priority is used in picture layer tiling. |
| 318 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, | 318 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, |
| 319 active_layer()->viewport_rect_for_tile_priority_in_content_space()); | 319 active_layer()->viewport_rect_for_tile_priority_in_content_space()); |
| 320 PictureLayerTilingSet* tilings = active_layer()->tilings(); | 320 PictureLayerTilingSet* tilings = active_layer()->tilings(); |
| 321 for (size_t i = 0; i < tilings->num_tilings(); i++) { | 321 for (size_t i = 0; i < tilings->num_tilings(); i++) { |
| 322 PictureLayerTiling* tiling = tilings->tiling_at(i); | 322 PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 323 EXPECT_EQ( | 323 EXPECT_EQ( |
| 324 tiling->GetCurrentVisibleRectForTesting(), | 324 tiling->GetCurrentVisibleRectForTesting(), |
| 325 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, | 325 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, |
| 326 tiling->contents_scale())); | 326 tiling->contents_scale_key())); |
| 327 } | 327 } |
| 328 | 328 |
| 329 // Update tiles with viewport for tile priority as (200, 200, 100, 100) in | 329 // Update tiles with viewport for tile priority as (200, 200, 100, 100) in |
| 330 // screen space and the transform for tile priority is translated and | 330 // screen space and the transform for tile priority is translated and |
| 331 // rotated. The actual viewport for tile priority used by PictureLayerImpl | 331 // rotated. The actual viewport for tile priority used by PictureLayerImpl |
| 332 // should be (200, 200, 100, 100) applied with the said transform. | 332 // should be (200, 200, 100, 100) applied with the said transform. |
| 333 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 333 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
| 334 | 334 |
| 335 viewport_rect_for_tile_priority = gfx::Rect(200, 200, 100, 100); | 335 viewport_rect_for_tile_priority = gfx::Rect(200, 200, 100, 100); |
| 336 transform_for_tile_priority.Translate(100, 100); | 336 transform_for_tile_priority.Translate(100, 100); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 352 viewport_rect_for_tile_priority); | 352 viewport_rect_for_tile_priority); |
| 353 | 353 |
| 354 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, | 354 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, |
| 355 active_layer()->viewport_rect_for_tile_priority_in_content_space()); | 355 active_layer()->viewport_rect_for_tile_priority_in_content_space()); |
| 356 tilings = active_layer()->tilings(); | 356 tilings = active_layer()->tilings(); |
| 357 for (size_t i = 0; i < tilings->num_tilings(); i++) { | 357 for (size_t i = 0; i < tilings->num_tilings(); i++) { |
| 358 PictureLayerTiling* tiling = tilings->tiling_at(i); | 358 PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 359 EXPECT_EQ( | 359 EXPECT_EQ( |
| 360 tiling->GetCurrentVisibleRectForTesting(), | 360 tiling->GetCurrentVisibleRectForTesting(), |
| 361 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, | 361 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, |
| 362 tiling->contents_scale())); | 362 tiling->contents_scale_key())); |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { | 366 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { |
| 367 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 367 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 368 gfx::Size layer_bounds(400, 400); | 368 gfx::Size layer_bounds(400, 400); |
| 369 SetupDefaultTrees(layer_bounds); | 369 SetupDefaultTrees(layer_bounds); |
| 370 | 370 |
| 371 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, | 371 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, |
| 372 false); | 372 false); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, | 428 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, |
| 429 gfx::Size(50, 50), layer_invalidation); | 429 gfx::Size(50, 50), layer_invalidation); |
| 430 | 430 |
| 431 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 431 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
| 432 EXPECT_EQ(3u, active_layer()->num_tilings()); | 432 EXPECT_EQ(3u, active_layer()->num_tilings()); |
| 433 | 433 |
| 434 const PictureLayerTilingSet* tilings = pending_layer()->tilings(); | 434 const PictureLayerTilingSet* tilings = pending_layer()->tilings(); |
| 435 EXPECT_GT(tilings->num_tilings(), 0u); | 435 EXPECT_GT(tilings->num_tilings(), 0u); |
| 436 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 436 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 437 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 437 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 438 gfx::Rect content_invalidation = | 438 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( |
| 439 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); | 439 layer_invalidation, tiling->contents_scale_key()); |
| 440 auto prioritized_tiles = | 440 auto prioritized_tiles = |
| 441 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 441 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 442 for (PictureLayerTiling::CoverageIterator iter( | 442 for (PictureLayerTiling::CoverageIterator iter( |
| 443 tiling, tiling->contents_scale(), | 443 tiling, tiling->contents_scale_key(), |
| 444 gfx::Rect(tiling->tiling_size())); | 444 gfx::Rect(tiling->tiling_size())); |
| 445 iter; ++iter) { | 445 iter; ++iter) { |
| 446 // We don't always have a tile, but when we do it's because it was | 446 // We don't always have a tile, but when we do it's because it was |
| 447 // invalidated and it has the latest raster source. | 447 // invalidated and it has the latest raster source. |
| 448 if (*iter) { | 448 if (*iter) { |
| 449 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 449 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 450 EXPECT_EQ(pending_raster_source.get(), | 450 EXPECT_EQ(pending_raster_source.get(), |
| 451 prioritized_tiles[*iter].raster_source()); | 451 prioritized_tiles[*iter].raster_source()); |
| 452 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); | 452 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); |
| 453 } else { | 453 } else { |
| 454 // We don't create tiles in non-invalidated regions. | 454 // We don't create tiles in non-invalidated regions. |
| 455 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); | 455 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 } | 458 } |
| 459 | 459 |
| 460 tilings = active_layer()->tilings(); | 460 tilings = active_layer()->tilings(); |
| 461 EXPECT_GT(tilings->num_tilings(), 0u); | 461 EXPECT_GT(tilings->num_tilings(), 0u); |
| 462 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 462 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 463 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 463 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 464 auto prioritized_tiles = | 464 auto prioritized_tiles = |
| 465 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 465 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 466 for (PictureLayerTiling::CoverageIterator iter( | 466 for (PictureLayerTiling::CoverageIterator iter( |
| 467 tiling, tiling->contents_scale(), | 467 tiling, tiling->contents_scale_key(), |
| 468 gfx::Rect(tiling->tiling_size())); | 468 gfx::Rect(tiling->tiling_size())); |
| 469 iter; ++iter) { | 469 iter; ++iter) { |
| 470 EXPECT_TRUE(*iter); | 470 EXPECT_TRUE(*iter); |
| 471 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 471 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 472 // Raster source will be updated upon activation. | 472 // Raster source will be updated upon activation. |
| 473 EXPECT_EQ(active_raster_source.get(), | 473 EXPECT_EQ(active_raster_source.get(), |
| 474 prioritized_tiles[*iter].raster_source()); | 474 prioritized_tiles[*iter].raster_source()); |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 } | 477 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 511 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 512 | 512 |
| 513 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 513 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 514 6.f, // ideal contents scale | 514 6.f, // ideal contents scale |
| 515 3.f, // device scale | 515 3.f, // device scale |
| 516 2.f, // page scale | 516 2.f, // page scale |
| 517 1.f, // maximum animation scale | 517 1.f, // maximum animation scale |
| 518 0.f, // starting animation scale | 518 0.f, // starting animation scale |
| 519 false); | 519 false); |
| 520 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 520 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 521 EXPECT_FLOAT_EQ(6.f, | 521 EXPECT_FLOAT_EQ( |
| 522 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 522 6.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 523 EXPECT_FLOAT_EQ(6.f * low_res_factor, | 523 EXPECT_FLOAT_EQ( |
| 524 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 524 6.f * low_res_factor, |
| 525 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 525 | 526 |
| 526 // If we change the page scale factor, then we should get new tilings. | 527 // If we change the page scale factor, then we should get new tilings. |
| 527 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 528 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 528 6.6f, // ideal contents scale | 529 6.6f, // ideal contents scale |
| 529 3.f, // device scale | 530 3.f, // device scale |
| 530 2.2f, // page scale | 531 2.2f, // page scale |
| 531 1.f, // maximum animation scale | 532 1.f, // maximum animation scale |
| 532 0.f, // starting animation scale | 533 0.f, // starting animation scale |
| 533 false); | 534 false); |
| 534 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); | 535 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); |
| 535 EXPECT_FLOAT_EQ(6.6f, | 536 EXPECT_FLOAT_EQ( |
| 536 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 537 6.6f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 537 EXPECT_FLOAT_EQ(6.6f * low_res_factor, | 538 EXPECT_FLOAT_EQ( |
| 538 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 539 6.6f * low_res_factor, |
| 540 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 539 | 541 |
| 540 // If we change the device scale factor, then we should get new tilings. | 542 // If we change the device scale factor, then we should get new tilings. |
| 541 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 543 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 542 7.26f, // ideal contents scale | 544 7.26f, // ideal contents scale |
| 543 3.3f, // device scale | 545 3.3f, // device scale |
| 544 2.2f, // page scale | 546 2.2f, // page scale |
| 545 1.f, // maximum animation scale | 547 1.f, // maximum animation scale |
| 546 0.f, // starting animation scale | 548 0.f, // starting animation scale |
| 547 false); | 549 false); |
| 548 ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); | 550 ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); |
| 549 EXPECT_FLOAT_EQ(7.26f, | 551 EXPECT_FLOAT_EQ( |
| 550 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 552 7.26f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 551 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 553 EXPECT_FLOAT_EQ( |
| 552 active_layer()->tilings()->tiling_at(3)->contents_scale()); | 554 7.26f * low_res_factor, |
| 555 active_layer()->tilings()->tiling_at(3)->contents_scale_key()); |
| 553 | 556 |
| 554 // If we change the device scale factor, but end up at the same total scale | 557 // If we change the device scale factor, but end up at the same total scale |
| 555 // factor somehow, then we don't get new tilings. | 558 // factor somehow, then we don't get new tilings. |
| 556 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 559 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 557 7.26f, // ideal contents scale | 560 7.26f, // ideal contents scale |
| 558 2.2f, // device scale | 561 2.2f, // device scale |
| 559 3.3f, // page scale | 562 3.3f, // page scale |
| 560 1.f, // maximum animation scale | 563 1.f, // maximum animation scale |
| 561 0.f, // starting animation scale | 564 0.f, // starting animation scale |
| 562 false); | 565 false); |
| 563 ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); | 566 ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); |
| 564 EXPECT_FLOAT_EQ(7.26f, | 567 EXPECT_FLOAT_EQ( |
| 565 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 568 7.26f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 566 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 569 EXPECT_FLOAT_EQ( |
| 567 active_layer()->tilings()->tiling_at(3)->contents_scale()); | 570 7.26f * low_res_factor, |
| 571 active_layer()->tilings()->tiling_at(3)->contents_scale_key()); |
| 568 } | 572 } |
| 569 | 573 |
| 570 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { | 574 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { |
| 571 gfx::Size layer_bounds(1300, 1900); | 575 gfx::Size layer_bounds(1300, 1900); |
| 572 SetupDefaultTrees(layer_bounds); | 576 SetupDefaultTrees(layer_bounds); |
| 573 | 577 |
| 574 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 578 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 575 EXPECT_LT(low_res_factor, 1.f); | 579 EXPECT_LT(low_res_factor, 1.f); |
| 576 | 580 |
| 577 pending_layer()->ReleaseTileResources(); | 581 pending_layer()->ReleaseTileResources(); |
| 578 EXPECT_FALSE(pending_layer()->tilings()); | 582 EXPECT_FALSE(pending_layer()->tilings()); |
| 579 pending_layer()->RecreateTileResources(); | 583 pending_layer()->RecreateTileResources(); |
| 580 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); | 584 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); |
| 581 | 585 |
| 582 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 586 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 583 6.f, // ideal contents scale | 587 6.f, // ideal contents scale |
| 584 3.f, // device scale | 588 3.f, // device scale |
| 585 2.f, // page scale | 589 2.f, // page scale |
| 586 1.f, // maximum animation scale | 590 1.f, // maximum animation scale |
| 587 0.f, // starting animation scale | 591 0.f, // starting animation scale |
| 588 false); | 592 false); |
| 589 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 593 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 590 EXPECT_FLOAT_EQ(6.f, | 594 EXPECT_FLOAT_EQ( |
| 591 pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 595 6.f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 592 | 596 |
| 593 // If we change the page scale factor, then we should get new tilings. | 597 // If we change the page scale factor, then we should get new tilings. |
| 594 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 598 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 595 6.6f, // ideal contents scale | 599 6.6f, // ideal contents scale |
| 596 3.f, // device scale | 600 3.f, // device scale |
| 597 2.2f, // page scale | 601 2.2f, // page scale |
| 598 1.f, // maximum animation scale | 602 1.f, // maximum animation scale |
| 599 0.f, // starting animation scale | 603 0.f, // starting animation scale |
| 600 false); | 604 false); |
| 601 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 605 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 602 EXPECT_FLOAT_EQ(6.6f, | 606 EXPECT_FLOAT_EQ( |
| 603 pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 607 6.6f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 604 | 608 |
| 605 // If we change the device scale factor, then we should get new tilings. | 609 // If we change the device scale factor, then we should get new tilings. |
| 606 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 610 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 607 7.26f, // ideal contents scale | 611 7.26f, // ideal contents scale |
| 608 3.3f, // device scale | 612 3.3f, // device scale |
| 609 2.2f, // page scale | 613 2.2f, // page scale |
| 610 1.f, // maximum animation scale | 614 1.f, // maximum animation scale |
| 611 0.f, // starting animation scale | 615 0.f, // starting animation scale |
| 612 false); | 616 false); |
| 613 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 617 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 614 EXPECT_FLOAT_EQ(7.26f, | 618 EXPECT_FLOAT_EQ( |
| 615 pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 619 7.26f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 616 | 620 |
| 617 // If we change the device scale factor, but end up at the same total scale | 621 // If we change the device scale factor, but end up at the same total scale |
| 618 // factor somehow, then we don't get new tilings. | 622 // factor somehow, then we don't get new tilings. |
| 619 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 623 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 620 7.26f, // ideal contents scale | 624 7.26f, // ideal contents scale |
| 621 2.2f, // device scale | 625 2.2f, // device scale |
| 622 3.3f, // page scale | 626 3.3f, // page scale |
| 623 1.f, // maximum animation scale | 627 1.f, // maximum animation scale |
| 624 0.f, // starting animation scale | 628 0.f, // starting animation scale |
| 625 false); | 629 false); |
| 626 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 630 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 627 EXPECT_FLOAT_EQ(7.26f, | 631 EXPECT_FLOAT_EQ( |
| 628 pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 632 7.26f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 629 } | 633 } |
| 630 | 634 |
| 631 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 635 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
| 632 // This test makes sure that if a layer can have tilings, then a commit makes | 636 // This test makes sure that if a layer can have tilings, then a commit makes |
| 633 // it not able to have tilings (empty size), and then a future commit that | 637 // it not able to have tilings (empty size), and then a future commit that |
| 634 // makes it valid again should be able to create tilings. | 638 // makes it valid again should be able to create tilings. |
| 635 gfx::Size layer_bounds(1300, 1900); | 639 gfx::Size layer_bounds(1300, 1900); |
| 636 | 640 |
| 637 scoped_refptr<FakeRasterSource> empty_raster_source = | 641 scoped_refptr<FakeRasterSource> empty_raster_source = |
| 638 FakeRasterSource::CreateEmpty(layer_bounds); | 642 FakeRasterSource::CreateEmpty(layer_bounds); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 } | 689 } |
| 686 | 690 |
| 687 TEST_F(PictureLayerImplTest, ZoomOutCrash) { | 691 TEST_F(PictureLayerImplTest, ZoomOutCrash) { |
| 688 gfx::Size layer_bounds(1300, 1900); | 692 gfx::Size layer_bounds(1300, 1900); |
| 689 | 693 |
| 690 // Set up the high and low res tilings before pinch zoom. | 694 // Set up the high and low res tilings before pinch zoom. |
| 691 SetupDefaultTrees(layer_bounds); | 695 SetupDefaultTrees(layer_bounds); |
| 692 ResetTilingsAndRasterScales(); | 696 ResetTilingsAndRasterScales(); |
| 693 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 697 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 694 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false); | 698 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false); |
| 695 EXPECT_EQ(32.f, active_layer()->HighResTiling()->contents_scale()); | 699 EXPECT_EQ(32.f, active_layer()->HighResTiling()->contents_scale_key()); |
| 696 host_impl()->PinchGestureBegin(); | 700 host_impl()->PinchGestureBegin(); |
| 697 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); | 701 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); |
| 698 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); | 702 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); |
| 699 EXPECT_EQ(active_layer()->tilings()->NumHighResTilings(), 1); | 703 EXPECT_EQ(active_layer()->tilings()->NumHighResTilings(), 1); |
| 700 } | 704 } |
| 701 | 705 |
| 702 TEST_F(PictureLayerImplTest, ScaledBoundsOverflowInt) { | 706 TEST_F(PictureLayerImplTest, ScaledBoundsOverflowInt) { |
| 703 // Limit visible size. | 707 // Limit visible size. |
| 704 gfx::Size viewport_size(1, 1); | 708 gfx::Size viewport_size(1, 1); |
| 705 host_impl()->SetViewportSize(viewport_size); | 709 host_impl()->SetViewportSize(viewport_size); |
| 706 | 710 |
| 707 gfx::Size layer_bounds(600000, 60); | 711 gfx::Size layer_bounds(600000, 60); |
| 708 | 712 |
| 709 // Set up the high and low res tilings before pinch zoom. | 713 // Set up the high and low res tilings before pinch zoom. |
| 710 SetupDefaultTrees(layer_bounds); | 714 SetupDefaultTrees(layer_bounds); |
| 711 ResetTilingsAndRasterScales(); | 715 ResetTilingsAndRasterScales(); |
| 712 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 716 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 713 float scale = 8000.f; | 717 float scale = 8000.f; |
| 714 | 718 |
| 715 // Verify this will overflow an int. | 719 // Verify this will overflow an int. |
| 716 EXPECT_GT(static_cast<float>(layer_bounds.width()) * scale, | 720 EXPECT_GT(static_cast<float>(layer_bounds.width()) * scale, |
| 717 static_cast<float>(std::numeric_limits<int>::max())); | 721 static_cast<float>(std::numeric_limits<int>::max())); |
| 718 | 722 |
| 719 SetContentsScaleOnBothLayers(scale, 1.0f, scale, 1.0f, 0.f, false); | 723 SetContentsScaleOnBothLayers(scale, 1.0f, scale, 1.0f, 0.f, false); |
| 720 float adjusted_scale = active_layer()->HighResTiling()->contents_scale(); | 724 float adjusted_scale = active_layer()->HighResTiling()->contents_scale_key(); |
| 721 EXPECT_LT(adjusted_scale, scale); | 725 EXPECT_LT(adjusted_scale, scale); |
| 722 | 726 |
| 723 // PopulateSharedQuadState CHECKs for overflows. | 727 // PopulateSharedQuadState CHECKs for overflows. |
| 724 // See http://crbug.com/679035 | 728 // See http://crbug.com/679035 |
| 725 active_layer()->draw_properties().visible_layer_rect = | 729 active_layer()->draw_properties().visible_layer_rect = |
| 726 gfx::Rect(layer_bounds); | 730 gfx::Rect(layer_bounds); |
| 727 SharedQuadState state; | 731 SharedQuadState state; |
| 728 active_layer()->PopulateScaledSharedQuadState(&state, adjusted_scale, | 732 active_layer()->PopulateScaledSharedQuadState(&state, adjusted_scale, |
| 729 adjusted_scale); | 733 adjusted_scale); |
| 730 } | 734 } |
| 731 | 735 |
| 732 TEST_F(PictureLayerImplTest, PinchGestureTilings) { | 736 TEST_F(PictureLayerImplTest, PinchGestureTilings) { |
| 733 gfx::Size layer_bounds(1300, 1900); | 737 gfx::Size layer_bounds(1300, 1900); |
| 734 | 738 |
| 735 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 739 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 736 // Set up the high and low res tilings before pinch zoom. | 740 // Set up the high and low res tilings before pinch zoom. |
| 737 SetupDefaultTrees(layer_bounds); | 741 SetupDefaultTrees(layer_bounds); |
| 738 ResetTilingsAndRasterScales(); | 742 ResetTilingsAndRasterScales(); |
| 739 | 743 |
| 740 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false); | 744 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false); |
| 741 EXPECT_EQ(active_layer()->num_tilings(), 2u); | 745 EXPECT_EQ(active_layer()->num_tilings(), 2u); |
| 742 EXPECT_EQ(pending_layer()->num_tilings(), 1u); | 746 EXPECT_EQ(pending_layer()->num_tilings(), 1u); |
| 743 EXPECT_EQ(active_layer()->tilings()->tiling_at(0)->contents_scale(), 2.f); | 747 EXPECT_EQ(active_layer()->tilings()->tiling_at(0)->contents_scale_key(), 2.f); |
| 744 EXPECT_EQ(active_layer()->tilings()->tiling_at(1)->contents_scale(), | 748 EXPECT_EQ(active_layer()->tilings()->tiling_at(1)->contents_scale_key(), |
| 745 2.f * low_res_factor); | 749 2.f * low_res_factor); |
| 746 // One of the tilings has to be a low resolution one. | 750 // One of the tilings has to be a low resolution one. |
| 747 EXPECT_EQ(LOW_RESOLUTION, | 751 EXPECT_EQ(LOW_RESOLUTION, |
| 748 active_layer()->tilings()->tiling_at(1)->resolution()); | 752 active_layer()->tilings()->tiling_at(1)->resolution()); |
| 749 | 753 |
| 750 // Ensure UpdateTiles won't remove any tilings. | 754 // Ensure UpdateTiles won't remove any tilings. |
| 751 active_layer()->MarkAllTilingsUsed(); | 755 active_layer()->MarkAllTilingsUsed(); |
| 752 | 756 |
| 753 // Start a pinch gesture. | 757 // Start a pinch gesture. |
| 754 host_impl()->PinchGestureBegin(); | 758 host_impl()->PinchGestureBegin(); |
| 755 | 759 |
| 756 // Zoom out by a small amount. We should create a tiling at half | 760 // Zoom out by a small amount. We should create a tiling at half |
| 757 // the scale (2/kMaxScaleRatioDuringPinch). | 761 // the scale (2/kMaxScaleRatioDuringPinch). |
| 758 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, 0.f, false); | 762 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, 0.f, false); |
| 759 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 763 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 760 EXPECT_FLOAT_EQ(2.0f, | 764 EXPECT_FLOAT_EQ( |
| 761 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 765 2.0f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 762 EXPECT_FLOAT_EQ(1.0f, | 766 EXPECT_FLOAT_EQ( |
| 763 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 767 1.0f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 764 EXPECT_FLOAT_EQ(2.0f * low_res_factor, | 768 EXPECT_FLOAT_EQ( |
| 765 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 769 2.0f * low_res_factor, |
| 770 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 766 // Since we're pinching, we shouldn't create a low resolution tiling. | 771 // Since we're pinching, we shouldn't create a low resolution tiling. |
| 767 EXPECT_FALSE( | 772 EXPECT_FALSE( |
| 768 active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); | 773 active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); |
| 769 | 774 |
| 770 // Ensure UpdateTiles won't remove any tilings. | 775 // Ensure UpdateTiles won't remove any tilings. |
| 771 active_layer()->MarkAllTilingsUsed(); | 776 active_layer()->MarkAllTilingsUsed(); |
| 772 | 777 |
| 773 // Zoom out further, close to our low-res scale factor. We should | 778 // Zoom out further, close to our low-res scale factor. We should |
| 774 // use that tiling as high-res, and not create a new tiling. | 779 // use that tiling as high-res, and not create a new tiling. |
| 775 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, | 780 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, |
| 776 low_res_factor * 2.1f, 1.0f, 0.f, false); | 781 low_res_factor * 2.1f, 1.0f, 0.f, false); |
| 777 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 782 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 778 EXPECT_FALSE( | 783 EXPECT_FALSE( |
| 779 active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); | 784 active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); |
| 780 | 785 |
| 781 // Zoom in a lot now. Since we increase by increments of | 786 // Zoom in a lot now. Since we increase by increments of |
| 782 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. | 787 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. |
| 783 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, 0.f, false); | 788 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, 0.f, false); |
| 784 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); | 789 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); |
| 785 EXPECT_FLOAT_EQ(4.0f, | 790 EXPECT_FLOAT_EQ( |
| 786 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 791 4.0f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 787 // Although one of the tilings matches the low resolution scale, it still | 792 // Although one of the tilings matches the low resolution scale, it still |
| 788 // shouldn't be marked as low resolution since we're pinching. | 793 // shouldn't be marked as low resolution since we're pinching. |
| 789 auto* low_res_tiling = | 794 auto* low_res_tiling = |
| 790 active_layer()->tilings()->FindTilingWithScaleKey(4.f * low_res_factor); | 795 active_layer()->tilings()->FindTilingWithScaleKey(4.f * low_res_factor); |
| 791 EXPECT_TRUE(low_res_tiling); | 796 EXPECT_TRUE(low_res_tiling); |
| 792 EXPECT_NE(LOW_RESOLUTION, low_res_tiling->resolution()); | 797 EXPECT_NE(LOW_RESOLUTION, low_res_tiling->resolution()); |
| 793 | 798 |
| 794 // Stop a pinch gesture. | 799 // Stop a pinch gesture. |
| 795 host_impl()->PinchGestureEnd(); | 800 host_impl()->PinchGestureEnd(); |
| 796 | 801 |
| 797 // Ensure UpdateTiles won't remove any tilings. | 802 // Ensure UpdateTiles won't remove any tilings. |
| 798 active_layer()->MarkAllTilingsUsed(); | 803 active_layer()->MarkAllTilingsUsed(); |
| 799 | 804 |
| 800 // After pinch ends, set the scale to what the raster scale was updated to | 805 // After pinch ends, set the scale to what the raster scale was updated to |
| 801 // (checked above). | 806 // (checked above). |
| 802 SetContentsScaleOnBothLayers(4.0f, 1.0f, 4.0f, 1.f, 0.f, false); | 807 SetContentsScaleOnBothLayers(4.0f, 1.0f, 4.0f, 1.f, 0.f, false); |
| 803 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); | 808 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); |
| 804 EXPECT_FLOAT_EQ(4.0f, | 809 EXPECT_FLOAT_EQ( |
| 805 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 810 4.0f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 806 // Now that we stopped pinching, the low resolution tiling that existed should | 811 // Now that we stopped pinching, the low resolution tiling that existed should |
| 807 // now be marked as low resolution. | 812 // now be marked as low resolution. |
| 808 low_res_tiling = | 813 low_res_tiling = |
| 809 active_layer()->tilings()->FindTilingWithScaleKey(4.f * low_res_factor); | 814 active_layer()->tilings()->FindTilingWithScaleKey(4.f * low_res_factor); |
| 810 EXPECT_TRUE(low_res_tiling); | 815 EXPECT_TRUE(low_res_tiling); |
| 811 EXPECT_EQ(LOW_RESOLUTION, low_res_tiling->resolution()); | 816 EXPECT_EQ(LOW_RESOLUTION, low_res_tiling->resolution()); |
| 812 } | 817 } |
| 813 | 818 |
| 814 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { | 819 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { |
| 815 gfx::Size layer_bounds(2600, 3800); | 820 gfx::Size layer_bounds(2600, 3800); |
| 816 SetupDefaultTrees(layer_bounds); | 821 SetupDefaultTrees(layer_bounds); |
| 817 | 822 |
| 818 ResetTilingsAndRasterScales(); | 823 ResetTilingsAndRasterScales(); |
| 819 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 824 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
| 820 | 825 |
| 821 // Set up the high and low res tilings before pinch zoom. | 826 // Set up the high and low res tilings before pinch zoom. |
| 822 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, 0.f, false); | 827 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, 0.f, false); |
| 823 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); | 828 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 824 EXPECT_FLOAT_EQ(0.24f, | 829 EXPECT_FLOAT_EQ( |
| 825 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 830 0.24f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 826 EXPECT_FLOAT_EQ(0.0625f, | 831 EXPECT_FLOAT_EQ( |
| 827 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 832 0.0625f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 828 | 833 |
| 829 // Ensure UpdateTiles won't remove any tilings. | 834 // Ensure UpdateTiles won't remove any tilings. |
| 830 active_layer()->MarkAllTilingsUsed(); | 835 active_layer()->MarkAllTilingsUsed(); |
| 831 | 836 |
| 832 // Start a pinch gesture. | 837 // Start a pinch gesture. |
| 833 host_impl()->PinchGestureBegin(); | 838 host_impl()->PinchGestureBegin(); |
| 834 | 839 |
| 835 // Zoom out by a small amount. We should create a tiling at half | 840 // Zoom out by a small amount. We should create a tiling at half |
| 836 // the scale (1/kMaxScaleRatioDuringPinch). | 841 // the scale (1/kMaxScaleRatioDuringPinch). |
| 837 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, 0.f, false); | 842 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, 0.f, false); |
| 838 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 843 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 839 EXPECT_FLOAT_EQ(0.24f, | 844 EXPECT_FLOAT_EQ( |
| 840 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 845 0.24f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 841 EXPECT_FLOAT_EQ(0.12f, | 846 EXPECT_FLOAT_EQ( |
| 842 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 847 0.12f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 843 EXPECT_FLOAT_EQ(0.0625, | 848 EXPECT_FLOAT_EQ( |
| 844 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 849 0.0625, active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 845 | 850 |
| 846 // Ensure UpdateTiles won't remove any tilings. | 851 // Ensure UpdateTiles won't remove any tilings. |
| 847 active_layer()->MarkAllTilingsUsed(); | 852 active_layer()->MarkAllTilingsUsed(); |
| 848 | 853 |
| 849 // Zoom out further, close to our low-res scale factor. We should | 854 // Zoom out further, close to our low-res scale factor. We should |
| 850 // use that tiling as high-res, and not create a new tiling. | 855 // use that tiling as high-res, and not create a new tiling. |
| 851 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, 0.f, false); | 856 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, 0.f, false); |
| 852 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 857 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 853 | 858 |
| 854 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in | 859 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in |
| 855 // because 0.25(desired_scale) is within the ratio(1.2). | 860 // because 0.25(desired_scale) is within the ratio(1.2). |
| 856 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, 0.f, false); | 861 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, 0.f, false); |
| 857 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 862 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 858 | 863 |
| 859 // Zoom in a lot. Since we move in factors of two, we should get a scale that | 864 // Zoom in a lot. Since we move in factors of two, we should get a scale that |
| 860 // is a power of 2 times 0.24. | 865 // is a power of 2 times 0.24. |
| 861 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, 0.f, false); | 866 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, 0.f, false); |
| 862 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); | 867 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); |
| 863 EXPECT_FLOAT_EQ(1.92f, | 868 EXPECT_FLOAT_EQ( |
| 864 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 869 1.92f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 865 } | 870 } |
| 866 | 871 |
| 867 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 872 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
| 868 gfx::Size layer_bounds(1300, 1900); | 873 gfx::Size layer_bounds(1300, 1900); |
| 869 | 874 |
| 870 std::vector<PictureLayerTiling*> used_tilings; | 875 std::vector<PictureLayerTiling*> used_tilings; |
| 871 | 876 |
| 872 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 877 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 873 EXPECT_LT(low_res_factor, 1.f); | 878 EXPECT_LT(low_res_factor, 1.f); |
| 874 | 879 |
| 875 float scale = 1.f; | 880 float scale = 1.f; |
| 876 float page_scale = 1.f; | 881 float page_scale = 1.f; |
| 877 | 882 |
| 878 SetupDefaultTrees(layer_bounds); | 883 SetupDefaultTrees(layer_bounds); |
| 879 active_layer()->SetHasWillChangeTransformHint(true); | 884 active_layer()->SetHasWillChangeTransformHint(true); |
| 880 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); | 885 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 881 EXPECT_FLOAT_EQ(1.f, | 886 EXPECT_FLOAT_EQ( |
| 882 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 887 1.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 883 EXPECT_FLOAT_EQ(1.f * low_res_factor, | 888 EXPECT_FLOAT_EQ( |
| 884 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 889 1.f * low_res_factor, |
| 890 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 885 | 891 |
| 886 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to | 892 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to |
| 887 // |used_tilings| variable, and it's here only to ensure that active_layer() | 893 // |used_tilings| variable, and it's here only to ensure that active_layer() |
| 888 // won't remove tilings before the test has a chance to verify behavior. | 894 // won't remove tilings before the test has a chance to verify behavior. |
| 889 active_layer()->MarkAllTilingsUsed(); | 895 active_layer()->MarkAllTilingsUsed(); |
| 890 | 896 |
| 891 // We only have ideal tilings, so they aren't removed. | 897 // We only have ideal tilings, so they aren't removed. |
| 892 used_tilings.clear(); | 898 used_tilings.clear(); |
| 893 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 899 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 894 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); | 900 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 895 EXPECT_FLOAT_EQ(1.f, | 901 EXPECT_FLOAT_EQ( |
| 896 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 902 1.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 897 EXPECT_FLOAT_EQ(1.f * low_res_factor, | 903 EXPECT_FLOAT_EQ( |
| 898 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 904 1.f * low_res_factor, |
| 905 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 899 | 906 |
| 900 host_impl()->PinchGestureBegin(); | 907 host_impl()->PinchGestureBegin(); |
| 901 | 908 |
| 902 // Changing the ideal but not creating new tilings. | 909 // Changing the ideal but not creating new tilings. |
| 903 scale = 1.5f; | 910 scale = 1.5f; |
| 904 page_scale = 1.5f; | 911 page_scale = 1.5f; |
| 905 SetContentsScaleOnBothLayers(scale, 1.f, page_scale, 1.f, 0.f, false); | 912 SetContentsScaleOnBothLayers(scale, 1.f, page_scale, 1.f, 0.f, false); |
| 906 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); | 913 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 907 EXPECT_FLOAT_EQ(1.f, | 914 EXPECT_FLOAT_EQ( |
| 908 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 915 1.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 909 EXPECT_FLOAT_EQ(1.f * low_res_factor, | 916 EXPECT_FLOAT_EQ( |
| 910 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 917 1.f * low_res_factor, |
| 918 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 911 | 919 |
| 912 // The tilings are still our target scale, so they aren't removed. | 920 // The tilings are still our target scale, so they aren't removed. |
| 913 used_tilings.clear(); | 921 used_tilings.clear(); |
| 914 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 922 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 915 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 923 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 916 EXPECT_FLOAT_EQ(1.f, | 924 EXPECT_FLOAT_EQ( |
| 917 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 925 1.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 918 EXPECT_FLOAT_EQ(1.f * low_res_factor, | 926 EXPECT_FLOAT_EQ( |
| 919 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 927 1.f * low_res_factor, |
| 928 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 920 | 929 |
| 921 host_impl()->PinchGestureEnd(); | 930 host_impl()->PinchGestureEnd(); |
| 922 | 931 |
| 923 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 932 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
| 924 scale = 1.2f; | 933 scale = 1.2f; |
| 925 page_scale = 1.2f; | 934 page_scale = 1.2f; |
| 926 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, 0.f, false); | 935 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, 0.f, false); |
| 927 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); | 936 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); |
| 928 EXPECT_FLOAT_EQ(1.2f, | 937 EXPECT_FLOAT_EQ( |
| 929 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 938 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 930 EXPECT_FLOAT_EQ(1.f, | 939 EXPECT_FLOAT_EQ( |
| 931 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 940 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 932 EXPECT_FLOAT_EQ(1.2f * low_res_factor, | 941 EXPECT_FLOAT_EQ( |
| 933 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 942 1.2f * low_res_factor, |
| 934 EXPECT_FLOAT_EQ(1.f * low_res_factor, | 943 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 935 active_layer()->tilings()->tiling_at(3)->contents_scale()); | 944 EXPECT_FLOAT_EQ( |
| 945 1.f * low_res_factor, |
| 946 active_layer()->tilings()->tiling_at(3)->contents_scale_key()); |
| 936 | 947 |
| 937 // Ensure UpdateTiles won't remove any tilings. | 948 // Ensure UpdateTiles won't remove any tilings. |
| 938 active_layer()->MarkAllTilingsUsed(); | 949 active_layer()->MarkAllTilingsUsed(); |
| 939 | 950 |
| 940 // Mark the non-ideal tilings as used. They won't be removed. | 951 // Mark the non-ideal tilings as used. They won't be removed. |
| 941 used_tilings.clear(); | 952 used_tilings.clear(); |
| 942 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); | 953 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); |
| 943 used_tilings.push_back(active_layer()->tilings()->tiling_at(3)); | 954 used_tilings.push_back(active_layer()->tilings()->tiling_at(3)); |
| 944 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 955 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 945 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); | 956 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); |
| 946 EXPECT_FLOAT_EQ(1.2f, | 957 EXPECT_FLOAT_EQ( |
| 947 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 958 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 948 EXPECT_FLOAT_EQ(1.f, | 959 EXPECT_FLOAT_EQ( |
| 949 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 960 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 950 EXPECT_FLOAT_EQ(1.2f * low_res_factor, | 961 EXPECT_FLOAT_EQ( |
| 951 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 962 1.2f * low_res_factor, |
| 952 EXPECT_FLOAT_EQ(1.f * low_res_factor, | 963 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 953 active_layer()->tilings()->tiling_at(3)->contents_scale()); | 964 EXPECT_FLOAT_EQ( |
| 965 1.f * low_res_factor, |
| 966 active_layer()->tilings()->tiling_at(3)->contents_scale_key()); |
| 954 | 967 |
| 955 // Now move the ideal scale to 0.5. Our target stays 1.2. | 968 // Now move the ideal scale to 0.5. Our target stays 1.2. |
| 956 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, 0.f, false); | 969 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, 0.f, false); |
| 957 | 970 |
| 958 // The high resolution tiling is between target and ideal, so is not | 971 // The high resolution tiling is between target and ideal, so is not |
| 959 // removed. The low res tiling for the old ideal=1.0 scale is removed. | 972 // removed. The low res tiling for the old ideal=1.0 scale is removed. |
| 960 used_tilings.clear(); | 973 used_tilings.clear(); |
| 961 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 974 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 962 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 975 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 963 EXPECT_FLOAT_EQ(1.2f, | 976 EXPECT_FLOAT_EQ( |
| 964 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 977 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 965 EXPECT_FLOAT_EQ(1.f, | 978 EXPECT_FLOAT_EQ( |
| 966 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 979 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 967 EXPECT_FLOAT_EQ(1.2f * low_res_factor, | 980 EXPECT_FLOAT_EQ( |
| 968 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 981 1.2f * low_res_factor, |
| 982 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 969 | 983 |
| 970 // Now move the ideal scale to 1.0. Our target stays 1.2. | 984 // Now move the ideal scale to 1.0. Our target stays 1.2. |
| 971 SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, 0.f, false); | 985 SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, 0.f, false); |
| 972 | 986 |
| 973 // All the tilings are between are target and the ideal, so they are not | 987 // All the tilings are between are target and the ideal, so they are not |
| 974 // removed. | 988 // removed. |
| 975 used_tilings.clear(); | 989 used_tilings.clear(); |
| 976 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 990 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 977 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 991 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 978 EXPECT_FLOAT_EQ(1.2f, | 992 EXPECT_FLOAT_EQ( |
| 979 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 993 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 980 EXPECT_FLOAT_EQ(1.f, | 994 EXPECT_FLOAT_EQ( |
| 981 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 995 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 982 EXPECT_FLOAT_EQ(1.2f * low_res_factor, | 996 EXPECT_FLOAT_EQ( |
| 983 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 997 1.2f * low_res_factor, |
| 998 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 984 | 999 |
| 985 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 1000 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
| 986 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.1f, 1.f, page_scale, 1.f, | 1001 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.1f, 1.f, page_scale, 1.f, |
| 987 0.f, false); | 1002 0.f, false); |
| 988 | 1003 |
| 989 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 1004 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
| 990 // in the range [1.0,1.2] and are kept. | 1005 // in the range [1.0,1.2] and are kept. |
| 991 used_tilings.clear(); | 1006 used_tilings.clear(); |
| 992 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 1007 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 993 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 1008 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 994 EXPECT_FLOAT_EQ(1.2f, | 1009 EXPECT_FLOAT_EQ( |
| 995 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 1010 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 996 EXPECT_FLOAT_EQ(1.f, | 1011 EXPECT_FLOAT_EQ( |
| 997 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 1012 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 998 EXPECT_FLOAT_EQ(1.2f * low_res_factor, | 1013 EXPECT_FLOAT_EQ( |
| 999 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 1014 1.2f * low_res_factor, |
| 1015 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 1000 | 1016 |
| 1001 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 1017 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
| 1002 // 1.2 still. | 1018 // 1.2 still. |
| 1003 SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.1f, 1.f, page_scale, 1.f, | 1019 SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.1f, 1.f, page_scale, 1.f, |
| 1004 0.f, false); | 1020 0.f, false); |
| 1005 | 1021 |
| 1006 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 1022 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
| 1007 // target raster scale. But it is in our used tilings set, so nothing is | 1023 // target raster scale. But it is in our used tilings set, so nothing is |
| 1008 // deleted. | 1024 // deleted. |
| 1009 used_tilings.clear(); | 1025 used_tilings.clear(); |
| 1010 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); | 1026 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); |
| 1011 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 1027 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1012 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 1028 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 1013 EXPECT_FLOAT_EQ(1.2f, | 1029 EXPECT_FLOAT_EQ( |
| 1014 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 1030 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 1015 EXPECT_FLOAT_EQ(1.f, | 1031 EXPECT_FLOAT_EQ( |
| 1016 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 1032 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 1017 EXPECT_FLOAT_EQ(1.2f * low_res_factor, | 1033 EXPECT_FLOAT_EQ( |
| 1018 active_layer()->tilings()->tiling_at(2)->contents_scale()); | 1034 1.2f * low_res_factor, |
| 1035 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); |
| 1019 | 1036 |
| 1020 // If we remove it from our used tilings set, it is outside the range to keep | 1037 // If we remove it from our used tilings set, it is outside the range to keep |
| 1021 // so it is deleted. | 1038 // so it is deleted. |
| 1022 used_tilings.clear(); | 1039 used_tilings.clear(); |
| 1023 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 1040 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1024 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 1041 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 1025 EXPECT_FLOAT_EQ(1.2f, | 1042 EXPECT_FLOAT_EQ( |
| 1026 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 1043 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 1027 EXPECT_FLOAT_EQ(1.2 * low_res_factor, | 1044 EXPECT_FLOAT_EQ( |
| 1028 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 1045 1.2 * low_res_factor, |
| 1046 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 1029 } | 1047 } |
| 1030 | 1048 |
| 1031 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { | 1049 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { |
| 1032 // Make sure this layer covers multiple tiles, since otherwise low | 1050 // Make sure this layer covers multiple tiles, since otherwise low |
| 1033 // res won't get created because it is too small. | 1051 // res won't get created because it is too small. |
| 1034 gfx::Size tile_size(host_impl()->settings().default_tile_size); | 1052 gfx::Size tile_size(host_impl()->settings().default_tile_size); |
| 1035 // Avoid max untiled layer size heuristics via fixed tile size. | 1053 // Avoid max untiled layer size heuristics via fixed tile size. |
| 1036 gfx::Size layer_bounds(tile_size.width() + 1, tile_size.height() + 1); | 1054 gfx::Size layer_bounds(tile_size.width() + 1, tile_size.height() + 1); |
| 1037 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1055 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 1038 | 1056 |
| 1039 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 1057 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 1040 float contents_scale = 1.f; | 1058 float contents_scale = 1.f; |
| 1041 float device_scale = 1.f; | 1059 float device_scale = 1.f; |
| 1042 float page_scale = 1.f; | 1060 float page_scale = 1.f; |
| 1043 float maximum_animation_scale = 1.f; | 1061 float maximum_animation_scale = 1.f; |
| 1044 float starting_animation_scale = 0.f; | 1062 float starting_animation_scale = 0.f; |
| 1045 bool animating_transform = true; | 1063 bool animating_transform = true; |
| 1046 | 1064 |
| 1047 ResetTilingsAndRasterScales(); | 1065 ResetTilingsAndRasterScales(); |
| 1048 | 1066 |
| 1049 // Animating, so don't create low res even if there isn't one already. | 1067 // Animating, so don't create low res even if there isn't one already. |
| 1050 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1068 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1051 maximum_animation_scale, | 1069 maximum_animation_scale, |
| 1052 starting_animation_scale, animating_transform); | 1070 starting_animation_scale, animating_transform); |
| 1053 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1071 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 1.f); |
| 1054 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1072 EXPECT_BOTH_EQ(num_tilings(), 1u); |
| 1055 | 1073 |
| 1056 // Stop animating, low res gets created. | 1074 // Stop animating, low res gets created. |
| 1057 animating_transform = false; | 1075 animating_transform = false; |
| 1058 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1076 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1059 maximum_animation_scale, | 1077 maximum_animation_scale, |
| 1060 starting_animation_scale, animating_transform); | 1078 starting_animation_scale, animating_transform); |
| 1061 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1079 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 1.f); |
| 1062 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), low_res_factor); | 1080 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale_key(), |
| 1081 low_res_factor); |
| 1063 EXPECT_EQ(active_layer()->num_tilings(), 2u); | 1082 EXPECT_EQ(active_layer()->num_tilings(), 2u); |
| 1064 EXPECT_EQ(pending_layer()->num_tilings(), 1u); | 1083 EXPECT_EQ(pending_layer()->num_tilings(), 1u); |
| 1065 | 1084 |
| 1066 // Ensure UpdateTiles won't remove any tilings. | 1085 // Ensure UpdateTiles won't remove any tilings. |
| 1067 active_layer()->MarkAllTilingsUsed(); | 1086 active_layer()->MarkAllTilingsUsed(); |
| 1068 | 1087 |
| 1069 // Page scale animation, new high res, but no low res. We still have | 1088 // Page scale animation, new high res, but no low res. We still have |
| 1070 // a tiling at the previous scale, it's just not marked as low res on the | 1089 // a tiling at the previous scale, it's just not marked as low res on the |
| 1071 // active layer. The pending layer drops non-ideal tilings. | 1090 // active layer. The pending layer drops non-ideal tilings. |
| 1072 contents_scale = 2.f; | 1091 contents_scale = 2.f; |
| 1073 page_scale = 2.f; | 1092 page_scale = 2.f; |
| 1074 maximum_animation_scale = 2.f; | 1093 maximum_animation_scale = 2.f; |
| 1075 animating_transform = true; | 1094 animating_transform = true; |
| 1076 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1095 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1077 maximum_animation_scale, | 1096 maximum_animation_scale, |
| 1078 starting_animation_scale, animating_transform); | 1097 starting_animation_scale, animating_transform); |
| 1079 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1098 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); |
| 1080 EXPECT_FALSE(active_layer()->LowResTiling()); | 1099 EXPECT_FALSE(active_layer()->LowResTiling()); |
| 1081 EXPECT_FALSE(pending_layer()->LowResTiling()); | 1100 EXPECT_FALSE(pending_layer()->LowResTiling()); |
| 1082 EXPECT_EQ(3u, active_layer()->num_tilings()); | 1101 EXPECT_EQ(3u, active_layer()->num_tilings()); |
| 1083 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 1102 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
| 1084 | 1103 |
| 1085 // Stop animating, new low res gets created for final page scale. | 1104 // Stop animating, new low res gets created for final page scale. |
| 1086 animating_transform = false; | 1105 animating_transform = false; |
| 1087 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1106 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1088 maximum_animation_scale, | 1107 maximum_animation_scale, |
| 1089 starting_animation_scale, animating_transform); | 1108 starting_animation_scale, animating_transform); |
| 1090 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1109 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); |
| 1091 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), | 1110 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale_key(), |
| 1092 2.f * low_res_factor); | 1111 2.f * low_res_factor); |
| 1093 EXPECT_EQ(4u, active_layer()->num_tilings()); | 1112 EXPECT_EQ(4u, active_layer()->num_tilings()); |
| 1094 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 1113 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
| 1095 } | 1114 } |
| 1096 | 1115 |
| 1097 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { | 1116 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
| 1098 gfx::Size layer_bounds(host_impl()->settings().default_tile_size); | 1117 gfx::Size layer_bounds(host_impl()->settings().default_tile_size); |
| 1099 | 1118 |
| 1100 scoped_refptr<FakeRasterSource> pending_raster_source = | 1119 scoped_refptr<FakeRasterSource> pending_raster_source = |
| 1101 FakeRasterSource::CreateFilled(layer_bounds); | 1120 FakeRasterSource::CreateFilled(layer_bounds); |
| 1102 scoped_refptr<FakeRasterSource> active_raster_source = | 1121 scoped_refptr<FakeRasterSource> active_raster_source = |
| 1103 FakeRasterSource::CreateFilled(layer_bounds); | 1122 FakeRasterSource::CreateFilled(layer_bounds); |
| 1104 | 1123 |
| 1105 SetupTrees(pending_raster_source, active_raster_source); | 1124 SetupTrees(pending_raster_source, active_raster_source); |
| 1106 | 1125 |
| 1107 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 1126 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 1108 float device_scale = 1.f; | 1127 float device_scale = 1.f; |
| 1109 float page_scale = 1.f; | 1128 float page_scale = 1.f; |
| 1110 float maximum_animation_scale = 1.f; | 1129 float maximum_animation_scale = 1.f; |
| 1111 float starting_animation_scale = 0.f; | 1130 float starting_animation_scale = 0.f; |
| 1112 bool animating_transform = false; | 1131 bool animating_transform = false; |
| 1113 | 1132 |
| 1114 // Contents exactly fit on one tile at scale 1, no low res. | 1133 // Contents exactly fit on one tile at scale 1, no low res. |
| 1115 float contents_scale = 1.f; | 1134 float contents_scale = 1.f; |
| 1116 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1135 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1117 maximum_animation_scale, | 1136 maximum_animation_scale, |
| 1118 starting_animation_scale, animating_transform); | 1137 starting_animation_scale, animating_transform); |
| 1119 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1138 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), contents_scale); |
| 1120 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1139 EXPECT_BOTH_EQ(num_tilings(), 1u); |
| 1121 | 1140 |
| 1122 ResetTilingsAndRasterScales(); | 1141 ResetTilingsAndRasterScales(); |
| 1123 | 1142 |
| 1124 // Contents that are smaller than one tile, no low res. | 1143 // Contents that are smaller than one tile, no low res. |
| 1125 contents_scale = 0.123f; | 1144 contents_scale = 0.123f; |
| 1126 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1145 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1127 maximum_animation_scale, | 1146 maximum_animation_scale, |
| 1128 starting_animation_scale, animating_transform); | 1147 starting_animation_scale, animating_transform); |
| 1129 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1148 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), contents_scale); |
| 1130 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1149 EXPECT_BOTH_EQ(num_tilings(), 1u); |
| 1131 | 1150 |
| 1132 // TODO(danakj): Remove these when raster scale doesn't get fixed? | 1151 // TODO(danakj): Remove these when raster scale doesn't get fixed? |
| 1133 ResetTilingsAndRasterScales(); | 1152 ResetTilingsAndRasterScales(); |
| 1134 | 1153 |
| 1135 // Any content bounds that would create more than one tile will | 1154 // Any content bounds that would create more than one tile will |
| 1136 // generate a low res tiling. | 1155 // generate a low res tiling. |
| 1137 contents_scale = 2.5f; | 1156 contents_scale = 2.5f; |
| 1138 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1157 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1139 maximum_animation_scale, | 1158 maximum_animation_scale, |
| 1140 starting_animation_scale, animating_transform); | 1159 starting_animation_scale, animating_transform); |
| 1141 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1160 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), contents_scale); |
| 1142 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), | 1161 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale_key(), |
| 1143 contents_scale * low_res_factor); | 1162 contents_scale * low_res_factor); |
| 1144 EXPECT_FALSE(pending_layer()->LowResTiling()); | 1163 EXPECT_FALSE(pending_layer()->LowResTiling()); |
| 1145 EXPECT_EQ(active_layer()->num_tilings(), 2u); | 1164 EXPECT_EQ(active_layer()->num_tilings(), 2u); |
| 1146 EXPECT_EQ(pending_layer()->num_tilings(), 1u); | 1165 EXPECT_EQ(pending_layer()->num_tilings(), 1u); |
| 1147 | 1166 |
| 1148 // Mask layers dont create low res since they always fit on one tile. | 1167 // Mask layers dont create low res since they always fit on one tile. |
| 1149 std::unique_ptr<FakePictureLayerImpl> mask = | 1168 std::unique_ptr<FakePictureLayerImpl> mask = |
| 1150 FakePictureLayerImpl::CreateSingleTextureMaskWithRasterSource( | 1169 FakePictureLayerImpl::CreateSingleTextureMaskWithRasterSource( |
| 1151 host_impl()->pending_tree(), 3, pending_raster_source); | 1170 host_impl()->pending_tree(), 3, pending_raster_source); |
| 1152 mask->SetBounds(layer_bounds); | 1171 mask->SetBounds(layer_bounds); |
| 1153 mask->SetDrawsContent(true); | 1172 mask->SetDrawsContent(true); |
| 1154 pending_layer()->test_properties()->SetMaskLayer(std::move(mask)); | 1173 pending_layer()->test_properties()->SetMaskLayer(std::move(mask)); |
| 1155 pending_layer()->test_properties()->force_render_surface = true; | 1174 pending_layer()->test_properties()->force_render_surface = true; |
| 1156 RebuildPropertyTreesOnPendingTree(); | 1175 RebuildPropertyTreesOnPendingTree(); |
| 1157 host_impl()->pending_tree()->UpdateDrawProperties(false); | 1176 host_impl()->pending_tree()->UpdateDrawProperties(false); |
| 1158 | 1177 |
| 1159 FakePictureLayerImpl* mask_raw = static_cast<FakePictureLayerImpl*>( | 1178 FakePictureLayerImpl* mask_raw = static_cast<FakePictureLayerImpl*>( |
| 1160 pending_layer()->test_properties()->mask_layer); | 1179 pending_layer()->test_properties()->mask_layer); |
| 1161 // We did an UpdateDrawProperties above, which will set a contents scale on | 1180 // We did an UpdateDrawProperties above, which will set a contents scale on |
| 1162 // the mask layer, so allow us to reset the contents scale. | 1181 // the mask layer, so allow us to reset the contents scale. |
| 1163 mask_raw->ReleaseTileResources(); | 1182 mask_raw->ReleaseTileResources(); |
| 1164 mask_raw->RecreateTileResources(); | 1183 mask_raw->RecreateTileResources(); |
| 1165 | 1184 |
| 1166 SetupDrawPropertiesAndUpdateTiles( | 1185 SetupDrawPropertiesAndUpdateTiles( |
| 1167 mask_raw, contents_scale, device_scale, page_scale, | 1186 mask_raw, contents_scale, device_scale, page_scale, |
| 1168 maximum_animation_scale, starting_animation_scale, animating_transform); | 1187 maximum_animation_scale, starting_animation_scale, animating_transform); |
| 1169 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); | 1188 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale_key(), contents_scale); |
| 1170 EXPECT_EQ(mask_raw->num_tilings(), 1u); | 1189 EXPECT_EQ(mask_raw->num_tilings(), 1u); |
| 1171 } | 1190 } |
| 1172 | 1191 |
| 1173 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { | 1192 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { |
| 1174 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1193 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1175 | 1194 |
| 1176 gfx::Size layer_bounds(1000, 1000); | 1195 gfx::Size layer_bounds(1000, 1000); |
| 1177 | 1196 |
| 1178 scoped_refptr<FakeRasterSource> valid_raster_source = | 1197 scoped_refptr<FakeRasterSource> valid_raster_source = |
| 1179 FakeRasterSource::CreateFilled(layer_bounds); | 1198 FakeRasterSource::CreateFilled(layer_bounds); |
| 1180 SetupPendingTree(valid_raster_source); | 1199 SetupPendingTree(valid_raster_source); |
| 1181 | 1200 |
| 1182 std::unique_ptr<FakePictureLayerImpl> mask_ptr = | 1201 std::unique_ptr<FakePictureLayerImpl> mask_ptr = |
| 1183 FakePictureLayerImpl::CreateSingleTextureMaskWithRasterSource( | 1202 FakePictureLayerImpl::CreateSingleTextureMaskWithRasterSource( |
| 1184 host_impl()->pending_tree(), 3, valid_raster_source); | 1203 host_impl()->pending_tree(), 3, valid_raster_source); |
| 1185 mask_ptr->SetBounds(layer_bounds); | 1204 mask_ptr->SetBounds(layer_bounds); |
| 1186 mask_ptr->SetDrawsContent(true); | 1205 mask_ptr->SetDrawsContent(true); |
| 1187 pending_layer()->test_properties()->SetMaskLayer(std::move(mask_ptr)); | 1206 pending_layer()->test_properties()->SetMaskLayer(std::move(mask_ptr)); |
| 1188 pending_layer()->test_properties()->force_render_surface = true; | 1207 pending_layer()->test_properties()->force_render_surface = true; |
| 1189 | 1208 |
| 1190 RebuildPropertyTreesOnPendingTree(); | 1209 RebuildPropertyTreesOnPendingTree(); |
| 1191 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1210 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1192 bool update_lcd_text = false; | 1211 bool update_lcd_text = false; |
| 1193 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1212 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 1194 | 1213 |
| 1195 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>( | 1214 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>( |
| 1196 pending_layer()->test_properties()->mask_layer); | 1215 pending_layer()->test_properties()->mask_layer); |
| 1197 | 1216 |
| 1198 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); | 1217 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale_key()); |
| 1199 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1218 EXPECT_EQ(1u, pending_mask->num_tilings()); |
| 1200 | 1219 |
| 1201 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1220 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1202 pending_mask->HighResTiling()->AllTilesForTesting()); | 1221 pending_mask->HighResTiling()->AllTilesForTesting()); |
| 1203 | 1222 |
| 1204 ActivateTree(); | 1223 ActivateTree(); |
| 1205 | 1224 |
| 1206 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>( | 1225 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>( |
| 1207 host_impl()->active_tree()->LayerById(pending_mask->id())); | 1226 host_impl()->active_tree()->LayerById(pending_mask->id())); |
| 1208 | 1227 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1234 FakeRasterSource::CreateFilled(huge_bounds); | 1253 FakeRasterSource::CreateFilled(huge_bounds); |
| 1235 | 1254 |
| 1236 SetupPendingTree(huge_raster_source); | 1255 SetupPendingTree(huge_raster_source); |
| 1237 pending_mask->SetBounds(huge_bounds); | 1256 pending_mask->SetBounds(huge_bounds); |
| 1238 pending_mask->SetRasterSourceOnPending(huge_raster_source, Region()); | 1257 pending_mask->SetRasterSourceOnPending(huge_raster_source, Region()); |
| 1239 | 1258 |
| 1240 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1259 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1241 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1260 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 1242 | 1261 |
| 1243 // The mask tiling gets scaled down. | 1262 // The mask tiling gets scaled down. |
| 1244 EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f); | 1263 EXPECT_LT(pending_mask->HighResTiling()->contents_scale_key(), 1.f); |
| 1245 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1264 EXPECT_EQ(1u, pending_mask->num_tilings()); |
| 1246 | 1265 |
| 1247 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1266 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1248 pending_mask->HighResTiling()->AllTilesForTesting()); | 1267 pending_mask->HighResTiling()->AllTilesForTesting()); |
| 1249 | 1268 |
| 1250 ActivateTree(); | 1269 ActivateTree(); |
| 1251 | 1270 |
| 1252 // Mask layers have a tiling with a single tile in it. | 1271 // Mask layers have a tiling with a single tile in it. |
| 1253 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1272 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
| 1254 // The mask resource exists. | 1273 // The mask resource exists. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1337 |
| 1319 RebuildPropertyTreesOnPendingTree(); | 1338 RebuildPropertyTreesOnPendingTree(); |
| 1320 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1339 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1321 bool update_lcd_text = false; | 1340 bool update_lcd_text = false; |
| 1322 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1341 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 1323 | 1342 |
| 1324 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>( | 1343 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>( |
| 1325 pending_layer()->test_properties()->mask_layer); | 1344 pending_layer()->test_properties()->mask_layer); |
| 1326 | 1345 |
| 1327 // Masks are scaled, and do not have a low res tiling. | 1346 // Masks are scaled, and do not have a low res tiling. |
| 1328 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale()); | 1347 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale_key()); |
| 1329 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1348 EXPECT_EQ(1u, pending_mask->num_tilings()); |
| 1330 | 1349 |
| 1331 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1350 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1332 pending_mask->HighResTiling()->AllTilesForTesting()); | 1351 pending_mask->HighResTiling()->AllTilesForTesting()); |
| 1333 | 1352 |
| 1334 ActivateTree(); | 1353 ActivateTree(); |
| 1335 | 1354 |
| 1336 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>( | 1355 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>( |
| 1337 host_impl()->active_tree()->LayerById(pending_mask->id())); | 1356 host_impl()->active_tree()->LayerById(pending_mask->id())); |
| 1338 | 1357 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1672 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1654 | 1673 |
| 1655 gfx::Size tile_size(100, 100); | 1674 gfx::Size tile_size(100, 100); |
| 1656 gfx::Size layer_bounds(400, 400); | 1675 gfx::Size layer_bounds(400, 400); |
| 1657 gfx::Rect external_viewport_for_tile_priority(400, 200); | 1676 gfx::Rect external_viewport_for_tile_priority(400, 200); |
| 1658 gfx::Rect visible_layer_rect(200, 400); | 1677 gfx::Rect visible_layer_rect(200, 400); |
| 1659 | 1678 |
| 1660 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1679 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 1661 | 1680 |
| 1662 ASSERT_EQ(1u, pending_layer()->num_tilings()); | 1681 ASSERT_EQ(1u, pending_layer()->num_tilings()); |
| 1663 ASSERT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); | 1682 ASSERT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale_key()); |
| 1664 | 1683 |
| 1665 // Set external viewport for tile priority. | 1684 // Set external viewport for tile priority. |
| 1666 gfx::Transform transform; | 1685 gfx::Transform transform; |
| 1667 gfx::Transform transform_for_tile_priority; | 1686 gfx::Transform transform_for_tile_priority; |
| 1668 host_impl()->SetExternalTilePriorityConstraints( | 1687 host_impl()->SetExternalTilePriorityConstraints( |
| 1669 external_viewport_for_tile_priority, transform_for_tile_priority); | 1688 external_viewport_for_tile_priority, transform_for_tile_priority); |
| 1670 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1689 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1671 bool update_lcd_text = false; | 1690 bool update_lcd_text = false; |
| 1672 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1691 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 1673 | 1692 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 gfx::Size viewport_size(400, 400); | 1870 gfx::Size viewport_size(400, 400); |
| 1852 | 1871 |
| 1853 host_impl()->SetViewportSize(viewport_size); | 1872 host_impl()->SetViewportSize(viewport_size); |
| 1854 SetInitialDeviceScaleFactor(2.f); | 1873 SetInitialDeviceScaleFactor(2.f); |
| 1855 | 1874 |
| 1856 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1875 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 1857 active_layer()->SetHasWillChangeTransformHint(true); | 1876 active_layer()->SetHasWillChangeTransformHint(true); |
| 1858 | 1877 |
| 1859 // One ideal tile exists, this will get used when drawing. | 1878 // One ideal tile exists, this will get used when drawing. |
| 1860 std::vector<Tile*> ideal_tiles; | 1879 std::vector<Tile*> ideal_tiles; |
| 1861 EXPECT_EQ(2.f, active_layer()->HighResTiling()->contents_scale()); | 1880 EXPECT_EQ(2.f, active_layer()->HighResTiling()->contents_scale_key()); |
| 1862 ideal_tiles.push_back(active_layer()->HighResTiling()->TileAt(0, 0)); | 1881 ideal_tiles.push_back(active_layer()->HighResTiling()->TileAt(0, 0)); |
| 1863 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1882 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1864 ideal_tiles); | 1883 ideal_tiles); |
| 1865 | 1884 |
| 1866 // Due to layer scale throttling, the raster contents scale is changed to 1, | 1885 // Due to layer scale throttling, the raster contents scale is changed to 1, |
| 1867 // while the ideal is still 2. | 1886 // while the ideal is still 2. |
| 1868 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, | 1887 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1869 false); | 1888 false); |
| 1870 SetupDrawPropertiesAndUpdateTiles(active_layer(), 2.f, 1.f, 1.f, 1.f, 0.f, | 1889 SetupDrawPropertiesAndUpdateTiles(active_layer(), 2.f, 1.f, 1.f, 1.f, 0.f, |
| 1871 false); | 1890 false); |
| 1872 | 1891 |
| 1873 EXPECT_EQ(1.f, active_layer()->HighResTiling()->contents_scale()); | 1892 EXPECT_EQ(1.f, active_layer()->HighResTiling()->contents_scale_key()); |
| 1874 EXPECT_EQ(1.f, active_layer()->raster_contents_scale()); | 1893 EXPECT_EQ(1.f, active_layer()->raster_contents_scale()); |
| 1875 EXPECT_EQ(2.f, active_layer()->ideal_contents_scale()); | 1894 EXPECT_EQ(2.f, active_layer()->ideal_contents_scale()); |
| 1876 | 1895 |
| 1877 // Both tilings still exist. | 1896 // Both tilings still exist. |
| 1878 EXPECT_EQ(2.f, active_layer()->tilings()->tiling_at(0)->contents_scale()); | 1897 EXPECT_EQ(2.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 1879 EXPECT_EQ(1.f, active_layer()->tilings()->tiling_at(1)->contents_scale()); | 1898 EXPECT_EQ(1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 1880 | 1899 |
| 1881 // All high res tiles have resources. | 1900 // All high res tiles have resources. |
| 1882 std::vector<Tile*> high_tiles = | 1901 std::vector<Tile*> high_tiles = |
| 1883 active_layer()->HighResTiling()->AllTilesForTesting(); | 1902 active_layer()->HighResTiling()->AllTilesForTesting(); |
| 1884 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1903 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1885 high_tiles); | 1904 high_tiles); |
| 1886 | 1905 |
| 1887 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 1906 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1888 AppendQuadsData data; | 1907 AppendQuadsData data; |
| 1889 active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1908 active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 | 2462 |
| 2444 // No tilings should be pushed to active layer. | 2463 // No tilings should be pushed to active layer. |
| 2445 pending_layer()->PushPropertiesTo(active_layer()); | 2464 pending_layer()->PushPropertiesTo(active_layer()); |
| 2446 EXPECT_EQ(0u, active_layer()->num_tilings()); | 2465 EXPECT_EQ(0u, active_layer()->num_tilings()); |
| 2447 } | 2466 } |
| 2448 | 2467 |
| 2449 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { | 2468 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { |
| 2450 SetupDefaultTrees(gfx::Size(10, 10)); | 2469 SetupDefaultTrees(gfx::Size(10, 10)); |
| 2451 | 2470 |
| 2452 // We start with a tiling at scale 1. | 2471 // We start with a tiling at scale 1. |
| 2453 EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); | 2472 EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale_key()); |
| 2454 | 2473 |
| 2455 // When we page scale up by 2.3, we get a new tiling that is a power of 2, in | 2474 // When we page scale up by 2.3, we get a new tiling that is a power of 2, in |
| 2456 // this case 4. | 2475 // this case 4. |
| 2457 host_impl()->PinchGestureBegin(); | 2476 host_impl()->PinchGestureBegin(); |
| 2458 float high_res_scale = 2.3f; | 2477 float high_res_scale = 2.3f; |
| 2459 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, | 2478 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, |
| 2460 false); | 2479 false); |
| 2461 EXPECT_EQ(4.f, pending_layer()->HighResTiling()->contents_scale()); | 2480 EXPECT_EQ(4.f, pending_layer()->HighResTiling()->contents_scale_key()); |
| 2462 } | 2481 } |
| 2463 | 2482 |
| 2464 TEST_F(PictureLayerImplTest, PinchingTooSmall) { | 2483 TEST_F(PictureLayerImplTest, PinchingTooSmall) { |
| 2465 SetupDefaultTrees(gfx::Size(10, 10)); | 2484 SetupDefaultTrees(gfx::Size(10, 10)); |
| 2466 | 2485 |
| 2467 // We start with a tiling at scale 1. | 2486 // We start with a tiling at scale 1. |
| 2468 EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); | 2487 EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale_key()); |
| 2469 | 2488 |
| 2470 host_impl()->PinchGestureBegin(); | 2489 host_impl()->PinchGestureBegin(); |
| 2471 float high_res_scale = 0.0001f; | 2490 float high_res_scale = 0.0001f; |
| 2472 EXPECT_LT(high_res_scale, pending_layer()->MinimumContentsScale()); | 2491 EXPECT_LT(high_res_scale, pending_layer()->MinimumContentsScale()); |
| 2473 | 2492 |
| 2474 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, | 2493 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, |
| 2475 false); | 2494 false); |
| 2476 EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), | 2495 EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), |
| 2477 pending_layer()->HighResTiling()->contents_scale()); | 2496 pending_layer()->HighResTiling()->contents_scale_key()); |
| 2478 } | 2497 } |
| 2479 | 2498 |
| 2480 TEST_F(PictureLayerImplTest, PinchingTooSmallWithContentsScale) { | 2499 TEST_F(PictureLayerImplTest, PinchingTooSmallWithContentsScale) { |
| 2481 SetupDefaultTrees(gfx::Size(10, 10)); | 2500 SetupDefaultTrees(gfx::Size(10, 10)); |
| 2482 | 2501 |
| 2483 ResetTilingsAndRasterScales(); | 2502 ResetTilingsAndRasterScales(); |
| 2484 | 2503 |
| 2485 float contents_scale = 0.15f; | 2504 float contents_scale = 0.15f; |
| 2486 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, 0.f, false); | 2505 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, 0.f, false); |
| 2487 | 2506 |
| 2488 ASSERT_GE(pending_layer()->num_tilings(), 0u); | 2507 ASSERT_GE(pending_layer()->num_tilings(), 0u); |
| 2489 EXPECT_FLOAT_EQ(contents_scale, | 2508 EXPECT_FLOAT_EQ(contents_scale, |
| 2490 pending_layer()->HighResTiling()->contents_scale()); | 2509 pending_layer()->HighResTiling()->contents_scale_key()); |
| 2491 | 2510 |
| 2492 host_impl()->PinchGestureBegin(); | 2511 host_impl()->PinchGestureBegin(); |
| 2493 | 2512 |
| 2494 float page_scale = 0.0001f; | 2513 float page_scale = 0.0001f; |
| 2495 EXPECT_LT(page_scale * contents_scale, | 2514 EXPECT_LT(page_scale * contents_scale, |
| 2496 pending_layer()->MinimumContentsScale()); | 2515 pending_layer()->MinimumContentsScale()); |
| 2497 | 2516 |
| 2498 SetContentsScaleOnBothLayers(contents_scale * page_scale, 1.f, page_scale, | 2517 SetContentsScaleOnBothLayers(contents_scale * page_scale, 1.f, page_scale, |
| 2499 1.f, 0.f, false); | 2518 1.f, 0.f, false); |
| 2500 ASSERT_GE(pending_layer()->num_tilings(), 0u); | 2519 ASSERT_GE(pending_layer()->num_tilings(), 0u); |
| 2501 EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), | 2520 EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), |
| 2502 pending_layer()->HighResTiling()->contents_scale()); | 2521 pending_layer()->HighResTiling()->contents_scale_key()); |
| 2503 } | 2522 } |
| 2504 | 2523 |
| 2505 TEST_F(PictureLayerImplTest, ConsiderAnimationStartScaleForRasterScale) { | 2524 TEST_F(PictureLayerImplTest, ConsiderAnimationStartScaleForRasterScale) { |
| 2506 gfx::Size viewport_size(1000, 1000); | 2525 gfx::Size viewport_size(1000, 1000); |
| 2507 host_impl()->SetViewportSize(viewport_size); | 2526 host_impl()->SetViewportSize(viewport_size); |
| 2508 | 2527 |
| 2509 gfx::Size layer_bounds(100, 100); | 2528 gfx::Size layer_bounds(100, 100); |
| 2510 SetupDefaultTrees(layer_bounds); | 2529 SetupDefaultTrees(layer_bounds); |
| 2511 | 2530 |
| 2512 float contents_scale = 2.f; | 2531 float contents_scale = 2.f; |
| 2513 float device_scale = 1.f; | 2532 float device_scale = 1.f; |
| 2514 float page_scale = 1.f; | 2533 float page_scale = 1.f; |
| 2515 float maximum_animation_scale = 3.f; | 2534 float maximum_animation_scale = 3.f; |
| 2516 float starting_animation_scale = 1.f; | 2535 float starting_animation_scale = 1.f; |
| 2517 bool animating_transform = true; | 2536 bool animating_transform = true; |
| 2518 | 2537 |
| 2519 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2538 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 1.f); |
| 2520 | 2539 |
| 2521 // Maximum animation scale is greater than starting animation scale | 2540 // Maximum animation scale is greater than starting animation scale |
| 2522 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2541 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2523 maximum_animation_scale, | 2542 maximum_animation_scale, |
| 2524 starting_animation_scale, animating_transform); | 2543 starting_animation_scale, animating_transform); |
| 2525 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 2544 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); |
| 2526 | 2545 |
| 2527 animating_transform = false; | 2546 animating_transform = false; |
| 2528 | 2547 |
| 2529 // Once we stop animating, a new high-res tiling should be created. | 2548 // Once we stop animating, a new high-res tiling should be created. |
| 2530 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2549 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2531 maximum_animation_scale, | 2550 maximum_animation_scale, |
| 2532 starting_animation_scale, animating_transform); | 2551 starting_animation_scale, animating_transform); |
| 2533 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2552 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); |
| 2534 | 2553 |
| 2535 // Starting animation scale greater than maximum animation scale | 2554 // Starting animation scale greater than maximum animation scale |
| 2536 // Bounds at starting scale within the viewport | 2555 // Bounds at starting scale within the viewport |
| 2537 animating_transform = true; | 2556 animating_transform = true; |
| 2538 starting_animation_scale = 5.f; | 2557 starting_animation_scale = 5.f; |
| 2539 | 2558 |
| 2540 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2559 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2541 maximum_animation_scale, | 2560 maximum_animation_scale, |
| 2542 starting_animation_scale, animating_transform); | 2561 starting_animation_scale, animating_transform); |
| 2543 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 5.f); | 2562 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 5.f); |
| 2544 | 2563 |
| 2545 // Once we stop animating, a new high-res tiling should be created. | 2564 // Once we stop animating, a new high-res tiling should be created. |
| 2546 animating_transform = false; | 2565 animating_transform = false; |
| 2547 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2566 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2548 maximum_animation_scale, | 2567 maximum_animation_scale, |
| 2549 starting_animation_scale, animating_transform); | 2568 starting_animation_scale, animating_transform); |
| 2550 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2569 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); |
| 2551 | 2570 |
| 2552 // Starting Animation scale greater than maximum animation scale | 2571 // Starting Animation scale greater than maximum animation scale |
| 2553 // Bounds at starting scale outisde the viewport | 2572 // Bounds at starting scale outisde the viewport |
| 2554 animating_transform = true; | 2573 animating_transform = true; |
| 2555 starting_animation_scale = 11.f; | 2574 starting_animation_scale = 11.f; |
| 2556 | 2575 |
| 2557 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2576 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2558 maximum_animation_scale, | 2577 maximum_animation_scale, |
| 2559 starting_animation_scale, animating_transform); | 2578 starting_animation_scale, animating_transform); |
| 2560 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 2579 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); |
| 2561 } | 2580 } |
| 2562 | 2581 |
| 2563 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimation) { | 2582 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimation) { |
| 2564 gfx::Size viewport_size(1000, 1000); | 2583 gfx::Size viewport_size(1000, 1000); |
| 2565 host_impl()->SetViewportSize(viewport_size); | 2584 host_impl()->SetViewportSize(viewport_size); |
| 2566 | 2585 |
| 2567 gfx::Size layer_bounds(100, 100); | 2586 gfx::Size layer_bounds(100, 100); |
| 2568 SetupDefaultTrees(layer_bounds); | 2587 SetupDefaultTrees(layer_bounds); |
| 2569 | 2588 |
| 2570 float contents_scale = 1.f; | 2589 float contents_scale = 1.f; |
| 2571 float device_scale = 1.f; | 2590 float device_scale = 1.f; |
| 2572 float page_scale = 1.f; | 2591 float page_scale = 1.f; |
| 2573 float maximum_animation_scale = 1.f; | 2592 float maximum_animation_scale = 1.f; |
| 2574 float starting_animation_scale = 0.f; | 2593 float starting_animation_scale = 0.f; |
| 2575 bool animating_transform = false; | 2594 bool animating_transform = false; |
| 2576 | 2595 |
| 2577 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2596 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 1.f); |
| 2578 | 2597 |
| 2579 // Starting an animation should cause tiling resolution to get set to the | 2598 // Starting an animation should cause tiling resolution to get set to the |
| 2580 // maximum animation scale factor. | 2599 // maximum animation scale factor. |
| 2581 animating_transform = true; | 2600 animating_transform = true; |
| 2582 maximum_animation_scale = 3.f; | 2601 maximum_animation_scale = 3.f; |
| 2583 contents_scale = 2.f; | 2602 contents_scale = 2.f; |
| 2584 | 2603 |
| 2585 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2604 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2586 maximum_animation_scale, | 2605 maximum_animation_scale, |
| 2587 starting_animation_scale, animating_transform); | 2606 starting_animation_scale, animating_transform); |
| 2588 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 2607 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); |
| 2589 | 2608 |
| 2590 // Further changes to scale during the animation should not cause a new | 2609 // Further changes to scale during the animation should not cause a new |
| 2591 // high-res tiling to get created. | 2610 // high-res tiling to get created. |
| 2592 contents_scale = 4.f; | 2611 contents_scale = 4.f; |
| 2593 maximum_animation_scale = 5.f; | 2612 maximum_animation_scale = 5.f; |
| 2594 | 2613 |
| 2595 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2614 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2596 maximum_animation_scale, | 2615 maximum_animation_scale, |
| 2597 starting_animation_scale, animating_transform); | 2616 starting_animation_scale, animating_transform); |
| 2598 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 2617 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); |
| 2599 | 2618 |
| 2600 // Once we stop animating, a new high-res tiling should be created. | 2619 // Once we stop animating, a new high-res tiling should be created. |
| 2601 animating_transform = false; | 2620 animating_transform = false; |
| 2602 | 2621 |
| 2603 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2622 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2604 maximum_animation_scale, | 2623 maximum_animation_scale, |
| 2605 starting_animation_scale, animating_transform); | 2624 starting_animation_scale, animating_transform); |
| 2606 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2625 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 4.f); |
| 2607 | 2626 |
| 2608 // When animating with an unknown maximum animation scale factor, a new | 2627 // When animating with an unknown maximum animation scale factor, a new |
| 2609 // high-res tiling should be created at a source scale of 1. | 2628 // high-res tiling should be created at a source scale of 1. |
| 2610 animating_transform = true; | 2629 animating_transform = true; |
| 2611 contents_scale = 2.f; | 2630 contents_scale = 2.f; |
| 2612 maximum_animation_scale = 0.f; | 2631 maximum_animation_scale = 0.f; |
| 2613 | 2632 |
| 2614 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2633 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2615 maximum_animation_scale, | 2634 maximum_animation_scale, |
| 2616 starting_animation_scale, animating_transform); | 2635 starting_animation_scale, animating_transform); |
| 2617 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); | 2636 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), |
| 2637 page_scale * device_scale); |
| 2618 | 2638 |
| 2619 // Further changes to scale during the animation should not cause a new | 2639 // Further changes to scale during the animation should not cause a new |
| 2620 // high-res tiling to get created. | 2640 // high-res tiling to get created. |
| 2621 contents_scale = 3.f; | 2641 contents_scale = 3.f; |
| 2622 | 2642 |
| 2623 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2643 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2624 maximum_animation_scale, | 2644 maximum_animation_scale, |
| 2625 starting_animation_scale, animating_transform); | 2645 starting_animation_scale, animating_transform); |
| 2626 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); | 2646 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), |
| 2647 page_scale * device_scale); |
| 2627 | 2648 |
| 2628 // Once we stop animating, a new high-res tiling should be created. | 2649 // Once we stop animating, a new high-res tiling should be created. |
| 2629 animating_transform = false; | 2650 animating_transform = false; |
| 2630 contents_scale = 4.f; | 2651 contents_scale = 4.f; |
| 2631 | 2652 |
| 2632 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2653 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2633 maximum_animation_scale, | 2654 maximum_animation_scale, |
| 2634 starting_animation_scale, animating_transform); | 2655 starting_animation_scale, animating_transform); |
| 2635 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2656 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 4.f); |
| 2636 | 2657 |
| 2637 // When animating with a maxmium animation scale factor that is so large | 2658 // When animating with a maxmium animation scale factor that is so large |
| 2638 // that the layer grows larger than the viewport at this scale, a new | 2659 // that the layer grows larger than the viewport at this scale, a new |
| 2639 // high-res tiling should get created at a source scale of 1, not at its | 2660 // high-res tiling should get created at a source scale of 1, not at its |
| 2640 // maximum scale. | 2661 // maximum scale. |
| 2641 animating_transform = true; | 2662 animating_transform = true; |
| 2642 contents_scale = 2.f; | 2663 contents_scale = 2.f; |
| 2643 maximum_animation_scale = 11.f; | 2664 maximum_animation_scale = 11.f; |
| 2644 | 2665 |
| 2645 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2666 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2646 maximum_animation_scale, | 2667 maximum_animation_scale, |
| 2647 starting_animation_scale, animating_transform); | 2668 starting_animation_scale, animating_transform); |
| 2648 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); | 2669 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), |
| 2670 page_scale * device_scale); |
| 2649 | 2671 |
| 2650 // Once we stop animating, a new high-res tiling should be created. | 2672 // Once we stop animating, a new high-res tiling should be created. |
| 2651 animating_transform = false; | 2673 animating_transform = false; |
| 2652 contents_scale = 11.f; | 2674 contents_scale = 11.f; |
| 2653 | 2675 |
| 2654 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2676 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2655 maximum_animation_scale, | 2677 maximum_animation_scale, |
| 2656 starting_animation_scale, animating_transform); | 2678 starting_animation_scale, animating_transform); |
| 2657 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); | 2679 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 11.f); |
| 2658 | 2680 |
| 2659 // When animating with a maxmium animation scale factor that is so large | 2681 // When animating with a maxmium animation scale factor that is so large |
| 2660 // that the layer grows larger than the viewport at this scale, and where | 2682 // that the layer grows larger than the viewport at this scale, and where |
| 2661 // the intial source scale is < 1, a new high-res tiling should get created | 2683 // the intial source scale is < 1, a new high-res tiling should get created |
| 2662 // at source scale 1. | 2684 // at source scale 1. |
| 2663 animating_transform = true; | 2685 animating_transform = true; |
| 2664 contents_scale = 0.1f; | 2686 contents_scale = 0.1f; |
| 2665 maximum_animation_scale = 11.f; | 2687 maximum_animation_scale = 11.f; |
| 2666 | 2688 |
| 2667 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2689 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2668 maximum_animation_scale, | 2690 maximum_animation_scale, |
| 2669 starting_animation_scale, animating_transform); | 2691 starting_animation_scale, animating_transform); |
| 2670 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); | 2692 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), |
| 2693 device_scale * page_scale); |
| 2671 | 2694 |
| 2672 // Once we stop animating, a new high-res tiling should be created. | 2695 // Once we stop animating, a new high-res tiling should be created. |
| 2673 animating_transform = false; | 2696 animating_transform = false; |
| 2674 contents_scale = 12.f; | 2697 contents_scale = 12.f; |
| 2675 | 2698 |
| 2676 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2699 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2677 maximum_animation_scale, | 2700 maximum_animation_scale, |
| 2678 starting_animation_scale, animating_transform); | 2701 starting_animation_scale, animating_transform); |
| 2679 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 12.f); | 2702 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 12.f); |
| 2680 | 2703 |
| 2681 // When animating toward a smaller scale, but that is still so large that the | 2704 // When animating toward a smaller scale, but that is still so large that the |
| 2682 // layer grows larger than the viewport at this scale, a new high-res tiling | 2705 // layer grows larger than the viewport at this scale, a new high-res tiling |
| 2683 // should get created at source scale 1. | 2706 // should get created at source scale 1. |
| 2684 animating_transform = true; | 2707 animating_transform = true; |
| 2685 contents_scale = 11.f; | 2708 contents_scale = 11.f; |
| 2686 maximum_animation_scale = 11.f; | 2709 maximum_animation_scale = 11.f; |
| 2687 | 2710 |
| 2688 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2711 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2689 maximum_animation_scale, | 2712 maximum_animation_scale, |
| 2690 starting_animation_scale, animating_transform); | 2713 starting_animation_scale, animating_transform); |
| 2691 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); | 2714 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), |
| 2715 device_scale * page_scale); |
| 2692 | 2716 |
| 2693 // Once we stop animating, a new high-res tiling should be created. | 2717 // Once we stop animating, a new high-res tiling should be created. |
| 2694 animating_transform = false; | 2718 animating_transform = false; |
| 2695 contents_scale = 11.f; | 2719 contents_scale = 11.f; |
| 2696 | 2720 |
| 2697 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2721 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2698 maximum_animation_scale, | 2722 maximum_animation_scale, |
| 2699 starting_animation_scale, animating_transform); | 2723 starting_animation_scale, animating_transform); |
| 2700 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); | 2724 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 11.f); |
| 2701 } | 2725 } |
| 2702 | 2726 |
| 2703 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { | 2727 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { |
| 2704 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 2728 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 2705 | 2729 |
| 2706 host_impl()->SetViewportSize(gfx::Size(500, 500)); | 2730 host_impl()->SetViewportSize(gfx::Size(500, 500)); |
| 2707 | 2731 |
| 2708 gfx::Size layer_bounds(1000, 1000); | 2732 gfx::Size layer_bounds(1000, 1000); |
| 2709 | 2733 |
| 2710 scoped_refptr<FakeRasterSource> pending_raster_source = | 2734 scoped_refptr<FakeRasterSource> pending_raster_source = |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2955 TilePriority priority = prioritized_tile.priority(); | 2979 TilePriority priority = prioritized_tile.priority(); |
| 2956 | 2980 |
| 2957 if (priority.priority_bin == TilePriority::NOW) { | 2981 if (priority.priority_bin == TilePriority::NOW) { |
| 2958 reached_visible = true; | 2982 reached_visible = true; |
| 2959 last_tile = prioritized_tile; | 2983 last_tile = prioritized_tile; |
| 2960 break; | 2984 break; |
| 2961 } | 2985 } |
| 2962 | 2986 |
| 2963 EXPECT_FALSE(tile->required_for_activation()); | 2987 EXPECT_FALSE(tile->required_for_activation()); |
| 2964 | 2988 |
| 2965 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > | 2989 while (std::abs(tile->contents_scale_key() - expected_scales[scale_index]) > |
| 2966 std::numeric_limits<float>::epsilon()) { | 2990 std::numeric_limits<float>::epsilon()) { |
| 2967 ++scale_index; | 2991 ++scale_index; |
| 2968 ASSERT_LT(scale_index, arraysize(expected_scales)); | 2992 ASSERT_LT(scale_index, arraysize(expected_scales)); |
| 2969 } | 2993 } |
| 2970 | 2994 |
| 2971 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); | 2995 EXPECT_FLOAT_EQ(tile->contents_scale_key(), expected_scales[scale_index]); |
| 2972 unique_tiles.insert(tile); | 2996 unique_tiles.insert(tile); |
| 2973 | 2997 |
| 2974 if (tile->required_for_activation() == | 2998 if (tile->required_for_activation() == |
| 2975 last_tile.tile()->required_for_activation() && | 2999 last_tile.tile()->required_for_activation() && |
| 2976 std::abs(tile->contents_scale() - last_tile.tile()->contents_scale()) < | 3000 std::abs(tile->contents_scale_key() - |
| 3001 last_tile.tile()->contents_scale_key()) < |
| 2977 std::numeric_limits<float>::epsilon()) { | 3002 std::numeric_limits<float>::epsilon()) { |
| 2978 if (priority.distance_to_visible <= | 3003 if (priority.distance_to_visible <= |
| 2979 last_tile.priority().distance_to_visible) | 3004 last_tile.priority().distance_to_visible) |
| 2980 ++distance_decreasing; | 3005 ++distance_decreasing; |
| 2981 else | 3006 else |
| 2982 ++distance_increasing; | 3007 ++distance_increasing; |
| 2983 } | 3008 } |
| 2984 | 3009 |
| 2985 last_tile = prioritized_tile; | 3010 last_tile = prioritized_tile; |
| 2986 queue->Pop(); | 3011 queue->Pop(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3002 TilePriority priority = prioritized_tile.priority(); | 3027 TilePriority priority = prioritized_tile.priority(); |
| 3003 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 3028 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
| 3004 | 3029 |
| 3005 if (reached_required) { | 3030 if (reached_required) { |
| 3006 EXPECT_TRUE(tile->required_for_activation()); | 3031 EXPECT_TRUE(tile->required_for_activation()); |
| 3007 } else if (tile->required_for_activation()) { | 3032 } else if (tile->required_for_activation()) { |
| 3008 reached_required = true; | 3033 reached_required = true; |
| 3009 scale_index = 0; | 3034 scale_index = 0; |
| 3010 } | 3035 } |
| 3011 | 3036 |
| 3012 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > | 3037 while (std::abs(tile->contents_scale_key() - expected_scales[scale_index]) > |
| 3013 std::numeric_limits<float>::epsilon()) { | 3038 std::numeric_limits<float>::epsilon()) { |
| 3014 ++scale_index; | 3039 ++scale_index; |
| 3015 ASSERT_LT(scale_index, arraysize(expected_scales)); | 3040 ASSERT_LT(scale_index, arraysize(expected_scales)); |
| 3016 } | 3041 } |
| 3017 | 3042 |
| 3018 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); | 3043 EXPECT_FLOAT_EQ(tile->contents_scale_key(), expected_scales[scale_index]); |
| 3019 unique_tiles.insert(tile); | 3044 unique_tiles.insert(tile); |
| 3020 queue->Pop(); | 3045 queue->Pop(); |
| 3021 } | 3046 } |
| 3022 | 3047 |
| 3023 EXPECT_TRUE(reached_required); | 3048 EXPECT_TRUE(reached_required); |
| 3024 EXPECT_EQ(all_tiles_set.size(), unique_tiles.size()); | 3049 EXPECT_EQ(all_tiles_set.size(), unique_tiles.size()); |
| 3025 } | 3050 } |
| 3026 | 3051 |
| 3027 TEST_F(PictureLayerImplTest, Occlusion) { | 3052 TEST_F(PictureLayerImplTest, Occlusion) { |
| 3028 gfx::Size tile_size(102, 102); | 3053 gfx::Size tile_size(102, 102); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 float contents_scale = 2.f; | 3108 float contents_scale = 2.f; |
| 3084 float device_scale = 1.f; | 3109 float device_scale = 1.f; |
| 3085 float page_scale = 1.f; | 3110 float page_scale = 1.f; |
| 3086 float maximum_animation_scale = 1.f; | 3111 float maximum_animation_scale = 1.f; |
| 3087 float starting_animation_scale = 0.f; | 3112 float starting_animation_scale = 0.f; |
| 3088 bool animating_transform = false; | 3113 bool animating_transform = false; |
| 3089 | 3114 |
| 3090 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3115 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3091 maximum_animation_scale, | 3116 maximum_animation_scale, |
| 3092 starting_animation_scale, animating_transform); | 3117 starting_animation_scale, animating_transform); |
| 3093 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 3118 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); |
| 3094 | 3119 |
| 3095 // Changing the source scale without being in an animation will cause | 3120 // Changing the source scale without being in an animation will cause |
| 3096 // the layer to change scale. | 3121 // the layer to change scale. |
| 3097 contents_scale = 3.f; | 3122 contents_scale = 3.f; |
| 3098 | 3123 |
| 3099 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3124 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3100 maximum_animation_scale, | 3125 maximum_animation_scale, |
| 3101 starting_animation_scale, animating_transform); | 3126 starting_animation_scale, animating_transform); |
| 3102 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 3127 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); |
| 3103 | 3128 |
| 3104 contents_scale = 0.5f; | 3129 contents_scale = 0.5f; |
| 3105 | 3130 |
| 3106 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3131 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3107 maximum_animation_scale, | 3132 maximum_animation_scale, |
| 3108 starting_animation_scale, animating_transform); | 3133 starting_animation_scale, animating_transform); |
| 3109 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); | 3134 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 0.5f); |
| 3110 | 3135 |
| 3111 // However, if the layer has a will-change property, then the raster scale | 3136 // However, if the layer has a will-change property, then the raster scale |
| 3112 // will get fixed at the last value. | 3137 // will get fixed at the last value. |
| 3113 active_layer()->SetHasWillChangeTransformHint(true); | 3138 active_layer()->SetHasWillChangeTransformHint(true); |
| 3114 pending_layer()->SetHasWillChangeTransformHint(true); | 3139 pending_layer()->SetHasWillChangeTransformHint(true); |
| 3115 | 3140 |
| 3116 contents_scale = 3.f; | 3141 contents_scale = 3.f; |
| 3117 | 3142 |
| 3118 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3143 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3119 maximum_animation_scale, | 3144 maximum_animation_scale, |
| 3120 starting_animation_scale, animating_transform); | 3145 starting_animation_scale, animating_transform); |
| 3121 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); | 3146 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 0.5f); |
| 3122 | 3147 |
| 3123 // Further changes to the source scale will no longer be reflected in the | 3148 // Further changes to the source scale will no longer be reflected in the |
| 3124 // contents scale. | 3149 // contents scale. |
| 3125 contents_scale = 1.f; | 3150 contents_scale = 1.f; |
| 3126 | 3151 |
| 3127 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3152 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3128 maximum_animation_scale, | 3153 maximum_animation_scale, |
| 3129 starting_animation_scale, animating_transform); | 3154 starting_animation_scale, animating_transform); |
| 3130 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); | 3155 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 0.5f); |
| 3131 | 3156 |
| 3132 // Disabling the will-change hint will once again make the raster scale update | 3157 // Disabling the will-change hint will once again make the raster scale update |
| 3133 // with the ideal scale. | 3158 // with the ideal scale. |
| 3134 active_layer()->SetHasWillChangeTransformHint(false); | 3159 active_layer()->SetHasWillChangeTransformHint(false); |
| 3135 pending_layer()->SetHasWillChangeTransformHint(false); | 3160 pending_layer()->SetHasWillChangeTransformHint(false); |
| 3136 | 3161 |
| 3137 contents_scale = 3.f; | 3162 contents_scale = 3.f; |
| 3138 | 3163 |
| 3139 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3164 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3140 maximum_animation_scale, | 3165 maximum_animation_scale, |
| 3141 starting_animation_scale, animating_transform); | 3166 starting_animation_scale, animating_transform); |
| 3142 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 3167 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); |
| 3143 } | 3168 } |
| 3144 | 3169 |
| 3145 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3170 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
| 3146 gfx::Size tile_size(100, 100); | 3171 gfx::Size tile_size(100, 100); |
| 3147 gfx::Size layer_bounds(1000, 1000); | 3172 gfx::Size layer_bounds(1000, 1000); |
| 3148 | 3173 |
| 3149 // Make sure pending tree has tiles. | 3174 // Make sure pending tree has tiles. |
| 3150 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3175 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3151 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3176 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3152 | 3177 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3215 ResetTilingsAndRasterScales(); | 3240 ResetTilingsAndRasterScales(); |
| 3216 | 3241 |
| 3217 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 3242 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 3218 6.f, // ideal contents scale | 3243 6.f, // ideal contents scale |
| 3219 3.f, // device scale | 3244 3.f, // device scale |
| 3220 2.f, // page scale | 3245 2.f, // page scale |
| 3221 1.f, // maximum animation scale | 3246 1.f, // maximum animation scale |
| 3222 0.f, // starting animation scale | 3247 0.f, // starting animation scale |
| 3223 false); | 3248 false); |
| 3224 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); | 3249 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); |
| 3225 EXPECT_FLOAT_EQ(6.f, | 3250 EXPECT_FLOAT_EQ( |
| 3226 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 3251 6.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 3227 | 3252 |
| 3228 // If we change the page scale factor, then we should get new tilings. | 3253 // If we change the page scale factor, then we should get new tilings. |
| 3229 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 3254 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 3230 6.6f, // ideal contents scale | 3255 6.6f, // ideal contents scale |
| 3231 3.f, // device scale | 3256 3.f, // device scale |
| 3232 2.2f, // page scale | 3257 2.2f, // page scale |
| 3233 1.f, // maximum animation scale | 3258 1.f, // maximum animation scale |
| 3234 0.f, // starting animation scale | 3259 0.f, // starting animation scale |
| 3235 false); | 3260 false); |
| 3236 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 3261 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 3237 EXPECT_FLOAT_EQ(6.6f, | 3262 EXPECT_FLOAT_EQ( |
| 3238 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 3263 6.6f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 3239 | 3264 |
| 3240 // If we change the device scale factor, then we should get new tilings. | 3265 // If we change the device scale factor, then we should get new tilings. |
| 3241 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 3266 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 3242 7.26f, // ideal contents scale | 3267 7.26f, // ideal contents scale |
| 3243 3.3f, // device scale | 3268 3.3f, // device scale |
| 3244 2.2f, // page scale | 3269 2.2f, // page scale |
| 3245 1.f, // maximum animation scale | 3270 1.f, // maximum animation scale |
| 3246 0.f, // starting animation scale | 3271 0.f, // starting animation scale |
| 3247 false); | 3272 false); |
| 3248 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 3273 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 3249 EXPECT_FLOAT_EQ(7.26f, | 3274 EXPECT_FLOAT_EQ( |
| 3250 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 3275 7.26f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 3251 | 3276 |
| 3252 // If we change the device scale factor, but end up at the same total scale | 3277 // If we change the device scale factor, but end up at the same total scale |
| 3253 // factor somehow, then we don't get new tilings. | 3278 // factor somehow, then we don't get new tilings. |
| 3254 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 3279 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
| 3255 7.26f, // ideal contents scale | 3280 7.26f, // ideal contents scale |
| 3256 2.2f, // device scale | 3281 2.2f, // device scale |
| 3257 3.3f, // page scale | 3282 3.3f, // page scale |
| 3258 1.f, // maximum animation scale | 3283 1.f, // maximum animation scale |
| 3259 0.f, // starting animation scale | 3284 0.f, // starting animation scale |
| 3260 false); | 3285 false); |
| 3261 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 3286 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| 3262 EXPECT_FLOAT_EQ(7.26f, | 3287 EXPECT_FLOAT_EQ( |
| 3263 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 3288 7.26f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 3264 } | 3289 } |
| 3265 | 3290 |
| 3266 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { | 3291 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { |
| 3267 gfx::Size layer_bounds(1300, 1900); | 3292 gfx::Size layer_bounds(1300, 1900); |
| 3268 SetupDefaultTrees(layer_bounds); | 3293 SetupDefaultTrees(layer_bounds); |
| 3269 | 3294 |
| 3270 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 3295 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 3271 EXPECT_LT(low_res_factor, 1.f); | 3296 EXPECT_LT(low_res_factor, 1.f); |
| 3272 | 3297 |
| 3273 ResetTilingsAndRasterScales(); | 3298 ResetTilingsAndRasterScales(); |
| 3274 | 3299 |
| 3275 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3300 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 3276 6.f, // ideal contents scale | 3301 6.f, // ideal contents scale |
| 3277 3.f, // device scale | 3302 3.f, // device scale |
| 3278 2.f, // page scale | 3303 2.f, // page scale |
| 3279 1.f, // maximum animation scale | 3304 1.f, // maximum animation scale |
| 3280 0.f, // starting animation scale | 3305 0.f, // starting animation scale |
| 3281 false); | 3306 false); |
| 3282 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3307 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 3283 EXPECT_FLOAT_EQ(6.f, | 3308 EXPECT_FLOAT_EQ( |
| 3284 pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 3309 6.f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 3285 | 3310 |
| 3286 // If we change the page scale factor, then we should get new tilings. | 3311 // If we change the page scale factor, then we should get new tilings. |
| 3287 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3312 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 3288 6.6f, // ideal contents scale | 3313 6.6f, // ideal contents scale |
| 3289 3.f, // device scale | 3314 3.f, // device scale |
| 3290 2.2f, // page scale | 3315 2.2f, // page scale |
| 3291 1.f, // maximum animation scale | 3316 1.f, // maximum animation scale |
| 3292 0.f, // starting animation scale | 3317 0.f, // starting animation scale |
| 3293 false); | 3318 false); |
| 3294 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3319 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 3295 EXPECT_FLOAT_EQ(6.6f, | 3320 EXPECT_FLOAT_EQ( |
| 3296 pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 3321 6.6f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 3297 | 3322 |
| 3298 // If we change the device scale factor, then we should get new tilings. | 3323 // If we change the device scale factor, then we should get new tilings. |
| 3299 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3324 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 3300 7.26f, // ideal contents scale | 3325 7.26f, // ideal contents scale |
| 3301 3.3f, // device scale | 3326 3.3f, // device scale |
| 3302 2.2f, // page scale | 3327 2.2f, // page scale |
| 3303 1.f, // maximum animation scale | 3328 1.f, // maximum animation scale |
| 3304 0.f, // starting animation scale | 3329 0.f, // starting animation scale |
| 3305 false); | 3330 false); |
| 3306 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3331 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 3307 EXPECT_FLOAT_EQ(7.26f, | 3332 EXPECT_FLOAT_EQ( |
| 3308 pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 3333 7.26f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 3309 | 3334 |
| 3310 // If we change the device scale factor, but end up at the same total scale | 3335 // If we change the device scale factor, but end up at the same total scale |
| 3311 // factor somehow, then we don't get new tilings. | 3336 // factor somehow, then we don't get new tilings. |
| 3312 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3337 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
| 3313 7.26f, // ideal contents scale | 3338 7.26f, // ideal contents scale |
| 3314 2.2f, // device scale | 3339 2.2f, // device scale |
| 3315 3.3f, // page scale | 3340 3.3f, // page scale |
| 3316 1.f, // maximum animation scale | 3341 1.f, // maximum animation scale |
| 3317 0.f, // starting animation scale | 3342 0.f, // starting animation scale |
| 3318 false); | 3343 false); |
| 3319 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3344 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| 3320 EXPECT_FLOAT_EQ(7.26f, | 3345 EXPECT_FLOAT_EQ( |
| 3321 pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 3346 7.26f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 3322 } | 3347 } |
| 3323 | 3348 |
| 3324 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { | 3349 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
| 3325 gfx::Size layer_bounds(400, 400); | 3350 gfx::Size layer_bounds(400, 400); |
| 3326 gfx::Size tile_size(100, 100); | 3351 gfx::Size tile_size(100, 100); |
| 3327 | 3352 |
| 3328 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 3353 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 3329 | 3354 |
| 3330 Tile* some_active_tile = | 3355 Tile* some_active_tile = |
| 3331 active_layer()->HighResTiling()->AllTilesForTesting()[0]; | 3356 active_layer()->HighResTiling()->AllTilesForTesting()[0]; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3421 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 3446 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3422 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); | 3447 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); |
| 3423 | 3448 |
| 3424 host_impl()->PinchGestureEnd(); | 3449 host_impl()->PinchGestureEnd(); |
| 3425 | 3450 |
| 3426 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 3451 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
| 3427 scale /= 4.f; | 3452 scale /= 4.f; |
| 3428 page_scale /= 4.f; | 3453 page_scale /= 4.f; |
| 3429 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, 0.f, false); | 3454 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, 0.f, false); |
| 3430 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 3455 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 3431 EXPECT_FLOAT_EQ(1.f, | 3456 EXPECT_FLOAT_EQ( |
| 3432 active_layer()->tilings()->tiling_at(1)->contents_scale()); | 3457 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 3433 | 3458 |
| 3434 // Ensure UpdateTiles won't remove any tilings. | 3459 // Ensure UpdateTiles won't remove any tilings. |
| 3435 active_layer()->MarkAllTilingsUsed(); | 3460 active_layer()->MarkAllTilingsUsed(); |
| 3436 | 3461 |
| 3437 // Mark the non-ideal tilings as used. They won't be removed. | 3462 // Mark the non-ideal tilings as used. They won't be removed. |
| 3438 used_tilings.clear(); | 3463 used_tilings.clear(); |
| 3439 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); | 3464 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); |
| 3440 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 3465 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3441 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 3466 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 3442 | 3467 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3643 | 3668 |
| 3644 bool last_tile_is_occluded = last_tile.is_occluded(); | 3669 bool last_tile_is_occluded = last_tile.is_occluded(); |
| 3645 if (!last_tile_is_occluded) { | 3670 if (!last_tile_is_occluded) { |
| 3646 TilePriority::PriorityBin tile_priority_bin = | 3671 TilePriority::PriorityBin tile_priority_bin = |
| 3647 prioritized_tile.priority().priority_bin; | 3672 prioritized_tile.priority().priority_bin; |
| 3648 TilePriority::PriorityBin last_tile_priority_bin = | 3673 TilePriority::PriorityBin last_tile_priority_bin = |
| 3649 last_tile.priority().priority_bin; | 3674 last_tile.priority().priority_bin; |
| 3650 | 3675 |
| 3651 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || | 3676 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || |
| 3652 tile->required_for_activation() || | 3677 tile->required_for_activation() || |
| 3653 tile->contents_scale() != | 3678 tile->contents_scale_key() != |
| 3654 last_tile.tile()->contents_scale()) | 3679 last_tile.tile()->contents_scale_key()) |
| 3655 << "line: " << source_line; | 3680 << "line: " << source_line; |
| 3656 } | 3681 } |
| 3657 } | 3682 } |
| 3658 last_tile = prioritized_tile; | 3683 last_tile = prioritized_tile; |
| 3659 queue->Pop(); | 3684 queue->Pop(); |
| 3660 } | 3685 } |
| 3661 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) | 3686 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) |
| 3662 << "line: " << source_line; | 3687 << "line: " << source_line; |
| 3663 } | 3688 } |
| 3664 }; | 3689 }; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3922 for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { | 3947 for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { |
| 3923 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); | 3948 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); |
| 3924 auto prioritized_tiles = | 3949 auto prioritized_tiles = |
| 3925 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 3950 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 3926 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 3951 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 3927 | 3952 |
| 3928 occluded_tile_count = 0; | 3953 occluded_tile_count = 0; |
| 3929 for (size_t j = 0; j < tiles.size(); ++j) { | 3954 for (size_t j = 0; j < tiles.size(); ++j) { |
| 3930 if (prioritized_tiles[tiles[j]].is_occluded()) { | 3955 if (prioritized_tiles[tiles[j]].is_occluded()) { |
| 3931 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 3956 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 3932 tiles[j]->content_rect(), 1.f / tiles[j]->contents_scale()); | 3957 tiles[j]->content_rect(), 1.f / tiles[j]->contents_scale_key()); |
| 3933 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 3958 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
| 3934 occluded_tile_count++; | 3959 occluded_tile_count++; |
| 3935 } | 3960 } |
| 3936 } | 3961 } |
| 3937 | 3962 |
| 3938 switch (i) { | 3963 switch (i) { |
| 3939 case 0: | 3964 case 0: |
| 3940 EXPECT_EQ(occluded_tile_count, 30); | 3965 EXPECT_EQ(occluded_tile_count, 30); |
| 3941 break; | 3966 break; |
| 3942 case 1: | 3967 case 1: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3986 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 4011 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 3987 | 4012 |
| 3988 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, | 4013 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, |
| 3989 gfx::Rect(layer_bounds)); | 4014 gfx::Rect(layer_bounds)); |
| 3990 iter; ++iter) { | 4015 iter; ++iter) { |
| 3991 if (!*iter) | 4016 if (!*iter) |
| 3992 continue; | 4017 continue; |
| 3993 const Tile* tile = *iter; | 4018 const Tile* tile = *iter; |
| 3994 | 4019 |
| 3995 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4020 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 3996 tile->content_rect(), 1.f / tile->contents_scale()); | 4021 tile->content_rect(), 1.f / tile->contents_scale_key()); |
| 3997 // Tiles are occluded on the active tree iff they lie beneath the | 4022 // Tiles are occluded on the active tree iff they lie beneath the |
| 3998 // occluding layer. | 4023 // occluding layer. |
| 3999 EXPECT_EQ(prioritized_tiles[tile].is_occluded(), | 4024 EXPECT_EQ(prioritized_tiles[tile].is_occluded(), |
| 4000 scaled_content_rect.x() >= occluding_layer_position.x()); | 4025 scaled_content_rect.x() >= occluding_layer_position.x()); |
| 4001 } | 4026 } |
| 4002 } | 4027 } |
| 4003 | 4028 |
| 4004 // Partially invalidate the pending layer. | 4029 // Partially invalidate the pending layer. |
| 4005 SetupPendingTreeWithInvalidation(pending_raster_source, invalidation_rect); | 4030 SetupPendingTreeWithInvalidation(pending_raster_source, invalidation_rect); |
| 4006 | 4031 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4022 | 4047 |
| 4023 if (tiling->resolution() == LOW_RESOLUTION) { | 4048 if (tiling->resolution() == LOW_RESOLUTION) { |
| 4024 EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinTiling(tiling)); | 4049 EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinTiling(tiling)); |
| 4025 continue; | 4050 continue; |
| 4026 } | 4051 } |
| 4027 | 4052 |
| 4028 Tile* twin_tile = | 4053 Tile* twin_tile = |
| 4029 active_layer()->GetPendingOrActiveTwinTiling(tiling)->TileAt( | 4054 active_layer()->GetPendingOrActiveTwinTiling(tiling)->TileAt( |
| 4030 iter.i(), iter.j()); | 4055 iter.i(), iter.j()); |
| 4031 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4056 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
| 4032 tile->content_rect(), 1.f / tile->contents_scale()); | 4057 tile->content_rect(), 1.f / tile->contents_scale_key()); |
| 4033 | 4058 |
| 4034 if (scaled_content_rect.Intersects(invalidation_rect)) { | 4059 if (scaled_content_rect.Intersects(invalidation_rect)) { |
| 4035 // Tiles inside the invalidation rect exist on both trees. | 4060 // Tiles inside the invalidation rect exist on both trees. |
| 4036 EXPECT_TRUE(twin_tile); | 4061 EXPECT_TRUE(twin_tile); |
| 4037 EXPECT_NE(tile, twin_tile); | 4062 EXPECT_NE(tile, twin_tile); |
| 4038 } else { | 4063 } else { |
| 4039 // Tiles outside the invalidation rect only exist on the active tree. | 4064 // Tiles outside the invalidation rect only exist on the active tree. |
| 4040 EXPECT_FALSE(twin_tile); | 4065 EXPECT_FALSE(twin_tile); |
| 4041 } | 4066 } |
| 4042 } | 4067 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4130 else | 4155 else |
| 4131 EXPECT_FALSE(tile); | 4156 EXPECT_FALSE(tile); |
| 4132 | 4157 |
| 4133 if (!tile) | 4158 if (!tile) |
| 4134 continue; | 4159 continue; |
| 4135 if (prioritized_tiles[tile].is_occluded()) | 4160 if (prioritized_tiles[tile].is_occluded()) |
| 4136 occluded_tile_count_on_pending++; | 4161 occluded_tile_count_on_pending++; |
| 4137 } | 4162 } |
| 4138 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | 4163 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], |
| 4139 occluded_tile_count_on_pending) | 4164 occluded_tile_count_on_pending) |
| 4140 << tiling->contents_scale(); | 4165 << tiling->contents_scale_key(); |
| 4141 } | 4166 } |
| 4142 | 4167 |
| 4143 // Verify number of occluded tiles on the active layer for each tiling. | 4168 // Verify number of occluded tiles on the active layer for each tiling. |
| 4144 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { | 4169 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { |
| 4145 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); | 4170 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); |
| 4146 auto prioritized_tiles = | 4171 auto prioritized_tiles = |
| 4147 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 4172 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 4148 | 4173 |
| 4149 size_t occluded_tile_count_on_active = 0u; | 4174 size_t occluded_tile_count_on_active = 0u; |
| 4150 for (PictureLayerTiling::CoverageIterator iter(tiling, dest_scale, | 4175 for (PictureLayerTiling::CoverageIterator iter(tiling, dest_scale, |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4720 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { | 4745 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { |
| 4721 gfx::Size layer_bounds(1300, 1900); | 4746 gfx::Size layer_bounds(1300, 1900); |
| 4722 | 4747 |
| 4723 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 4748 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 4724 SetupDefaultTrees(layer_bounds); | 4749 SetupDefaultTrees(layer_bounds); |
| 4725 ResetTilingsAndRasterScales(); | 4750 ResetTilingsAndRasterScales(); |
| 4726 | 4751 |
| 4727 float page_scale = 2.f; | 4752 float page_scale = 2.f; |
| 4728 SetContentsScaleOnBothLayers(page_scale, 1.0f, page_scale, 1.0f, 0.f, false); | 4753 SetContentsScaleOnBothLayers(page_scale, 1.0f, page_scale, 1.0f, 0.f, false); |
| 4729 EXPECT_BOTH_EQ(num_tilings(), 1u); | 4754 EXPECT_BOTH_EQ(num_tilings(), 1u); |
| 4730 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), page_scale); | 4755 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale_key(), page_scale); |
| 4731 | 4756 |
| 4732 host_impl()->PinchGestureBegin(); | 4757 host_impl()->PinchGestureBegin(); |
| 4733 | 4758 |
| 4734 // Zoom out to exactly the low res factor so that the previous high res | 4759 // Zoom out to exactly the low res factor so that the previous high res |
| 4735 // would be equal to the current low res (if it were possible to have one). | 4760 // would be equal to the current low res (if it were possible to have one). |
| 4736 float zoomed = page_scale / low_res_factor; | 4761 float zoomed = page_scale / low_res_factor; |
| 4737 SetContentsScaleOnBothLayers(zoomed, 1.0f, zoomed, 1.0f, 0.f, false); | 4762 SetContentsScaleOnBothLayers(zoomed, 1.0f, zoomed, 1.0f, 0.f, false); |
| 4738 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 4763 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
| 4739 EXPECT_EQ(zoomed, pending_layer()->tilings()->tiling_at(0)->contents_scale()); | 4764 EXPECT_EQ(zoomed, |
| 4765 pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 4740 } | 4766 } |
| 4741 | 4767 |
| 4742 TEST_F(PictureLayerImplTest, HighResWasLowResCollision) { | 4768 TEST_F(PictureLayerImplTest, HighResWasLowResCollision) { |
| 4743 gfx::Size layer_bounds(1300, 1900); | 4769 gfx::Size layer_bounds(1300, 1900); |
| 4744 | 4770 |
| 4745 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 4771 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| 4746 | 4772 |
| 4747 SetupDefaultTrees(layer_bounds); | 4773 SetupDefaultTrees(layer_bounds); |
| 4748 ResetTilingsAndRasterScales(); | 4774 ResetTilingsAndRasterScales(); |
| 4749 | 4775 |
| 4750 float page_scale = 4.f; | 4776 float page_scale = 4.f; |
| 4751 float low_res = page_scale * low_res_factor; | 4777 float low_res = page_scale * low_res_factor; |
| 4752 float extra_low_res = low_res * low_res_factor; | 4778 float extra_low_res = low_res * low_res_factor; |
| 4753 SetupDrawPropertiesAndUpdateTiles(active_layer(), page_scale, 1.0f, | 4779 SetupDrawPropertiesAndUpdateTiles(active_layer(), page_scale, 1.0f, |
| 4754 page_scale, 1.0f, 0.f, false); | 4780 page_scale, 1.0f, 0.f, false); |
| 4755 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); | 4781 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); |
| 4756 EXPECT_EQ(page_scale, | 4782 EXPECT_EQ(page_scale, |
| 4757 active_layer()->tilings()->tiling_at(0)->contents_scale()); | 4783 active_layer()->tilings()->tiling_at(0)->contents_scale_key()); |
| 4758 EXPECT_EQ(low_res, active_layer()->tilings()->tiling_at(1)->contents_scale()); | 4784 EXPECT_EQ(low_res, |
| 4785 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); |
| 4759 | 4786 |
| 4760 // Grab a current low res tile. | 4787 // Grab a current low res tile. |
| 4761 PictureLayerTiling* old_low_res_tiling = | 4788 PictureLayerTiling* old_low_res_tiling = |
| 4762 active_layer()->tilings()->tiling_at(1); | 4789 active_layer()->tilings()->tiling_at(1); |
| 4763 Tile::Id old_low_res_tile_id = | 4790 Tile::Id old_low_res_tile_id = |
| 4764 active_layer()->tilings()->tiling_at(1)->TileAt(0, 0)->id(); | 4791 active_layer()->tilings()->tiling_at(1)->TileAt(0, 0)->id(); |
| 4765 | 4792 |
| 4766 // The tiling knows it has low res content. | 4793 // The tiling knows it has low res content. |
| 4767 EXPECT_TRUE(active_layer() | 4794 EXPECT_TRUE(active_layer() |
| 4768 ->tilings() | 4795 ->tilings() |
| 4769 ->tiling_at(1) | 4796 ->tiling_at(1) |
| 4770 ->may_contain_low_resolution_tiles()); | 4797 ->may_contain_low_resolution_tiles()); |
| 4771 | 4798 |
| 4772 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 4799 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 4773 | 4800 |
| 4774 // Zoom in to exactly the low res factor so that the previous low res | 4801 // Zoom in to exactly the low res factor so that the previous low res |
| 4775 // would be equal to the current high res. | 4802 // would be equal to the current high res. |
| 4776 SetupDrawPropertiesAndUpdateTiles(active_layer(), low_res, 1.0f, low_res, | 4803 SetupDrawPropertiesAndUpdateTiles(active_layer(), low_res, 1.0f, low_res, |
| 4777 1.0f, 0.f, false); | 4804 1.0f, 0.f, false); |
| 4778 // 3 tilings. The old high res, the new high res (old low res) and the new low | 4805 // 3 tilings. The old high res, the new high res (old low res) and the new low |
| 4779 // res. | 4806 // res. |
| 4780 EXPECT_EQ(3u, active_layer()->num_tilings()); | 4807 EXPECT_EQ(3u, active_layer()->num_tilings()); |
| 4781 | 4808 |
| 4782 PictureLayerTilingSet* tilings = active_layer()->tilings(); | 4809 PictureLayerTilingSet* tilings = active_layer()->tilings(); |
| 4783 EXPECT_EQ(page_scale, tilings->tiling_at(0)->contents_scale()); | 4810 EXPECT_EQ(page_scale, tilings->tiling_at(0)->contents_scale_key()); |
| 4784 EXPECT_EQ(low_res, tilings->tiling_at(1)->contents_scale()); | 4811 EXPECT_EQ(low_res, tilings->tiling_at(1)->contents_scale_key()); |
| 4785 EXPECT_EQ(extra_low_res, tilings->tiling_at(2)->contents_scale()); | 4812 EXPECT_EQ(extra_low_res, tilings->tiling_at(2)->contents_scale_key()); |
| 4786 | 4813 |
| 4787 EXPECT_EQ(NON_IDEAL_RESOLUTION, tilings->tiling_at(0)->resolution()); | 4814 EXPECT_EQ(NON_IDEAL_RESOLUTION, tilings->tiling_at(0)->resolution()); |
| 4788 EXPECT_EQ(HIGH_RESOLUTION, tilings->tiling_at(1)->resolution()); | 4815 EXPECT_EQ(HIGH_RESOLUTION, tilings->tiling_at(1)->resolution()); |
| 4789 EXPECT_EQ(LOW_RESOLUTION, tilings->tiling_at(2)->resolution()); | 4816 EXPECT_EQ(LOW_RESOLUTION, tilings->tiling_at(2)->resolution()); |
| 4790 | 4817 |
| 4791 // The old low res tile was destroyed and replaced. | 4818 // The old low res tile was destroyed and replaced. |
| 4792 EXPECT_EQ(old_low_res_tiling, tilings->tiling_at(1)); | 4819 EXPECT_EQ(old_low_res_tiling, tilings->tiling_at(1)); |
| 4793 EXPECT_NE(old_low_res_tile_id, tilings->tiling_at(1)->TileAt(0, 0)->id()); | 4820 EXPECT_NE(old_low_res_tile_id, tilings->tiling_at(1)->TileAt(0, 0)->id()); |
| 4794 EXPECT_TRUE(tilings->tiling_at(1)->TileAt(0, 0)); | 4821 EXPECT_TRUE(tilings->tiling_at(1)->TileAt(0, 0)); |
| 4795 | 4822 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4846 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f. | 4873 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f. |
| 4847 const float suggested_ideal_contents_scale = 2.f; | 4874 const float suggested_ideal_contents_scale = 2.f; |
| 4848 const float device_scale_factor = 3.f; | 4875 const float device_scale_factor = 3.f; |
| 4849 const float page_scale_factor = 4.f; | 4876 const float page_scale_factor = 4.f; |
| 4850 const float animation_contents_scale = 1.f; | 4877 const float animation_contents_scale = 1.f; |
| 4851 const bool animating_transform_to_screen = false; | 4878 const bool animating_transform_to_screen = false; |
| 4852 SetupDrawPropertiesAndUpdateTiles( | 4879 SetupDrawPropertiesAndUpdateTiles( |
| 4853 pending_layer_ptr, suggested_ideal_contents_scale, device_scale_factor, | 4880 pending_layer_ptr, suggested_ideal_contents_scale, device_scale_factor, |
| 4854 page_scale_factor, animation_contents_scale, animation_contents_scale, | 4881 page_scale_factor, animation_contents_scale, animation_contents_scale, |
| 4855 animating_transform_to_screen); | 4882 animating_transform_to_screen); |
| 4856 EXPECT_EQ(1.f, pending_layer_ptr->tilings()->tiling_at(0)->contents_scale()); | 4883 EXPECT_EQ(1.f, |
| 4884 pending_layer_ptr->tilings()->tiling_at(0)->contents_scale_key()); |
| 4857 | 4885 |
| 4858 // Push to active layer. | 4886 // Push to active layer. |
| 4859 host_impl()->ActivateSyncTree(); | 4887 host_impl()->ActivateSyncTree(); |
| 4860 | 4888 |
| 4861 FakePictureLayerImpl* active_layer = static_cast<FakePictureLayerImpl*>( | 4889 FakePictureLayerImpl* active_layer = static_cast<FakePictureLayerImpl*>( |
| 4862 host_impl()->active_tree()->root_layer_for_testing()); | 4890 host_impl()->active_tree()->root_layer_for_testing()); |
| 4863 SetupDrawPropertiesAndUpdateTiles( | 4891 SetupDrawPropertiesAndUpdateTiles( |
| 4864 active_layer, suggested_ideal_contents_scale, device_scale_factor, | 4892 active_layer, suggested_ideal_contents_scale, device_scale_factor, |
| 4865 page_scale_factor, animation_contents_scale, animation_contents_scale, | 4893 page_scale_factor, animation_contents_scale, animation_contents_scale, |
| 4866 animating_transform_to_screen); | 4894 animating_transform_to_screen); |
| 4867 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale()); | 4895 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale_key()); |
| 4868 active_layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 4896 active_layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 4869 | 4897 |
| 4870 // Create resources for the tiles. | 4898 // Create resources for the tiles. |
| 4871 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 4899 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
| 4872 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); | 4900 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); |
| 4873 | 4901 |
| 4874 // Draw. | 4902 // Draw. |
| 4875 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 4903 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 4876 AppendQuadsData data; | 4904 AppendQuadsData data; |
| 4877 active_layer->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 4905 active_layer->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4913 // Scale 0.6. | 4941 // Scale 0.6. |
| 4914 case 6: | 4942 case 6: |
| 4915 expected_contents_scale = 1.f; | 4943 expected_contents_scale = 1.f; |
| 4916 break; | 4944 break; |
| 4917 } | 4945 } |
| 4918 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, | 4946 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, |
| 4919 1.f, 1.f, 1.f, 1.f, false); | 4947 1.f, 1.f, 1.f, 1.f, false); |
| 4920 EXPECT_FLOAT_EQ(expected_contents_scale, | 4948 EXPECT_FLOAT_EQ(expected_contents_scale, |
| 4921 pending_layer_ptr->picture_layer_tiling_set() | 4949 pending_layer_ptr->picture_layer_tiling_set() |
| 4922 ->FindTilingWithResolution(HIGH_RESOLUTION) | 4950 ->FindTilingWithResolution(HIGH_RESOLUTION) |
| 4923 ->contents_scale()) | 4951 ->contents_scale_key()) |
| 4924 << "ideal_contents_scale: " << ideal_contents_scale; | 4952 << "ideal_contents_scale: " << ideal_contents_scale; |
| 4925 } | 4953 } |
| 4926 | 4954 |
| 4927 expected_contents_scale = 1.f; | 4955 expected_contents_scale = 1.f; |
| 4928 for (int i = 30; i >= 1; --i) { | 4956 for (int i = 30; i >= 1; --i) { |
| 4929 float ideal_contents_scale = 0.1f * i - 1e-6; | 4957 float ideal_contents_scale = 0.1f * i - 1e-6; |
| 4930 switch (i) { | 4958 switch (i) { |
| 4931 // Scale 0.2. | 4959 // Scale 0.2. |
| 4932 case 2: | 4960 case 2: |
| 4933 expected_contents_scale = 0.5f; | 4961 expected_contents_scale = 0.5f; |
| 4934 break; | 4962 break; |
| 4935 // Scale 0.1. | 4963 // Scale 0.1. |
| 4936 case 1: | 4964 case 1: |
| 4937 expected_contents_scale = 0.25f; | 4965 expected_contents_scale = 0.25f; |
| 4938 break; | 4966 break; |
| 4939 } | 4967 } |
| 4940 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, | 4968 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, |
| 4941 1.f, 1.f, 1.f, 1.f, false); | 4969 1.f, 1.f, 1.f, 1.f, false); |
| 4942 EXPECT_FLOAT_EQ(expected_contents_scale, | 4970 EXPECT_FLOAT_EQ(expected_contents_scale, |
| 4943 pending_layer_ptr->picture_layer_tiling_set() | 4971 pending_layer_ptr->picture_layer_tiling_set() |
| 4944 ->FindTilingWithResolution(HIGH_RESOLUTION) | 4972 ->FindTilingWithResolution(HIGH_RESOLUTION) |
| 4945 ->contents_scale()) | 4973 ->contents_scale_key()) |
| 4946 << "ideal_contents_scale: " << ideal_contents_scale; | 4974 << "ideal_contents_scale: " << ideal_contents_scale; |
| 4947 } | 4975 } |
| 4948 } | 4976 } |
| 4949 | 4977 |
| 4950 } // namespace | 4978 } // namespace |
| 4951 } // namespace cc | 4979 } // namespace cc |
| OLD | NEW |