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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 animating_transform_to_screen); | 195 animating_transform_to_screen); |
196 layer->UpdateTiles(); | 196 layer->UpdateTiles(); |
197 } | 197 } |
198 | 198 |
199 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource( | 199 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource( |
200 const PictureLayerTiling* tiling, | 200 const PictureLayerTiling* tiling, |
201 RasterSource* raster_source) { | 201 RasterSource* raster_source) { |
202 auto prioritized_tiles = | 202 auto prioritized_tiles = |
203 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 203 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
204 for (PictureLayerTiling::CoverageIterator iter( | 204 for (PictureLayerTiling::CoverageIterator iter( |
205 tiling, tiling->contents_scale_key(), | 205 tiling, tiling->contents_scale(), |
206 gfx::Rect(tiling->tiling_size())); | 206 gfx::Rect(tiling->tiling_size())); |
207 iter; ++iter) { | 207 iter; ++iter) { |
208 EXPECT_TRUE(*iter); | 208 EXPECT_TRUE(*iter); |
209 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source()); | 209 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source()); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 void SetContentsScaleOnBothLayers(float contents_scale, | 213 void SetContentsScaleOnBothLayers(float contents_scale, |
214 float device_scale_factor, | 214 float device_scale_factor, |
215 float page_scale_factor, | 215 float page_scale_factor, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 // Verify the viewport rect for tile priority is used in picture layer tiling. | 328 // Verify the viewport rect for tile priority is used in picture layer tiling. |
329 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, | 329 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, |
330 active_layer()->viewport_rect_for_tile_priority_in_content_space()); | 330 active_layer()->viewport_rect_for_tile_priority_in_content_space()); |
331 PictureLayerTilingSet* tilings = active_layer()->tilings(); | 331 PictureLayerTilingSet* tilings = active_layer()->tilings(); |
332 for (size_t i = 0; i < tilings->num_tilings(); i++) { | 332 for (size_t i = 0; i < tilings->num_tilings(); i++) { |
333 PictureLayerTiling* tiling = tilings->tiling_at(i); | 333 PictureLayerTiling* tiling = tilings->tiling_at(i); |
334 EXPECT_EQ( | 334 EXPECT_EQ( |
335 tiling->GetCurrentVisibleRectForTesting(), | 335 tiling->GetCurrentVisibleRectForTesting(), |
336 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, | 336 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, |
337 tiling->contents_scale_key())); | 337 tiling->contents_scale())); |
338 } | 338 } |
339 | 339 |
340 // Update tiles with viewport for tile priority as (200, 200, 100, 100) in | 340 // Update tiles with viewport for tile priority as (200, 200, 100, 100) in |
341 // screen space and the transform for tile priority is translated and | 341 // screen space and the transform for tile priority is translated and |
342 // rotated. The actual viewport for tile priority used by PictureLayerImpl | 342 // rotated. The actual viewport for tile priority used by PictureLayerImpl |
343 // should be (200, 200, 100, 100) applied with the said transform. | 343 // should be (200, 200, 100, 100) applied with the said transform. |
344 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 344 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
345 | 345 |
346 viewport_rect_for_tile_priority = gfx::Rect(200, 200, 100, 100); | 346 viewport_rect_for_tile_priority = gfx::Rect(200, 200, 100, 100); |
347 transform_for_tile_priority.Translate(100, 100); | 347 transform_for_tile_priority.Translate(100, 100); |
(...skipping 15 matching lines...) Expand all Loading... |
363 viewport_rect_for_tile_priority); | 363 viewport_rect_for_tile_priority); |
364 | 364 |
365 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, | 365 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, |
366 active_layer()->viewport_rect_for_tile_priority_in_content_space()); | 366 active_layer()->viewport_rect_for_tile_priority_in_content_space()); |
367 tilings = active_layer()->tilings(); | 367 tilings = active_layer()->tilings(); |
368 for (size_t i = 0; i < tilings->num_tilings(); i++) { | 368 for (size_t i = 0; i < tilings->num_tilings(); i++) { |
369 PictureLayerTiling* tiling = tilings->tiling_at(i); | 369 PictureLayerTiling* tiling = tilings->tiling_at(i); |
370 EXPECT_EQ( | 370 EXPECT_EQ( |
371 tiling->GetCurrentVisibleRectForTesting(), | 371 tiling->GetCurrentVisibleRectForTesting(), |
372 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, | 372 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, |
373 tiling->contents_scale_key())); | 373 tiling->contents_scale())); |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { | 377 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { |
378 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 378 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
379 gfx::Size layer_bounds(400, 400); | 379 gfx::Size layer_bounds(400, 400); |
380 SetupDefaultTrees(layer_bounds); | 380 SetupDefaultTrees(layer_bounds); |
381 | 381 |
382 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, | 382 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, |
383 false); | 383 false); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, | 439 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, |
440 gfx::Size(50, 50), layer_invalidation); | 440 gfx::Size(50, 50), layer_invalidation); |
441 | 441 |
442 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 442 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
443 EXPECT_EQ(3u, active_layer()->num_tilings()); | 443 EXPECT_EQ(3u, active_layer()->num_tilings()); |
444 | 444 |
445 const PictureLayerTilingSet* tilings = pending_layer()->tilings(); | 445 const PictureLayerTilingSet* tilings = pending_layer()->tilings(); |
446 EXPECT_GT(tilings->num_tilings(), 0u); | 446 EXPECT_GT(tilings->num_tilings(), 0u); |
447 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 447 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
448 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 448 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
449 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( | 449 gfx::Rect content_invalidation = |
450 layer_invalidation, tiling->contents_scale_key()); | 450 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); |
451 auto prioritized_tiles = | 451 auto prioritized_tiles = |
452 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 452 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
453 for (PictureLayerTiling::CoverageIterator iter( | 453 for (PictureLayerTiling::CoverageIterator iter( |
454 tiling, tiling->contents_scale_key(), | 454 tiling, tiling->contents_scale(), |
455 gfx::Rect(tiling->tiling_size())); | 455 gfx::Rect(tiling->tiling_size())); |
456 iter; ++iter) { | 456 iter; ++iter) { |
457 // We don't always have a tile, but when we do it's because it was | 457 // We don't always have a tile, but when we do it's because it was |
458 // invalidated and it has the latest raster source. | 458 // invalidated and it has the latest raster source. |
459 if (*iter) { | 459 if (*iter) { |
460 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 460 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
461 EXPECT_EQ(pending_raster_source.get(), | 461 EXPECT_EQ(pending_raster_source.get(), |
462 prioritized_tiles[*iter].raster_source()); | 462 prioritized_tiles[*iter].raster_source()); |
463 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); | 463 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); |
464 } else { | 464 } else { |
465 // We don't create tiles in non-invalidated regions. | 465 // We don't create tiles in non-invalidated regions. |
466 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); | 466 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); |
467 } | 467 } |
468 } | 468 } |
469 } | 469 } |
470 | 470 |
471 tilings = active_layer()->tilings(); | 471 tilings = active_layer()->tilings(); |
472 EXPECT_GT(tilings->num_tilings(), 0u); | 472 EXPECT_GT(tilings->num_tilings(), 0u); |
473 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 473 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
474 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 474 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
475 auto prioritized_tiles = | 475 auto prioritized_tiles = |
476 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 476 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
477 for (PictureLayerTiling::CoverageIterator iter( | 477 for (PictureLayerTiling::CoverageIterator iter( |
478 tiling, tiling->contents_scale_key(), | 478 tiling, tiling->contents_scale(), |
479 gfx::Rect(tiling->tiling_size())); | 479 gfx::Rect(tiling->tiling_size())); |
480 iter; ++iter) { | 480 iter; ++iter) { |
481 EXPECT_TRUE(*iter); | 481 EXPECT_TRUE(*iter); |
482 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 482 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
483 // Raster source will be updated upon activation. | 483 // Raster source will be updated upon activation. |
484 EXPECT_EQ(active_raster_source.get(), | 484 EXPECT_EQ(active_raster_source.get(), |
485 prioritized_tiles[*iter].raster_source()); | 485 prioritized_tiles[*iter].raster_source()); |
486 } | 486 } |
487 } | 487 } |
488 } | 488 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 522 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
523 | 523 |
524 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 524 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
525 6.f, // ideal contents scale | 525 6.f, // ideal contents scale |
526 3.f, // device scale | 526 3.f, // device scale |
527 2.f, // page scale | 527 2.f, // page scale |
528 1.f, // maximum animation scale | 528 1.f, // maximum animation scale |
529 0.f, // starting animation scale | 529 0.f, // starting animation scale |
530 false); | 530 false); |
531 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 531 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
532 EXPECT_FLOAT_EQ( | 532 EXPECT_FLOAT_EQ(6.f, |
533 6.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 533 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
534 EXPECT_FLOAT_EQ( | 534 EXPECT_FLOAT_EQ(6.f * low_res_factor, |
535 6.f * low_res_factor, | 535 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
536 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | |
537 | 536 |
538 // If we change the page scale factor, then we should get new tilings. | 537 // If we change the page scale factor, then we should get new tilings. |
539 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 538 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
540 6.6f, // ideal contents scale | 539 6.6f, // ideal contents scale |
541 3.f, // device scale | 540 3.f, // device scale |
542 2.2f, // page scale | 541 2.2f, // page scale |
543 1.f, // maximum animation scale | 542 1.f, // maximum animation scale |
544 0.f, // starting animation scale | 543 0.f, // starting animation scale |
545 false); | 544 false); |
546 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); | 545 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); |
547 EXPECT_FLOAT_EQ( | 546 EXPECT_FLOAT_EQ(6.6f, |
548 6.6f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 547 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
549 EXPECT_FLOAT_EQ( | 548 EXPECT_FLOAT_EQ(6.6f * low_res_factor, |
550 6.6f * low_res_factor, | 549 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
551 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | |
552 | 550 |
553 // If we change the device scale factor, then we should get new tilings. | 551 // If we change the device scale factor, then we should get new tilings. |
554 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 552 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
555 7.26f, // ideal contents scale | 553 7.26f, // ideal contents scale |
556 3.3f, // device scale | 554 3.3f, // device scale |
557 2.2f, // page scale | 555 2.2f, // page scale |
558 1.f, // maximum animation scale | 556 1.f, // maximum animation scale |
559 0.f, // starting animation scale | 557 0.f, // starting animation scale |
560 false); | 558 false); |
561 ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); | 559 ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); |
562 EXPECT_FLOAT_EQ( | 560 EXPECT_FLOAT_EQ(7.26f, |
563 7.26f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 561 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
564 EXPECT_FLOAT_EQ( | 562 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
565 7.26f * low_res_factor, | 563 active_layer()->tilings()->tiling_at(3)->contents_scale()); |
566 active_layer()->tilings()->tiling_at(3)->contents_scale_key()); | |
567 | 564 |
568 // If we change the device scale factor, but end up at the same total scale | 565 // If we change the device scale factor, but end up at the same total scale |
569 // factor somehow, then we don't get new tilings. | 566 // factor somehow, then we don't get new tilings. |
570 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 567 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
571 7.26f, // ideal contents scale | 568 7.26f, // ideal contents scale |
572 2.2f, // device scale | 569 2.2f, // device scale |
573 3.3f, // page scale | 570 3.3f, // page scale |
574 1.f, // maximum animation scale | 571 1.f, // maximum animation scale |
575 0.f, // starting animation scale | 572 0.f, // starting animation scale |
576 false); | 573 false); |
577 ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); | 574 ASSERT_EQ(6u, active_layer()->tilings()->num_tilings()); |
578 EXPECT_FLOAT_EQ( | 575 EXPECT_FLOAT_EQ(7.26f, |
579 7.26f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 576 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
580 EXPECT_FLOAT_EQ( | 577 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
581 7.26f * low_res_factor, | 578 active_layer()->tilings()->tiling_at(3)->contents_scale()); |
582 active_layer()->tilings()->tiling_at(3)->contents_scale_key()); | |
583 } | 579 } |
584 | 580 |
585 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { | 581 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { |
586 gfx::Size layer_bounds(1300, 1900); | 582 gfx::Size layer_bounds(1300, 1900); |
587 SetupDefaultTrees(layer_bounds); | 583 SetupDefaultTrees(layer_bounds); |
588 | 584 |
589 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 585 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
590 EXPECT_LT(low_res_factor, 1.f); | 586 EXPECT_LT(low_res_factor, 1.f); |
591 | 587 |
592 pending_layer()->ReleaseTileResources(); | 588 pending_layer()->ReleaseTileResources(); |
593 EXPECT_FALSE(pending_layer()->tilings()); | 589 EXPECT_FALSE(pending_layer()->tilings()); |
594 pending_layer()->RecreateTileResources(); | 590 pending_layer()->RecreateTileResources(); |
595 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); | 591 EXPECT_EQ(0u, pending_layer()->tilings()->num_tilings()); |
596 | 592 |
597 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 593 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
598 6.f, // ideal contents scale | 594 6.f, // ideal contents scale |
599 3.f, // device scale | 595 3.f, // device scale |
600 2.f, // page scale | 596 2.f, // page scale |
601 1.f, // maximum animation scale | 597 1.f, // maximum animation scale |
602 0.f, // starting animation scale | 598 0.f, // starting animation scale |
603 false); | 599 false); |
604 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 600 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
605 EXPECT_FLOAT_EQ( | 601 EXPECT_FLOAT_EQ(6.f, |
606 6.f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 602 pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
607 | 603 |
608 // If we change the page scale factor, then we should get new tilings. | 604 // If we change the page scale factor, then we should get new tilings. |
609 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 605 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
610 6.6f, // ideal contents scale | 606 6.6f, // ideal contents scale |
611 3.f, // device scale | 607 3.f, // device scale |
612 2.2f, // page scale | 608 2.2f, // page scale |
613 1.f, // maximum animation scale | 609 1.f, // maximum animation scale |
614 0.f, // starting animation scale | 610 0.f, // starting animation scale |
615 false); | 611 false); |
616 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 612 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
617 EXPECT_FLOAT_EQ( | 613 EXPECT_FLOAT_EQ(6.6f, |
618 6.6f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 614 pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
619 | 615 |
620 // If we change the device scale factor, then we should get new tilings. | 616 // If we change the device scale factor, then we should get new tilings. |
621 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 617 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
622 7.26f, // ideal contents scale | 618 7.26f, // ideal contents scale |
623 3.3f, // device scale | 619 3.3f, // device scale |
624 2.2f, // page scale | 620 2.2f, // page scale |
625 1.f, // maximum animation scale | 621 1.f, // maximum animation scale |
626 0.f, // starting animation scale | 622 0.f, // starting animation scale |
627 false); | 623 false); |
628 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 624 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
629 EXPECT_FLOAT_EQ( | 625 EXPECT_FLOAT_EQ(7.26f, |
630 7.26f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 626 pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
631 | 627 |
632 // If we change the device scale factor, but end up at the same total scale | 628 // If we change the device scale factor, but end up at the same total scale |
633 // factor somehow, then we don't get new tilings. | 629 // factor somehow, then we don't get new tilings. |
634 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 630 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
635 7.26f, // ideal contents scale | 631 7.26f, // ideal contents scale |
636 2.2f, // device scale | 632 2.2f, // device scale |
637 3.3f, // page scale | 633 3.3f, // page scale |
638 1.f, // maximum animation scale | 634 1.f, // maximum animation scale |
639 0.f, // starting animation scale | 635 0.f, // starting animation scale |
640 false); | 636 false); |
641 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 637 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
642 EXPECT_FLOAT_EQ( | 638 EXPECT_FLOAT_EQ(7.26f, |
643 7.26f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 639 pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
644 } | 640 } |
645 | 641 |
646 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 642 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
647 // This test makes sure that if a layer can have tilings, then a commit makes | 643 // This test makes sure that if a layer can have tilings, then a commit makes |
648 // it not able to have tilings (empty size), and then a future commit that | 644 // it not able to have tilings (empty size), and then a future commit that |
649 // makes it valid again should be able to create tilings. | 645 // makes it valid again should be able to create tilings. |
650 gfx::Size layer_bounds(1300, 1900); | 646 gfx::Size layer_bounds(1300, 1900); |
651 | 647 |
652 scoped_refptr<FakeRasterSource> empty_raster_source = | 648 scoped_refptr<FakeRasterSource> empty_raster_source = |
653 FakeRasterSource::CreateEmpty(layer_bounds); | 649 FakeRasterSource::CreateEmpty(layer_bounds); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 } | 696 } |
701 | 697 |
702 TEST_F(PictureLayerImplTest, ZoomOutCrash) { | 698 TEST_F(PictureLayerImplTest, ZoomOutCrash) { |
703 gfx::Size layer_bounds(1300, 1900); | 699 gfx::Size layer_bounds(1300, 1900); |
704 | 700 |
705 // Set up the high and low res tilings before pinch zoom. | 701 // Set up the high and low res tilings before pinch zoom. |
706 SetupDefaultTrees(layer_bounds); | 702 SetupDefaultTrees(layer_bounds); |
707 ResetTilingsAndRasterScales(); | 703 ResetTilingsAndRasterScales(); |
708 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 704 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
709 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false); | 705 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false); |
710 EXPECT_EQ(32.f, active_layer()->HighResTiling()->contents_scale_key()); | 706 EXPECT_EQ(32.f, active_layer()->HighResTiling()->contents_scale()); |
711 host_impl()->PinchGestureBegin(); | 707 host_impl()->PinchGestureBegin(); |
712 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); | 708 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); |
713 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); | 709 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); |
714 EXPECT_EQ(active_layer()->tilings()->NumHighResTilings(), 1); | 710 EXPECT_EQ(active_layer()->tilings()->NumHighResTilings(), 1); |
715 } | 711 } |
716 | 712 |
717 TEST_F(PictureLayerImplTest, PinchGestureTilings) { | 713 TEST_F(PictureLayerImplTest, PinchGestureTilings) { |
718 gfx::Size layer_bounds(1300, 1900); | 714 gfx::Size layer_bounds(1300, 1900); |
719 | 715 |
720 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 716 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
721 // Set up the high and low res tilings before pinch zoom. | 717 // Set up the high and low res tilings before pinch zoom. |
722 SetupDefaultTrees(layer_bounds); | 718 SetupDefaultTrees(layer_bounds); |
723 ResetTilingsAndRasterScales(); | 719 ResetTilingsAndRasterScales(); |
724 | 720 |
725 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false); | 721 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false); |
726 EXPECT_EQ(active_layer()->num_tilings(), 2u); | 722 EXPECT_EQ(active_layer()->num_tilings(), 2u); |
727 EXPECT_EQ(pending_layer()->num_tilings(), 1u); | 723 EXPECT_EQ(pending_layer()->num_tilings(), 1u); |
728 EXPECT_EQ(active_layer()->tilings()->tiling_at(0)->contents_scale_key(), 2.f); | 724 EXPECT_EQ(active_layer()->tilings()->tiling_at(0)->contents_scale(), 2.f); |
729 EXPECT_EQ(active_layer()->tilings()->tiling_at(1)->contents_scale_key(), | 725 EXPECT_EQ(active_layer()->tilings()->tiling_at(1)->contents_scale(), |
730 2.f * low_res_factor); | 726 2.f * low_res_factor); |
731 // One of the tilings has to be a low resolution one. | 727 // One of the tilings has to be a low resolution one. |
732 EXPECT_EQ(LOW_RESOLUTION, | 728 EXPECT_EQ(LOW_RESOLUTION, |
733 active_layer()->tilings()->tiling_at(1)->resolution()); | 729 active_layer()->tilings()->tiling_at(1)->resolution()); |
734 | 730 |
735 // Ensure UpdateTiles won't remove any tilings. | 731 // Ensure UpdateTiles won't remove any tilings. |
736 active_layer()->MarkAllTilingsUsed(); | 732 active_layer()->MarkAllTilingsUsed(); |
737 | 733 |
738 // Start a pinch gesture. | 734 // Start a pinch gesture. |
739 host_impl()->PinchGestureBegin(); | 735 host_impl()->PinchGestureBegin(); |
740 | 736 |
741 // Zoom out by a small amount. We should create a tiling at half | 737 // Zoom out by a small amount. We should create a tiling at half |
742 // the scale (2/kMaxScaleRatioDuringPinch). | 738 // the scale (2/kMaxScaleRatioDuringPinch). |
743 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, 0.f, false); | 739 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, 0.f, false); |
744 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 740 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
745 EXPECT_FLOAT_EQ( | 741 EXPECT_FLOAT_EQ(2.0f, |
746 2.0f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 742 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
747 EXPECT_FLOAT_EQ( | 743 EXPECT_FLOAT_EQ(1.0f, |
748 1.0f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 744 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
749 EXPECT_FLOAT_EQ( | 745 EXPECT_FLOAT_EQ(2.0f * low_res_factor, |
750 2.0f * low_res_factor, | 746 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
751 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | |
752 // Since we're pinching, we shouldn't create a low resolution tiling. | 747 // Since we're pinching, we shouldn't create a low resolution tiling. |
753 EXPECT_FALSE( | 748 EXPECT_FALSE( |
754 active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); | 749 active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); |
755 | 750 |
756 // Ensure UpdateTiles won't remove any tilings. | 751 // Ensure UpdateTiles won't remove any tilings. |
757 active_layer()->MarkAllTilingsUsed(); | 752 active_layer()->MarkAllTilingsUsed(); |
758 | 753 |
759 // Zoom out further, close to our low-res scale factor. We should | 754 // Zoom out further, close to our low-res scale factor. We should |
760 // use that tiling as high-res, and not create a new tiling. | 755 // use that tiling as high-res, and not create a new tiling. |
761 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, | 756 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, |
762 low_res_factor * 2.1f, 1.0f, 0.f, false); | 757 low_res_factor * 2.1f, 1.0f, 0.f, false); |
763 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 758 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
764 EXPECT_FALSE( | 759 EXPECT_FALSE( |
765 active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); | 760 active_layer()->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); |
766 | 761 |
767 // Zoom in a lot now. Since we increase by increments of | 762 // Zoom in a lot now. Since we increase by increments of |
768 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. | 763 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. |
769 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, 0.f, false); | 764 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, 0.f, false); |
770 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); | 765 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); |
771 EXPECT_FLOAT_EQ( | 766 EXPECT_FLOAT_EQ(4.0f, |
772 4.0f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 767 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
773 // Although one of the tilings matches the low resolution scale, it still | 768 // Although one of the tilings matches the low resolution scale, it still |
774 // shouldn't be marked as low resolution since we're pinching. | 769 // shouldn't be marked as low resolution since we're pinching. |
775 auto* low_res_tiling = | 770 auto* low_res_tiling = |
776 active_layer()->tilings()->FindTilingWithScaleKey(4.f * low_res_factor); | 771 active_layer()->tilings()->FindTilingWithScaleKey(4.f * low_res_factor); |
777 EXPECT_TRUE(low_res_tiling); | 772 EXPECT_TRUE(low_res_tiling); |
778 EXPECT_NE(LOW_RESOLUTION, low_res_tiling->resolution()); | 773 EXPECT_NE(LOW_RESOLUTION, low_res_tiling->resolution()); |
779 | 774 |
780 // Stop a pinch gesture. | 775 // Stop a pinch gesture. |
781 host_impl()->PinchGestureEnd(); | 776 host_impl()->PinchGestureEnd(); |
782 | 777 |
783 // Ensure UpdateTiles won't remove any tilings. | 778 // Ensure UpdateTiles won't remove any tilings. |
784 active_layer()->MarkAllTilingsUsed(); | 779 active_layer()->MarkAllTilingsUsed(); |
785 | 780 |
786 // After pinch ends, set the scale to what the raster scale was updated to | 781 // After pinch ends, set the scale to what the raster scale was updated to |
787 // (checked above). | 782 // (checked above). |
788 SetContentsScaleOnBothLayers(4.0f, 1.0f, 4.0f, 1.f, 0.f, false); | 783 SetContentsScaleOnBothLayers(4.0f, 1.0f, 4.0f, 1.f, 0.f, false); |
789 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); | 784 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); |
790 EXPECT_FLOAT_EQ( | 785 EXPECT_FLOAT_EQ(4.0f, |
791 4.0f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 786 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
792 // Now that we stopped pinching, the low resolution tiling that existed should | 787 // Now that we stopped pinching, the low resolution tiling that existed should |
793 // now be marked as low resolution. | 788 // now be marked as low resolution. |
794 low_res_tiling = | 789 low_res_tiling = |
795 active_layer()->tilings()->FindTilingWithScaleKey(4.f * low_res_factor); | 790 active_layer()->tilings()->FindTilingWithScaleKey(4.f * low_res_factor); |
796 EXPECT_TRUE(low_res_tiling); | 791 EXPECT_TRUE(low_res_tiling); |
797 EXPECT_EQ(LOW_RESOLUTION, low_res_tiling->resolution()); | 792 EXPECT_EQ(LOW_RESOLUTION, low_res_tiling->resolution()); |
798 } | 793 } |
799 | 794 |
800 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { | 795 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { |
801 gfx::Size layer_bounds(2600, 3800); | 796 gfx::Size layer_bounds(2600, 3800); |
802 SetupDefaultTrees(layer_bounds); | 797 SetupDefaultTrees(layer_bounds); |
803 | 798 |
804 ResetTilingsAndRasterScales(); | 799 ResetTilingsAndRasterScales(); |
805 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); | 800 EXPECT_EQ(0u, active_layer()->tilings()->num_tilings()); |
806 | 801 |
807 // Set up the high and low res tilings before pinch zoom. | 802 // Set up the high and low res tilings before pinch zoom. |
808 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, 0.f, false); | 803 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, 0.f, false); |
809 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); | 804 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); |
810 EXPECT_FLOAT_EQ( | 805 EXPECT_FLOAT_EQ(0.24f, |
811 0.24f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 806 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
812 EXPECT_FLOAT_EQ( | 807 EXPECT_FLOAT_EQ(0.0625f, |
813 0.0625f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 808 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
814 | 809 |
815 // Ensure UpdateTiles won't remove any tilings. | 810 // Ensure UpdateTiles won't remove any tilings. |
816 active_layer()->MarkAllTilingsUsed(); | 811 active_layer()->MarkAllTilingsUsed(); |
817 | 812 |
818 // Start a pinch gesture. | 813 // Start a pinch gesture. |
819 host_impl()->PinchGestureBegin(); | 814 host_impl()->PinchGestureBegin(); |
820 | 815 |
821 // Zoom out by a small amount. We should create a tiling at half | 816 // Zoom out by a small amount. We should create a tiling at half |
822 // the scale (1/kMaxScaleRatioDuringPinch). | 817 // the scale (1/kMaxScaleRatioDuringPinch). |
823 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, 0.f, false); | 818 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, 0.f, false); |
824 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 819 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
825 EXPECT_FLOAT_EQ( | 820 EXPECT_FLOAT_EQ(0.24f, |
826 0.24f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 821 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
827 EXPECT_FLOAT_EQ( | 822 EXPECT_FLOAT_EQ(0.12f, |
828 0.12f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 823 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
829 EXPECT_FLOAT_EQ( | 824 EXPECT_FLOAT_EQ(0.0625, |
830 0.0625, active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | 825 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
831 | 826 |
832 // Ensure UpdateTiles won't remove any tilings. | 827 // Ensure UpdateTiles won't remove any tilings. |
833 active_layer()->MarkAllTilingsUsed(); | 828 active_layer()->MarkAllTilingsUsed(); |
834 | 829 |
835 // Zoom out further, close to our low-res scale factor. We should | 830 // Zoom out further, close to our low-res scale factor. We should |
836 // use that tiling as high-res, and not create a new tiling. | 831 // use that tiling as high-res, and not create a new tiling. |
837 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, 0.f, false); | 832 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, 0.f, false); |
838 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 833 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
839 | 834 |
840 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in | 835 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in |
841 // because 0.25(desired_scale) is within the ratio(1.2). | 836 // because 0.25(desired_scale) is within the ratio(1.2). |
842 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, 0.f, false); | 837 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, 0.f, false); |
843 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); | 838 EXPECT_EQ(3u, active_layer()->tilings()->num_tilings()); |
844 | 839 |
845 // Zoom in a lot. Since we move in factors of two, we should get a scale that | 840 // Zoom in a lot. Since we move in factors of two, we should get a scale that |
846 // is a power of 2 times 0.24. | 841 // is a power of 2 times 0.24. |
847 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, 0.f, false); | 842 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, 0.f, false); |
848 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); | 843 EXPECT_EQ(4u, active_layer()->tilings()->num_tilings()); |
849 EXPECT_FLOAT_EQ( | 844 EXPECT_FLOAT_EQ(1.92f, |
850 1.92f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 845 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
851 } | 846 } |
852 | 847 |
853 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 848 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
854 gfx::Size layer_bounds(1300, 1900); | 849 gfx::Size layer_bounds(1300, 1900); |
855 | 850 |
856 std::vector<PictureLayerTiling*> used_tilings; | 851 std::vector<PictureLayerTiling*> used_tilings; |
857 | 852 |
858 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 853 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
859 EXPECT_LT(low_res_factor, 1.f); | 854 EXPECT_LT(low_res_factor, 1.f); |
860 | 855 |
861 float scale = 1.f; | 856 float scale = 1.f; |
862 float page_scale = 1.f; | 857 float page_scale = 1.f; |
863 | 858 |
864 SetupDefaultTrees(layer_bounds); | 859 SetupDefaultTrees(layer_bounds); |
865 active_layer()->SetHasWillChangeTransformHint(true); | 860 active_layer()->SetHasWillChangeTransformHint(true); |
866 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); | 861 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); |
867 EXPECT_FLOAT_EQ( | 862 EXPECT_FLOAT_EQ(1.f, |
868 1.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 863 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
869 EXPECT_FLOAT_EQ( | 864 EXPECT_FLOAT_EQ(1.f * low_res_factor, |
870 1.f * low_res_factor, | 865 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
871 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | |
872 | 866 |
873 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to | 867 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to |
874 // |used_tilings| variable, and it's here only to ensure that active_layer() | 868 // |used_tilings| variable, and it's here only to ensure that active_layer() |
875 // won't remove tilings before the test has a chance to verify behavior. | 869 // won't remove tilings before the test has a chance to verify behavior. |
876 active_layer()->MarkAllTilingsUsed(); | 870 active_layer()->MarkAllTilingsUsed(); |
877 | 871 |
878 // We only have ideal tilings, so they aren't removed. | 872 // We only have ideal tilings, so they aren't removed. |
879 used_tilings.clear(); | 873 used_tilings.clear(); |
880 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 874 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
881 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); | 875 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); |
882 EXPECT_FLOAT_EQ( | 876 EXPECT_FLOAT_EQ(1.f, |
883 1.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 877 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
884 EXPECT_FLOAT_EQ( | 878 EXPECT_FLOAT_EQ(1.f * low_res_factor, |
885 1.f * low_res_factor, | 879 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
886 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | |
887 | 880 |
888 host_impl()->PinchGestureBegin(); | 881 host_impl()->PinchGestureBegin(); |
889 | 882 |
890 // Changing the ideal but not creating new tilings. | 883 // Changing the ideal but not creating new tilings. |
891 scale = 1.5f; | 884 scale = 1.5f; |
892 page_scale = 1.5f; | 885 page_scale = 1.5f; |
893 SetContentsScaleOnBothLayers(scale, 1.f, page_scale, 1.f, 0.f, false); | 886 SetContentsScaleOnBothLayers(scale, 1.f, page_scale, 1.f, 0.f, false); |
894 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); | 887 EXPECT_FLOAT_EQ(2u, active_layer()->tilings()->num_tilings()); |
895 EXPECT_FLOAT_EQ( | 888 EXPECT_FLOAT_EQ(1.f, |
896 1.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 889 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
897 EXPECT_FLOAT_EQ( | 890 EXPECT_FLOAT_EQ(1.f * low_res_factor, |
898 1.f * low_res_factor, | 891 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
899 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | |
900 | 892 |
901 // The tilings are still our target scale, so they aren't removed. | 893 // The tilings are still our target scale, so they aren't removed. |
902 used_tilings.clear(); | 894 used_tilings.clear(); |
903 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 895 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
904 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 896 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
905 EXPECT_FLOAT_EQ( | 897 EXPECT_FLOAT_EQ(1.f, |
906 1.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 898 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
907 EXPECT_FLOAT_EQ( | 899 EXPECT_FLOAT_EQ(1.f * low_res_factor, |
908 1.f * low_res_factor, | 900 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
909 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | |
910 | 901 |
911 host_impl()->PinchGestureEnd(); | 902 host_impl()->PinchGestureEnd(); |
912 | 903 |
913 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 904 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
914 scale = 1.2f; | 905 scale = 1.2f; |
915 page_scale = 1.2f; | 906 page_scale = 1.2f; |
916 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, 0.f, false); | 907 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, 0.f, false); |
917 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); | 908 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); |
918 EXPECT_FLOAT_EQ( | 909 EXPECT_FLOAT_EQ(1.2f, |
919 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 910 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
920 EXPECT_FLOAT_EQ( | 911 EXPECT_FLOAT_EQ(1.f, |
921 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 912 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
922 EXPECT_FLOAT_EQ( | 913 EXPECT_FLOAT_EQ(1.2f * low_res_factor, |
923 1.2f * low_res_factor, | 914 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
924 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | 915 EXPECT_FLOAT_EQ(1.f * low_res_factor, |
925 EXPECT_FLOAT_EQ( | 916 active_layer()->tilings()->tiling_at(3)->contents_scale()); |
926 1.f * low_res_factor, | |
927 active_layer()->tilings()->tiling_at(3)->contents_scale_key()); | |
928 | 917 |
929 // Ensure UpdateTiles won't remove any tilings. | 918 // Ensure UpdateTiles won't remove any tilings. |
930 active_layer()->MarkAllTilingsUsed(); | 919 active_layer()->MarkAllTilingsUsed(); |
931 | 920 |
932 // Mark the non-ideal tilings as used. They won't be removed. | 921 // Mark the non-ideal tilings as used. They won't be removed. |
933 used_tilings.clear(); | 922 used_tilings.clear(); |
934 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); | 923 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); |
935 used_tilings.push_back(active_layer()->tilings()->tiling_at(3)); | 924 used_tilings.push_back(active_layer()->tilings()->tiling_at(3)); |
936 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 925 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
937 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); | 926 ASSERT_EQ(4u, active_layer()->tilings()->num_tilings()); |
938 EXPECT_FLOAT_EQ( | 927 EXPECT_FLOAT_EQ(1.2f, |
939 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 928 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
940 EXPECT_FLOAT_EQ( | 929 EXPECT_FLOAT_EQ(1.f, |
941 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 930 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
942 EXPECT_FLOAT_EQ( | 931 EXPECT_FLOAT_EQ(1.2f * low_res_factor, |
943 1.2f * low_res_factor, | 932 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
944 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | 933 EXPECT_FLOAT_EQ(1.f * low_res_factor, |
945 EXPECT_FLOAT_EQ( | 934 active_layer()->tilings()->tiling_at(3)->contents_scale()); |
946 1.f * low_res_factor, | |
947 active_layer()->tilings()->tiling_at(3)->contents_scale_key()); | |
948 | 935 |
949 // Now move the ideal scale to 0.5. Our target stays 1.2. | 936 // Now move the ideal scale to 0.5. Our target stays 1.2. |
950 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, 0.f, false); | 937 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, 0.f, false); |
951 | 938 |
952 // The high resolution tiling is between target and ideal, so is not | 939 // The high resolution tiling is between target and ideal, so is not |
953 // removed. The low res tiling for the old ideal=1.0 scale is removed. | 940 // removed. The low res tiling for the old ideal=1.0 scale is removed. |
954 used_tilings.clear(); | 941 used_tilings.clear(); |
955 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 942 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
956 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 943 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
957 EXPECT_FLOAT_EQ( | 944 EXPECT_FLOAT_EQ(1.2f, |
958 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 945 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
959 EXPECT_FLOAT_EQ( | 946 EXPECT_FLOAT_EQ(1.f, |
960 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 947 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
961 EXPECT_FLOAT_EQ( | 948 EXPECT_FLOAT_EQ(1.2f * low_res_factor, |
962 1.2f * low_res_factor, | 949 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
963 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | |
964 | 950 |
965 // Now move the ideal scale to 1.0. Our target stays 1.2. | 951 // Now move the ideal scale to 1.0. Our target stays 1.2. |
966 SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, 0.f, false); | 952 SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, 0.f, false); |
967 | 953 |
968 // All the tilings are between are target and the ideal, so they are not | 954 // All the tilings are between are target and the ideal, so they are not |
969 // removed. | 955 // removed. |
970 used_tilings.clear(); | 956 used_tilings.clear(); |
971 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 957 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
972 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 958 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
973 EXPECT_FLOAT_EQ( | 959 EXPECT_FLOAT_EQ(1.2f, |
974 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 960 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
975 EXPECT_FLOAT_EQ( | 961 EXPECT_FLOAT_EQ(1.f, |
976 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 962 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
977 EXPECT_FLOAT_EQ( | 963 EXPECT_FLOAT_EQ(1.2f * low_res_factor, |
978 1.2f * low_res_factor, | 964 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
979 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | |
980 | 965 |
981 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 966 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
982 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.1f, 1.f, page_scale, 1.f, | 967 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.1f, 1.f, page_scale, 1.f, |
983 0.f, false); | 968 0.f, false); |
984 | 969 |
985 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 970 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
986 // in the range [1.0,1.2] and are kept. | 971 // in the range [1.0,1.2] and are kept. |
987 used_tilings.clear(); | 972 used_tilings.clear(); |
988 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 973 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
989 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 974 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
990 EXPECT_FLOAT_EQ( | 975 EXPECT_FLOAT_EQ(1.2f, |
991 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 976 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
992 EXPECT_FLOAT_EQ( | 977 EXPECT_FLOAT_EQ(1.f, |
993 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 978 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
994 EXPECT_FLOAT_EQ( | 979 EXPECT_FLOAT_EQ(1.2f * low_res_factor, |
995 1.2f * low_res_factor, | 980 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
996 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | |
997 | 981 |
998 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 982 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
999 // 1.2 still. | 983 // 1.2 still. |
1000 SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.1f, 1.f, page_scale, 1.f, | 984 SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.1f, 1.f, page_scale, 1.f, |
1001 0.f, false); | 985 0.f, false); |
1002 | 986 |
1003 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 987 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
1004 // target raster scale. But it is in our used tilings set, so nothing is | 988 // target raster scale. But it is in our used tilings set, so nothing is |
1005 // deleted. | 989 // deleted. |
1006 used_tilings.clear(); | 990 used_tilings.clear(); |
1007 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); | 991 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); |
1008 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 992 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
1009 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 993 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
1010 EXPECT_FLOAT_EQ( | 994 EXPECT_FLOAT_EQ(1.2f, |
1011 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 995 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
1012 EXPECT_FLOAT_EQ( | 996 EXPECT_FLOAT_EQ(1.f, |
1013 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 997 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
1014 EXPECT_FLOAT_EQ( | 998 EXPECT_FLOAT_EQ(1.2f * low_res_factor, |
1015 1.2f * low_res_factor, | 999 active_layer()->tilings()->tiling_at(2)->contents_scale()); |
1016 active_layer()->tilings()->tiling_at(2)->contents_scale_key()); | |
1017 | 1000 |
1018 // If we remove it from our used tilings set, it is outside the range to keep | 1001 // If we remove it from our used tilings set, it is outside the range to keep |
1019 // so it is deleted. | 1002 // so it is deleted. |
1020 used_tilings.clear(); | 1003 used_tilings.clear(); |
1021 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 1004 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
1022 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 1005 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
1023 EXPECT_FLOAT_EQ( | 1006 EXPECT_FLOAT_EQ(1.2f, |
1024 1.2f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 1007 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
1025 EXPECT_FLOAT_EQ( | 1008 EXPECT_FLOAT_EQ(1.2 * low_res_factor, |
1026 1.2 * low_res_factor, | 1009 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
1027 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | |
1028 } | 1010 } |
1029 | 1011 |
1030 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { | 1012 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { |
1031 // Make sure this layer covers multiple tiles, since otherwise low | 1013 // Make sure this layer covers multiple tiles, since otherwise low |
1032 // res won't get created because it is too small. | 1014 // res won't get created because it is too small. |
1033 gfx::Size tile_size(host_impl()->settings().default_tile_size); | 1015 gfx::Size tile_size(host_impl()->settings().default_tile_size); |
1034 // Avoid max untiled layer size heuristics via fixed tile size. | 1016 // Avoid max untiled layer size heuristics via fixed tile size. |
1035 gfx::Size layer_bounds(tile_size.width() + 1, tile_size.height() + 1); | 1017 gfx::Size layer_bounds(tile_size.width() + 1, tile_size.height() + 1); |
1036 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1018 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
1037 | 1019 |
1038 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 1020 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
1039 float contents_scale = 1.f; | 1021 float contents_scale = 1.f; |
1040 float device_scale = 1.f; | 1022 float device_scale = 1.f; |
1041 float page_scale = 1.f; | 1023 float page_scale = 1.f; |
1042 float maximum_animation_scale = 1.f; | 1024 float maximum_animation_scale = 1.f; |
1043 float starting_animation_scale = 0.f; | 1025 float starting_animation_scale = 0.f; |
1044 bool animating_transform = true; | 1026 bool animating_transform = true; |
1045 | 1027 |
1046 ResetTilingsAndRasterScales(); | 1028 ResetTilingsAndRasterScales(); |
1047 | 1029 |
1048 // Animating, so don't create low res even if there isn't one already. | 1030 // Animating, so don't create low res even if there isn't one already. |
1049 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1031 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1050 maximum_animation_scale, | 1032 maximum_animation_scale, |
1051 starting_animation_scale, animating_transform); | 1033 starting_animation_scale, animating_transform); |
1052 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 1.f); | 1034 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1053 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1035 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1054 | 1036 |
1055 // Stop animating, low res gets created. | 1037 // Stop animating, low res gets created. |
1056 animating_transform = false; | 1038 animating_transform = false; |
1057 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1039 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1058 maximum_animation_scale, | 1040 maximum_animation_scale, |
1059 starting_animation_scale, animating_transform); | 1041 starting_animation_scale, animating_transform); |
1060 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 1.f); | 1042 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1061 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale_key(), | 1043 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), low_res_factor); |
1062 low_res_factor); | |
1063 EXPECT_EQ(active_layer()->num_tilings(), 2u); | 1044 EXPECT_EQ(active_layer()->num_tilings(), 2u); |
1064 EXPECT_EQ(pending_layer()->num_tilings(), 1u); | 1045 EXPECT_EQ(pending_layer()->num_tilings(), 1u); |
1065 | 1046 |
1066 // Ensure UpdateTiles won't remove any tilings. | 1047 // Ensure UpdateTiles won't remove any tilings. |
1067 active_layer()->MarkAllTilingsUsed(); | 1048 active_layer()->MarkAllTilingsUsed(); |
1068 | 1049 |
1069 // Page scale animation, new high res, but no low res. We still have | 1050 // 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 | 1051 // 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. | 1052 // active layer. The pending layer drops non-ideal tilings. |
1072 contents_scale = 2.f; | 1053 contents_scale = 2.f; |
1073 page_scale = 2.f; | 1054 page_scale = 2.f; |
1074 maximum_animation_scale = 2.f; | 1055 maximum_animation_scale = 2.f; |
1075 animating_transform = true; | 1056 animating_transform = true; |
1076 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1057 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1077 maximum_animation_scale, | 1058 maximum_animation_scale, |
1078 starting_animation_scale, animating_transform); | 1059 starting_animation_scale, animating_transform); |
1079 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); | 1060 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1080 EXPECT_FALSE(active_layer()->LowResTiling()); | 1061 EXPECT_FALSE(active_layer()->LowResTiling()); |
1081 EXPECT_FALSE(pending_layer()->LowResTiling()); | 1062 EXPECT_FALSE(pending_layer()->LowResTiling()); |
1082 EXPECT_EQ(3u, active_layer()->num_tilings()); | 1063 EXPECT_EQ(3u, active_layer()->num_tilings()); |
1083 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 1064 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
1084 | 1065 |
1085 // Stop animating, new low res gets created for final page scale. | 1066 // Stop animating, new low res gets created for final page scale. |
1086 animating_transform = false; | 1067 animating_transform = false; |
1087 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1068 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1088 maximum_animation_scale, | 1069 maximum_animation_scale, |
1089 starting_animation_scale, animating_transform); | 1070 starting_animation_scale, animating_transform); |
1090 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); | 1071 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1091 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale_key(), | 1072 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), |
1092 2.f * low_res_factor); | 1073 2.f * low_res_factor); |
1093 EXPECT_EQ(4u, active_layer()->num_tilings()); | 1074 EXPECT_EQ(4u, active_layer()->num_tilings()); |
1094 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 1075 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
1095 } | 1076 } |
1096 | 1077 |
1097 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { | 1078 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
1098 gfx::Size layer_bounds(host_impl()->settings().default_tile_size); | 1079 gfx::Size layer_bounds(host_impl()->settings().default_tile_size); |
1099 | 1080 |
1100 scoped_refptr<FakeRasterSource> pending_raster_source = | 1081 scoped_refptr<FakeRasterSource> pending_raster_source = |
1101 FakeRasterSource::CreateFilled(layer_bounds); | 1082 FakeRasterSource::CreateFilled(layer_bounds); |
1102 scoped_refptr<FakeRasterSource> active_raster_source = | 1083 scoped_refptr<FakeRasterSource> active_raster_source = |
1103 FakeRasterSource::CreateFilled(layer_bounds); | 1084 FakeRasterSource::CreateFilled(layer_bounds); |
1104 | 1085 |
1105 SetupTrees(pending_raster_source, active_raster_source); | 1086 SetupTrees(pending_raster_source, active_raster_source); |
1106 | 1087 |
1107 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 1088 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
1108 float device_scale = 1.f; | 1089 float device_scale = 1.f; |
1109 float page_scale = 1.f; | 1090 float page_scale = 1.f; |
1110 float maximum_animation_scale = 1.f; | 1091 float maximum_animation_scale = 1.f; |
1111 float starting_animation_scale = 0.f; | 1092 float starting_animation_scale = 0.f; |
1112 bool animating_transform = false; | 1093 bool animating_transform = false; |
1113 | 1094 |
1114 // Contents exactly fit on one tile at scale 1, no low res. | 1095 // Contents exactly fit on one tile at scale 1, no low res. |
1115 float contents_scale = 1.f; | 1096 float contents_scale = 1.f; |
1116 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1097 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1117 maximum_animation_scale, | 1098 maximum_animation_scale, |
1118 starting_animation_scale, animating_transform); | 1099 starting_animation_scale, animating_transform); |
1119 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), contents_scale); | 1100 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1120 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1101 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1121 | 1102 |
1122 ResetTilingsAndRasterScales(); | 1103 ResetTilingsAndRasterScales(); |
1123 | 1104 |
1124 // Contents that are smaller than one tile, no low res. | 1105 // Contents that are smaller than one tile, no low res. |
1125 contents_scale = 0.123f; | 1106 contents_scale = 0.123f; |
1126 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1107 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1127 maximum_animation_scale, | 1108 maximum_animation_scale, |
1128 starting_animation_scale, animating_transform); | 1109 starting_animation_scale, animating_transform); |
1129 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), contents_scale); | 1110 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1130 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1111 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1131 | 1112 |
1132 // TODO(danakj): Remove these when raster scale doesn't get fixed? | 1113 // TODO(danakj): Remove these when raster scale doesn't get fixed? |
1133 ResetTilingsAndRasterScales(); | 1114 ResetTilingsAndRasterScales(); |
1134 | 1115 |
1135 // Any content bounds that would create more than one tile will | 1116 // Any content bounds that would create more than one tile will |
1136 // generate a low res tiling. | 1117 // generate a low res tiling. |
1137 contents_scale = 2.5f; | 1118 contents_scale = 2.5f; |
1138 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1119 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1139 maximum_animation_scale, | 1120 maximum_animation_scale, |
1140 starting_animation_scale, animating_transform); | 1121 starting_animation_scale, animating_transform); |
1141 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), contents_scale); | 1122 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1142 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale_key(), | 1123 EXPECT_EQ(active_layer()->LowResTiling()->contents_scale(), |
1143 contents_scale * low_res_factor); | 1124 contents_scale * low_res_factor); |
1144 EXPECT_FALSE(pending_layer()->LowResTiling()); | 1125 EXPECT_FALSE(pending_layer()->LowResTiling()); |
1145 EXPECT_EQ(active_layer()->num_tilings(), 2u); | 1126 EXPECT_EQ(active_layer()->num_tilings(), 2u); |
1146 EXPECT_EQ(pending_layer()->num_tilings(), 1u); | 1127 EXPECT_EQ(pending_layer()->num_tilings(), 1u); |
1147 | 1128 |
1148 // Mask layers dont create low res since they always fit on one tile. | 1129 // Mask layers dont create low res since they always fit on one tile. |
1149 std::unique_ptr<FakePictureLayerImpl> mask = | 1130 std::unique_ptr<FakePictureLayerImpl> mask = |
1150 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1131 FakePictureLayerImpl::CreateMaskWithRasterSource( |
1151 host_impl()->pending_tree(), 3, pending_raster_source); | 1132 host_impl()->pending_tree(), 3, pending_raster_source); |
1152 mask->SetBounds(layer_bounds); | 1133 mask->SetBounds(layer_bounds); |
1153 mask->SetDrawsContent(true); | 1134 mask->SetDrawsContent(true); |
1154 pending_layer()->test_properties()->SetMaskLayer(std::move(mask)); | 1135 pending_layer()->test_properties()->SetMaskLayer(std::move(mask)); |
1155 pending_layer()->SetHasRenderSurface(true); | 1136 pending_layer()->SetHasRenderSurface(true); |
1156 RebuildPropertyTreesOnPendingTree(); | 1137 RebuildPropertyTreesOnPendingTree(); |
1157 host_impl()->pending_tree()->UpdateDrawProperties(false); | 1138 host_impl()->pending_tree()->UpdateDrawProperties(false); |
1158 | 1139 |
1159 FakePictureLayerImpl* mask_raw = static_cast<FakePictureLayerImpl*>( | 1140 FakePictureLayerImpl* mask_raw = static_cast<FakePictureLayerImpl*>( |
1160 pending_layer()->test_properties()->mask_layer); | 1141 pending_layer()->test_properties()->mask_layer); |
1161 // We did an UpdateDrawProperties above, which will set a contents scale on | 1142 // We did an UpdateDrawProperties above, which will set a contents scale on |
1162 // the mask layer, so allow us to reset the contents scale. | 1143 // the mask layer, so allow us to reset the contents scale. |
1163 mask_raw->ReleaseTileResources(); | 1144 mask_raw->ReleaseTileResources(); |
1164 mask_raw->RecreateTileResources(); | 1145 mask_raw->RecreateTileResources(); |
1165 | 1146 |
1166 SetupDrawPropertiesAndUpdateTiles( | 1147 SetupDrawPropertiesAndUpdateTiles( |
1167 mask_raw, contents_scale, device_scale, page_scale, | 1148 mask_raw, contents_scale, device_scale, page_scale, |
1168 maximum_animation_scale, starting_animation_scale, animating_transform); | 1149 maximum_animation_scale, starting_animation_scale, animating_transform); |
1169 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale_key(), contents_scale); | 1150 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); |
1170 EXPECT_EQ(mask_raw->num_tilings(), 1u); | 1151 EXPECT_EQ(mask_raw->num_tilings(), 1u); |
1171 } | 1152 } |
1172 | 1153 |
1173 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { | 1154 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { |
1174 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1155 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
1175 | 1156 |
1176 gfx::Size layer_bounds(1000, 1000); | 1157 gfx::Size layer_bounds(1000, 1000); |
1177 | 1158 |
1178 scoped_refptr<FakeRasterSource> valid_raster_source = | 1159 scoped_refptr<FakeRasterSource> valid_raster_source = |
1179 FakeRasterSource::CreateFilled(layer_bounds); | 1160 FakeRasterSource::CreateFilled(layer_bounds); |
1180 SetupPendingTree(valid_raster_source); | 1161 SetupPendingTree(valid_raster_source); |
1181 | 1162 |
1182 std::unique_ptr<FakePictureLayerImpl> mask_ptr = | 1163 std::unique_ptr<FakePictureLayerImpl> mask_ptr = |
1183 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1164 FakePictureLayerImpl::CreateMaskWithRasterSource( |
1184 host_impl()->pending_tree(), 3, valid_raster_source); | 1165 host_impl()->pending_tree(), 3, valid_raster_source); |
1185 mask_ptr->SetBounds(layer_bounds); | 1166 mask_ptr->SetBounds(layer_bounds); |
1186 mask_ptr->SetDrawsContent(true); | 1167 mask_ptr->SetDrawsContent(true); |
1187 pending_layer()->test_properties()->SetMaskLayer(std::move(mask_ptr)); | 1168 pending_layer()->test_properties()->SetMaskLayer(std::move(mask_ptr)); |
1188 pending_layer()->test_properties()->force_render_surface = true; | 1169 pending_layer()->test_properties()->force_render_surface = true; |
1189 | 1170 |
1190 RebuildPropertyTreesOnPendingTree(); | 1171 RebuildPropertyTreesOnPendingTree(); |
1191 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1172 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
1192 bool update_lcd_text = false; | 1173 bool update_lcd_text = false; |
1193 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1174 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
1194 | 1175 |
1195 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>( | 1176 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>( |
1196 pending_layer()->test_properties()->mask_layer); | 1177 pending_layer()->test_properties()->mask_layer); |
1197 | 1178 |
1198 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale_key()); | 1179 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); |
1199 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1180 EXPECT_EQ(1u, pending_mask->num_tilings()); |
1200 | 1181 |
1201 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1182 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
1202 pending_mask->HighResTiling()->AllTilesForTesting()); | 1183 pending_mask->HighResTiling()->AllTilesForTesting()); |
1203 | 1184 |
1204 ActivateTree(); | 1185 ActivateTree(); |
1205 | 1186 |
1206 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>( | 1187 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>( |
1207 host_impl()->active_tree()->LayerById(pending_mask->id())); | 1188 host_impl()->active_tree()->LayerById(pending_mask->id())); |
1208 | 1189 |
(...skipping 25 matching lines...) Expand all Loading... |
1234 FakeRasterSource::CreateFilled(huge_bounds); | 1215 FakeRasterSource::CreateFilled(huge_bounds); |
1235 | 1216 |
1236 SetupPendingTree(huge_raster_source); | 1217 SetupPendingTree(huge_raster_source); |
1237 pending_mask->SetBounds(huge_bounds); | 1218 pending_mask->SetBounds(huge_bounds); |
1238 pending_mask->SetRasterSourceOnPending(huge_raster_source, Region()); | 1219 pending_mask->SetRasterSourceOnPending(huge_raster_source, Region()); |
1239 | 1220 |
1240 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1221 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
1241 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1222 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
1242 | 1223 |
1243 // The mask tiling gets scaled down. | 1224 // The mask tiling gets scaled down. |
1244 EXPECT_LT(pending_mask->HighResTiling()->contents_scale_key(), 1.f); | 1225 EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f); |
1245 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1226 EXPECT_EQ(1u, pending_mask->num_tilings()); |
1246 | 1227 |
1247 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1228 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
1248 pending_mask->HighResTiling()->AllTilesForTesting()); | 1229 pending_mask->HighResTiling()->AllTilesForTesting()); |
1249 | 1230 |
1250 ActivateTree(); | 1231 ActivateTree(); |
1251 | 1232 |
1252 // Mask layers have a tiling with a single tile in it. | 1233 // Mask layers have a tiling with a single tile in it. |
1253 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1234 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1254 // The mask resource exists. | 1235 // The mask resource exists. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 | 1299 |
1319 RebuildPropertyTreesOnPendingTree(); | 1300 RebuildPropertyTreesOnPendingTree(); |
1320 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1301 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
1321 bool update_lcd_text = false; | 1302 bool update_lcd_text = false; |
1322 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1303 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
1323 | 1304 |
1324 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>( | 1305 FakePictureLayerImpl* pending_mask = static_cast<FakePictureLayerImpl*>( |
1325 pending_layer()->test_properties()->mask_layer); | 1306 pending_layer()->test_properties()->mask_layer); |
1326 | 1307 |
1327 // Masks are scaled, and do not have a low res tiling. | 1308 // Masks are scaled, and do not have a low res tiling. |
1328 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale_key()); | 1309 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale()); |
1329 EXPECT_EQ(1u, pending_mask->num_tilings()); | 1310 EXPECT_EQ(1u, pending_mask->num_tilings()); |
1330 | 1311 |
1331 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1312 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
1332 pending_mask->HighResTiling()->AllTilesForTesting()); | 1313 pending_mask->HighResTiling()->AllTilesForTesting()); |
1333 | 1314 |
1334 ActivateTree(); | 1315 ActivateTree(); |
1335 | 1316 |
1336 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>( | 1317 FakePictureLayerImpl* active_mask = static_cast<FakePictureLayerImpl*>( |
1337 host_impl()->active_tree()->LayerById(pending_mask->id())); | 1318 host_impl()->active_tree()->LayerById(pending_mask->id())); |
1338 | 1319 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1634 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
1654 | 1635 |
1655 gfx::Size tile_size(100, 100); | 1636 gfx::Size tile_size(100, 100); |
1656 gfx::Size layer_bounds(400, 400); | 1637 gfx::Size layer_bounds(400, 400); |
1657 gfx::Rect external_viewport_for_tile_priority(400, 200); | 1638 gfx::Rect external_viewport_for_tile_priority(400, 200); |
1658 gfx::Rect visible_layer_rect(200, 400); | 1639 gfx::Rect visible_layer_rect(200, 400); |
1659 | 1640 |
1660 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1641 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
1661 | 1642 |
1662 ASSERT_EQ(1u, pending_layer()->num_tilings()); | 1643 ASSERT_EQ(1u, pending_layer()->num_tilings()); |
1663 ASSERT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale_key()); | 1644 ASSERT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); |
1664 | 1645 |
1665 // Set external viewport for tile priority. | 1646 // Set external viewport for tile priority. |
1666 gfx::Transform transform; | 1647 gfx::Transform transform; |
1667 gfx::Transform transform_for_tile_priority; | 1648 gfx::Transform transform_for_tile_priority; |
1668 host_impl()->SetExternalTilePriorityConstraints( | 1649 host_impl()->SetExternalTilePriorityConstraints( |
1669 external_viewport_for_tile_priority, transform_for_tile_priority); | 1650 external_viewport_for_tile_priority, transform_for_tile_priority); |
1670 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1651 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
1671 bool update_lcd_text = false; | 1652 bool update_lcd_text = false; |
1672 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 1653 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
1673 | 1654 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 gfx::Size viewport_size(400, 400); | 1832 gfx::Size viewport_size(400, 400); |
1852 | 1833 |
1853 host_impl()->SetViewportSize(viewport_size); | 1834 host_impl()->SetViewportSize(viewport_size); |
1854 SetInitialDeviceScaleFactor(2.f); | 1835 SetInitialDeviceScaleFactor(2.f); |
1855 | 1836 |
1856 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1837 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
1857 active_layer()->SetHasWillChangeTransformHint(true); | 1838 active_layer()->SetHasWillChangeTransformHint(true); |
1858 | 1839 |
1859 // One ideal tile exists, this will get used when drawing. | 1840 // One ideal tile exists, this will get used when drawing. |
1860 std::vector<Tile*> ideal_tiles; | 1841 std::vector<Tile*> ideal_tiles; |
1861 EXPECT_EQ(2.f, active_layer()->HighResTiling()->contents_scale_key()); | 1842 EXPECT_EQ(2.f, active_layer()->HighResTiling()->contents_scale()); |
1862 ideal_tiles.push_back(active_layer()->HighResTiling()->TileAt(0, 0)); | 1843 ideal_tiles.push_back(active_layer()->HighResTiling()->TileAt(0, 0)); |
1863 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1844 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
1864 ideal_tiles); | 1845 ideal_tiles); |
1865 | 1846 |
1866 // Due to layer scale throttling, the raster contents scale is changed to 1, | 1847 // Due to layer scale throttling, the raster contents scale is changed to 1, |
1867 // while the ideal is still 2. | 1848 // while the ideal is still 2. |
1868 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, | 1849 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, |
1869 false); | 1850 false); |
1870 SetupDrawPropertiesAndUpdateTiles(active_layer(), 2.f, 1.f, 1.f, 1.f, 0.f, | 1851 SetupDrawPropertiesAndUpdateTiles(active_layer(), 2.f, 1.f, 1.f, 1.f, 0.f, |
1871 false); | 1852 false); |
1872 | 1853 |
1873 EXPECT_EQ(1.f, active_layer()->HighResTiling()->contents_scale_key()); | 1854 EXPECT_EQ(1.f, active_layer()->HighResTiling()->contents_scale()); |
1874 EXPECT_EQ(1.f, active_layer()->raster_contents_scale()); | 1855 EXPECT_EQ(1.f, active_layer()->raster_contents_scale()); |
1875 EXPECT_EQ(2.f, active_layer()->ideal_contents_scale()); | 1856 EXPECT_EQ(2.f, active_layer()->ideal_contents_scale()); |
1876 | 1857 |
1877 // Both tilings still exist. | 1858 // Both tilings still exist. |
1878 EXPECT_EQ(2.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 1859 EXPECT_EQ(2.f, active_layer()->tilings()->tiling_at(0)->contents_scale()); |
1879 EXPECT_EQ(1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 1860 EXPECT_EQ(1.f, active_layer()->tilings()->tiling_at(1)->contents_scale()); |
1880 | 1861 |
1881 // All high res tiles have resources. | 1862 // All high res tiles have resources. |
1882 std::vector<Tile*> high_tiles = | 1863 std::vector<Tile*> high_tiles = |
1883 active_layer()->HighResTiling()->AllTilesForTesting(); | 1864 active_layer()->HighResTiling()->AllTilesForTesting(); |
1884 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 1865 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
1885 high_tiles); | 1866 high_tiles); |
1886 | 1867 |
1887 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 1868 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
1888 AppendQuadsData data; | 1869 AppendQuadsData data; |
1889 active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1870 active_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 | 2424 |
2444 // No tilings should be pushed to active layer. | 2425 // No tilings should be pushed to active layer. |
2445 pending_layer()->PushPropertiesTo(active_layer()); | 2426 pending_layer()->PushPropertiesTo(active_layer()); |
2446 EXPECT_EQ(0u, active_layer()->num_tilings()); | 2427 EXPECT_EQ(0u, active_layer()->num_tilings()); |
2447 } | 2428 } |
2448 | 2429 |
2449 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { | 2430 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { |
2450 SetupDefaultTrees(gfx::Size(10, 10)); | 2431 SetupDefaultTrees(gfx::Size(10, 10)); |
2451 | 2432 |
2452 // We start with a tiling at scale 1. | 2433 // We start with a tiling at scale 1. |
2453 EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale_key()); | 2434 EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); |
2454 | 2435 |
2455 // When we page scale up by 2.3, we get a new tiling that is a power of 2, in | 2436 // When we page scale up by 2.3, we get a new tiling that is a power of 2, in |
2456 // this case 4. | 2437 // this case 4. |
2457 host_impl()->PinchGestureBegin(); | 2438 host_impl()->PinchGestureBegin(); |
2458 float high_res_scale = 2.3f; | 2439 float high_res_scale = 2.3f; |
2459 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, | 2440 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, |
2460 false); | 2441 false); |
2461 EXPECT_EQ(4.f, pending_layer()->HighResTiling()->contents_scale_key()); | 2442 EXPECT_EQ(4.f, pending_layer()->HighResTiling()->contents_scale()); |
2462 } | 2443 } |
2463 | 2444 |
2464 TEST_F(PictureLayerImplTest, PinchingTooSmall) { | 2445 TEST_F(PictureLayerImplTest, PinchingTooSmall) { |
2465 SetupDefaultTrees(gfx::Size(10, 10)); | 2446 SetupDefaultTrees(gfx::Size(10, 10)); |
2466 | 2447 |
2467 // We start with a tiling at scale 1. | 2448 // We start with a tiling at scale 1. |
2468 EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale_key()); | 2449 EXPECT_EQ(1.f, pending_layer()->HighResTiling()->contents_scale()); |
2469 | 2450 |
2470 host_impl()->PinchGestureBegin(); | 2451 host_impl()->PinchGestureBegin(); |
2471 float high_res_scale = 0.0001f; | 2452 float high_res_scale = 0.0001f; |
2472 EXPECT_LT(high_res_scale, pending_layer()->MinimumContentsScale()); | 2453 EXPECT_LT(high_res_scale, pending_layer()->MinimumContentsScale()); |
2473 | 2454 |
2474 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, | 2455 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, |
2475 false); | 2456 false); |
2476 EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), | 2457 EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), |
2477 pending_layer()->HighResTiling()->contents_scale_key()); | 2458 pending_layer()->HighResTiling()->contents_scale()); |
2478 } | 2459 } |
2479 | 2460 |
2480 TEST_F(PictureLayerImplTest, PinchingTooSmallWithContentsScale) { | 2461 TEST_F(PictureLayerImplTest, PinchingTooSmallWithContentsScale) { |
2481 SetupDefaultTrees(gfx::Size(10, 10)); | 2462 SetupDefaultTrees(gfx::Size(10, 10)); |
2482 | 2463 |
2483 ResetTilingsAndRasterScales(); | 2464 ResetTilingsAndRasterScales(); |
2484 | 2465 |
2485 float contents_scale = 0.15f; | 2466 float contents_scale = 0.15f; |
2486 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, 0.f, false); | 2467 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, 0.f, false); |
2487 | 2468 |
2488 ASSERT_GE(pending_layer()->num_tilings(), 0u); | 2469 ASSERT_GE(pending_layer()->num_tilings(), 0u); |
2489 EXPECT_FLOAT_EQ(contents_scale, | 2470 EXPECT_FLOAT_EQ(contents_scale, |
2490 pending_layer()->HighResTiling()->contents_scale_key()); | 2471 pending_layer()->HighResTiling()->contents_scale()); |
2491 | 2472 |
2492 host_impl()->PinchGestureBegin(); | 2473 host_impl()->PinchGestureBegin(); |
2493 | 2474 |
2494 float page_scale = 0.0001f; | 2475 float page_scale = 0.0001f; |
2495 EXPECT_LT(page_scale * contents_scale, | 2476 EXPECT_LT(page_scale * contents_scale, |
2496 pending_layer()->MinimumContentsScale()); | 2477 pending_layer()->MinimumContentsScale()); |
2497 | 2478 |
2498 SetContentsScaleOnBothLayers(contents_scale * page_scale, 1.f, page_scale, | 2479 SetContentsScaleOnBothLayers(contents_scale * page_scale, 1.f, page_scale, |
2499 1.f, 0.f, false); | 2480 1.f, 0.f, false); |
2500 ASSERT_GE(pending_layer()->num_tilings(), 0u); | 2481 ASSERT_GE(pending_layer()->num_tilings(), 0u); |
2501 EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), | 2482 EXPECT_FLOAT_EQ(pending_layer()->MinimumContentsScale(), |
2502 pending_layer()->HighResTiling()->contents_scale_key()); | 2483 pending_layer()->HighResTiling()->contents_scale()); |
2503 } | 2484 } |
2504 | 2485 |
2505 TEST_F(PictureLayerImplTest, ConsiderAnimationStartScaleForRasterScale) { | 2486 TEST_F(PictureLayerImplTest, ConsiderAnimationStartScaleForRasterScale) { |
2506 gfx::Size viewport_size(1000, 1000); | 2487 gfx::Size viewport_size(1000, 1000); |
2507 host_impl()->SetViewportSize(viewport_size); | 2488 host_impl()->SetViewportSize(viewport_size); |
2508 | 2489 |
2509 gfx::Size layer_bounds(100, 100); | 2490 gfx::Size layer_bounds(100, 100); |
2510 SetupDefaultTrees(layer_bounds); | 2491 SetupDefaultTrees(layer_bounds); |
2511 | 2492 |
2512 float contents_scale = 2.f; | 2493 float contents_scale = 2.f; |
2513 float device_scale = 1.f; | 2494 float device_scale = 1.f; |
2514 float page_scale = 1.f; | 2495 float page_scale = 1.f; |
2515 float maximum_animation_scale = 3.f; | 2496 float maximum_animation_scale = 3.f; |
2516 float starting_animation_scale = 1.f; | 2497 float starting_animation_scale = 1.f; |
2517 bool animating_transform = true; | 2498 bool animating_transform = true; |
2518 | 2499 |
2519 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 1.f); | 2500 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
2520 | 2501 |
2521 // Maximum animation scale is greater than starting animation scale | 2502 // Maximum animation scale is greater than starting animation scale |
2522 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2503 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2523 maximum_animation_scale, | 2504 maximum_animation_scale, |
2524 starting_animation_scale, animating_transform); | 2505 starting_animation_scale, animating_transform); |
2525 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); | 2506 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
2526 | 2507 |
2527 animating_transform = false; | 2508 animating_transform = false; |
2528 | 2509 |
2529 // Once we stop animating, a new high-res tiling should be created. | 2510 // Once we stop animating, a new high-res tiling should be created. |
2530 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2511 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2531 maximum_animation_scale, | 2512 maximum_animation_scale, |
2532 starting_animation_scale, animating_transform); | 2513 starting_animation_scale, animating_transform); |
2533 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); | 2514 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
2534 | 2515 |
2535 // Starting animation scale greater than maximum animation scale | 2516 // Starting animation scale greater than maximum animation scale |
2536 // Bounds at starting scale within the viewport | 2517 // Bounds at starting scale within the viewport |
2537 animating_transform = true; | 2518 animating_transform = true; |
2538 starting_animation_scale = 5.f; | 2519 starting_animation_scale = 5.f; |
2539 | 2520 |
2540 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2521 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2541 maximum_animation_scale, | 2522 maximum_animation_scale, |
2542 starting_animation_scale, animating_transform); | 2523 starting_animation_scale, animating_transform); |
2543 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 5.f); | 2524 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 5.f); |
2544 | 2525 |
2545 // Once we stop animating, a new high-res tiling should be created. | 2526 // Once we stop animating, a new high-res tiling should be created. |
2546 animating_transform = false; | 2527 animating_transform = false; |
2547 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2528 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2548 maximum_animation_scale, | 2529 maximum_animation_scale, |
2549 starting_animation_scale, animating_transform); | 2530 starting_animation_scale, animating_transform); |
2550 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); | 2531 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
2551 | 2532 |
2552 // Starting Animation scale greater than maximum animation scale | 2533 // Starting Animation scale greater than maximum animation scale |
2553 // Bounds at starting scale outisde the viewport | 2534 // Bounds at starting scale outisde the viewport |
2554 animating_transform = true; | 2535 animating_transform = true; |
2555 starting_animation_scale = 11.f; | 2536 starting_animation_scale = 11.f; |
2556 | 2537 |
2557 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2538 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2558 maximum_animation_scale, | 2539 maximum_animation_scale, |
2559 starting_animation_scale, animating_transform); | 2540 starting_animation_scale, animating_transform); |
2560 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); | 2541 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
2561 } | 2542 } |
2562 | 2543 |
2563 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimation) { | 2544 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimation) { |
2564 gfx::Size viewport_size(1000, 1000); | 2545 gfx::Size viewport_size(1000, 1000); |
2565 host_impl()->SetViewportSize(viewport_size); | 2546 host_impl()->SetViewportSize(viewport_size); |
2566 | 2547 |
2567 gfx::Size layer_bounds(100, 100); | 2548 gfx::Size layer_bounds(100, 100); |
2568 SetupDefaultTrees(layer_bounds); | 2549 SetupDefaultTrees(layer_bounds); |
2569 | 2550 |
2570 float contents_scale = 1.f; | 2551 float contents_scale = 1.f; |
2571 float device_scale = 1.f; | 2552 float device_scale = 1.f; |
2572 float page_scale = 1.f; | 2553 float page_scale = 1.f; |
2573 float maximum_animation_scale = 1.f; | 2554 float maximum_animation_scale = 1.f; |
2574 float starting_animation_scale = 0.f; | 2555 float starting_animation_scale = 0.f; |
2575 bool animating_transform = false; | 2556 bool animating_transform = false; |
2576 | 2557 |
2577 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 1.f); | 2558 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
2578 | 2559 |
2579 // Starting an animation should cause tiling resolution to get set to the | 2560 // Starting an animation should cause tiling resolution to get set to the |
2580 // maximum animation scale factor. | 2561 // maximum animation scale factor. |
2581 animating_transform = true; | 2562 animating_transform = true; |
2582 maximum_animation_scale = 3.f; | 2563 maximum_animation_scale = 3.f; |
2583 contents_scale = 2.f; | 2564 contents_scale = 2.f; |
2584 | 2565 |
2585 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2566 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2586 maximum_animation_scale, | 2567 maximum_animation_scale, |
2587 starting_animation_scale, animating_transform); | 2568 starting_animation_scale, animating_transform); |
2588 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); | 2569 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
2589 | 2570 |
2590 // Further changes to scale during the animation should not cause a new | 2571 // Further changes to scale during the animation should not cause a new |
2591 // high-res tiling to get created. | 2572 // high-res tiling to get created. |
2592 contents_scale = 4.f; | 2573 contents_scale = 4.f; |
2593 maximum_animation_scale = 5.f; | 2574 maximum_animation_scale = 5.f; |
2594 | 2575 |
2595 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2576 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2596 maximum_animation_scale, | 2577 maximum_animation_scale, |
2597 starting_animation_scale, animating_transform); | 2578 starting_animation_scale, animating_transform); |
2598 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); | 2579 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
2599 | 2580 |
2600 // Once we stop animating, a new high-res tiling should be created. | 2581 // Once we stop animating, a new high-res tiling should be created. |
2601 animating_transform = false; | 2582 animating_transform = false; |
2602 | 2583 |
2603 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2584 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2604 maximum_animation_scale, | 2585 maximum_animation_scale, |
2605 starting_animation_scale, animating_transform); | 2586 starting_animation_scale, animating_transform); |
2606 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 4.f); | 2587 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
2607 | 2588 |
2608 // When animating with an unknown maximum animation scale factor, a new | 2589 // When animating with an unknown maximum animation scale factor, a new |
2609 // high-res tiling should be created at a source scale of 1. | 2590 // high-res tiling should be created at a source scale of 1. |
2610 animating_transform = true; | 2591 animating_transform = true; |
2611 contents_scale = 2.f; | 2592 contents_scale = 2.f; |
2612 maximum_animation_scale = 0.f; | 2593 maximum_animation_scale = 0.f; |
2613 | 2594 |
2614 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2595 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2615 maximum_animation_scale, | 2596 maximum_animation_scale, |
2616 starting_animation_scale, animating_transform); | 2597 starting_animation_scale, animating_transform); |
2617 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), | 2598 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
2618 page_scale * device_scale); | |
2619 | 2599 |
2620 // Further changes to scale during the animation should not cause a new | 2600 // Further changes to scale during the animation should not cause a new |
2621 // high-res tiling to get created. | 2601 // high-res tiling to get created. |
2622 contents_scale = 3.f; | 2602 contents_scale = 3.f; |
2623 | 2603 |
2624 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2604 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2625 maximum_animation_scale, | 2605 maximum_animation_scale, |
2626 starting_animation_scale, animating_transform); | 2606 starting_animation_scale, animating_transform); |
2627 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), | 2607 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
2628 page_scale * device_scale); | |
2629 | 2608 |
2630 // Once we stop animating, a new high-res tiling should be created. | 2609 // Once we stop animating, a new high-res tiling should be created. |
2631 animating_transform = false; | 2610 animating_transform = false; |
2632 contents_scale = 4.f; | 2611 contents_scale = 4.f; |
2633 | 2612 |
2634 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2613 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2635 maximum_animation_scale, | 2614 maximum_animation_scale, |
2636 starting_animation_scale, animating_transform); | 2615 starting_animation_scale, animating_transform); |
2637 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 4.f); | 2616 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
2638 | 2617 |
2639 // When animating with a maxmium animation scale factor that is so large | 2618 // When animating with a maxmium animation scale factor that is so large |
2640 // that the layer grows larger than the viewport at this scale, a new | 2619 // that the layer grows larger than the viewport at this scale, a new |
2641 // high-res tiling should get created at a source scale of 1, not at its | 2620 // high-res tiling should get created at a source scale of 1, not at its |
2642 // maximum scale. | 2621 // maximum scale. |
2643 animating_transform = true; | 2622 animating_transform = true; |
2644 contents_scale = 2.f; | 2623 contents_scale = 2.f; |
2645 maximum_animation_scale = 11.f; | 2624 maximum_animation_scale = 11.f; |
2646 | 2625 |
2647 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2626 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2648 maximum_animation_scale, | 2627 maximum_animation_scale, |
2649 starting_animation_scale, animating_transform); | 2628 starting_animation_scale, animating_transform); |
2650 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), | 2629 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
2651 page_scale * device_scale); | |
2652 | 2630 |
2653 // Once we stop animating, a new high-res tiling should be created. | 2631 // Once we stop animating, a new high-res tiling should be created. |
2654 animating_transform = false; | 2632 animating_transform = false; |
2655 contents_scale = 11.f; | 2633 contents_scale = 11.f; |
2656 | 2634 |
2657 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2635 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2658 maximum_animation_scale, | 2636 maximum_animation_scale, |
2659 starting_animation_scale, animating_transform); | 2637 starting_animation_scale, animating_transform); |
2660 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 11.f); | 2638 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); |
2661 | 2639 |
2662 // When animating with a maxmium animation scale factor that is so large | 2640 // When animating with a maxmium animation scale factor that is so large |
2663 // that the layer grows larger than the viewport at this scale, and where | 2641 // that the layer grows larger than the viewport at this scale, and where |
2664 // the intial source scale is < 1, a new high-res tiling should get created | 2642 // the intial source scale is < 1, a new high-res tiling should get created |
2665 // at source scale 1. | 2643 // at source scale 1. |
2666 animating_transform = true; | 2644 animating_transform = true; |
2667 contents_scale = 0.1f; | 2645 contents_scale = 0.1f; |
2668 maximum_animation_scale = 11.f; | 2646 maximum_animation_scale = 11.f; |
2669 | 2647 |
2670 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2648 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2671 maximum_animation_scale, | 2649 maximum_animation_scale, |
2672 starting_animation_scale, animating_transform); | 2650 starting_animation_scale, animating_transform); |
2673 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), | 2651 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); |
2674 device_scale * page_scale); | |
2675 | 2652 |
2676 // Once we stop animating, a new high-res tiling should be created. | 2653 // Once we stop animating, a new high-res tiling should be created. |
2677 animating_transform = false; | 2654 animating_transform = false; |
2678 contents_scale = 12.f; | 2655 contents_scale = 12.f; |
2679 | 2656 |
2680 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2657 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2681 maximum_animation_scale, | 2658 maximum_animation_scale, |
2682 starting_animation_scale, animating_transform); | 2659 starting_animation_scale, animating_transform); |
2683 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 12.f); | 2660 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 12.f); |
2684 | 2661 |
2685 // When animating toward a smaller scale, but that is still so large that the | 2662 // When animating toward a smaller scale, but that is still so large that the |
2686 // layer grows larger than the viewport at this scale, a new high-res tiling | 2663 // layer grows larger than the viewport at this scale, a new high-res tiling |
2687 // should get created at source scale 1. | 2664 // should get created at source scale 1. |
2688 animating_transform = true; | 2665 animating_transform = true; |
2689 contents_scale = 11.f; | 2666 contents_scale = 11.f; |
2690 maximum_animation_scale = 11.f; | 2667 maximum_animation_scale = 11.f; |
2691 | 2668 |
2692 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2669 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2693 maximum_animation_scale, | 2670 maximum_animation_scale, |
2694 starting_animation_scale, animating_transform); | 2671 starting_animation_scale, animating_transform); |
2695 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), | 2672 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); |
2696 device_scale * page_scale); | |
2697 | 2673 |
2698 // Once we stop animating, a new high-res tiling should be created. | 2674 // Once we stop animating, a new high-res tiling should be created. |
2699 animating_transform = false; | 2675 animating_transform = false; |
2700 contents_scale = 11.f; | 2676 contents_scale = 11.f; |
2701 | 2677 |
2702 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 2678 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2703 maximum_animation_scale, | 2679 maximum_animation_scale, |
2704 starting_animation_scale, animating_transform); | 2680 starting_animation_scale, animating_transform); |
2705 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 11.f); | 2681 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); |
2706 } | 2682 } |
2707 | 2683 |
2708 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { | 2684 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { |
2709 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 2685 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
2710 | 2686 |
2711 host_impl()->SetViewportSize(gfx::Size(500, 500)); | 2687 host_impl()->SetViewportSize(gfx::Size(500, 500)); |
2712 | 2688 |
2713 gfx::Size layer_bounds(1000, 1000); | 2689 gfx::Size layer_bounds(1000, 1000); |
2714 | 2690 |
2715 scoped_refptr<FakeRasterSource> pending_raster_source = | 2691 scoped_refptr<FakeRasterSource> pending_raster_source = |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2960 TilePriority priority = prioritized_tile.priority(); | 2936 TilePriority priority = prioritized_tile.priority(); |
2961 | 2937 |
2962 if (priority.priority_bin == TilePriority::NOW) { | 2938 if (priority.priority_bin == TilePriority::NOW) { |
2963 reached_visible = true; | 2939 reached_visible = true; |
2964 last_tile = prioritized_tile; | 2940 last_tile = prioritized_tile; |
2965 break; | 2941 break; |
2966 } | 2942 } |
2967 | 2943 |
2968 EXPECT_FALSE(tile->required_for_activation()); | 2944 EXPECT_FALSE(tile->required_for_activation()); |
2969 | 2945 |
2970 while (std::abs(tile->contents_scale_key() - expected_scales[scale_index]) > | 2946 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > |
2971 std::numeric_limits<float>::epsilon()) { | 2947 std::numeric_limits<float>::epsilon()) { |
2972 ++scale_index; | 2948 ++scale_index; |
2973 ASSERT_LT(scale_index, arraysize(expected_scales)); | 2949 ASSERT_LT(scale_index, arraysize(expected_scales)); |
2974 } | 2950 } |
2975 | 2951 |
2976 EXPECT_FLOAT_EQ(tile->contents_scale_key(), expected_scales[scale_index]); | 2952 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); |
2977 unique_tiles.insert(tile); | 2953 unique_tiles.insert(tile); |
2978 | 2954 |
2979 if (tile->required_for_activation() == | 2955 if (tile->required_for_activation() == |
2980 last_tile.tile()->required_for_activation() && | 2956 last_tile.tile()->required_for_activation() && |
2981 std::abs(tile->contents_scale_key() - | 2957 std::abs(tile->contents_scale() - last_tile.tile()->contents_scale()) < |
2982 last_tile.tile()->contents_scale_key()) < | |
2983 std::numeric_limits<float>::epsilon()) { | 2958 std::numeric_limits<float>::epsilon()) { |
2984 if (priority.distance_to_visible <= | 2959 if (priority.distance_to_visible <= |
2985 last_tile.priority().distance_to_visible) | 2960 last_tile.priority().distance_to_visible) |
2986 ++distance_decreasing; | 2961 ++distance_decreasing; |
2987 else | 2962 else |
2988 ++distance_increasing; | 2963 ++distance_increasing; |
2989 } | 2964 } |
2990 | 2965 |
2991 last_tile = prioritized_tile; | 2966 last_tile = prioritized_tile; |
2992 queue->Pop(); | 2967 queue->Pop(); |
(...skipping 15 matching lines...) Expand all Loading... |
3008 TilePriority priority = prioritized_tile.priority(); | 2983 TilePriority priority = prioritized_tile.priority(); |
3009 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2984 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
3010 | 2985 |
3011 if (reached_required) { | 2986 if (reached_required) { |
3012 EXPECT_TRUE(tile->required_for_activation()); | 2987 EXPECT_TRUE(tile->required_for_activation()); |
3013 } else if (tile->required_for_activation()) { | 2988 } else if (tile->required_for_activation()) { |
3014 reached_required = true; | 2989 reached_required = true; |
3015 scale_index = 0; | 2990 scale_index = 0; |
3016 } | 2991 } |
3017 | 2992 |
3018 while (std::abs(tile->contents_scale_key() - expected_scales[scale_index]) > | 2993 while (std::abs(tile->contents_scale() - expected_scales[scale_index]) > |
3019 std::numeric_limits<float>::epsilon()) { | 2994 std::numeric_limits<float>::epsilon()) { |
3020 ++scale_index; | 2995 ++scale_index; |
3021 ASSERT_LT(scale_index, arraysize(expected_scales)); | 2996 ASSERT_LT(scale_index, arraysize(expected_scales)); |
3022 } | 2997 } |
3023 | 2998 |
3024 EXPECT_FLOAT_EQ(tile->contents_scale_key(), expected_scales[scale_index]); | 2999 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); |
3025 unique_tiles.insert(tile); | 3000 unique_tiles.insert(tile); |
3026 queue->Pop(); | 3001 queue->Pop(); |
3027 } | 3002 } |
3028 | 3003 |
3029 EXPECT_TRUE(reached_required); | 3004 EXPECT_TRUE(reached_required); |
3030 EXPECT_EQ(all_tiles_set.size(), unique_tiles.size()); | 3005 EXPECT_EQ(all_tiles_set.size(), unique_tiles.size()); |
3031 } | 3006 } |
3032 | 3007 |
3033 TEST_F(PictureLayerImplTest, Occlusion) { | 3008 TEST_F(PictureLayerImplTest, Occlusion) { |
3034 gfx::Size tile_size(102, 102); | 3009 gfx::Size tile_size(102, 102); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3089 float contents_scale = 2.f; | 3064 float contents_scale = 2.f; |
3090 float device_scale = 1.f; | 3065 float device_scale = 1.f; |
3091 float page_scale = 1.f; | 3066 float page_scale = 1.f; |
3092 float maximum_animation_scale = 1.f; | 3067 float maximum_animation_scale = 1.f; |
3093 float starting_animation_scale = 0.f; | 3068 float starting_animation_scale = 0.f; |
3094 bool animating_transform = false; | 3069 bool animating_transform = false; |
3095 | 3070 |
3096 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3071 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3097 maximum_animation_scale, | 3072 maximum_animation_scale, |
3098 starting_animation_scale, animating_transform); | 3073 starting_animation_scale, animating_transform); |
3099 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 2.f); | 3074 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
3100 | 3075 |
3101 // Changing the source scale without being in an animation will cause | 3076 // Changing the source scale without being in an animation will cause |
3102 // the layer to change scale. | 3077 // the layer to change scale. |
3103 contents_scale = 3.f; | 3078 contents_scale = 3.f; |
3104 | 3079 |
3105 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3080 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3106 maximum_animation_scale, | 3081 maximum_animation_scale, |
3107 starting_animation_scale, animating_transform); | 3082 starting_animation_scale, animating_transform); |
3108 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); | 3083 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
3109 | 3084 |
3110 contents_scale = 0.5f; | 3085 contents_scale = 0.5f; |
3111 | 3086 |
3112 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3087 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3113 maximum_animation_scale, | 3088 maximum_animation_scale, |
3114 starting_animation_scale, animating_transform); | 3089 starting_animation_scale, animating_transform); |
3115 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 0.5f); | 3090 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); |
3116 | 3091 |
3117 // However, if the layer has a will-change property, then the raster scale | 3092 // However, if the layer has a will-change property, then the raster scale |
3118 // will get fixed at the last value. | 3093 // will get fixed at the last value. |
3119 active_layer()->SetHasWillChangeTransformHint(true); | 3094 active_layer()->SetHasWillChangeTransformHint(true); |
3120 pending_layer()->SetHasWillChangeTransformHint(true); | 3095 pending_layer()->SetHasWillChangeTransformHint(true); |
3121 | 3096 |
3122 contents_scale = 3.f; | 3097 contents_scale = 3.f; |
3123 | 3098 |
3124 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3099 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3125 maximum_animation_scale, | 3100 maximum_animation_scale, |
3126 starting_animation_scale, animating_transform); | 3101 starting_animation_scale, animating_transform); |
3127 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 0.5f); | 3102 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); |
3128 | 3103 |
3129 // Further changes to the source scale will no longer be reflected in the | 3104 // Further changes to the source scale will no longer be reflected in the |
3130 // contents scale. | 3105 // contents scale. |
3131 contents_scale = 1.f; | 3106 contents_scale = 1.f; |
3132 | 3107 |
3133 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3108 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3134 maximum_animation_scale, | 3109 maximum_animation_scale, |
3135 starting_animation_scale, animating_transform); | 3110 starting_animation_scale, animating_transform); |
3136 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 0.5f); | 3111 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); |
3137 | 3112 |
3138 // Disabling the will-change hint will once again make the raster scale update | 3113 // Disabling the will-change hint will once again make the raster scale update |
3139 // with the ideal scale. | 3114 // with the ideal scale. |
3140 active_layer()->SetHasWillChangeTransformHint(false); | 3115 active_layer()->SetHasWillChangeTransformHint(false); |
3141 pending_layer()->SetHasWillChangeTransformHint(false); | 3116 pending_layer()->SetHasWillChangeTransformHint(false); |
3142 | 3117 |
3143 contents_scale = 3.f; | 3118 contents_scale = 3.f; |
3144 | 3119 |
3145 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3120 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3146 maximum_animation_scale, | 3121 maximum_animation_scale, |
3147 starting_animation_scale, animating_transform); | 3122 starting_animation_scale, animating_transform); |
3148 EXPECT_BOTH_EQ(HighResTiling()->contents_scale_key(), 3.f); | 3123 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
3149 } | 3124 } |
3150 | 3125 |
3151 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3126 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
3152 gfx::Size tile_size(100, 100); | 3127 gfx::Size tile_size(100, 100); |
3153 gfx::Size layer_bounds(1000, 1000); | 3128 gfx::Size layer_bounds(1000, 1000); |
3154 | 3129 |
3155 // Make sure pending tree has tiles. | 3130 // Make sure pending tree has tiles. |
3156 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3131 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3157 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3132 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3158 | 3133 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3221 ResetTilingsAndRasterScales(); | 3196 ResetTilingsAndRasterScales(); |
3222 | 3197 |
3223 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 3198 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
3224 6.f, // ideal contents scale | 3199 6.f, // ideal contents scale |
3225 3.f, // device scale | 3200 3.f, // device scale |
3226 2.f, // page scale | 3201 2.f, // page scale |
3227 1.f, // maximum animation scale | 3202 1.f, // maximum animation scale |
3228 0.f, // starting animation scale | 3203 0.f, // starting animation scale |
3229 false); | 3204 false); |
3230 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); | 3205 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); |
3231 EXPECT_FLOAT_EQ( | 3206 EXPECT_FLOAT_EQ(6.f, |
3232 6.f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 3207 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
3233 | 3208 |
3234 // If we change the page scale factor, then we should get new tilings. | 3209 // If we change the page scale factor, then we should get new tilings. |
3235 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 3210 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
3236 6.6f, // ideal contents scale | 3211 6.6f, // ideal contents scale |
3237 3.f, // device scale | 3212 3.f, // device scale |
3238 2.2f, // page scale | 3213 2.2f, // page scale |
3239 1.f, // maximum animation scale | 3214 1.f, // maximum animation scale |
3240 0.f, // starting animation scale | 3215 0.f, // starting animation scale |
3241 false); | 3216 false); |
3242 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 3217 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
3243 EXPECT_FLOAT_EQ( | 3218 EXPECT_FLOAT_EQ(6.6f, |
3244 6.6f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 3219 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
3245 | 3220 |
3246 // If we change the device scale factor, then we should get new tilings. | 3221 // If we change the device scale factor, then we should get new tilings. |
3247 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 3222 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
3248 7.26f, // ideal contents scale | 3223 7.26f, // ideal contents scale |
3249 3.3f, // device scale | 3224 3.3f, // device scale |
3250 2.2f, // page scale | 3225 2.2f, // page scale |
3251 1.f, // maximum animation scale | 3226 1.f, // maximum animation scale |
3252 0.f, // starting animation scale | 3227 0.f, // starting animation scale |
3253 false); | 3228 false); |
3254 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 3229 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
3255 EXPECT_FLOAT_EQ( | 3230 EXPECT_FLOAT_EQ(7.26f, |
3256 7.26f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 3231 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
3257 | 3232 |
3258 // If we change the device scale factor, but end up at the same total scale | 3233 // If we change the device scale factor, but end up at the same total scale |
3259 // factor somehow, then we don't get new tilings. | 3234 // factor somehow, then we don't get new tilings. |
3260 SetupDrawPropertiesAndUpdateTiles(active_layer(), | 3235 SetupDrawPropertiesAndUpdateTiles(active_layer(), |
3261 7.26f, // ideal contents scale | 3236 7.26f, // ideal contents scale |
3262 2.2f, // device scale | 3237 2.2f, // device scale |
3263 3.3f, // page scale | 3238 3.3f, // page scale |
3264 1.f, // maximum animation scale | 3239 1.f, // maximum animation scale |
3265 0.f, // starting animation scale | 3240 0.f, // starting animation scale |
3266 false); | 3241 false); |
3267 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | 3242 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
3268 EXPECT_FLOAT_EQ( | 3243 EXPECT_FLOAT_EQ(7.26f, |
3269 7.26f, active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 3244 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
3270 } | 3245 } |
3271 | 3246 |
3272 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { | 3247 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { |
3273 gfx::Size layer_bounds(1300, 1900); | 3248 gfx::Size layer_bounds(1300, 1900); |
3274 SetupDefaultTrees(layer_bounds); | 3249 SetupDefaultTrees(layer_bounds); |
3275 | 3250 |
3276 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 3251 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
3277 EXPECT_LT(low_res_factor, 1.f); | 3252 EXPECT_LT(low_res_factor, 1.f); |
3278 | 3253 |
3279 ResetTilingsAndRasterScales(); | 3254 ResetTilingsAndRasterScales(); |
3280 | 3255 |
3281 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3256 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
3282 6.f, // ideal contents scale | 3257 6.f, // ideal contents scale |
3283 3.f, // device scale | 3258 3.f, // device scale |
3284 2.f, // page scale | 3259 2.f, // page scale |
3285 1.f, // maximum animation scale | 3260 1.f, // maximum animation scale |
3286 0.f, // starting animation scale | 3261 0.f, // starting animation scale |
3287 false); | 3262 false); |
3288 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3263 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
3289 EXPECT_FLOAT_EQ( | 3264 EXPECT_FLOAT_EQ(6.f, |
3290 6.f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 3265 pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
3291 | 3266 |
3292 // If we change the page scale factor, then we should get new tilings. | 3267 // If we change the page scale factor, then we should get new tilings. |
3293 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3268 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
3294 6.6f, // ideal contents scale | 3269 6.6f, // ideal contents scale |
3295 3.f, // device scale | 3270 3.f, // device scale |
3296 2.2f, // page scale | 3271 2.2f, // page scale |
3297 1.f, // maximum animation scale | 3272 1.f, // maximum animation scale |
3298 0.f, // starting animation scale | 3273 0.f, // starting animation scale |
3299 false); | 3274 false); |
3300 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3275 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
3301 EXPECT_FLOAT_EQ( | 3276 EXPECT_FLOAT_EQ(6.6f, |
3302 6.6f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 3277 pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
3303 | 3278 |
3304 // If we change the device scale factor, then we should get new tilings. | 3279 // If we change the device scale factor, then we should get new tilings. |
3305 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3280 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
3306 7.26f, // ideal contents scale | 3281 7.26f, // ideal contents scale |
3307 3.3f, // device scale | 3282 3.3f, // device scale |
3308 2.2f, // page scale | 3283 2.2f, // page scale |
3309 1.f, // maximum animation scale | 3284 1.f, // maximum animation scale |
3310 0.f, // starting animation scale | 3285 0.f, // starting animation scale |
3311 false); | 3286 false); |
3312 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3287 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
3313 EXPECT_FLOAT_EQ( | 3288 EXPECT_FLOAT_EQ(7.26f, |
3314 7.26f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 3289 pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
3315 | 3290 |
3316 // If we change the device scale factor, but end up at the same total scale | 3291 // If we change the device scale factor, but end up at the same total scale |
3317 // factor somehow, then we don't get new tilings. | 3292 // factor somehow, then we don't get new tilings. |
3318 SetupDrawPropertiesAndUpdateTiles(pending_layer(), | 3293 SetupDrawPropertiesAndUpdateTiles(pending_layer(), |
3319 7.26f, // ideal contents scale | 3294 7.26f, // ideal contents scale |
3320 2.2f, // device scale | 3295 2.2f, // device scale |
3321 3.3f, // page scale | 3296 3.3f, // page scale |
3322 1.f, // maximum animation scale | 3297 1.f, // maximum animation scale |
3323 0.f, // starting animation scale | 3298 0.f, // starting animation scale |
3324 false); | 3299 false); |
3325 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 3300 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
3326 EXPECT_FLOAT_EQ( | 3301 EXPECT_FLOAT_EQ(7.26f, |
3327 7.26f, pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 3302 pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
3328 } | 3303 } |
3329 | 3304 |
3330 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { | 3305 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
3331 gfx::Size layer_bounds(400, 400); | 3306 gfx::Size layer_bounds(400, 400); |
3332 gfx::Size tile_size(100, 100); | 3307 gfx::Size tile_size(100, 100); |
3333 | 3308 |
3334 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 3309 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
3335 | 3310 |
3336 Tile* some_active_tile = | 3311 Tile* some_active_tile = |
3337 active_layer()->HighResTiling()->AllTilesForTesting()[0]; | 3312 active_layer()->HighResTiling()->AllTilesForTesting()[0]; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3427 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 3402 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
3428 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); | 3403 ASSERT_EQ(1u, active_layer()->tilings()->num_tilings()); |
3429 | 3404 |
3430 host_impl()->PinchGestureEnd(); | 3405 host_impl()->PinchGestureEnd(); |
3431 | 3406 |
3432 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 3407 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
3433 scale /= 4.f; | 3408 scale /= 4.f; |
3434 page_scale /= 4.f; | 3409 page_scale /= 4.f; |
3435 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, 0.f, false); | 3410 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, 0.f, false); |
3436 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 3411 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
3437 EXPECT_FLOAT_EQ( | 3412 EXPECT_FLOAT_EQ(1.f, |
3438 1.f, active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | 3413 active_layer()->tilings()->tiling_at(1)->contents_scale()); |
3439 | 3414 |
3440 // Ensure UpdateTiles won't remove any tilings. | 3415 // Ensure UpdateTiles won't remove any tilings. |
3441 active_layer()->MarkAllTilingsUsed(); | 3416 active_layer()->MarkAllTilingsUsed(); |
3442 | 3417 |
3443 // Mark the non-ideal tilings as used. They won't be removed. | 3418 // Mark the non-ideal tilings as used. They won't be removed. |
3444 used_tilings.clear(); | 3419 used_tilings.clear(); |
3445 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); | 3420 used_tilings.push_back(active_layer()->tilings()->tiling_at(1)); |
3446 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); | 3421 active_layer()->CleanUpTilingsOnActiveLayer(used_tilings); |
3447 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); | 3422 ASSERT_EQ(2u, active_layer()->tilings()->num_tilings()); |
3448 | 3423 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3649 | 3624 |
3650 bool last_tile_is_occluded = last_tile.is_occluded(); | 3625 bool last_tile_is_occluded = last_tile.is_occluded(); |
3651 if (!last_tile_is_occluded) { | 3626 if (!last_tile_is_occluded) { |
3652 TilePriority::PriorityBin tile_priority_bin = | 3627 TilePriority::PriorityBin tile_priority_bin = |
3653 prioritized_tile.priority().priority_bin; | 3628 prioritized_tile.priority().priority_bin; |
3654 TilePriority::PriorityBin last_tile_priority_bin = | 3629 TilePriority::PriorityBin last_tile_priority_bin = |
3655 last_tile.priority().priority_bin; | 3630 last_tile.priority().priority_bin; |
3656 | 3631 |
3657 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || | 3632 EXPECT_TRUE(tile_priority_bin < last_tile_priority_bin || |
3658 tile->required_for_activation() || | 3633 tile->required_for_activation() || |
3659 tile->contents_scale_key() != | 3634 tile->contents_scale() != |
3660 last_tile.tile()->contents_scale_key()) | 3635 last_tile.tile()->contents_scale()) |
3661 << "line: " << source_line; | 3636 << "line: " << source_line; |
3662 } | 3637 } |
3663 } | 3638 } |
3664 last_tile = prioritized_tile; | 3639 last_tile = prioritized_tile; |
3665 queue->Pop(); | 3640 queue->Pop(); |
3666 } | 3641 } |
3667 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) | 3642 EXPECT_EQ(expected_occluded_tile_count, occluded_tile_count) |
3668 << "line: " << source_line; | 3643 << "line: " << source_line; |
3669 } | 3644 } |
3670 }; | 3645 }; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3928 for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { | 3903 for (size_t i = 0; i < pending_layer()->num_tilings(); ++i) { |
3929 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); | 3904 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(i); |
3930 auto prioritized_tiles = | 3905 auto prioritized_tiles = |
3931 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 3906 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
3932 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 3907 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
3933 | 3908 |
3934 occluded_tile_count = 0; | 3909 occluded_tile_count = 0; |
3935 for (size_t j = 0; j < tiles.size(); ++j) { | 3910 for (size_t j = 0; j < tiles.size(); ++j) { |
3936 if (prioritized_tiles[tiles[j]].is_occluded()) { | 3911 if (prioritized_tiles[tiles[j]].is_occluded()) { |
3937 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 3912 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
3938 tiles[j]->content_rect(), 1.f / tiles[j]->raster_scales().width(), | 3913 tiles[j]->content_rect(), 1.f / tiles[j]->contents_scale()); |
3939 1.f / tiles[j]->raster_scales().height()); | |
3940 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 3914 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
3941 occluded_tile_count++; | 3915 occluded_tile_count++; |
3942 } | 3916 } |
3943 } | 3917 } |
3944 | 3918 |
3945 switch (i) { | 3919 switch (i) { |
3946 case 0: | 3920 case 0: |
3947 EXPECT_EQ(occluded_tile_count, 30); | 3921 EXPECT_EQ(occluded_tile_count, 30); |
3948 break; | 3922 break; |
3949 case 1: | 3923 case 1: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3993 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 3967 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
3994 | 3968 |
3995 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, | 3969 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, |
3996 gfx::Rect(layer_bounds)); | 3970 gfx::Rect(layer_bounds)); |
3997 iter; ++iter) { | 3971 iter; ++iter) { |
3998 if (!*iter) | 3972 if (!*iter) |
3999 continue; | 3973 continue; |
4000 const Tile* tile = *iter; | 3974 const Tile* tile = *iter; |
4001 | 3975 |
4002 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 3976 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
4003 tile->content_rect(), 1.f / tile->raster_scales().width(), | 3977 tile->content_rect(), 1.f / tile->contents_scale()); |
4004 1.f / tile->raster_scales().height()); | |
4005 // Tiles are occluded on the active tree iff they lie beneath the | 3978 // Tiles are occluded on the active tree iff they lie beneath the |
4006 // occluding layer. | 3979 // occluding layer. |
4007 EXPECT_EQ(prioritized_tiles[tile].is_occluded(), | 3980 EXPECT_EQ(prioritized_tiles[tile].is_occluded(), |
4008 scaled_content_rect.x() >= occluding_layer_position.x()); | 3981 scaled_content_rect.x() >= occluding_layer_position.x()); |
4009 } | 3982 } |
4010 } | 3983 } |
4011 | 3984 |
4012 // Partially invalidate the pending layer. | 3985 // Partially invalidate the pending layer. |
4013 SetupPendingTreeWithInvalidation(pending_raster_source, invalidation_rect); | 3986 SetupPendingTreeWithInvalidation(pending_raster_source, invalidation_rect); |
4014 | 3987 |
(...skipping 15 matching lines...) Expand all Loading... |
4030 | 4003 |
4031 if (tiling->resolution() == LOW_RESOLUTION) { | 4004 if (tiling->resolution() == LOW_RESOLUTION) { |
4032 EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinTiling(tiling)); | 4005 EXPECT_FALSE(active_layer()->GetPendingOrActiveTwinTiling(tiling)); |
4033 continue; | 4006 continue; |
4034 } | 4007 } |
4035 | 4008 |
4036 Tile* twin_tile = | 4009 Tile* twin_tile = |
4037 active_layer()->GetPendingOrActiveTwinTiling(tiling)->TileAt( | 4010 active_layer()->GetPendingOrActiveTwinTiling(tiling)->TileAt( |
4038 iter.i(), iter.j()); | 4011 iter.i(), iter.j()); |
4039 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4012 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
4040 tile->content_rect(), 1.f / tile->raster_scales().height(), | 4013 tile->content_rect(), 1.f / tile->contents_scale()); |
4041 1.f / tile->raster_scales().width()); | |
4042 | 4014 |
4043 if (scaled_content_rect.Intersects(invalidation_rect)) { | 4015 if (scaled_content_rect.Intersects(invalidation_rect)) { |
4044 // Tiles inside the invalidation rect exist on both trees. | 4016 // Tiles inside the invalidation rect exist on both trees. |
4045 EXPECT_TRUE(twin_tile); | 4017 EXPECT_TRUE(twin_tile); |
4046 EXPECT_NE(tile, twin_tile); | 4018 EXPECT_NE(tile, twin_tile); |
4047 } else { | 4019 } else { |
4048 // Tiles outside the invalidation rect only exist on the active tree. | 4020 // Tiles outside the invalidation rect only exist on the active tree. |
4049 EXPECT_FALSE(twin_tile); | 4021 EXPECT_FALSE(twin_tile); |
4050 } | 4022 } |
4051 } | 4023 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4139 else | 4111 else |
4140 EXPECT_FALSE(tile); | 4112 EXPECT_FALSE(tile); |
4141 | 4113 |
4142 if (!tile) | 4114 if (!tile) |
4143 continue; | 4115 continue; |
4144 if (prioritized_tiles[tile].is_occluded()) | 4116 if (prioritized_tiles[tile].is_occluded()) |
4145 occluded_tile_count_on_pending++; | 4117 occluded_tile_count_on_pending++; |
4146 } | 4118 } |
4147 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | 4119 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], |
4148 occluded_tile_count_on_pending) | 4120 occluded_tile_count_on_pending) |
4149 << tiling->contents_scale_key(); | 4121 << tiling->contents_scale(); |
4150 } | 4122 } |
4151 | 4123 |
4152 // Verify number of occluded tiles on the active layer for each tiling. | 4124 // Verify number of occluded tiles on the active layer for each tiling. |
4153 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { | 4125 for (size_t i = 0; i < active_layer()->num_tilings(); ++i) { |
4154 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); | 4126 PictureLayerTiling* tiling = active_layer()->tilings()->tiling_at(i); |
4155 auto prioritized_tiles = | 4127 auto prioritized_tiles = |
4156 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); | 4128 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
4157 | 4129 |
4158 size_t occluded_tile_count_on_active = 0u; | 4130 size_t occluded_tile_count_on_active = 0u; |
4159 for (PictureLayerTiling::CoverageIterator iter(tiling, dest_scale, | 4131 for (PictureLayerTiling::CoverageIterator iter(tiling, dest_scale, |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4729 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { | 4701 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { |
4730 gfx::Size layer_bounds(1300, 1900); | 4702 gfx::Size layer_bounds(1300, 1900); |
4731 | 4703 |
4732 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 4704 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
4733 SetupDefaultTrees(layer_bounds); | 4705 SetupDefaultTrees(layer_bounds); |
4734 ResetTilingsAndRasterScales(); | 4706 ResetTilingsAndRasterScales(); |
4735 | 4707 |
4736 float page_scale = 2.f; | 4708 float page_scale = 2.f; |
4737 SetContentsScaleOnBothLayers(page_scale, 1.0f, page_scale, 1.0f, 0.f, false); | 4709 SetContentsScaleOnBothLayers(page_scale, 1.0f, page_scale, 1.0f, 0.f, false); |
4738 EXPECT_BOTH_EQ(num_tilings(), 1u); | 4710 EXPECT_BOTH_EQ(num_tilings(), 1u); |
4739 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale_key(), page_scale); | 4711 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), page_scale); |
4740 | 4712 |
4741 host_impl()->PinchGestureBegin(); | 4713 host_impl()->PinchGestureBegin(); |
4742 | 4714 |
4743 // Zoom out to exactly the low res factor so that the previous high res | 4715 // Zoom out to exactly the low res factor so that the previous high res |
4744 // would be equal to the current low res (if it were possible to have one). | 4716 // would be equal to the current low res (if it were possible to have one). |
4745 float zoomed = page_scale / low_res_factor; | 4717 float zoomed = page_scale / low_res_factor; |
4746 SetContentsScaleOnBothLayers(zoomed, 1.0f, zoomed, 1.0f, 0.f, false); | 4718 SetContentsScaleOnBothLayers(zoomed, 1.0f, zoomed, 1.0f, 0.f, false); |
4747 EXPECT_EQ(1u, pending_layer()->num_tilings()); | 4719 EXPECT_EQ(1u, pending_layer()->num_tilings()); |
4748 EXPECT_EQ(zoomed, | 4720 EXPECT_EQ(zoomed, pending_layer()->tilings()->tiling_at(0)->contents_scale()); |
4749 pending_layer()->tilings()->tiling_at(0)->contents_scale_key()); | |
4750 } | 4721 } |
4751 | 4722 |
4752 TEST_F(PictureLayerImplTest, HighResWasLowResCollision) { | 4723 TEST_F(PictureLayerImplTest, HighResWasLowResCollision) { |
4753 gfx::Size layer_bounds(1300, 1900); | 4724 gfx::Size layer_bounds(1300, 1900); |
4754 | 4725 |
4755 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 4726 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
4756 | 4727 |
4757 SetupDefaultTrees(layer_bounds); | 4728 SetupDefaultTrees(layer_bounds); |
4758 ResetTilingsAndRasterScales(); | 4729 ResetTilingsAndRasterScales(); |
4759 | 4730 |
4760 float page_scale = 4.f; | 4731 float page_scale = 4.f; |
4761 float low_res = page_scale * low_res_factor; | 4732 float low_res = page_scale * low_res_factor; |
4762 float extra_low_res = low_res * low_res_factor; | 4733 float extra_low_res = low_res * low_res_factor; |
4763 SetupDrawPropertiesAndUpdateTiles(active_layer(), page_scale, 1.0f, | 4734 SetupDrawPropertiesAndUpdateTiles(active_layer(), page_scale, 1.0f, |
4764 page_scale, 1.0f, 0.f, false); | 4735 page_scale, 1.0f, 0.f, false); |
4765 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); | 4736 EXPECT_EQ(2u, active_layer()->tilings()->num_tilings()); |
4766 EXPECT_EQ(page_scale, | 4737 EXPECT_EQ(page_scale, |
4767 active_layer()->tilings()->tiling_at(0)->contents_scale_key()); | 4738 active_layer()->tilings()->tiling_at(0)->contents_scale()); |
4768 EXPECT_EQ(low_res, | 4739 EXPECT_EQ(low_res, active_layer()->tilings()->tiling_at(1)->contents_scale()); |
4769 active_layer()->tilings()->tiling_at(1)->contents_scale_key()); | |
4770 | 4740 |
4771 // Grab a current low res tile. | 4741 // Grab a current low res tile. |
4772 PictureLayerTiling* old_low_res_tiling = | 4742 PictureLayerTiling* old_low_res_tiling = |
4773 active_layer()->tilings()->tiling_at(1); | 4743 active_layer()->tilings()->tiling_at(1); |
4774 Tile::Id old_low_res_tile_id = | 4744 Tile::Id old_low_res_tile_id = |
4775 active_layer()->tilings()->tiling_at(1)->TileAt(0, 0)->id(); | 4745 active_layer()->tilings()->tiling_at(1)->TileAt(0, 0)->id(); |
4776 | 4746 |
4777 // The tiling knows it has low res content. | 4747 // The tiling knows it has low res content. |
4778 EXPECT_TRUE(active_layer() | 4748 EXPECT_TRUE(active_layer() |
4779 ->tilings() | 4749 ->tilings() |
4780 ->tiling_at(1) | 4750 ->tiling_at(1) |
4781 ->may_contain_low_resolution_tiles()); | 4751 ->may_contain_low_resolution_tiles()); |
4782 | 4752 |
4783 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 4753 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
4784 | 4754 |
4785 // Zoom in to exactly the low res factor so that the previous low res | 4755 // Zoom in to exactly the low res factor so that the previous low res |
4786 // would be equal to the current high res. | 4756 // would be equal to the current high res. |
4787 SetupDrawPropertiesAndUpdateTiles(active_layer(), low_res, 1.0f, low_res, | 4757 SetupDrawPropertiesAndUpdateTiles(active_layer(), low_res, 1.0f, low_res, |
4788 1.0f, 0.f, false); | 4758 1.0f, 0.f, false); |
4789 // 3 tilings. The old high res, the new high res (old low res) and the new low | 4759 // 3 tilings. The old high res, the new high res (old low res) and the new low |
4790 // res. | 4760 // res. |
4791 EXPECT_EQ(3u, active_layer()->num_tilings()); | 4761 EXPECT_EQ(3u, active_layer()->num_tilings()); |
4792 | 4762 |
4793 PictureLayerTilingSet* tilings = active_layer()->tilings(); | 4763 PictureLayerTilingSet* tilings = active_layer()->tilings(); |
4794 EXPECT_EQ(page_scale, tilings->tiling_at(0)->contents_scale_key()); | 4764 EXPECT_EQ(page_scale, tilings->tiling_at(0)->contents_scale()); |
4795 EXPECT_EQ(low_res, tilings->tiling_at(1)->contents_scale_key()); | 4765 EXPECT_EQ(low_res, tilings->tiling_at(1)->contents_scale()); |
4796 EXPECT_EQ(extra_low_res, tilings->tiling_at(2)->contents_scale_key()); | 4766 EXPECT_EQ(extra_low_res, tilings->tiling_at(2)->contents_scale()); |
4797 | 4767 |
4798 EXPECT_EQ(NON_IDEAL_RESOLUTION, tilings->tiling_at(0)->resolution()); | 4768 EXPECT_EQ(NON_IDEAL_RESOLUTION, tilings->tiling_at(0)->resolution()); |
4799 EXPECT_EQ(HIGH_RESOLUTION, tilings->tiling_at(1)->resolution()); | 4769 EXPECT_EQ(HIGH_RESOLUTION, tilings->tiling_at(1)->resolution()); |
4800 EXPECT_EQ(LOW_RESOLUTION, tilings->tiling_at(2)->resolution()); | 4770 EXPECT_EQ(LOW_RESOLUTION, tilings->tiling_at(2)->resolution()); |
4801 | 4771 |
4802 // The old low res tile was destroyed and replaced. | 4772 // The old low res tile was destroyed and replaced. |
4803 EXPECT_EQ(old_low_res_tiling, tilings->tiling_at(1)); | 4773 EXPECT_EQ(old_low_res_tiling, tilings->tiling_at(1)); |
4804 EXPECT_NE(old_low_res_tile_id, tilings->tiling_at(1)->TileAt(0, 0)->id()); | 4774 EXPECT_NE(old_low_res_tile_id, tilings->tiling_at(1)->TileAt(0, 0)->id()); |
4805 EXPECT_TRUE(tilings->tiling_at(1)->TileAt(0, 0)); | 4775 EXPECT_TRUE(tilings->tiling_at(1)->TileAt(0, 0)); |
4806 | 4776 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4857 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f. | 4827 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f. |
4858 const float suggested_ideal_contents_scale = 2.f; | 4828 const float suggested_ideal_contents_scale = 2.f; |
4859 const float device_scale_factor = 3.f; | 4829 const float device_scale_factor = 3.f; |
4860 const float page_scale_factor = 4.f; | 4830 const float page_scale_factor = 4.f; |
4861 const float animation_contents_scale = 1.f; | 4831 const float animation_contents_scale = 1.f; |
4862 const bool animating_transform_to_screen = false; | 4832 const bool animating_transform_to_screen = false; |
4863 SetupDrawPropertiesAndUpdateTiles( | 4833 SetupDrawPropertiesAndUpdateTiles( |
4864 pending_layer_ptr, suggested_ideal_contents_scale, device_scale_factor, | 4834 pending_layer_ptr, suggested_ideal_contents_scale, device_scale_factor, |
4865 page_scale_factor, animation_contents_scale, animation_contents_scale, | 4835 page_scale_factor, animation_contents_scale, animation_contents_scale, |
4866 animating_transform_to_screen); | 4836 animating_transform_to_screen); |
4867 EXPECT_EQ(1.f, | 4837 EXPECT_EQ(1.f, pending_layer_ptr->tilings()->tiling_at(0)->contents_scale()); |
4868 pending_layer_ptr->tilings()->tiling_at(0)->contents_scale_key()); | |
4869 | 4838 |
4870 // Push to active layer. | 4839 // Push to active layer. |
4871 host_impl()->ActivateSyncTree(); | 4840 host_impl()->ActivateSyncTree(); |
4872 | 4841 |
4873 FakePictureLayerImpl* active_layer = static_cast<FakePictureLayerImpl*>( | 4842 FakePictureLayerImpl* active_layer = static_cast<FakePictureLayerImpl*>( |
4874 host_impl()->active_tree()->root_layer_for_testing()); | 4843 host_impl()->active_tree()->root_layer_for_testing()); |
4875 SetupDrawPropertiesAndUpdateTiles( | 4844 SetupDrawPropertiesAndUpdateTiles( |
4876 active_layer, suggested_ideal_contents_scale, device_scale_factor, | 4845 active_layer, suggested_ideal_contents_scale, device_scale_factor, |
4877 page_scale_factor, animation_contents_scale, animation_contents_scale, | 4846 page_scale_factor, animation_contents_scale, animation_contents_scale, |
4878 animating_transform_to_screen); | 4847 animating_transform_to_screen); |
4879 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale_key()); | 4848 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale()); |
4880 active_layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 4849 active_layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
4881 | 4850 |
4882 // Create resources for the tiles. | 4851 // Create resources for the tiles. |
4883 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( | 4852 host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( |
4884 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); | 4853 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); |
4885 | 4854 |
4886 // Draw. | 4855 // Draw. |
4887 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 4856 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
4888 AppendQuadsData data; | 4857 AppendQuadsData data; |
4889 active_layer->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 4858 active_layer->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4925 // Scale 0.6. | 4894 // Scale 0.6. |
4926 case 6: | 4895 case 6: |
4927 expected_contents_scale = 1.f; | 4896 expected_contents_scale = 1.f; |
4928 break; | 4897 break; |
4929 } | 4898 } |
4930 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, | 4899 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, |
4931 1.f, 1.f, 1.f, 1.f, false); | 4900 1.f, 1.f, 1.f, 1.f, false); |
4932 EXPECT_FLOAT_EQ(expected_contents_scale, | 4901 EXPECT_FLOAT_EQ(expected_contents_scale, |
4933 pending_layer_ptr->picture_layer_tiling_set() | 4902 pending_layer_ptr->picture_layer_tiling_set() |
4934 ->FindTilingWithResolution(HIGH_RESOLUTION) | 4903 ->FindTilingWithResolution(HIGH_RESOLUTION) |
4935 ->contents_scale_key()) | 4904 ->contents_scale()) |
4936 << "ideal_contents_scale: " << ideal_contents_scale; | 4905 << "ideal_contents_scale: " << ideal_contents_scale; |
4937 } | 4906 } |
4938 | 4907 |
4939 expected_contents_scale = 1.f; | 4908 expected_contents_scale = 1.f; |
4940 for (int i = 30; i >= 1; --i) { | 4909 for (int i = 30; i >= 1; --i) { |
4941 float ideal_contents_scale = 0.1f * i - 1e-6; | 4910 float ideal_contents_scale = 0.1f * i - 1e-6; |
4942 switch (i) { | 4911 switch (i) { |
4943 // Scale 0.2. | 4912 // Scale 0.2. |
4944 case 2: | 4913 case 2: |
4945 expected_contents_scale = 0.5f; | 4914 expected_contents_scale = 0.5f; |
4946 break; | 4915 break; |
4947 // Scale 0.1. | 4916 // Scale 0.1. |
4948 case 1: | 4917 case 1: |
4949 expected_contents_scale = 0.25f; | 4918 expected_contents_scale = 0.25f; |
4950 break; | 4919 break; |
4951 } | 4920 } |
4952 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, | 4921 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, |
4953 1.f, 1.f, 1.f, 1.f, false); | 4922 1.f, 1.f, 1.f, 1.f, false); |
4954 EXPECT_FLOAT_EQ(expected_contents_scale, | 4923 EXPECT_FLOAT_EQ(expected_contents_scale, |
4955 pending_layer_ptr->picture_layer_tiling_set() | 4924 pending_layer_ptr->picture_layer_tiling_set() |
4956 ->FindTilingWithResolution(HIGH_RESOLUTION) | 4925 ->FindTilingWithResolution(HIGH_RESOLUTION) |
4957 ->contents_scale_key()) | 4926 ->contents_scale()) |
4958 << "ideal_contents_scale: " << ideal_contents_scale; | 4927 << "ideal_contents_scale: " << ideal_contents_scale; |
4959 } | 4928 } |
4960 } | 4929 } |
4961 | 4930 |
4962 } // namespace | 4931 } // namespace |
4963 } // namespace cc | 4932 } // namespace cc |
OLD | NEW |