OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 iter; | 147 iter; |
148 ++iter) { | 148 ++iter) { |
149 EXPECT_TRUE(*iter); | 149 EXPECT_TRUE(*iter); |
150 EXPECT_EQ(pile, iter->picture_pile()); | 150 EXPECT_EQ(pile, iter->picture_pile()); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void SetContentsScaleOnBothLayers(float contents_scale, | 154 void SetContentsScaleOnBothLayers(float contents_scale, |
155 float device_scale_factor, | 155 float device_scale_factor, |
156 float page_scale_factor, | 156 float page_scale_factor, |
| 157 float maximum_animation_contents_scale, |
157 bool animating_transform) { | 158 bool animating_transform) { |
158 float result_scale_x, result_scale_y; | 159 float result_scale_x, result_scale_y; |
159 gfx::Size result_bounds; | 160 gfx::Size result_bounds; |
160 pending_layer_->CalculateContentsScale( | 161 pending_layer_->CalculateContentsScale(contents_scale, |
161 contents_scale, | 162 device_scale_factor, |
162 device_scale_factor, | 163 page_scale_factor, |
163 page_scale_factor, | 164 maximum_animation_contents_scale, |
164 animating_transform, | 165 animating_transform, |
165 &result_scale_x, | 166 &result_scale_x, |
166 &result_scale_y, | 167 &result_scale_y, |
167 &result_bounds); | 168 &result_bounds); |
168 active_layer_->CalculateContentsScale( | 169 active_layer_->CalculateContentsScale(contents_scale, |
169 contents_scale, | 170 device_scale_factor, |
170 device_scale_factor, | 171 page_scale_factor, |
171 page_scale_factor, | 172 maximum_animation_contents_scale, |
172 animating_transform, | 173 animating_transform, |
173 &result_scale_x, | 174 &result_scale_x, |
174 &result_scale_y, | 175 &result_scale_y, |
175 &result_bounds); | 176 &result_bounds); |
176 } | 177 } |
177 | 178 |
178 void ResetTilingsAndRasterScales() { | 179 void ResetTilingsAndRasterScales() { |
179 pending_layer_->ReleaseResources(); | 180 pending_layer_->ReleaseResources(); |
180 active_layer_->ReleaseResources(); | 181 active_layer_->ReleaseResources(); |
181 } | 182 } |
182 | 183 |
183 void AssertAllTilesRequired(PictureLayerTiling* tiling) { | 184 void AssertAllTilesRequired(PictureLayerTiling* tiling) { |
184 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 185 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
185 for (size_t i = 0; i < tiles.size(); ++i) | 186 for (size_t i = 0; i < tiles.size(); ++i) |
(...skipping 18 matching lines...) Expand all Loading... |
204 | 205 |
205 scoped_refptr<FakePicturePileImpl> pending_pile = | 206 scoped_refptr<FakePicturePileImpl> pending_pile = |
206 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 207 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
207 scoped_refptr<FakePicturePileImpl> active_pile = | 208 scoped_refptr<FakePicturePileImpl> active_pile = |
208 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 209 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
209 | 210 |
210 SetupTrees(pending_pile, active_pile); | 211 SetupTrees(pending_pile, active_pile); |
211 | 212 |
212 float result_scale_x, result_scale_y; | 213 float result_scale_x, result_scale_y; |
213 gfx::Size result_bounds; | 214 gfx::Size result_bounds; |
214 active_layer_->CalculateContentsScale( | 215 active_layer_->CalculateContentsScale(1.f, |
215 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 216 1.f, |
| 217 1.f, |
| 218 1.f, |
| 219 false, |
| 220 &result_scale_x, |
| 221 &result_scale_y, |
| 222 &result_bounds); |
216 | 223 |
217 // Add 1x1 rects at the centers of each tile, then re-record pile contents | 224 // Add 1x1 rects at the centers of each tile, then re-record pile contents |
218 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 225 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
219 std::vector<Tile*> tiles = | 226 std::vector<Tile*> tiles = |
220 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 227 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
221 EXPECT_EQ(16u, tiles.size()); | 228 EXPECT_EQ(16u, tiles.size()); |
222 std::vector<SkRect> rects; | 229 std::vector<SkRect> rects; |
223 std::vector<Tile*>::const_iterator tile_iter; | 230 std::vector<Tile*>::const_iterator tile_iter; |
224 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 231 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
225 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); | 232 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 313 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
307 EXPECT_EQ(0u, paired_layers.size()); | 314 EXPECT_EQ(0u, paired_layers.size()); |
308 | 315 |
309 // Update tile priorities will force the layer to register itself. | 316 // Update tile priorities will force the layer to register itself. |
310 float dummy_contents_scale_x; | 317 float dummy_contents_scale_x; |
311 float dummy_contents_scale_y; | 318 float dummy_contents_scale_y; |
312 gfx::Size dummy_content_bounds; | 319 gfx::Size dummy_content_bounds; |
313 active_layer_->CalculateContentsScale(1.f, | 320 active_layer_->CalculateContentsScale(1.f, |
314 1.f, | 321 1.f, |
315 1.f, | 322 1.f, |
| 323 1.f, |
316 false, | 324 false, |
317 &dummy_contents_scale_x, | 325 &dummy_contents_scale_x, |
318 &dummy_contents_scale_y, | 326 &dummy_contents_scale_y, |
319 &dummy_content_bounds); | 327 &dummy_content_bounds); |
320 active_layer_->UpdateTilePriorities(); | 328 active_layer_->UpdateTilePriorities(); |
321 host_impl_.pending_tree()->UpdateDrawProperties(); | 329 host_impl_.pending_tree()->UpdateDrawProperties(); |
322 pending_layer_->CalculateContentsScale(1.f, | 330 pending_layer_->CalculateContentsScale(1.f, |
323 1.f, | 331 1.f, |
324 1.f, | 332 1.f, |
| 333 1.f, |
325 false, | 334 false, |
326 &dummy_contents_scale_x, | 335 &dummy_contents_scale_x, |
327 &dummy_contents_scale_y, | 336 &dummy_contents_scale_y, |
328 &dummy_content_bounds); | 337 &dummy_content_bounds); |
329 pending_layer_->UpdateTilePriorities(); | 338 pending_layer_->UpdateTilePriorities(); |
330 | 339 |
331 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 340 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
332 EXPECT_EQ(1u, paired_layers.size()); | 341 EXPECT_EQ(1u, paired_layers.size()); |
333 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | 342 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); |
334 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | 343 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); |
335 | 344 |
336 // Destroy and recreate tile manager. | 345 // Destroy and recreate tile manager. |
337 host_impl_.DidLoseOutputSurface(); | 346 host_impl_.DidLoseOutputSurface(); |
338 scoped_ptr<TestWebGraphicsContext3D> context = | 347 scoped_ptr<TestWebGraphicsContext3D> context = |
339 TestWebGraphicsContext3D::Create(); | 348 TestWebGraphicsContext3D::Create(); |
340 host_impl_.InitializeRenderer( | 349 host_impl_.InitializeRenderer( |
341 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); | 350 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); |
342 | 351 |
343 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 352 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
344 EXPECT_EQ(0u, paired_layers.size()); | 353 EXPECT_EQ(0u, paired_layers.size()); |
345 | 354 |
346 active_layer_->CalculateContentsScale(1.f, | 355 active_layer_->CalculateContentsScale(1.f, |
347 1.f, | 356 1.f, |
348 1.f, | 357 1.f, |
| 358 1.f, |
349 false, | 359 false, |
350 &dummy_contents_scale_x, | 360 &dummy_contents_scale_x, |
351 &dummy_contents_scale_y, | 361 &dummy_contents_scale_y, |
352 &dummy_content_bounds); | 362 &dummy_content_bounds); |
353 active_layer_->UpdateTilePriorities(); | 363 active_layer_->UpdateTilePriorities(); |
354 host_impl_.pending_tree()->UpdateDrawProperties(); | 364 host_impl_.pending_tree()->UpdateDrawProperties(); |
355 pending_layer_->CalculateContentsScale(1.f, | 365 pending_layer_->CalculateContentsScale(1.f, |
356 1.f, | 366 1.f, |
357 1.f, | 367 1.f, |
| 368 1.f, |
358 false, | 369 false, |
359 &dummy_contents_scale_x, | 370 &dummy_contents_scale_x, |
360 &dummy_contents_scale_y, | 371 &dummy_contents_scale_y, |
361 &dummy_content_bounds); | 372 &dummy_content_bounds); |
362 pending_layer_->UpdateTilePriorities(); | 373 pending_layer_->UpdateTilePriorities(); |
363 | 374 |
364 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 375 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
365 EXPECT_EQ(1u, paired_layers.size()); | 376 EXPECT_EQ(1u, paired_layers.size()); |
366 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | 377 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); |
367 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | 378 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); |
(...skipping 14 matching lines...) Expand all Loading... |
382 SetupTrees(pending_pile, active_pile); | 393 SetupTrees(pending_pile, active_pile); |
383 | 394 |
384 Region invalidation; | 395 Region invalidation; |
385 AddDefaultTilingsWithInvalidation(invalidation); | 396 AddDefaultTilingsWithInvalidation(invalidation); |
386 float dummy_contents_scale_x; | 397 float dummy_contents_scale_x; |
387 float dummy_contents_scale_y; | 398 float dummy_contents_scale_y; |
388 gfx::Size dummy_content_bounds; | 399 gfx::Size dummy_content_bounds; |
389 active_layer_->CalculateContentsScale(1.f, | 400 active_layer_->CalculateContentsScale(1.f, |
390 1.f, | 401 1.f, |
391 1.f, | 402 1.f, |
| 403 1.f, |
392 false, | 404 false, |
393 &dummy_contents_scale_x, | 405 &dummy_contents_scale_x, |
394 &dummy_contents_scale_y, | 406 &dummy_contents_scale_y, |
395 &dummy_content_bounds); | 407 &dummy_content_bounds); |
396 | 408 |
397 EXPECT_TRUE(host_impl_.manage_tiles_needed()); | 409 EXPECT_TRUE(host_impl_.manage_tiles_needed()); |
398 active_layer_->UpdateTilePriorities(); | 410 active_layer_->UpdateTilePriorities(); |
399 host_impl_.ManageTiles(); | 411 host_impl_.ManageTiles(); |
400 EXPECT_FALSE(host_impl_.manage_tiles_needed()); | 412 EXPECT_FALSE(host_impl_.manage_tiles_needed()); |
401 | 413 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 scoped_refptr<FakePicturePileImpl> pending_pile = | 606 scoped_refptr<FakePicturePileImpl> pending_pile = |
595 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 607 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
596 scoped_refptr<FakePicturePileImpl> active_pile = | 608 scoped_refptr<FakePicturePileImpl> active_pile = |
597 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 609 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
598 | 610 |
599 float result_scale_x, result_scale_y; | 611 float result_scale_x, result_scale_y; |
600 gfx::Size result_bounds; | 612 gfx::Size result_bounds; |
601 | 613 |
602 SetupTrees(pending_pile, active_pile); | 614 SetupTrees(pending_pile, active_pile); |
603 | 615 |
604 pending_layer_->CalculateContentsScale( | 616 pending_layer_->CalculateContentsScale(1.f, |
605 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 617 1.f, |
| 618 1.f, |
| 619 1.f, |
| 620 false, |
| 621 &result_scale_x, |
| 622 &result_scale_y, |
| 623 &result_bounds); |
606 | 624 |
607 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 625 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
608 } | 626 } |
609 | 627 |
610 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { | 628 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
611 gfx::Size tile_size(400, 400); | 629 gfx::Size tile_size(400, 400); |
612 gfx::Size layer_bounds(1300, 1900); | 630 gfx::Size layer_bounds(1300, 1900); |
613 | 631 |
614 scoped_refptr<FakePicturePileImpl> pending_pile = | 632 scoped_refptr<FakePicturePileImpl> pending_pile = |
615 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 633 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
616 scoped_refptr<FakePicturePileImpl> active_pile = | 634 scoped_refptr<FakePicturePileImpl> active_pile = |
617 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 635 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
618 | 636 |
619 float result_scale_x, result_scale_y; | 637 float result_scale_x, result_scale_y; |
620 gfx::Size result_bounds; | 638 gfx::Size result_bounds; |
621 | 639 |
622 SetupTrees(pending_pile, active_pile); | 640 SetupTrees(pending_pile, active_pile); |
623 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 641 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
624 | 642 |
625 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 643 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
626 EXPECT_LT(low_res_factor, 1.f); | 644 EXPECT_LT(low_res_factor, 1.f); |
627 | 645 |
628 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 646 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
629 1.7f, // device scale | 647 1.7f, // device scale |
630 3.2f, // page cale | 648 3.2f, // page scale |
| 649 1.f, // maximum animation scale |
631 false, | 650 false, |
632 &result_scale_x, | 651 &result_scale_x, |
633 &result_scale_y, | 652 &result_scale_y, |
634 &result_bounds); | 653 &result_bounds); |
635 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 654 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
636 EXPECT_FLOAT_EQ( | 655 EXPECT_FLOAT_EQ( |
637 1.3f, | 656 1.3f, |
638 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 657 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
639 EXPECT_FLOAT_EQ( | 658 EXPECT_FLOAT_EQ( |
640 1.3f * low_res_factor, | 659 1.3f * low_res_factor, |
641 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 660 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
642 | 661 |
643 // If we change the layer's CSS scale factor, then we should not get new | 662 // If we change the layer's CSS scale factor, then we should not get new |
644 // tilings. | 663 // tilings. |
645 pending_layer_->CalculateContentsScale(1.8f, // ideal contents scale | 664 pending_layer_->CalculateContentsScale(1.8f, // ideal contents scale |
646 1.7f, // device scale | 665 1.7f, // device scale |
647 3.2f, // page cale | 666 3.2f, // page scale |
| 667 1.f, // maximum animation scale |
648 false, | 668 false, |
649 &result_scale_x, | 669 &result_scale_x, |
650 &result_scale_y, | 670 &result_scale_y, |
651 &result_bounds); | 671 &result_bounds); |
652 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 672 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
653 EXPECT_FLOAT_EQ( | 673 EXPECT_FLOAT_EQ( |
654 1.3f, | 674 1.3f, |
655 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 675 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
656 EXPECT_FLOAT_EQ( | 676 EXPECT_FLOAT_EQ( |
657 1.3f * low_res_factor, | 677 1.3f * low_res_factor, |
658 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 678 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
659 | 679 |
660 // If we change the page scale factor, then we should get new tilings. | 680 // If we change the page scale factor, then we should get new tilings. |
661 pending_layer_->CalculateContentsScale(1.8f, // ideal contents scale | 681 pending_layer_->CalculateContentsScale(1.8f, // ideal contents scale |
662 1.7f, // device scale | 682 1.7f, // device scale |
663 2.2f, // page cale | 683 2.2f, // page scale |
| 684 1.f, // maximum animation scale |
664 false, | 685 false, |
665 &result_scale_x, | 686 &result_scale_x, |
666 &result_scale_y, | 687 &result_scale_y, |
667 &result_bounds); | 688 &result_bounds); |
668 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); | 689 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); |
669 EXPECT_FLOAT_EQ( | 690 EXPECT_FLOAT_EQ( |
670 1.8f, | 691 1.8f, |
671 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 692 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
672 EXPECT_FLOAT_EQ( | 693 EXPECT_FLOAT_EQ( |
673 1.8f * low_res_factor, | 694 1.8f * low_res_factor, |
674 pending_layer_->tilings()->tiling_at(2)->contents_scale()); | 695 pending_layer_->tilings()->tiling_at(2)->contents_scale()); |
675 | 696 |
676 // If we change the device scale factor, then we should get new tilings. | 697 // If we change the device scale factor, then we should get new tilings. |
677 pending_layer_->CalculateContentsScale(1.9f, // ideal contents scale | 698 pending_layer_->CalculateContentsScale(1.9f, // ideal contents scale |
678 1.4f, // device scale | 699 1.4f, // device scale |
679 2.2f, // page cale | 700 2.2f, // page scale |
| 701 1.f, // maximum animation scale |
680 false, | 702 false, |
681 &result_scale_x, | 703 &result_scale_x, |
682 &result_scale_y, | 704 &result_scale_y, |
683 &result_bounds); | 705 &result_bounds); |
684 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 706 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
685 EXPECT_FLOAT_EQ( | 707 EXPECT_FLOAT_EQ( |
686 1.9f, | 708 1.9f, |
687 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 709 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
688 EXPECT_FLOAT_EQ( | 710 EXPECT_FLOAT_EQ( |
689 1.9f * low_res_factor, | 711 1.9f * low_res_factor, |
690 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 712 pending_layer_->tilings()->tiling_at(3)->contents_scale()); |
691 | 713 |
692 // If we change the device scale factor, but end up at the same total scale | 714 // If we change the device scale factor, but end up at the same total scale |
693 // factor somehow, then we don't get new tilings. | 715 // factor somehow, then we don't get new tilings. |
694 pending_layer_->CalculateContentsScale(1.9f, // ideal contents scale | 716 pending_layer_->CalculateContentsScale(1.9f, // ideal contents scale |
695 2.2f, // device scale | 717 2.2f, // device scale |
696 1.4f, // page cale | 718 1.4f, // page scale |
| 719 1.f, // maximum animation scale |
697 false, | 720 false, |
698 &result_scale_x, | 721 &result_scale_x, |
699 &result_scale_y, | 722 &result_scale_y, |
700 &result_bounds); | 723 &result_bounds); |
701 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 724 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
702 EXPECT_FLOAT_EQ( | 725 EXPECT_FLOAT_EQ( |
703 1.9f, | 726 1.9f, |
704 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 727 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
705 EXPECT_FLOAT_EQ( | 728 EXPECT_FLOAT_EQ( |
706 1.9f * low_res_factor, | 729 1.9f * low_res_factor, |
(...skipping 12 matching lines...) Expand all Loading... |
719 scoped_refptr<FakePicturePileImpl> valid_pile = | 742 scoped_refptr<FakePicturePileImpl> valid_pile = |
720 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 743 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
721 | 744 |
722 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 745 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
723 EXPECT_LT(low_res_factor, 1.f); | 746 EXPECT_LT(low_res_factor, 1.f); |
724 | 747 |
725 float high_res_scale = 1.3f; | 748 float high_res_scale = 1.3f; |
726 float low_res_scale = high_res_scale * low_res_factor; | 749 float low_res_scale = high_res_scale * low_res_factor; |
727 float device_scale = 1.7f; | 750 float device_scale = 1.7f; |
728 float page_scale = 3.2f; | 751 float page_scale = 3.2f; |
| 752 float maximum_animation_scale = 1.f; |
729 float result_scale_x, result_scale_y; | 753 float result_scale_x, result_scale_y; |
730 gfx::Size result_bounds; | 754 gfx::Size result_bounds; |
731 | 755 |
732 SetupPendingTree(valid_pile); | 756 SetupPendingTree(valid_pile); |
733 pending_layer_->CalculateContentsScale(high_res_scale, | 757 pending_layer_->CalculateContentsScale(high_res_scale, |
734 device_scale, | 758 device_scale, |
735 page_scale, | 759 page_scale, |
| 760 maximum_animation_scale, |
736 false, | 761 false, |
737 &result_scale_x, | 762 &result_scale_x, |
738 &result_scale_y, | 763 &result_scale_y, |
739 &result_bounds); | 764 &result_bounds); |
740 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 765 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
741 EXPECT_FLOAT_EQ(high_res_scale, | 766 EXPECT_FLOAT_EQ(high_res_scale, |
742 pending_layer_->HighResTiling()->contents_scale()); | 767 pending_layer_->HighResTiling()->contents_scale()); |
743 EXPECT_FLOAT_EQ(low_res_scale, | 768 EXPECT_FLOAT_EQ(low_res_scale, |
744 pending_layer_->LowResTiling()->contents_scale()); | 769 pending_layer_->LowResTiling()->contents_scale()); |
745 | 770 |
746 ActivateTree(); | 771 ActivateTree(); |
747 SetupPendingTree(empty_pile); | 772 SetupPendingTree(empty_pile); |
748 pending_layer_->CalculateContentsScale(high_res_scale, | 773 pending_layer_->CalculateContentsScale(high_res_scale, |
749 device_scale, | 774 device_scale, |
750 page_scale, | 775 page_scale, |
| 776 maximum_animation_scale, |
751 false, | 777 false, |
752 &result_scale_x, | 778 &result_scale_x, |
753 &result_scale_y, | 779 &result_scale_y, |
754 &result_bounds); | 780 &result_bounds); |
755 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 781 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
756 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 782 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
757 | 783 |
758 ActivateTree(); | 784 ActivateTree(); |
759 active_layer_->CalculateContentsScale(high_res_scale, | 785 active_layer_->CalculateContentsScale(high_res_scale, |
760 device_scale, | 786 device_scale, |
761 page_scale, | 787 page_scale, |
| 788 maximum_animation_scale, |
762 false, | 789 false, |
763 &result_scale_x, | 790 &result_scale_x, |
764 &result_scale_y, | 791 &result_scale_y, |
765 &result_bounds); | 792 &result_bounds); |
766 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 793 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
767 | 794 |
768 SetupPendingTree(valid_pile); | 795 SetupPendingTree(valid_pile); |
769 pending_layer_->CalculateContentsScale(high_res_scale, | 796 pending_layer_->CalculateContentsScale(high_res_scale, |
770 device_scale, | 797 device_scale, |
771 page_scale, | 798 page_scale, |
| 799 maximum_animation_scale, |
772 false, | 800 false, |
773 &result_scale_x, | 801 &result_scale_x, |
774 &result_scale_y, | 802 &result_scale_y, |
775 &result_bounds); | 803 &result_bounds); |
776 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 804 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
777 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 805 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
778 EXPECT_FLOAT_EQ(high_res_scale, | 806 EXPECT_FLOAT_EQ(high_res_scale, |
779 pending_layer_->HighResTiling()->contents_scale()); | 807 pending_layer_->HighResTiling()->contents_scale()); |
780 EXPECT_FLOAT_EQ(low_res_scale, | 808 EXPECT_FLOAT_EQ(low_res_scale, |
781 pending_layer_->LowResTiling()->contents_scale()); | 809 pending_layer_->LowResTiling()->contents_scale()); |
782 } | 810 } |
783 | 811 |
784 TEST_F(PictureLayerImplTest, ZoomOutCrash) { | 812 TEST_F(PictureLayerImplTest, ZoomOutCrash) { |
785 gfx::Size tile_size(400, 400); | 813 gfx::Size tile_size(400, 400); |
786 gfx::Size layer_bounds(1300, 1900); | 814 gfx::Size layer_bounds(1300, 1900); |
787 | 815 |
788 // Set up the high and low res tilings before pinch zoom. | 816 // Set up the high and low res tilings before pinch zoom. |
789 scoped_refptr<FakePicturePileImpl> pending_pile = | 817 scoped_refptr<FakePicturePileImpl> pending_pile = |
790 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 818 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
791 scoped_refptr<FakePicturePileImpl> active_pile = | 819 scoped_refptr<FakePicturePileImpl> active_pile = |
792 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 820 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
793 | 821 |
794 SetupTrees(pending_pile, active_pile); | 822 SetupTrees(pending_pile, active_pile); |
795 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 823 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
796 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, false); | 824 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, false); |
797 host_impl_.PinchGestureBegin(); | 825 host_impl_.PinchGestureBegin(); |
798 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false); | 826 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); |
799 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false); | 827 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); |
800 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); | 828 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); |
801 } | 829 } |
802 | 830 |
803 TEST_F(PictureLayerImplTest, PinchGestureTilings) { | 831 TEST_F(PictureLayerImplTest, PinchGestureTilings) { |
804 gfx::Size tile_size(400, 400); | 832 gfx::Size tile_size(400, 400); |
805 gfx::Size layer_bounds(1300, 1900); | 833 gfx::Size layer_bounds(1300, 1900); |
806 | 834 |
807 scoped_refptr<FakePicturePileImpl> pending_pile = | 835 scoped_refptr<FakePicturePileImpl> pending_pile = |
808 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 836 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
809 scoped_refptr<FakePicturePileImpl> active_pile = | 837 scoped_refptr<FakePicturePileImpl> active_pile = |
810 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 838 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
811 | 839 |
812 // Set up the high and low res tilings before pinch zoom. | 840 // Set up the high and low res tilings before pinch zoom. |
813 SetupTrees(pending_pile, active_pile); | 841 SetupTrees(pending_pile, active_pile); |
814 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 842 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
815 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false); | 843 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); |
816 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 844 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
817 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 845 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
818 EXPECT_FLOAT_EQ( | 846 EXPECT_FLOAT_EQ( |
819 1.0f, | 847 1.0f, |
820 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 848 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
821 EXPECT_FLOAT_EQ( | 849 EXPECT_FLOAT_EQ( |
822 1.0f * low_res_factor, | 850 1.0f * low_res_factor, |
823 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 851 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
824 | 852 |
825 // Start a pinch gesture. | 853 // Start a pinch gesture. |
826 host_impl_.PinchGestureBegin(); | 854 host_impl_.PinchGestureBegin(); |
827 | 855 |
828 // Zoom out by a small amount. We should create a tiling at half | 856 // Zoom out by a small amount. We should create a tiling at half |
829 // the scale (1/kMaxScaleRatioDuringPinch). | 857 // the scale (1/kMaxScaleRatioDuringPinch). |
830 SetContentsScaleOnBothLayers(0.90f, 1.0f, 0.9f, false); | 858 SetContentsScaleOnBothLayers(0.90f, 1.0f, 0.9f, 1.0f, false); |
831 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 859 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
832 EXPECT_FLOAT_EQ( | 860 EXPECT_FLOAT_EQ( |
833 1.0f, | 861 1.0f, |
834 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 862 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
835 EXPECT_FLOAT_EQ( | 863 EXPECT_FLOAT_EQ( |
836 0.5f, | 864 0.5f, |
837 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 865 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
838 EXPECT_FLOAT_EQ( | 866 EXPECT_FLOAT_EQ( |
839 1.0f * low_res_factor, | 867 1.0f * low_res_factor, |
840 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 868 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
841 | 869 |
842 // Zoom out further, close to our low-res scale factor. We should | 870 // Zoom out further, close to our low-res scale factor. We should |
843 // use that tiling as high-res, and not create a new tiling. | 871 // use that tiling as high-res, and not create a new tiling. |
844 SetContentsScaleOnBothLayers(low_res_factor, 1.0f, low_res_factor, false); | 872 SetContentsScaleOnBothLayers( |
| 873 low_res_factor, 1.0f, low_res_factor, 1.0f, false); |
845 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 874 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
846 | 875 |
847 // Zoom in a lot now. Since we increase by increments of | 876 // Zoom in a lot now. Since we increase by increments of |
848 // kMaxScaleRatioDuringPinch, this will first use 0.5, then 1.0 | 877 // kMaxScaleRatioDuringPinch, this will first use 0.5, then 1.0 |
849 // and then finally create a new tiling at 2.0. | 878 // and then finally create a new tiling at 2.0. |
850 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false); | 879 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, 1.f, false); |
851 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 880 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
852 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false); | 881 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, 1.f, false); |
853 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 882 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
854 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false); | 883 SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, 1.f, false); |
855 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); | 884 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
856 EXPECT_FLOAT_EQ( | 885 EXPECT_FLOAT_EQ( |
857 2.0f, | 886 2.0f, |
858 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 887 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
859 } | 888 } |
860 | 889 |
861 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 890 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
862 gfx::Size tile_size(400, 400); | 891 gfx::Size tile_size(400, 400); |
863 gfx::Size layer_bounds(1300, 1900); | 892 gfx::Size layer_bounds(1300, 1900); |
864 | 893 |
865 scoped_refptr<FakePicturePileImpl> pending_pile = | 894 scoped_refptr<FakePicturePileImpl> pending_pile = |
866 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 895 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
867 scoped_refptr<FakePicturePileImpl> active_pile = | 896 scoped_refptr<FakePicturePileImpl> active_pile = |
868 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 897 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
869 | 898 |
870 float result_scale_x, result_scale_y; | 899 float result_scale_x, result_scale_y; |
871 gfx::Size result_bounds; | 900 gfx::Size result_bounds; |
872 std::vector<PictureLayerTiling*> used_tilings; | 901 std::vector<PictureLayerTiling*> used_tilings; |
873 | 902 |
874 SetupTrees(pending_pile, active_pile); | 903 SetupTrees(pending_pile, active_pile); |
875 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 904 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
876 | 905 |
877 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 906 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
878 EXPECT_LT(low_res_factor, 1.f); | 907 EXPECT_LT(low_res_factor, 1.f); |
879 | 908 |
880 float device_scale = 1.7f; | 909 float device_scale = 1.7f; |
881 float page_scale = 3.2f; | 910 float page_scale = 3.2f; |
882 | 911 |
883 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, false); | 912 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); |
884 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 913 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
885 | 914 |
886 // We only have ideal tilings, so they aren't removed. | 915 // We only have ideal tilings, so they aren't removed. |
887 used_tilings.clear(); | 916 used_tilings.clear(); |
888 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 917 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
889 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 918 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
890 | 919 |
891 // Changing the ideal but not creating new tilings. | 920 // Changing the ideal but not creating new tilings. |
892 SetContentsScaleOnBothLayers(1.5f, device_scale, page_scale, false); | 921 SetContentsScaleOnBothLayers(1.5f, device_scale, page_scale, 1.f, false); |
893 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 922 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
894 | 923 |
895 // The tilings are still our target scale, so they aren't removed. | 924 // The tilings are still our target scale, so they aren't removed. |
896 used_tilings.clear(); | 925 used_tilings.clear(); |
897 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 926 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
898 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 927 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
899 | 928 |
900 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 929 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
901 page_scale = 1.2f; | 930 page_scale = 1.2f; |
902 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, false); | 931 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, false); |
903 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 932 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
904 EXPECT_FLOAT_EQ( | 933 EXPECT_FLOAT_EQ( |
905 1.f, | 934 1.f, |
906 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 935 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
907 EXPECT_FLOAT_EQ( | 936 EXPECT_FLOAT_EQ( |
908 1.f * low_res_factor, | 937 1.f * low_res_factor, |
909 active_layer_->tilings()->tiling_at(3)->contents_scale()); | 938 active_layer_->tilings()->tiling_at(3)->contents_scale()); |
910 | 939 |
911 // Mark the non-ideal tilings as used. They won't be removed. | 940 // Mark the non-ideal tilings as used. They won't be removed. |
912 used_tilings.clear(); | 941 used_tilings.clear(); |
913 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 942 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
914 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); | 943 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); |
915 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 944 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
916 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 945 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
917 | 946 |
918 // Now move the ideal scale to 0.5. Our target stays 1.2. | 947 // Now move the ideal scale to 0.5. Our target stays 1.2. |
919 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, false); | 948 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, false); |
920 | 949 |
921 // The high resolution tiling is between target and ideal, so is not | 950 // The high resolution tiling is between target and ideal, so is not |
922 // removed. The low res tiling for the old ideal=1.0 scale is removed. | 951 // removed. The low res tiling for the old ideal=1.0 scale is removed. |
923 used_tilings.clear(); | 952 used_tilings.clear(); |
924 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 953 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
925 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 954 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
926 | 955 |
927 // Now move the ideal scale to 1.0. Our target stays 1.2. | 956 // Now move the ideal scale to 1.0. Our target stays 1.2. |
928 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, false); | 957 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); |
929 | 958 |
930 // All the tilings are between are target and the ideal, so they are not | 959 // All the tilings are between are target and the ideal, so they are not |
931 // removed. | 960 // removed. |
932 used_tilings.clear(); | 961 used_tilings.clear(); |
933 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 962 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
934 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 963 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
935 | 964 |
936 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 965 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
937 active_layer_->CalculateContentsScale(1.1f, | 966 active_layer_->CalculateContentsScale(1.1f, |
938 device_scale, | 967 device_scale, |
939 page_scale, | 968 page_scale, |
| 969 1.f, |
940 false, | 970 false, |
941 &result_scale_x, | 971 &result_scale_x, |
942 &result_scale_y, | 972 &result_scale_y, |
943 &result_bounds); | 973 &result_bounds); |
944 | 974 |
945 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 975 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
946 // in the range [1.0,1.2] and are kept. | 976 // in the range [1.0,1.2] and are kept. |
947 used_tilings.clear(); | 977 used_tilings.clear(); |
948 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 978 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
949 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 979 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
950 | 980 |
951 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 981 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
952 // 1.2 still. | 982 // 1.2 still. |
953 pending_layer_->CalculateContentsScale(1.1f, | 983 pending_layer_->CalculateContentsScale(1.1f, |
954 device_scale, | 984 device_scale, |
955 page_scale, | 985 page_scale, |
| 986 1.f, |
956 false, | 987 false, |
957 &result_scale_x, | 988 &result_scale_x, |
958 &result_scale_y, | 989 &result_scale_y, |
959 &result_bounds); | 990 &result_bounds); |
960 | 991 |
961 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 992 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
962 // target raster scale. But it is in our used tilings set, so nothing is | 993 // target raster scale. But it is in our used tilings set, so nothing is |
963 // deleted. | 994 // deleted. |
964 used_tilings.clear(); | 995 used_tilings.clear(); |
965 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 996 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
(...skipping 19 matching lines...) Expand all Loading... |
985 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 1016 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
986 SetupDefaultTrees(gfx::Size(tile_size.width() + 1, tile_size.height() + 1)); | 1017 SetupDefaultTrees(gfx::Size(tile_size.width() + 1, tile_size.height() + 1)); |
987 // Avoid max untiled layer size heuristics via fixed tile size. | 1018 // Avoid max untiled layer size heuristics via fixed tile size. |
988 pending_layer_->set_fixed_tile_size(tile_size); | 1019 pending_layer_->set_fixed_tile_size(tile_size); |
989 active_layer_->set_fixed_tile_size(tile_size); | 1020 active_layer_->set_fixed_tile_size(tile_size); |
990 | 1021 |
991 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 1022 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
992 float contents_scale = 1.f; | 1023 float contents_scale = 1.f; |
993 float device_scale = 1.f; | 1024 float device_scale = 1.f; |
994 float page_scale = 1.f; | 1025 float page_scale = 1.f; |
| 1026 float maximum_animation_scale = 1.f; |
995 bool animating_transform = true; | 1027 bool animating_transform = true; |
996 | 1028 |
997 // Animating, so don't create low res even if there isn't one already. | 1029 // Animating, so don't create low res even if there isn't one already. |
998 SetContentsScaleOnBothLayers( | 1030 SetContentsScaleOnBothLayers(contents_scale, |
999 contents_scale, device_scale, page_scale, animating_transform); | 1031 device_scale, |
| 1032 page_scale, |
| 1033 maximum_animation_scale, |
| 1034 animating_transform); |
1000 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1035 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1001 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1036 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1002 | 1037 |
1003 // Stop animating, low res gets created. | 1038 // Stop animating, low res gets created. |
1004 animating_transform = false; | 1039 animating_transform = false; |
1005 SetContentsScaleOnBothLayers( | 1040 SetContentsScaleOnBothLayers(contents_scale, |
1006 contents_scale, device_scale, page_scale, animating_transform); | 1041 device_scale, |
| 1042 page_scale, |
| 1043 maximum_animation_scale, |
| 1044 animating_transform); |
1007 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1045 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1008 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); | 1046 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
1009 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1047 EXPECT_BOTH_EQ(num_tilings(), 2u); |
1010 | 1048 |
1011 // Page scale animation, new high res, but not new low res because animating. | 1049 // Page scale animation, new high res, but not new low res because animating. |
1012 contents_scale = 2.f; | 1050 contents_scale = 2.f; |
1013 page_scale = 2.f; | 1051 page_scale = 2.f; |
1014 animating_transform = true; | 1052 animating_transform = true; |
1015 SetContentsScaleOnBothLayers( | 1053 SetContentsScaleOnBothLayers(contents_scale, |
1016 contents_scale, device_scale, page_scale, animating_transform); | 1054 device_scale, |
| 1055 page_scale, |
| 1056 maximum_animation_scale, |
| 1057 animating_transform); |
1017 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1058 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1018 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); | 1059 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
1019 EXPECT_BOTH_EQ(num_tilings(), 3u); | 1060 EXPECT_BOTH_EQ(num_tilings(), 3u); |
1020 | 1061 |
1021 // Stop animating, new low res gets created for final page scale. | 1062 // Stop animating, new low res gets created for final page scale. |
1022 animating_transform = false; | 1063 animating_transform = false; |
1023 SetContentsScaleOnBothLayers( | 1064 SetContentsScaleOnBothLayers(contents_scale, |
1024 contents_scale, device_scale, page_scale, animating_transform); | 1065 device_scale, |
| 1066 page_scale, |
| 1067 maximum_animation_scale, |
| 1068 animating_transform); |
1025 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1069 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1026 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); | 1070 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); |
1027 EXPECT_BOTH_EQ(num_tilings(), 4u); | 1071 EXPECT_BOTH_EQ(num_tilings(), 4u); |
1028 } | 1072 } |
1029 | 1073 |
1030 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { | 1074 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
1031 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 1075 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
1032 SetupDefaultTrees(tile_size); | 1076 SetupDefaultTrees(tile_size); |
1033 | 1077 |
1034 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 1078 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
1035 float device_scale = 1.f; | 1079 float device_scale = 1.f; |
1036 float page_scale = 1.f; | 1080 float page_scale = 1.f; |
| 1081 float maximum_animation_scale = 1.f; |
1037 bool animating_transform = false; | 1082 bool animating_transform = false; |
1038 | 1083 |
1039 // Contents exactly fit on one tile at scale 1, no low res. | 1084 // Contents exactly fit on one tile at scale 1, no low res. |
1040 float contents_scale = 1.f; | 1085 float contents_scale = 1.f; |
1041 SetContentsScaleOnBothLayers( | 1086 SetContentsScaleOnBothLayers(contents_scale, |
1042 contents_scale, device_scale, page_scale, animating_transform); | 1087 device_scale, |
| 1088 page_scale, |
| 1089 maximum_animation_scale, |
| 1090 animating_transform); |
1043 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1091 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1044 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1092 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1045 | 1093 |
1046 ResetTilingsAndRasterScales(); | 1094 ResetTilingsAndRasterScales(); |
1047 | 1095 |
1048 // Contents that are smaller than one tile, no low res. | 1096 // Contents that are smaller than one tile, no low res. |
1049 contents_scale = 0.123f; | 1097 contents_scale = 0.123f; |
1050 SetContentsScaleOnBothLayers( | 1098 SetContentsScaleOnBothLayers(contents_scale, |
1051 contents_scale, device_scale, page_scale, animating_transform); | 1099 device_scale, |
| 1100 page_scale, |
| 1101 maximum_animation_scale, |
| 1102 animating_transform); |
1052 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1103 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1053 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1104 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1054 | 1105 |
1055 ResetTilingsAndRasterScales(); | 1106 ResetTilingsAndRasterScales(); |
1056 | 1107 |
1057 // Any content bounds that would create more than one tile will | 1108 // Any content bounds that would create more than one tile will |
1058 // generate a low res tiling. | 1109 // generate a low res tiling. |
1059 contents_scale = 2.5f; | 1110 contents_scale = 2.5f; |
1060 SetContentsScaleOnBothLayers( | 1111 SetContentsScaleOnBothLayers(contents_scale, |
1061 contents_scale, device_scale, page_scale, animating_transform); | 1112 device_scale, |
| 1113 page_scale, |
| 1114 maximum_animation_scale, |
| 1115 animating_transform); |
1062 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1116 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1063 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), | 1117 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), |
1064 contents_scale * low_res_factor); | 1118 contents_scale * low_res_factor); |
1065 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1119 EXPECT_BOTH_EQ(num_tilings(), 2u); |
1066 | 1120 |
1067 ResetTilingsAndRasterScales(); | 1121 ResetTilingsAndRasterScales(); |
1068 | 1122 |
1069 // Mask layers dont create low res since they always fit on one tile. | 1123 // Mask layers dont create low res since they always fit on one tile. |
1070 pending_layer_->SetIsMask(true); | 1124 pending_layer_->SetIsMask(true); |
1071 active_layer_->SetIsMask(true); | 1125 active_layer_->SetIsMask(true); |
1072 SetContentsScaleOnBothLayers( | 1126 SetContentsScaleOnBothLayers(contents_scale, |
1073 contents_scale, device_scale, page_scale, animating_transform); | 1127 device_scale, |
| 1128 page_scale, |
| 1129 maximum_animation_scale, |
| 1130 animating_transform); |
1074 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1131 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1075 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1132 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1076 } | 1133 } |
1077 | 1134 |
1078 TEST_F(PictureLayerImplTest, ReleaseResources) { | 1135 TEST_F(PictureLayerImplTest, ReleaseResources) { |
1079 gfx::Size tile_size(400, 400); | 1136 gfx::Size tile_size(400, 400); |
1080 gfx::Size layer_bounds(1300, 1900); | 1137 gfx::Size layer_bounds(1300, 1900); |
1081 | 1138 |
1082 scoped_refptr<FakePicturePileImpl> pending_pile = | 1139 scoped_refptr<FakePicturePileImpl> pending_pile = |
1083 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1140 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1084 scoped_refptr<FakePicturePileImpl> active_pile = | 1141 scoped_refptr<FakePicturePileImpl> active_pile = |
1085 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1142 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1086 | 1143 |
1087 float result_scale_x, result_scale_y; | 1144 float result_scale_x, result_scale_y; |
1088 gfx::Size result_bounds; | 1145 gfx::Size result_bounds; |
1089 | 1146 |
1090 SetupTrees(pending_pile, active_pile); | 1147 SetupTrees(pending_pile, active_pile); |
1091 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1148 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1092 | 1149 |
1093 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 1150 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
1094 2.7f, // device scale | 1151 2.7f, // device scale |
1095 3.2f, // page cale | 1152 3.2f, // page scale |
| 1153 1.f, // maximum animation scale |
1096 false, | 1154 false, |
1097 &result_scale_x, | 1155 &result_scale_x, |
1098 &result_scale_y, | 1156 &result_scale_y, |
1099 &result_bounds); | 1157 &result_bounds); |
1100 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1158 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1101 | 1159 |
1102 // All tilings should be removed when losing output surface. | 1160 // All tilings should be removed when losing output surface. |
1103 active_layer_->ReleaseResources(); | 1161 active_layer_->ReleaseResources(); |
1104 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1162 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
1105 pending_layer_->ReleaseResources(); | 1163 pending_layer_->ReleaseResources(); |
1106 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1164 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1107 | 1165 |
1108 // This should create new tilings. | 1166 // This should create new tilings. |
1109 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 1167 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
1110 2.7f, // device scale | 1168 2.7f, // device scale |
1111 3.2f, // page cale | 1169 3.2f, // page scale |
| 1170 1.f, // maximum animation scale |
1112 false, | 1171 false, |
1113 &result_scale_x, | 1172 &result_scale_x, |
1114 &result_scale_y, | 1173 &result_scale_y, |
1115 &result_bounds); | 1174 &result_bounds); |
1116 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1175 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1117 } | 1176 } |
1118 | 1177 |
1119 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { | 1178 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
1120 // The default max tile size is larger than 400x400. | 1179 // The default max tile size is larger than 400x400. |
1121 gfx::Size tile_size(400, 400); | 1180 gfx::Size tile_size(400, 400); |
1122 gfx::Size layer_bounds(5000, 5000); | 1181 gfx::Size layer_bounds(5000, 5000); |
1123 | 1182 |
1124 scoped_refptr<FakePicturePileImpl> pending_pile = | 1183 scoped_refptr<FakePicturePileImpl> pending_pile = |
1125 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1184 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1126 scoped_refptr<FakePicturePileImpl> active_pile = | 1185 scoped_refptr<FakePicturePileImpl> active_pile = |
1127 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1186 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1128 | 1187 |
1129 float result_scale_x, result_scale_y; | 1188 float result_scale_x, result_scale_y; |
1130 gfx::Size result_bounds; | 1189 gfx::Size result_bounds; |
1131 | 1190 |
1132 SetupTrees(pending_pile, active_pile); | 1191 SetupTrees(pending_pile, active_pile); |
1133 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1192 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1134 | 1193 |
1135 pending_layer_->CalculateContentsScale( | 1194 pending_layer_->CalculateContentsScale(1.f, |
1136 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1195 1.f, |
| 1196 1.f, |
| 1197 1.f, |
| 1198 false, |
| 1199 &result_scale_x, |
| 1200 &result_scale_y, |
| 1201 &result_bounds); |
1137 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1202 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1138 | 1203 |
1139 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1204 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1140 | 1205 |
1141 // The default value. | 1206 // The default value. |
1142 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1207 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
1143 host_impl_.settings().default_tile_size.ToString()); | 1208 host_impl_.settings().default_tile_size.ToString()); |
1144 | 1209 |
1145 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1210 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
1146 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1211 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
1147 tile->content_rect().size().ToString()); | 1212 tile->content_rect().size().ToString()); |
1148 | 1213 |
1149 pending_layer_->ReleaseResources(); | 1214 pending_layer_->ReleaseResources(); |
1150 | 1215 |
1151 // Change the max texture size on the output surface context. | 1216 // Change the max texture size on the output surface context. |
1152 scoped_ptr<TestWebGraphicsContext3D> context = | 1217 scoped_ptr<TestWebGraphicsContext3D> context = |
1153 TestWebGraphicsContext3D::Create(); | 1218 TestWebGraphicsContext3D::Create(); |
1154 context->set_max_texture_size(140); | 1219 context->set_max_texture_size(140); |
1155 host_impl_.DidLoseOutputSurface(); | 1220 host_impl_.DidLoseOutputSurface(); |
1156 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1221 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
1157 context.Pass()).PassAs<OutputSurface>()); | 1222 context.Pass()).PassAs<OutputSurface>()); |
1158 | 1223 |
1159 pending_layer_->CalculateContentsScale( | 1224 pending_layer_->CalculateContentsScale(1.f, |
1160 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1225 1.f, |
| 1226 1.f, |
| 1227 1.f, |
| 1228 false, |
| 1229 &result_scale_x, |
| 1230 &result_scale_y, |
| 1231 &result_bounds); |
1161 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1232 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1162 | 1233 |
1163 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1234 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1164 | 1235 |
1165 // Verify the tiles are not larger than the context's max texture size. | 1236 // Verify the tiles are not larger than the context's max texture size. |
1166 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1237 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
1167 EXPECT_GE(140, tile->content_rect().width()); | 1238 EXPECT_GE(140, tile->content_rect().width()); |
1168 EXPECT_GE(140, tile->content_rect().height()); | 1239 EXPECT_GE(140, tile->content_rect().height()); |
1169 } | 1240 } |
1170 | 1241 |
1171 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { | 1242 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { |
1172 // The default max tile size is larger than 400x400. | 1243 // The default max tile size is larger than 400x400. |
1173 gfx::Size tile_size(400, 400); | 1244 gfx::Size tile_size(400, 400); |
1174 gfx::Size layer_bounds(500, 500); | 1245 gfx::Size layer_bounds(500, 500); |
1175 | 1246 |
1176 scoped_refptr<FakePicturePileImpl> pending_pile = | 1247 scoped_refptr<FakePicturePileImpl> pending_pile = |
1177 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1248 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1178 scoped_refptr<FakePicturePileImpl> active_pile = | 1249 scoped_refptr<FakePicturePileImpl> active_pile = |
1179 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1250 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1180 | 1251 |
1181 float result_scale_x, result_scale_y; | 1252 float result_scale_x, result_scale_y; |
1182 gfx::Size result_bounds; | 1253 gfx::Size result_bounds; |
1183 | 1254 |
1184 SetupTrees(pending_pile, active_pile); | 1255 SetupTrees(pending_pile, active_pile); |
1185 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1256 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1186 | 1257 |
1187 pending_layer_->CalculateContentsScale( | 1258 pending_layer_->CalculateContentsScale(1.f, |
1188 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1259 1.f, |
| 1260 1.f, |
| 1261 1.f, |
| 1262 false, |
| 1263 &result_scale_x, |
| 1264 &result_scale_y, |
| 1265 &result_bounds); |
1189 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1266 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
1190 | 1267 |
1191 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1268 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1192 | 1269 |
1193 // The default value. The layer is smaller than this. | 1270 // The default value. The layer is smaller than this. |
1194 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1271 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
1195 host_impl_.settings().max_untiled_layer_size.ToString()); | 1272 host_impl_.settings().max_untiled_layer_size.ToString()); |
1196 | 1273 |
1197 // There should be a single tile since the layer is small. | 1274 // There should be a single tile since the layer is small. |
1198 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1275 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
1199 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1276 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
1200 | 1277 |
1201 pending_layer_->ReleaseResources(); | 1278 pending_layer_->ReleaseResources(); |
1202 | 1279 |
1203 // Change the max texture size on the output surface context. | 1280 // Change the max texture size on the output surface context. |
1204 scoped_ptr<TestWebGraphicsContext3D> context = | 1281 scoped_ptr<TestWebGraphicsContext3D> context = |
1205 TestWebGraphicsContext3D::Create(); | 1282 TestWebGraphicsContext3D::Create(); |
1206 context->set_max_texture_size(140); | 1283 context->set_max_texture_size(140); |
1207 host_impl_.DidLoseOutputSurface(); | 1284 host_impl_.DidLoseOutputSurface(); |
1208 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1285 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
1209 context.Pass()).PassAs<OutputSurface>()); | 1286 context.Pass()).PassAs<OutputSurface>()); |
1210 | 1287 |
1211 pending_layer_->CalculateContentsScale( | 1288 pending_layer_->CalculateContentsScale(1.f, |
1212 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1289 1.f, |
| 1290 1.f, |
| 1291 1.f, |
| 1292 false, |
| 1293 &result_scale_x, |
| 1294 &result_scale_y, |
| 1295 &result_bounds); |
1213 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1296 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
1214 | 1297 |
1215 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1298 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1216 | 1299 |
1217 // There should be more than one tile since the max texture size won't cover | 1300 // There should be more than one tile since the max texture size won't cover |
1218 // the layer. | 1301 // the layer. |
1219 high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1302 high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
1220 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); | 1303 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); |
1221 | 1304 |
1222 // Verify the tiles are not larger than the context's max texture size. | 1305 // Verify the tiles are not larger than the context's max texture size. |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 TEST_F(PictureLayerImplTest, TilingWithoutGpuRasterization) { | 1625 TEST_F(PictureLayerImplTest, TilingWithoutGpuRasterization) { |
1543 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 1626 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
1544 gfx::Size layer_bounds(default_tile_size.width() * 4, | 1627 gfx::Size layer_bounds(default_tile_size.width() * 4, |
1545 default_tile_size.height() * 4); | 1628 default_tile_size.height() * 4); |
1546 float result_scale_x, result_scale_y; | 1629 float result_scale_x, result_scale_y; |
1547 gfx::Size result_bounds; | 1630 gfx::Size result_bounds; |
1548 | 1631 |
1549 SetupDefaultTrees(layer_bounds); | 1632 SetupDefaultTrees(layer_bounds); |
1550 EXPECT_FALSE(pending_layer_->ShouldUseGpuRasterization()); | 1633 EXPECT_FALSE(pending_layer_->ShouldUseGpuRasterization()); |
1551 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1634 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1552 pending_layer_->CalculateContentsScale( | 1635 pending_layer_->CalculateContentsScale(1.f, |
1553 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1636 1.f, |
| 1637 1.f, |
| 1638 1.f, |
| 1639 false, |
| 1640 &result_scale_x, |
| 1641 &result_scale_y, |
| 1642 &result_bounds); |
1554 // Should have a low-res and a high-res tiling. | 1643 // Should have a low-res and a high-res tiling. |
1555 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1644 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1556 } | 1645 } |
1557 | 1646 |
1558 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { | 1647 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
1559 // Set up layers with tilings. | 1648 // Set up layers with tilings. |
1560 SetupDefaultTrees(gfx::Size(10, 10)); | 1649 SetupDefaultTrees(gfx::Size(10, 10)); |
1561 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, false); | 1650 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); |
1562 pending_layer_->PushPropertiesTo(active_layer_); | 1651 pending_layer_->PushPropertiesTo(active_layer_); |
1563 EXPECT_TRUE(pending_layer_->DrawsContent()); | 1652 EXPECT_TRUE(pending_layer_->DrawsContent()); |
1564 EXPECT_TRUE(pending_layer_->CanHaveTilings()); | 1653 EXPECT_TRUE(pending_layer_->CanHaveTilings()); |
1565 EXPECT_GE(pending_layer_->num_tilings(), 0u); | 1654 EXPECT_GE(pending_layer_->num_tilings(), 0u); |
1566 EXPECT_GE(active_layer_->num_tilings(), 0u); | 1655 EXPECT_GE(active_layer_->num_tilings(), 0u); |
1567 | 1656 |
1568 // Set content to false, which should make CanHaveTilings return false. | 1657 // Set content to false, which should make CanHaveTilings return false. |
1569 pending_layer_->SetDrawsContent(false); | 1658 pending_layer_->SetDrawsContent(false); |
1570 EXPECT_FALSE(pending_layer_->DrawsContent()); | 1659 EXPECT_FALSE(pending_layer_->DrawsContent()); |
1571 EXPECT_FALSE(pending_layer_->CanHaveTilings()); | 1660 EXPECT_FALSE(pending_layer_->CanHaveTilings()); |
1572 | 1661 |
1573 // No tilings should be pushed to active layer. | 1662 // No tilings should be pushed to active layer. |
1574 pending_layer_->PushPropertiesTo(active_layer_); | 1663 pending_layer_->PushPropertiesTo(active_layer_); |
1575 EXPECT_EQ(0u, active_layer_->num_tilings()); | 1664 EXPECT_EQ(0u, active_layer_->num_tilings()); |
1576 } | 1665 } |
1577 | 1666 |
1578 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { | 1667 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { |
1579 SetupDefaultTrees(gfx::Size(10, 10)); | 1668 SetupDefaultTrees(gfx::Size(10, 10)); |
1580 host_impl_.PinchGestureBegin(); | 1669 host_impl_.PinchGestureBegin(); |
1581 float high_res_scale = 2.3f; | 1670 float high_res_scale = 2.3f; |
1582 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, false); | 1671 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, false); |
1583 | 1672 |
1584 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 1673 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
1585 EXPECT_FLOAT_EQ(high_res_scale, | 1674 EXPECT_FLOAT_EQ(high_res_scale, |
1586 pending_layer_->HighResTiling()->contents_scale()); | 1675 pending_layer_->HighResTiling()->contents_scale()); |
1587 } | 1676 } |
1588 | 1677 |
1589 TEST_F(PictureLayerImplTest, FirstTilingTooSmall) { | 1678 TEST_F(PictureLayerImplTest, FirstTilingTooSmall) { |
1590 SetupDefaultTrees(gfx::Size(10, 10)); | 1679 SetupDefaultTrees(gfx::Size(10, 10)); |
1591 host_impl_.PinchGestureBegin(); | 1680 host_impl_.PinchGestureBegin(); |
1592 float high_res_scale = 0.0001f; | 1681 float high_res_scale = 0.0001f; |
1593 EXPECT_GT(pending_layer_->MinimumContentsScale(), high_res_scale); | 1682 EXPECT_GT(pending_layer_->MinimumContentsScale(), high_res_scale); |
1594 | 1683 |
1595 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, false); | 1684 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, false); |
1596 | 1685 |
1597 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 1686 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
1598 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), | 1687 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
1599 pending_layer_->HighResTiling()->contents_scale()); | 1688 pending_layer_->HighResTiling()->contents_scale()); |
1600 } | 1689 } |
1601 | 1690 |
1602 TEST_F(PictureLayerImplTest, PinchingTooSmall) { | 1691 TEST_F(PictureLayerImplTest, PinchingTooSmall) { |
1603 SetupDefaultTrees(gfx::Size(10, 10)); | 1692 SetupDefaultTrees(gfx::Size(10, 10)); |
1604 | 1693 |
1605 float contents_scale = 0.15f; | 1694 float contents_scale = 0.15f; |
1606 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, false); | 1695 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, false); |
1607 | 1696 |
1608 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 1697 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
1609 EXPECT_FLOAT_EQ(contents_scale, | 1698 EXPECT_FLOAT_EQ(contents_scale, |
1610 pending_layer_->HighResTiling()->contents_scale()); | 1699 pending_layer_->HighResTiling()->contents_scale()); |
1611 | 1700 |
1612 host_impl_.PinchGestureBegin(); | 1701 host_impl_.PinchGestureBegin(); |
1613 | 1702 |
1614 float page_scale = 0.0001f; | 1703 float page_scale = 0.0001f; |
1615 EXPECT_LT(page_scale * contents_scale, | 1704 EXPECT_LT(page_scale * contents_scale, |
1616 pending_layer_->MinimumContentsScale()); | 1705 pending_layer_->MinimumContentsScale()); |
1617 | 1706 |
1618 | 1707 SetContentsScaleOnBothLayers(contents_scale, 1.f, page_scale, 1.f, false); |
1619 SetContentsScaleOnBothLayers(contents_scale, 1.f, page_scale, false); | |
1620 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 1708 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
1621 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), | 1709 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
1622 pending_layer_->HighResTiling()->contents_scale()); | 1710 pending_layer_->HighResTiling()->contents_scale()); |
1623 } | 1711 } |
1624 | 1712 |
1625 class DeferredInitPictureLayerImplTest : public PictureLayerImplTest { | 1713 class DeferredInitPictureLayerImplTest : public PictureLayerImplTest { |
1626 public: | 1714 public: |
1627 virtual void InitializeRenderer() OVERRIDE { | 1715 virtual void InitializeRenderer() OVERRIDE { |
1628 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDeferredGL( | 1716 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDeferredGL( |
1629 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) | 1717 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 TEST_F(HybridRasterizationPictureLayerImplTest, Tiling) { | 1765 TEST_F(HybridRasterizationPictureLayerImplTest, Tiling) { |
1678 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 1766 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
1679 gfx::Size layer_bounds(default_tile_size.width() * 4, | 1767 gfx::Size layer_bounds(default_tile_size.width() * 4, |
1680 default_tile_size.height() * 4); | 1768 default_tile_size.height() * 4); |
1681 float result_scale_x, result_scale_y; | 1769 float result_scale_x, result_scale_y; |
1682 gfx::Size result_bounds; | 1770 gfx::Size result_bounds; |
1683 | 1771 |
1684 SetupDefaultTrees(layer_bounds); | 1772 SetupDefaultTrees(layer_bounds); |
1685 EXPECT_FALSE(pending_layer_->ShouldUseGpuRasterization()); | 1773 EXPECT_FALSE(pending_layer_->ShouldUseGpuRasterization()); |
1686 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1774 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1687 pending_layer_->CalculateContentsScale( | 1775 pending_layer_->CalculateContentsScale(1.f, |
1688 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1776 1.f, |
| 1777 1.f, |
| 1778 1.f, |
| 1779 false, |
| 1780 &result_scale_x, |
| 1781 &result_scale_y, |
| 1782 &result_bounds); |
1689 // Should have a low-res and a high-res tiling. | 1783 // Should have a low-res and a high-res tiling. |
1690 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1784 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1691 | 1785 |
1692 pending_layer_->SetHasGpuRasterizationHint(true); | 1786 pending_layer_->SetHasGpuRasterizationHint(true); |
1693 EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); | 1787 EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); |
1694 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1788 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1695 pending_layer_->CalculateContentsScale( | 1789 pending_layer_->CalculateContentsScale(1.f, |
1696 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1790 1.f, |
| 1791 1.f, |
| 1792 1.f, |
| 1793 false, |
| 1794 &result_scale_x, |
| 1795 &result_scale_y, |
| 1796 &result_bounds); |
1697 // Should only have the high-res tiling. | 1797 // Should only have the high-res tiling. |
1698 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1798 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
1699 } | 1799 } |
1700 | 1800 |
1701 TEST_F(HybridRasterizationPictureLayerImplTest, | 1801 TEST_F(HybridRasterizationPictureLayerImplTest, |
1702 HighResTilingDuringAnimationForCpuRasterization) { | 1802 HighResTilingDuringAnimationForCpuRasterization) { |
1703 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 1803 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
1704 SetupDefaultTrees(tile_size); | 1804 SetupDefaultTrees(tile_size); |
1705 pending_layer_->SetHasGpuRasterizationHint(false); | 1805 pending_layer_->SetHasGpuRasterizationHint(false); |
1706 active_layer_->SetHasGpuRasterizationHint(false); | 1806 active_layer_->SetHasGpuRasterizationHint(false); |
1707 | 1807 |
1708 float contents_scale = 1.f; | 1808 float contents_scale = 1.f; |
1709 float device_scale = 1.f; | 1809 float device_scale = 1.3f; |
1710 float page_scale = 1.f; | 1810 float page_scale = 1.4f; |
| 1811 float maximum_animation_scale = 1.f; |
1711 bool animating_transform = false; | 1812 bool animating_transform = false; |
1712 | 1813 |
1713 SetContentsScaleOnBothLayers( | 1814 SetContentsScaleOnBothLayers(contents_scale, |
1714 contents_scale, device_scale, page_scale, animating_transform); | 1815 device_scale, |
| 1816 page_scale, |
| 1817 maximum_animation_scale, |
| 1818 animating_transform); |
1715 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1819 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1716 | 1820 |
1717 // Changing contents scale shouldn't affect tiling resolution during the | 1821 // Since we're CPU-rasterizing, starting an animation should cause tiling |
1718 // animation, since we're CPU-rasterizing. | 1822 // resolution to get set to the maximum animation scale factor. |
1719 animating_transform = true; | 1823 animating_transform = true; |
| 1824 maximum_animation_scale = 3.f; |
1720 contents_scale = 2.f; | 1825 contents_scale = 2.f; |
1721 | 1826 |
1722 SetContentsScaleOnBothLayers( | 1827 SetContentsScaleOnBothLayers(contents_scale, |
1723 contents_scale, device_scale, page_scale, animating_transform); | 1828 device_scale, |
1724 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1829 page_scale, |
| 1830 maximum_animation_scale, |
| 1831 animating_transform); |
| 1832 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
| 1833 |
| 1834 // Further changes to scale during the animation should not cause a new |
| 1835 // high-res tiling to get created. |
| 1836 contents_scale = 4.f; |
| 1837 maximum_animation_scale = 5.f; |
| 1838 |
| 1839 SetContentsScaleOnBothLayers(contents_scale, |
| 1840 device_scale, |
| 1841 page_scale, |
| 1842 maximum_animation_scale, |
| 1843 animating_transform); |
| 1844 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
1725 | 1845 |
1726 // Once we stop animating, a new high-res tiling should be created. | 1846 // Once we stop animating, a new high-res tiling should be created. |
1727 animating_transform = false; | 1847 animating_transform = false; |
1728 SetContentsScaleOnBothLayers( | 1848 |
1729 contents_scale, device_scale, page_scale, animating_transform); | 1849 SetContentsScaleOnBothLayers(contents_scale, |
| 1850 device_scale, |
| 1851 page_scale, |
| 1852 maximum_animation_scale, |
| 1853 animating_transform); |
| 1854 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
| 1855 |
| 1856 // When animating with an unknown maximum animation scale factor, a new |
| 1857 // high-res tiling should be created at the animation's initial scale. |
| 1858 animating_transform = true; |
| 1859 contents_scale = 2.f; |
| 1860 maximum_animation_scale = 0.f; |
| 1861 |
| 1862 SetContentsScaleOnBothLayers(contents_scale, |
| 1863 device_scale, |
| 1864 page_scale, |
| 1865 maximum_animation_scale, |
| 1866 animating_transform); |
1730 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1867 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
| 1868 |
| 1869 // Further changes to scale during the animation should not cause a new |
| 1870 // high-res tiling to get created. |
| 1871 contents_scale = 3.f; |
| 1872 |
| 1873 SetContentsScaleOnBothLayers(contents_scale, |
| 1874 device_scale, |
| 1875 page_scale, |
| 1876 maximum_animation_scale, |
| 1877 animating_transform); |
| 1878 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
| 1879 |
| 1880 // Once we stop animating, a new high-res tiling should be created. |
| 1881 animating_transform = false; |
| 1882 contents_scale = 4.f; |
| 1883 |
| 1884 SetContentsScaleOnBothLayers(contents_scale, |
| 1885 device_scale, |
| 1886 page_scale, |
| 1887 maximum_animation_scale, |
| 1888 animating_transform); |
| 1889 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
1731 } | 1890 } |
1732 | 1891 |
1733 TEST_F(HybridRasterizationPictureLayerImplTest, | 1892 TEST_F(HybridRasterizationPictureLayerImplTest, |
1734 HighResTilingDuringAnimationForGpuRasterization) { | 1893 HighResTilingDuringAnimationForGpuRasterization) { |
1735 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 1894 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
1736 SetupDefaultTrees(tile_size); | 1895 SetupDefaultTrees(tile_size); |
1737 pending_layer_->SetHasGpuRasterizationHint(true); | 1896 pending_layer_->SetHasGpuRasterizationHint(true); |
1738 active_layer_->SetHasGpuRasterizationHint(true); | 1897 active_layer_->SetHasGpuRasterizationHint(true); |
1739 | 1898 |
1740 float contents_scale = 1.f; | 1899 float contents_scale = 1.f; |
1741 float device_scale = 1.f; | 1900 float device_scale = 1.f; |
1742 float page_scale = 1.f; | 1901 float page_scale = 1.f; |
| 1902 float maximum_animation_scale = 1.f; |
1743 bool animating_transform = false; | 1903 bool animating_transform = false; |
1744 | 1904 |
1745 SetContentsScaleOnBothLayers( | 1905 SetContentsScaleOnBothLayers(contents_scale, |
1746 contents_scale, device_scale, page_scale, animating_transform); | 1906 device_scale, |
| 1907 page_scale, |
| 1908 maximum_animation_scale, |
| 1909 animating_transform); |
1747 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1910 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1748 | 1911 |
1749 // Changing contents scale during an animation should cause tiling resolution | 1912 // Changing contents scale during an animation should cause tiling resolution |
1750 // to change, since we're GPU-rasterizing. | 1913 // to change, since we're GPU-rasterizing. The maximum animation scale should |
| 1914 // not have any effect. |
1751 animating_transform = true; | 1915 animating_transform = true; |
1752 contents_scale = 2.f; | 1916 contents_scale = 2.f; |
| 1917 maximum_animation_scale = 4.f; |
1753 | 1918 |
1754 SetContentsScaleOnBothLayers( | 1919 SetContentsScaleOnBothLayers(contents_scale, |
1755 contents_scale, device_scale, page_scale, animating_transform); | 1920 device_scale, |
| 1921 page_scale, |
| 1922 maximum_animation_scale, |
| 1923 animating_transform); |
1756 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1924 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1757 | 1925 |
1758 // Since we're re-rasterizing during the animation, scales smaller than 1 | 1926 // Since we're re-rasterizing during the animation, scales smaller than 1 |
1759 // should be respected. | 1927 // should be respected. |
1760 contents_scale = 0.5f; | 1928 contents_scale = 0.5f; |
1761 SetContentsScaleOnBothLayers( | 1929 SetContentsScaleOnBothLayers(contents_scale, |
1762 contents_scale, device_scale, page_scale, animating_transform); | 1930 device_scale, |
| 1931 page_scale, |
| 1932 maximum_animation_scale, |
| 1933 animating_transform); |
1763 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); | 1934 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); |
1764 | 1935 |
1765 // Tiling resolution should also update once we stop animating. | 1936 // Tiling resolution should also update once we stop animating. |
1766 contents_scale = 4.f; | 1937 contents_scale = 4.f; |
1767 animating_transform = false; | 1938 animating_transform = false; |
1768 SetContentsScaleOnBothLayers( | 1939 SetContentsScaleOnBothLayers(contents_scale, |
1769 contents_scale, device_scale, page_scale, animating_transform); | 1940 device_scale, |
| 1941 page_scale, |
| 1942 maximum_animation_scale, |
| 1943 animating_transform); |
1770 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 1944 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
1771 } | 1945 } |
1772 | 1946 |
1773 class GpuRasterizationPictureLayerImplTest : public PictureLayerImplTest { | 1947 class GpuRasterizationPictureLayerImplTest : public PictureLayerImplTest { |
1774 public: | 1948 public: |
1775 GpuRasterizationPictureLayerImplTest() | 1949 GpuRasterizationPictureLayerImplTest() |
1776 : PictureLayerImplTest(GpuRasterizationSettings()) {} | 1950 : PictureLayerImplTest(GpuRasterizationSettings()) {} |
1777 }; | 1951 }; |
1778 | 1952 |
1779 TEST_F(GpuRasterizationPictureLayerImplTest, Tiling) { | 1953 TEST_F(GpuRasterizationPictureLayerImplTest, Tiling) { |
1780 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 1954 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
1781 gfx::Size layer_bounds(default_tile_size.width() * 4, | 1955 gfx::Size layer_bounds(default_tile_size.width() * 4, |
1782 default_tile_size.height() * 4); | 1956 default_tile_size.height() * 4); |
1783 float result_scale_x, result_scale_y; | 1957 float result_scale_x, result_scale_y; |
1784 gfx::Size result_bounds; | 1958 gfx::Size result_bounds; |
1785 | 1959 |
1786 SetupDefaultTrees(layer_bounds); | 1960 SetupDefaultTrees(layer_bounds); |
1787 pending_layer_->SetHasGpuRasterizationHint(true); | 1961 pending_layer_->SetHasGpuRasterizationHint(true); |
1788 EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); | 1962 EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); |
1789 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1963 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1790 pending_layer_->CalculateContentsScale( | 1964 pending_layer_->CalculateContentsScale(1.f, |
1791 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1965 1.f, |
| 1966 1.f, |
| 1967 1.f, |
| 1968 false, |
| 1969 &result_scale_x, |
| 1970 &result_scale_y, |
| 1971 &result_bounds); |
1792 // Should only have the high-res tiling. | 1972 // Should only have the high-res tiling. |
1793 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1973 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
1794 | 1974 |
1795 pending_layer_->SetHasGpuRasterizationHint(false); | 1975 pending_layer_->SetHasGpuRasterizationHint(false); |
1796 EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); | 1976 EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); |
1797 // Should still have the high-res tiling. | 1977 // Should still have the high-res tiling. |
1798 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1978 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
1799 pending_layer_->CalculateContentsScale( | 1979 pending_layer_->CalculateContentsScale(1.f, |
1800 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 1980 1.f, |
| 1981 1.f, |
| 1982 1.f, |
| 1983 false, |
| 1984 &result_scale_x, |
| 1985 &result_scale_y, |
| 1986 &result_bounds); |
1801 // Should still only have the high-res tiling. | 1987 // Should still only have the high-res tiling. |
1802 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1988 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
1803 } | 1989 } |
1804 | 1990 |
1805 TEST_F(PictureLayerImplTest, LayerRasterTileIterator) { | 1991 TEST_F(PictureLayerImplTest, LayerRasterTileIterator) { |
1806 gfx::Size tile_size(100, 100); | 1992 gfx::Size tile_size(100, 100); |
1807 gfx::Size layer_bounds(1000, 1000); | 1993 gfx::Size layer_bounds(1000, 1000); |
1808 | 1994 |
1809 scoped_refptr<FakePicturePileImpl> pending_pile = | 1995 scoped_refptr<FakePicturePileImpl> pending_pile = |
1810 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1996 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); | 2221 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); |
2036 unique_tiles.insert(tile); | 2222 unique_tiles.insert(tile); |
2037 } | 2223 } |
2038 | 2224 |
2039 EXPECT_TRUE(reached_required); | 2225 EXPECT_TRUE(reached_required); |
2040 EXPECT_EQ(all_tiles_set.size(), unique_tiles.size()); | 2226 EXPECT_EQ(all_tiles_set.size(), unique_tiles.size()); |
2041 } | 2227 } |
2042 | 2228 |
2043 } // namespace | 2229 } // namespace |
2044 } // namespace cc | 2230 } // namespace cc |
OLD | NEW |