Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698