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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 pending_tree->SetRootLayer(pending_root.Pass()); | 230 pending_tree->SetRootLayer(pending_root.Pass()); |
231 | 231 |
232 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 232 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
233 host_impl_.pending_tree()->LayerById(id_)); | 233 host_impl_.pending_tree()->LayerById(id_)); |
234 | 234 |
235 // Add tilings/tiles for the layer. | 235 // Add tilings/tiles for the layer. |
236 bool update_lcd_text = false; | 236 bool update_lcd_text = false; |
237 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 237 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
238 } | 238 } |
239 | 239 |
240 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, | 240 void SetupDrawPropertiesAndUpdateTiles( |
241 float ideal_contents_scale, | 241 FakePictureLayerImpl* layer, |
242 float device_scale_factor, | 242 float ideal_contents_scale, |
243 float page_scale_factor, | 243 float device_scale_factor, |
244 float maximum_animation_contents_scale, | 244 float page_scale_factor, |
245 bool animating_transform_to_screen) { | 245 float maximum_animation_contents_scale, |
| 246 float starting_animation_contents_scale, |
| 247 bool animating_transform_to_screen) { |
246 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | 248 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; |
247 layer->draw_properties().device_scale_factor = device_scale_factor; | 249 layer->draw_properties().device_scale_factor = device_scale_factor; |
248 layer->draw_properties().page_scale_factor = page_scale_factor; | 250 layer->draw_properties().page_scale_factor = page_scale_factor; |
249 layer->draw_properties().maximum_animation_contents_scale = | 251 layer->draw_properties().maximum_animation_contents_scale = |
250 maximum_animation_contents_scale; | 252 maximum_animation_contents_scale; |
| 253 layer->draw_properties().starting_animation_contents_scale = |
| 254 starting_animation_contents_scale; |
251 layer->draw_properties().screen_space_transform_is_animating = | 255 layer->draw_properties().screen_space_transform_is_animating = |
252 animating_transform_to_screen; | 256 animating_transform_to_screen; |
253 bool resourceless_software_draw = false; | 257 bool resourceless_software_draw = false; |
254 layer->UpdateTiles(resourceless_software_draw); | 258 layer->UpdateTiles(resourceless_software_draw); |
255 } | 259 } |
256 static void VerifyAllTilesExistAndHavePile( | 260 static void VerifyAllTilesExistAndHavePile( |
257 const PictureLayerTiling* tiling, | 261 const PictureLayerTiling* tiling, |
258 PicturePileImpl* pile) { | 262 PicturePileImpl* pile) { |
259 for (PictureLayerTiling::CoverageIterator iter( | 263 for (PictureLayerTiling::CoverageIterator iter( |
260 tiling, | 264 tiling, |
261 tiling->contents_scale(), | 265 tiling->contents_scale(), |
262 gfx::Rect(tiling->tiling_size())); | 266 gfx::Rect(tiling->tiling_size())); |
263 iter; | 267 iter; |
264 ++iter) { | 268 ++iter) { |
265 EXPECT_TRUE(*iter); | 269 EXPECT_TRUE(*iter); |
266 EXPECT_EQ(pile, iter->raster_source()); | 270 EXPECT_EQ(pile, iter->raster_source()); |
267 } | 271 } |
268 } | 272 } |
269 | 273 |
270 void SetContentsScaleOnBothLayers(float contents_scale, | 274 void SetContentsScaleOnBothLayers(float contents_scale, |
271 float device_scale_factor, | 275 float device_scale_factor, |
272 float page_scale_factor, | 276 float page_scale_factor, |
273 float maximum_animation_contents_scale, | 277 float maximum_animation_contents_scale, |
| 278 float starting_animation_contents_scale, |
274 bool animating_transform) { | 279 bool animating_transform) { |
275 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 280 SetupDrawPropertiesAndUpdateTiles( |
276 contents_scale, | 281 pending_layer_, contents_scale, device_scale_factor, page_scale_factor, |
277 device_scale_factor, | 282 maximum_animation_contents_scale, starting_animation_contents_scale, |
278 page_scale_factor, | 283 animating_transform); |
279 maximum_animation_contents_scale, | |
280 animating_transform); | |
281 | 284 |
282 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 285 SetupDrawPropertiesAndUpdateTiles( |
283 contents_scale, | 286 active_layer_, contents_scale, device_scale_factor, page_scale_factor, |
284 device_scale_factor, | 287 maximum_animation_contents_scale, starting_animation_contents_scale, |
285 page_scale_factor, | 288 animating_transform); |
286 maximum_animation_contents_scale, | |
287 animating_transform); | |
288 } | 289 } |
289 | 290 |
290 void ResetTilingsAndRasterScales() { | 291 void ResetTilingsAndRasterScales() { |
291 if (pending_layer_) { | 292 if (pending_layer_) { |
292 pending_layer_->ReleaseResources(); | 293 pending_layer_->ReleaseResources(); |
293 EXPECT_FALSE(pending_layer_->tilings()); | 294 EXPECT_FALSE(pending_layer_->tilings()); |
294 pending_layer_->RecreateResources(); | 295 pending_layer_->RecreateResources(); |
295 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 296 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
296 } | 297 } |
297 | 298 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 gfx::Size tile_size(100, 100); | 432 gfx::Size tile_size(100, 100); |
432 gfx::Size layer_bounds(400, 400); | 433 gfx::Size layer_bounds(400, 400); |
433 | 434 |
434 scoped_refptr<FakePicturePileImpl> pending_pile = | 435 scoped_refptr<FakePicturePileImpl> pending_pile = |
435 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 436 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
436 scoped_refptr<FakePicturePileImpl> active_pile = | 437 scoped_refptr<FakePicturePileImpl> active_pile = |
437 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 438 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
438 | 439 |
439 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); | 440 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
440 | 441 |
441 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 442 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 443 false); |
442 | 444 |
443 time_ticks += base::TimeDelta::FromMilliseconds(200); | 445 time_ticks += base::TimeDelta::FromMilliseconds(200); |
444 host_impl_.SetCurrentBeginFrameArgs( | 446 host_impl_.SetCurrentBeginFrameArgs( |
445 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 447 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
446 | 448 |
447 // Update tiles with viewport for tile priority as (0, 0, 100, 100) and the | 449 // Update tiles with viewport for tile priority as (0, 0, 100, 100) and the |
448 // identify transform for tile priority. | 450 // identify transform for tile priority. |
449 bool resourceless_software_draw = false; | 451 bool resourceless_software_draw = false; |
450 gfx::Rect viewport = gfx::Rect(layer_bounds), | 452 gfx::Rect viewport = gfx::Rect(layer_bounds), |
451 viewport_rect_for_tile_priority = gfx::Rect(0, 0, 100, 100); | 453 viewport_rect_for_tile_priority = gfx::Rect(0, 0, 100, 100); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 gfx::Size tile_size(100, 100); | 529 gfx::Size tile_size(100, 100); |
528 gfx::Size layer_bounds(400, 400); | 530 gfx::Size layer_bounds(400, 400); |
529 | 531 |
530 scoped_refptr<FakePicturePileImpl> pending_pile = | 532 scoped_refptr<FakePicturePileImpl> pending_pile = |
531 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 533 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
532 scoped_refptr<FakePicturePileImpl> active_pile = | 534 scoped_refptr<FakePicturePileImpl> active_pile = |
533 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 535 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
534 | 536 |
535 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); | 537 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
536 | 538 |
537 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 539 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 540 false); |
538 | 541 |
539 // UpdateTiles with valid viewport. Should update tile viewport. | 542 // UpdateTiles with valid viewport. Should update tile viewport. |
540 // Note viewport is considered invalid if and only if in resourceless | 543 // Note viewport is considered invalid if and only if in resourceless |
541 // software draw. | 544 // software draw. |
542 bool resourceless_software_draw = false; | 545 bool resourceless_software_draw = false; |
543 gfx::Rect viewport = gfx::Rect(layer_bounds); | 546 gfx::Rect viewport = gfx::Rect(layer_bounds); |
544 gfx::Transform transform; | 547 gfx::Transform transform; |
545 host_impl_.SetExternalDrawConstraints(transform, | 548 host_impl_.SetExternalDrawConstraints(transform, |
546 viewport, | 549 viewport, |
547 viewport, | 550 viewport, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 gfx::Size tile_size(100, 100); | 612 gfx::Size tile_size(100, 100); |
610 gfx::Size layer_bounds(400, 400); | 613 gfx::Size layer_bounds(400, 400); |
611 | 614 |
612 scoped_refptr<FakePicturePileImpl> pending_pile = | 615 scoped_refptr<FakePicturePileImpl> pending_pile = |
613 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 616 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
614 scoped_refptr<FakePicturePileImpl> active_pile = | 617 scoped_refptr<FakePicturePileImpl> active_pile = |
615 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 618 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
616 | 619 |
617 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); | 620 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
618 | 621 |
619 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 622 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 623 false); |
620 | 624 |
621 time_ticks += base::TimeDelta::FromMilliseconds(200); | 625 time_ticks += base::TimeDelta::FromMilliseconds(200); |
622 host_impl_.SetCurrentBeginFrameArgs( | 626 host_impl_.SetCurrentBeginFrameArgs( |
623 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 627 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
624 | 628 |
625 bool resourceless_software_draw = false; | 629 bool resourceless_software_draw = false; |
626 gfx::Rect viewport = gfx::Rect(layer_bounds); | 630 gfx::Rect viewport = gfx::Rect(layer_bounds); |
627 gfx::Rect viewport_rect_for_tile_priority(0, 0, 100, 100); | 631 gfx::Rect viewport_rect_for_tile_priority(0, 0, 100, 100); |
628 gfx::Transform transform, transform_for_tile_priority; | 632 gfx::Transform transform, transform_for_tile_priority; |
629 | 633 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 active_layer_->ReleaseResources(); | 773 active_layer_->ReleaseResources(); |
770 EXPECT_FALSE(active_layer_->tilings()); | 774 EXPECT_FALSE(active_layer_->tilings()); |
771 active_layer_->RecreateResources(); | 775 active_layer_->RecreateResources(); |
772 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 776 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
773 | 777 |
774 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 778 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
775 6.f, // ideal contents scale | 779 6.f, // ideal contents scale |
776 3.f, // device scale | 780 3.f, // device scale |
777 2.f, // page scale | 781 2.f, // page scale |
778 1.f, // maximum animation scale | 782 1.f, // maximum animation scale |
| 783 0.f, // starting animation scale |
779 false); | 784 false); |
780 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 785 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
781 EXPECT_FLOAT_EQ(6.f, | 786 EXPECT_FLOAT_EQ(6.f, |
782 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 787 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
783 EXPECT_FLOAT_EQ(6.f * low_res_factor, | 788 EXPECT_FLOAT_EQ(6.f * low_res_factor, |
784 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 789 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
785 | 790 |
786 // If we change the page scale factor, then we should get new tilings. | 791 // If we change the page scale factor, then we should get new tilings. |
787 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 792 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
788 6.6f, // ideal contents scale | 793 6.6f, // ideal contents scale |
789 3.f, // device scale | 794 3.f, // device scale |
790 2.2f, // page scale | 795 2.2f, // page scale |
791 1.f, // maximum animation scale | 796 1.f, // maximum animation scale |
| 797 0.f, // starting animation scale |
792 false); | 798 false); |
793 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 799 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
794 EXPECT_FLOAT_EQ(6.6f, | 800 EXPECT_FLOAT_EQ(6.6f, |
795 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 801 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
796 EXPECT_FLOAT_EQ(6.6f * low_res_factor, | 802 EXPECT_FLOAT_EQ(6.6f * low_res_factor, |
797 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 803 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
798 | 804 |
799 // If we change the device scale factor, then we should get new tilings. | 805 // If we change the device scale factor, then we should get new tilings. |
800 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 806 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
801 7.26f, // ideal contents scale | 807 7.26f, // ideal contents scale |
802 3.3f, // device scale | 808 3.3f, // device scale |
803 2.2f, // page scale | 809 2.2f, // page scale |
804 1.f, // maximum animation scale | 810 1.f, // maximum animation scale |
| 811 0.f, // starting animation scale |
805 false); | 812 false); |
806 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); | 813 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); |
807 EXPECT_FLOAT_EQ(7.26f, | 814 EXPECT_FLOAT_EQ(7.26f, |
808 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 815 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
809 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 816 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
810 active_layer_->tilings()->tiling_at(3)->contents_scale()); | 817 active_layer_->tilings()->tiling_at(3)->contents_scale()); |
811 | 818 |
812 // If we change the device scale factor, but end up at the same total scale | 819 // If we change the device scale factor, but end up at the same total scale |
813 // factor somehow, then we don't get new tilings. | 820 // factor somehow, then we don't get new tilings. |
814 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 821 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
815 7.26f, // ideal contents scale | 822 7.26f, // ideal contents scale |
816 2.2f, // device scale | 823 2.2f, // device scale |
817 3.3f, // page scale | 824 3.3f, // page scale |
818 1.f, // maximum animation scale | 825 1.f, // maximum animation scale |
| 826 0.f, // starting animation scale |
819 false); | 827 false); |
820 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); | 828 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); |
821 EXPECT_FLOAT_EQ(7.26f, | 829 EXPECT_FLOAT_EQ(7.26f, |
822 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 830 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
823 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 831 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
824 active_layer_->tilings()->tiling_at(3)->contents_scale()); | 832 active_layer_->tilings()->tiling_at(3)->contents_scale()); |
825 } | 833 } |
826 | 834 |
827 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighAndLowResTiling) { | 835 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighAndLowResTiling) { |
828 gfx::Size tile_size(400, 400); | 836 gfx::Size tile_size(400, 400); |
(...skipping 12 matching lines...) Expand all Loading... |
841 pending_layer_->ReleaseResources(); | 849 pending_layer_->ReleaseResources(); |
842 EXPECT_FALSE(pending_layer_->tilings()); | 850 EXPECT_FALSE(pending_layer_->tilings()); |
843 pending_layer_->RecreateResources(); | 851 pending_layer_->RecreateResources(); |
844 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 852 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
845 | 853 |
846 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 854 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
847 6.f, // ideal contents scale | 855 6.f, // ideal contents scale |
848 3.f, // device scale | 856 3.f, // device scale |
849 2.f, // page scale | 857 2.f, // page scale |
850 1.f, // maximum animation scale | 858 1.f, // maximum animation scale |
| 859 0.f, // starting animation scale |
851 false); | 860 false); |
852 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 861 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
853 EXPECT_FLOAT_EQ(6.f, | 862 EXPECT_FLOAT_EQ(6.f, |
854 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 863 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
855 EXPECT_FLOAT_EQ(6.f * low_res_factor, | 864 EXPECT_FLOAT_EQ(6.f * low_res_factor, |
856 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 865 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
857 | 866 |
858 // If we change the page scale factor, then we should get new tilings. | 867 // If we change the page scale factor, then we should get new tilings. |
859 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 868 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
860 6.6f, // ideal contents scale | 869 6.6f, // ideal contents scale |
861 3.f, // device scale | 870 3.f, // device scale |
862 2.2f, // page scale | 871 2.2f, // page scale |
863 1.f, // maximum animation scale | 872 1.f, // maximum animation scale |
| 873 0.f, // starting animation scale |
864 false); | 874 false); |
865 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 875 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
866 EXPECT_FLOAT_EQ(6.6f, | 876 EXPECT_FLOAT_EQ(6.6f, |
867 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 877 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
868 EXPECT_FLOAT_EQ(6.6f * low_res_factor, | 878 EXPECT_FLOAT_EQ(6.6f * low_res_factor, |
869 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 879 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
870 | 880 |
871 // If we change the device scale factor, then we should get new tilings. | 881 // If we change the device scale factor, then we should get new tilings. |
872 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 882 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
873 7.26f, // ideal contents scale | 883 7.26f, // ideal contents scale |
874 3.3f, // device scale | 884 3.3f, // device scale |
875 2.2f, // page scale | 885 2.2f, // page scale |
876 1.f, // maximum animation scale | 886 1.f, // maximum animation scale |
| 887 0.f, // starting animation scale |
877 false); | 888 false); |
878 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 889 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
879 EXPECT_FLOAT_EQ(7.26f, | 890 EXPECT_FLOAT_EQ(7.26f, |
880 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 891 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
881 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 892 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
882 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 893 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
883 | 894 |
884 // If we change the device scale factor, but end up at the same total scale | 895 // If we change the device scale factor, but end up at the same total scale |
885 // factor somehow, then we don't get new tilings. | 896 // factor somehow, then we don't get new tilings. |
886 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 897 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
887 7.26f, // ideal contents scale | 898 7.26f, // ideal contents scale |
888 2.2f, // device scale | 899 2.2f, // device scale |
889 3.3f, // page scale | 900 3.3f, // page scale |
890 1.f, // maximum animation scale | 901 1.f, // maximum animation scale |
| 902 0.f, // starting animation scale |
891 false); | 903 false); |
892 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 904 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
893 EXPECT_FLOAT_EQ(7.26f, | 905 EXPECT_FLOAT_EQ(7.26f, |
894 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 906 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
895 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 907 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
896 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 908 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
897 } | 909 } |
898 | 910 |
899 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 911 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
900 // This test makes sure that if a layer can have tilings, then a commit makes | 912 // This test makes sure that if a layer can have tilings, then a commit makes |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 | 944 |
933 // Set up the high and low res tilings before pinch zoom. | 945 // Set up the high and low res tilings before pinch zoom. |
934 scoped_refptr<FakePicturePileImpl> pending_pile = | 946 scoped_refptr<FakePicturePileImpl> pending_pile = |
935 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 947 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
936 scoped_refptr<FakePicturePileImpl> active_pile = | 948 scoped_refptr<FakePicturePileImpl> active_pile = |
937 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 949 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
938 | 950 |
939 SetupTrees(pending_pile, active_pile); | 951 SetupTrees(pending_pile, active_pile); |
940 ResetTilingsAndRasterScales(); | 952 ResetTilingsAndRasterScales(); |
941 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 953 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
942 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, false); | 954 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false); |
943 EXPECT_EQ(32.f, active_layer_->HighResTiling()->contents_scale()); | 955 EXPECT_EQ(32.f, active_layer_->HighResTiling()->contents_scale()); |
944 host_impl_.PinchGestureBegin(); | 956 host_impl_.PinchGestureBegin(); |
945 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); | 957 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); |
946 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); | 958 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); |
947 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); | 959 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); |
948 } | 960 } |
949 | 961 |
950 TEST_F(PictureLayerImplTest, PinchGestureTilings) { | 962 TEST_F(PictureLayerImplTest, PinchGestureTilings) { |
951 gfx::Size tile_size(400, 400); | 963 gfx::Size tile_size(400, 400); |
952 gfx::Size layer_bounds(1300, 1900); | 964 gfx::Size layer_bounds(1300, 1900); |
953 | 965 |
954 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 966 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
955 | 967 |
956 scoped_refptr<FakePicturePileImpl> pending_pile = | 968 scoped_refptr<FakePicturePileImpl> pending_pile = |
957 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 969 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
958 scoped_refptr<FakePicturePileImpl> active_pile = | 970 scoped_refptr<FakePicturePileImpl> active_pile = |
959 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 971 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
960 | 972 |
961 // Set up the high and low res tilings before pinch zoom. | 973 // Set up the high and low res tilings before pinch zoom. |
962 SetupTrees(pending_pile, active_pile); | 974 SetupTrees(pending_pile, active_pile); |
963 ResetTilingsAndRasterScales(); | 975 ResetTilingsAndRasterScales(); |
964 | 976 |
965 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, false); | 977 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false); |
966 EXPECT_BOTH_EQ(num_tilings(), 2u); | 978 EXPECT_BOTH_EQ(num_tilings(), 2u); |
967 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), 2.f); | 979 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), 2.f); |
968 EXPECT_BOTH_EQ(tilings()->tiling_at(1)->contents_scale(), | 980 EXPECT_BOTH_EQ(tilings()->tiling_at(1)->contents_scale(), |
969 2.f * low_res_factor); | 981 2.f * low_res_factor); |
970 | 982 |
971 // Ensure UpdateTiles won't remove any tilings. | 983 // Ensure UpdateTiles won't remove any tilings. |
972 active_layer_->MarkAllTilingsUsed(); | 984 active_layer_->MarkAllTilingsUsed(); |
973 | 985 |
974 // Start a pinch gesture. | 986 // Start a pinch gesture. |
975 host_impl_.PinchGestureBegin(); | 987 host_impl_.PinchGestureBegin(); |
976 | 988 |
977 // Zoom out by a small amount. We should create a tiling at half | 989 // Zoom out by a small amount. We should create a tiling at half |
978 // the scale (2/kMaxScaleRatioDuringPinch). | 990 // the scale (2/kMaxScaleRatioDuringPinch). |
979 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, false); | 991 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, 0.f, false); |
980 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 992 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
981 EXPECT_FLOAT_EQ(2.0f, | 993 EXPECT_FLOAT_EQ(2.0f, |
982 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 994 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
983 EXPECT_FLOAT_EQ(1.0f, | 995 EXPECT_FLOAT_EQ(1.0f, |
984 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 996 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
985 EXPECT_FLOAT_EQ(2.0f * low_res_factor, | 997 EXPECT_FLOAT_EQ(2.0f * low_res_factor, |
986 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 998 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
987 | 999 |
988 // Ensure UpdateTiles won't remove any tilings. | 1000 // Ensure UpdateTiles won't remove any tilings. |
989 active_layer_->MarkAllTilingsUsed(); | 1001 active_layer_->MarkAllTilingsUsed(); |
990 | 1002 |
991 // Zoom out further, close to our low-res scale factor. We should | 1003 // Zoom out further, close to our low-res scale factor. We should |
992 // use that tiling as high-res, and not create a new tiling. | 1004 // use that tiling as high-res, and not create a new tiling. |
993 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, | 1005 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, |
994 low_res_factor * 2.1f, 1.0f, false); | 1006 low_res_factor * 2.1f, 1.0f, 0.f, false); |
995 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1007 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
996 | 1008 |
997 // Zoom in a lot now. Since we increase by increments of | 1009 // Zoom in a lot now. Since we increase by increments of |
998 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. | 1010 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. |
999 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, false); | 1011 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, 0.f, false); |
1000 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); | 1012 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
1001 EXPECT_FLOAT_EQ(4.0f, | 1013 EXPECT_FLOAT_EQ(4.0f, |
1002 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 1014 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
1003 } | 1015 } |
1004 | 1016 |
1005 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { | 1017 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { |
1006 gfx::Size tile_size(300, 300); | 1018 gfx::Size tile_size(300, 300); |
1007 gfx::Size layer_bounds(2600, 3800); | 1019 gfx::Size layer_bounds(2600, 3800); |
1008 | 1020 |
1009 scoped_refptr<FakePicturePileImpl> pending_pile = | 1021 scoped_refptr<FakePicturePileImpl> pending_pile = |
1010 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1022 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1011 scoped_refptr<FakePicturePileImpl> active_pile = | 1023 scoped_refptr<FakePicturePileImpl> active_pile = |
1012 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1024 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1013 | 1025 |
1014 SetupTrees(pending_pile, active_pile); | 1026 SetupTrees(pending_pile, active_pile); |
1015 | 1027 |
1016 ResetTilingsAndRasterScales(); | 1028 ResetTilingsAndRasterScales(); |
1017 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1029 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
1018 | 1030 |
1019 // Set up the high and low res tilings before pinch zoom. | 1031 // Set up the high and low res tilings before pinch zoom. |
1020 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, false); | 1032 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, 0.f, false); |
1021 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1033 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
1022 EXPECT_FLOAT_EQ(0.24f, | 1034 EXPECT_FLOAT_EQ(0.24f, |
1023 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 1035 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
1024 EXPECT_FLOAT_EQ(0.0625f, | 1036 EXPECT_FLOAT_EQ(0.0625f, |
1025 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 1037 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
1026 | 1038 |
1027 // Ensure UpdateTiles won't remove any tilings. | 1039 // Ensure UpdateTiles won't remove any tilings. |
1028 active_layer_->MarkAllTilingsUsed(); | 1040 active_layer_->MarkAllTilingsUsed(); |
1029 | 1041 |
1030 // Start a pinch gesture. | 1042 // Start a pinch gesture. |
1031 host_impl_.PinchGestureBegin(); | 1043 host_impl_.PinchGestureBegin(); |
1032 | 1044 |
1033 // Zoom out by a small amount. We should create a tiling at half | 1045 // Zoom out by a small amount. We should create a tiling at half |
1034 // the scale (1/kMaxScaleRatioDuringPinch). | 1046 // the scale (1/kMaxScaleRatioDuringPinch). |
1035 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, false); | 1047 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, 0.f, false); |
1036 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1048 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1037 EXPECT_FLOAT_EQ(0.24f, | 1049 EXPECT_FLOAT_EQ(0.24f, |
1038 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 1050 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
1039 EXPECT_FLOAT_EQ(0.12f, | 1051 EXPECT_FLOAT_EQ(0.12f, |
1040 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 1052 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
1041 EXPECT_FLOAT_EQ(0.0625, | 1053 EXPECT_FLOAT_EQ(0.0625, |
1042 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 1054 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
1043 | 1055 |
1044 // Ensure UpdateTiles won't remove any tilings. | 1056 // Ensure UpdateTiles won't remove any tilings. |
1045 active_layer_->MarkAllTilingsUsed(); | 1057 active_layer_->MarkAllTilingsUsed(); |
1046 | 1058 |
1047 // Zoom out further, close to our low-res scale factor. We should | 1059 // Zoom out further, close to our low-res scale factor. We should |
1048 // use that tiling as high-res, and not create a new tiling. | 1060 // use that tiling as high-res, and not create a new tiling. |
1049 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, false); | 1061 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, 0.f, false); |
1050 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1062 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1051 | 1063 |
1052 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in | 1064 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in |
1053 // because 0.25(desired_scale) is within the ratio(1.2). | 1065 // because 0.25(desired_scale) is within the ratio(1.2). |
1054 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, false); | 1066 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, 0.f, false); |
1055 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1067 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1056 | 1068 |
1057 // Zoom in a lot. Since we move in factors of two, we should get a scale that | 1069 // Zoom in a lot. Since we move in factors of two, we should get a scale that |
1058 // is a power of 2 times 0.24. | 1070 // is a power of 2 times 0.24. |
1059 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, false); | 1071 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, 0.f, false); |
1060 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); | 1072 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
1061 EXPECT_FLOAT_EQ(1.92f, | 1073 EXPECT_FLOAT_EQ(1.92f, |
1062 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 1074 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
1063 } | 1075 } |
1064 | 1076 |
1065 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 1077 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
1066 gfx::Size tile_size(400, 400); | 1078 gfx::Size tile_size(400, 400); |
1067 gfx::Size layer_bounds(1300, 1900); | 1079 gfx::Size layer_bounds(1300, 1900); |
1068 | 1080 |
1069 scoped_refptr<FakePicturePileImpl> pending_pile = | 1081 scoped_refptr<FakePicturePileImpl> pending_pile = |
(...skipping 21 matching lines...) Expand all Loading... |
1091 // We only have ideal tilings, so they aren't removed. | 1103 // We only have ideal tilings, so they aren't removed. |
1092 used_tilings.clear(); | 1104 used_tilings.clear(); |
1093 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1105 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1094 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1106 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
1095 | 1107 |
1096 host_impl_.PinchGestureBegin(); | 1108 host_impl_.PinchGestureBegin(); |
1097 | 1109 |
1098 // Changing the ideal but not creating new tilings. | 1110 // Changing the ideal but not creating new tilings. |
1099 scale = 1.5f; | 1111 scale = 1.5f; |
1100 page_scale = 1.5f; | 1112 page_scale = 1.5f; |
1101 SetContentsScaleOnBothLayers(scale, 1.f, page_scale, 1.f, false); | 1113 SetContentsScaleOnBothLayers(scale, 1.f, page_scale, 1.f, 0.f, false); |
1102 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1114 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
1103 | 1115 |
1104 // The tilings are still our target scale, so they aren't removed. | 1116 // The tilings are still our target scale, so they aren't removed. |
1105 used_tilings.clear(); | 1117 used_tilings.clear(); |
1106 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1118 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1107 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1119 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
1108 | 1120 |
1109 host_impl_.PinchGestureEnd(); | 1121 host_impl_.PinchGestureEnd(); |
1110 | 1122 |
1111 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 1123 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
1112 scale = 1.2f; | 1124 scale = 1.2f; |
1113 page_scale = 1.2f; | 1125 page_scale = 1.2f; |
1114 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, false); | 1126 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, 0.f, false); |
1115 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 1127 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
1116 EXPECT_FLOAT_EQ( | 1128 EXPECT_FLOAT_EQ( |
1117 1.f, | 1129 1.f, |
1118 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 1130 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
1119 EXPECT_FLOAT_EQ( | 1131 EXPECT_FLOAT_EQ( |
1120 1.f * low_res_factor, | 1132 1.f * low_res_factor, |
1121 active_layer_->tilings()->tiling_at(3)->contents_scale()); | 1133 active_layer_->tilings()->tiling_at(3)->contents_scale()); |
1122 | 1134 |
1123 // Ensure UpdateTiles won't remove any tilings. | 1135 // Ensure UpdateTiles won't remove any tilings. |
1124 active_layer_->MarkAllTilingsUsed(); | 1136 active_layer_->MarkAllTilingsUsed(); |
1125 | 1137 |
1126 // Mark the non-ideal tilings as used. They won't be removed. | 1138 // Mark the non-ideal tilings as used. They won't be removed. |
1127 used_tilings.clear(); | 1139 used_tilings.clear(); |
1128 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 1140 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
1129 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); | 1141 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); |
1130 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1142 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1131 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 1143 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
1132 | 1144 |
1133 // Now move the ideal scale to 0.5. Our target stays 1.2. | 1145 // Now move the ideal scale to 0.5. Our target stays 1.2. |
1134 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, false); | 1146 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, 0.f, false); |
1135 | 1147 |
1136 // The high resolution tiling is between target and ideal, so is not | 1148 // The high resolution tiling is between target and ideal, so is not |
1137 // removed. The low res tiling for the old ideal=1.0 scale is removed. | 1149 // removed. The low res tiling for the old ideal=1.0 scale is removed. |
1138 used_tilings.clear(); | 1150 used_tilings.clear(); |
1139 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1151 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1140 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1152 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1141 | 1153 |
1142 // Now move the ideal scale to 1.0. Our target stays 1.2. | 1154 // Now move the ideal scale to 1.0. Our target stays 1.2. |
1143 SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, false); | 1155 SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, 0.f, false); |
1144 | 1156 |
1145 // All the tilings are between are target and the ideal, so they are not | 1157 // All the tilings are between are target and the ideal, so they are not |
1146 // removed. | 1158 // removed. |
1147 used_tilings.clear(); | 1159 used_tilings.clear(); |
1148 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1160 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1149 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1161 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1150 | 1162 |
1151 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 1163 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
1152 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.1f, 1.f, page_scale, 1.f, | 1164 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.1f, 1.f, page_scale, 1.f, |
1153 false); | 1165 0.f, false); |
1154 | 1166 |
1155 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 1167 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
1156 // in the range [1.0,1.2] and are kept. | 1168 // in the range [1.0,1.2] and are kept. |
1157 used_tilings.clear(); | 1169 used_tilings.clear(); |
1158 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1170 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1159 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1171 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1160 | 1172 |
1161 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 1173 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
1162 // 1.2 still. | 1174 // 1.2 still. |
1163 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.1f, 1.f, page_scale, 1.f, | 1175 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.1f, 1.f, page_scale, 1.f, |
1164 false); | 1176 0.f, false); |
1165 | 1177 |
1166 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 1178 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
1167 // target raster scale. But it is in our used tilings set, so nothing is | 1179 // target raster scale. But it is in our used tilings set, so nothing is |
1168 // deleted. | 1180 // deleted. |
1169 used_tilings.clear(); | 1181 used_tilings.clear(); |
1170 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 1182 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
1171 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1183 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1172 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1184 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1173 | 1185 |
1174 // If we remove it from our used tilings set, it is outside the range to keep | 1186 // If we remove it from our used tilings set, it is outside the range to keep |
1175 // so it is deleted. | 1187 // so it is deleted. |
1176 used_tilings.clear(); | 1188 used_tilings.clear(); |
1177 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1189 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1178 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1190 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
1179 } | 1191 } |
1180 | 1192 |
1181 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { | 1193 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { |
1182 // Make sure this layer covers multiple tiles, since otherwise low | 1194 // Make sure this layer covers multiple tiles, since otherwise low |
1183 // res won't get created because it is too small. | 1195 // res won't get created because it is too small. |
1184 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 1196 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
1185 // Avoid max untiled layer size heuristics via fixed tile size. | 1197 // Avoid max untiled layer size heuristics via fixed tile size. |
1186 gfx::Size layer_bounds(tile_size.width() + 1, tile_size.height() + 1); | 1198 gfx::Size layer_bounds(tile_size.width() + 1, tile_size.height() + 1); |
1187 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1199 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
1188 | 1200 |
1189 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 1201 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
1190 float contents_scale = 1.f; | 1202 float contents_scale = 1.f; |
1191 float device_scale = 1.f; | 1203 float device_scale = 1.f; |
1192 float page_scale = 1.f; | 1204 float page_scale = 1.f; |
1193 float maximum_animation_scale = 1.f; | 1205 float maximum_animation_scale = 1.f; |
| 1206 float starting_animation_scale = 0.f; |
1194 bool animating_transform = true; | 1207 bool animating_transform = true; |
1195 | 1208 |
1196 ResetTilingsAndRasterScales(); | 1209 ResetTilingsAndRasterScales(); |
1197 | 1210 |
1198 // Animating, so don't create low res even if there isn't one already. | 1211 // Animating, so don't create low res even if there isn't one already. |
1199 SetContentsScaleOnBothLayers(contents_scale, | 1212 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1200 device_scale, | |
1201 page_scale, | |
1202 maximum_animation_scale, | 1213 maximum_animation_scale, |
1203 animating_transform); | 1214 starting_animation_scale, animating_transform); |
1204 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1215 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1205 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1216 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1206 | 1217 |
1207 // Stop animating, low res gets created. | 1218 // Stop animating, low res gets created. |
1208 animating_transform = false; | 1219 animating_transform = false; |
1209 SetContentsScaleOnBothLayers(contents_scale, | 1220 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1210 device_scale, | |
1211 page_scale, | |
1212 maximum_animation_scale, | 1221 maximum_animation_scale, |
1213 animating_transform); | 1222 starting_animation_scale, animating_transform); |
1214 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1223 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1215 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); | 1224 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
1216 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1225 EXPECT_BOTH_EQ(num_tilings(), 2u); |
1217 | 1226 |
1218 // Ensure UpdateTiles won't remove any tilings. | 1227 // Ensure UpdateTiles won't remove any tilings. |
1219 active_layer_->MarkAllTilingsUsed(); | 1228 active_layer_->MarkAllTilingsUsed(); |
1220 | 1229 |
1221 // Page scale animation, new high res, but no low res. We still have | 1230 // Page scale animation, new high res, but no low res. We still have |
1222 // a tiling at the previous scale, it's just not marked as low res on the | 1231 // a tiling at the previous scale, it's just not marked as low res on the |
1223 // active layer. The pending layer drops non-ideal tilings. | 1232 // active layer. The pending layer drops non-ideal tilings. |
1224 contents_scale = 2.f; | 1233 contents_scale = 2.f; |
1225 page_scale = 2.f; | 1234 page_scale = 2.f; |
1226 maximum_animation_scale = 2.f; | 1235 maximum_animation_scale = 2.f; |
1227 animating_transform = true; | 1236 animating_transform = true; |
1228 SetContentsScaleOnBothLayers(contents_scale, | 1237 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1229 device_scale, | |
1230 page_scale, | |
1231 maximum_animation_scale, | 1238 maximum_animation_scale, |
1232 animating_transform); | 1239 starting_animation_scale, animating_transform); |
1233 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1240 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1234 EXPECT_FALSE(active_layer_->LowResTiling()); | 1241 EXPECT_FALSE(active_layer_->LowResTiling()); |
1235 EXPECT_FALSE(pending_layer_->LowResTiling()); | 1242 EXPECT_FALSE(pending_layer_->LowResTiling()); |
1236 EXPECT_EQ(3u, active_layer_->num_tilings()); | 1243 EXPECT_EQ(3u, active_layer_->num_tilings()); |
1237 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1244 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
1238 | 1245 |
1239 // Stop animating, new low res gets created for final page scale. | 1246 // Stop animating, new low res gets created for final page scale. |
1240 animating_transform = false; | 1247 animating_transform = false; |
1241 SetContentsScaleOnBothLayers(contents_scale, | 1248 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1242 device_scale, | |
1243 page_scale, | |
1244 maximum_animation_scale, | 1249 maximum_animation_scale, |
1245 animating_transform); | 1250 starting_animation_scale, animating_transform); |
1246 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1251 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1247 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); | 1252 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); |
1248 EXPECT_EQ(4u, active_layer_->num_tilings()); | 1253 EXPECT_EQ(4u, active_layer_->num_tilings()); |
1249 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 1254 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
1250 } | 1255 } |
1251 | 1256 |
1252 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { | 1257 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
1253 gfx::Size layer_bounds(host_impl_.settings().default_tile_size); | 1258 gfx::Size layer_bounds(host_impl_.settings().default_tile_size); |
1254 gfx::Size tile_size(100, 100); | 1259 gfx::Size tile_size(100, 100); |
1255 | 1260 |
1256 scoped_refptr<FakePicturePileImpl> pending_pile = | 1261 scoped_refptr<FakePicturePileImpl> pending_pile = |
1257 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1262 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1258 scoped_refptr<FakePicturePileImpl> active_pile = | 1263 scoped_refptr<FakePicturePileImpl> active_pile = |
1259 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1264 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1260 | 1265 |
1261 SetupTrees(pending_pile, active_pile); | 1266 SetupTrees(pending_pile, active_pile); |
1262 | 1267 |
1263 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 1268 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
1264 float device_scale = 1.f; | 1269 float device_scale = 1.f; |
1265 float page_scale = 1.f; | 1270 float page_scale = 1.f; |
1266 float maximum_animation_scale = 1.f; | 1271 float maximum_animation_scale = 1.f; |
| 1272 float starting_animation_scale = 0.f; |
1267 bool animating_transform = false; | 1273 bool animating_transform = false; |
1268 | 1274 |
1269 // Contents exactly fit on one tile at scale 1, no low res. | 1275 // Contents exactly fit on one tile at scale 1, no low res. |
1270 float contents_scale = 1.f; | 1276 float contents_scale = 1.f; |
1271 SetContentsScaleOnBothLayers(contents_scale, | 1277 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1272 device_scale, | |
1273 page_scale, | |
1274 maximum_animation_scale, | 1278 maximum_animation_scale, |
1275 animating_transform); | 1279 starting_animation_scale, animating_transform); |
1276 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1280 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1277 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1281 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1278 | 1282 |
1279 ResetTilingsAndRasterScales(); | 1283 ResetTilingsAndRasterScales(); |
1280 | 1284 |
1281 // Contents that are smaller than one tile, no low res. | 1285 // Contents that are smaller than one tile, no low res. |
1282 contents_scale = 0.123f; | 1286 contents_scale = 0.123f; |
1283 SetContentsScaleOnBothLayers(contents_scale, | 1287 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1284 device_scale, | |
1285 page_scale, | |
1286 maximum_animation_scale, | 1288 maximum_animation_scale, |
1287 animating_transform); | 1289 starting_animation_scale, animating_transform); |
1288 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1290 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1289 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1291 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1290 | 1292 |
1291 ResetTilingsAndRasterScales(); | 1293 ResetTilingsAndRasterScales(); |
1292 | 1294 |
1293 // Any content bounds that would create more than one tile will | 1295 // Any content bounds that would create more than one tile will |
1294 // generate a low res tiling. | 1296 // generate a low res tiling. |
1295 contents_scale = 2.5f; | 1297 contents_scale = 2.5f; |
1296 SetContentsScaleOnBothLayers(contents_scale, | 1298 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
1297 device_scale, | |
1298 page_scale, | |
1299 maximum_animation_scale, | 1299 maximum_animation_scale, |
1300 animating_transform); | 1300 starting_animation_scale, animating_transform); |
1301 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1301 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1302 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), | 1302 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), |
1303 contents_scale * low_res_factor); | 1303 contents_scale * low_res_factor); |
1304 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1304 EXPECT_BOTH_EQ(num_tilings(), 2u); |
1305 | 1305 |
1306 // Mask layers dont create low res since they always fit on one tile. | 1306 // Mask layers dont create low res since they always fit on one tile. |
1307 scoped_ptr<FakePictureLayerImpl> mask = | 1307 scoped_ptr<FakePictureLayerImpl> mask = |
1308 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1308 FakePictureLayerImpl::CreateMaskWithRasterSource( |
1309 host_impl_.pending_tree(), 3, pending_pile); | 1309 host_impl_.pending_tree(), 3, pending_pile); |
1310 mask->SetBounds(layer_bounds); | 1310 mask->SetBounds(layer_bounds); |
1311 mask->SetContentBounds(layer_bounds); | 1311 mask->SetContentBounds(layer_bounds); |
1312 mask->SetDrawsContent(true); | 1312 mask->SetDrawsContent(true); |
1313 | 1313 |
1314 SetupDrawPropertiesAndUpdateTiles(mask.get(), contents_scale, device_scale, | 1314 SetupDrawPropertiesAndUpdateTiles( |
1315 page_scale, maximum_animation_scale, | 1315 mask.get(), contents_scale, device_scale, page_scale, |
1316 animating_transform); | 1316 maximum_animation_scale, starting_animation_scale, animating_transform); |
1317 EXPECT_EQ(mask->HighResTiling()->contents_scale(), contents_scale); | 1317 EXPECT_EQ(mask->HighResTiling()->contents_scale(), contents_scale); |
1318 EXPECT_EQ(mask->num_tilings(), 1u); | 1318 EXPECT_EQ(mask->num_tilings(), 1u); |
1319 } | 1319 } |
1320 | 1320 |
1321 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { | 1321 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { |
1322 base::TimeTicks time_ticks; | 1322 base::TimeTicks time_ticks; |
1323 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1323 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1324 host_impl_.SetCurrentBeginFrameArgs( | 1324 host_impl_.SetCurrentBeginFrameArgs( |
1325 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1325 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1326 | 1326 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 gfx::Size mask_texture_size; | 1367 gfx::Size mask_texture_size; |
1368 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1368 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
1369 EXPECT_NE(0u, mask_resource_id); | 1369 EXPECT_NE(0u, mask_resource_id); |
1370 EXPECT_EQ(active_mask->bounds(), mask_texture_size); | 1370 EXPECT_EQ(active_mask->bounds(), mask_texture_size); |
1371 | 1371 |
1372 // Drop resources and recreate them, still the same. | 1372 // Drop resources and recreate them, still the same. |
1373 pending_mask->ReleaseResources(); | 1373 pending_mask->ReleaseResources(); |
1374 active_mask->ReleaseResources(); | 1374 active_mask->ReleaseResources(); |
1375 pending_mask->RecreateResources(); | 1375 pending_mask->RecreateResources(); |
1376 active_mask->RecreateResources(); | 1376 active_mask->RecreateResources(); |
1377 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); | 1377 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1378 false); |
1378 active_mask->HighResTiling()->CreateAllTilesForTesting(); | 1379 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
1379 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1380 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1380 EXPECT_NE(0u, mask_resource_id); | 1381 EXPECT_NE(0u, mask_resource_id); |
1381 EXPECT_EQ(active_mask->bounds(), mask_texture_size); | 1382 EXPECT_EQ(active_mask->bounds(), mask_texture_size); |
1382 | 1383 |
1383 // Resize larger than the max texture size. | 1384 // Resize larger than the max texture size. |
1384 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; | 1385 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; |
1385 gfx::Size huge_bounds(max_texture_size + 1, 10); | 1386 gfx::Size huge_bounds(max_texture_size + 1, 10); |
1386 scoped_refptr<FakePicturePileImpl> huge_pile = | 1387 scoped_refptr<FakePicturePileImpl> huge_pile = |
1387 FakePicturePileImpl::CreateFilledPile(tile_size, huge_bounds); | 1388 FakePicturePileImpl::CreateFilledPile(tile_size, huge_bounds); |
(...skipping 24 matching lines...) Expand all Loading... |
1412 EXPECT_NE(0u, mask_resource_id); | 1413 EXPECT_NE(0u, mask_resource_id); |
1413 gfx::Size expected_size = active_mask->bounds(); | 1414 gfx::Size expected_size = active_mask->bounds(); |
1414 expected_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); | 1415 expected_size.SetToMin(gfx::Size(max_texture_size, max_texture_size)); |
1415 EXPECT_EQ(expected_size, mask_texture_size); | 1416 EXPECT_EQ(expected_size, mask_texture_size); |
1416 | 1417 |
1417 // Drop resources and recreate them, still the same. | 1418 // Drop resources and recreate them, still the same. |
1418 pending_mask->ReleaseResources(); | 1419 pending_mask->ReleaseResources(); |
1419 active_mask->ReleaseResources(); | 1420 active_mask->ReleaseResources(); |
1420 pending_mask->RecreateResources(); | 1421 pending_mask->RecreateResources(); |
1421 active_mask->RecreateResources(); | 1422 active_mask->RecreateResources(); |
1422 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); | 1423 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1424 false); |
1423 active_mask->HighResTiling()->CreateAllTilesForTesting(); | 1425 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
1424 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1426 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1425 EXPECT_NE(0u, mask_resource_id); | 1427 EXPECT_NE(0u, mask_resource_id); |
1426 EXPECT_EQ(expected_size, mask_texture_size); | 1428 EXPECT_EQ(expected_size, mask_texture_size); |
1427 | 1429 |
1428 // Do another activate, the same holds. | 1430 // Do another activate, the same holds. |
1429 SetupPendingTree(huge_pile); | 1431 SetupPendingTree(huge_pile); |
1430 ActivateTree(); | 1432 ActivateTree(); |
1431 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); | 1433 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1432 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1434 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 EXPECT_FALSE(pending_layer_->tilings()); | 1535 EXPECT_FALSE(pending_layer_->tilings()); |
1534 pending_layer_->RecreateResources(); | 1536 pending_layer_->RecreateResources(); |
1535 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1537 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1536 | 1538 |
1537 // This should create new tilings. | 1539 // This should create new tilings. |
1538 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 1540 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
1539 1.f, // ideal contents scale | 1541 1.f, // ideal contents scale |
1540 1.f, // device scale | 1542 1.f, // device scale |
1541 1.f, // page scale | 1543 1.f, // page scale |
1542 1.f, // maximum animation scale | 1544 1.f, // maximum animation scale |
| 1545 0.f, // starting animation_scale |
1543 false); | 1546 false); |
1544 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1547 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1545 } | 1548 } |
1546 | 1549 |
1547 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { | 1550 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { |
1548 // The default max tile size is larger than 400x400. | 1551 // The default max tile size is larger than 400x400. |
1549 gfx::Size tile_size(400, 400); | 1552 gfx::Size tile_size(400, 400); |
1550 gfx::Size layer_bounds(5000, 5000); | 1553 gfx::Size layer_bounds(5000, 5000); |
1551 | 1554 |
1552 scoped_refptr<FakePicturePileImpl> pending_pile = | 1555 scoped_refptr<FakePicturePileImpl> pending_pile = |
(...skipping 15 matching lines...) Expand all Loading... |
1568 ResetTilingsAndRasterScales(); | 1571 ResetTilingsAndRasterScales(); |
1569 | 1572 |
1570 // Change the max texture size on the output surface context. | 1573 // Change the max texture size on the output surface context. |
1571 scoped_ptr<TestWebGraphicsContext3D> context = | 1574 scoped_ptr<TestWebGraphicsContext3D> context = |
1572 TestWebGraphicsContext3D::Create(); | 1575 TestWebGraphicsContext3D::Create(); |
1573 context->set_max_texture_size(140); | 1576 context->set_max_texture_size(140); |
1574 host_impl_.DidLoseOutputSurface(); | 1577 host_impl_.DidLoseOutputSurface(); |
1575 host_impl_.InitializeRenderer( | 1578 host_impl_.InitializeRenderer( |
1576 FakeOutputSurface::Create3d(context.Pass()).Pass()); | 1579 FakeOutputSurface::Create3d(context.Pass()).Pass()); |
1577 | 1580 |
1578 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1581 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1582 false); |
1579 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1583 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1580 | 1584 |
1581 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1585 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1582 | 1586 |
1583 // Verify the tiles are not larger than the context's max texture size. | 1587 // Verify the tiles are not larger than the context's max texture size. |
1584 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1588 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
1585 EXPECT_GE(140, tile->content_rect().width()); | 1589 EXPECT_GE(140, tile->content_rect().width()); |
1586 EXPECT_GE(140, tile->content_rect().height()); | 1590 EXPECT_GE(140, tile->content_rect().height()); |
1587 } | 1591 } |
1588 | 1592 |
(...skipping 23 matching lines...) Expand all Loading... |
1612 ResetTilingsAndRasterScales(); | 1616 ResetTilingsAndRasterScales(); |
1613 | 1617 |
1614 // Change the max texture size on the output surface context. | 1618 // Change the max texture size on the output surface context. |
1615 scoped_ptr<TestWebGraphicsContext3D> context = | 1619 scoped_ptr<TestWebGraphicsContext3D> context = |
1616 TestWebGraphicsContext3D::Create(); | 1620 TestWebGraphicsContext3D::Create(); |
1617 context->set_max_texture_size(140); | 1621 context->set_max_texture_size(140); |
1618 host_impl_.DidLoseOutputSurface(); | 1622 host_impl_.DidLoseOutputSurface(); |
1619 host_impl_.InitializeRenderer( | 1623 host_impl_.InitializeRenderer( |
1620 FakeOutputSurface::Create3d(context.Pass()).Pass()); | 1624 FakeOutputSurface::Create3d(context.Pass()).Pass()); |
1621 | 1625 |
1622 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1626 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1627 false); |
1623 ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); | 1628 ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); |
1624 | 1629 |
1625 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1630 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1626 | 1631 |
1627 // There should be more than one tile since the max texture size won't cover | 1632 // There should be more than one tile since the max texture size won't cover |
1628 // the layer. | 1633 // the layer. |
1629 high_res_tiling = active_layer_->tilings()->tiling_at(0); | 1634 high_res_tiling = active_layer_->tilings()->tiling_at(0); |
1630 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); | 1635 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); |
1631 | 1636 |
1632 // Verify the tiles are not larger than the context's max texture size. | 1637 // Verify the tiles are not larger than the context's max texture size. |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 | 2014 |
2010 // One ideal tile exists, this will get used when drawing. | 2015 // One ideal tile exists, this will get used when drawing. |
2011 std::vector<Tile*> ideal_tiles; | 2016 std::vector<Tile*> ideal_tiles; |
2012 EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale()); | 2017 EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale()); |
2013 ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0)); | 2018 ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0)); |
2014 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 2019 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
2015 ideal_tiles); | 2020 ideal_tiles); |
2016 | 2021 |
2017 // Due to layer scale throttling, the raster contents scale is changed to 1, | 2022 // Due to layer scale throttling, the raster contents scale is changed to 1, |
2018 // while the ideal is still 2. | 2023 // while the ideal is still 2. |
2019 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 2024 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
2020 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.f, 1.f, 1.f, 1.f, false); | 2025 false); |
| 2026 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.f, 1.f, 1.f, 1.f, 0.f, |
| 2027 false); |
2021 | 2028 |
2022 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); | 2029 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); |
2023 EXPECT_EQ(1.f, active_layer_->raster_contents_scale()); | 2030 EXPECT_EQ(1.f, active_layer_->raster_contents_scale()); |
2024 EXPECT_EQ(2.f, active_layer_->ideal_contents_scale()); | 2031 EXPECT_EQ(2.f, active_layer_->ideal_contents_scale()); |
2025 | 2032 |
2026 // Both tilings still exist. | 2033 // Both tilings still exist. |
2027 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); | 2034 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); |
2028 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); | 2035 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); |
2029 | 2036 |
2030 // All high res tiles have resources. | 2037 // All high res tiles have resources. |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 // Now, set the bounds to be 1x1, so that minimum contents scale becomes 1. | 2481 // Now, set the bounds to be 1x1, so that minimum contents scale becomes 1. |
2475 pending_pile = | 2482 pending_pile = |
2476 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1, 1)); | 2483 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1, 1)); |
2477 SetupPendingTree(pending_pile); | 2484 SetupPendingTree(pending_pile); |
2478 | 2485 |
2479 // Another sanity check. | 2486 // Another sanity check. |
2480 EXPECT_EQ(1.f, pending_layer_->MinimumContentsScale()); | 2487 EXPECT_EQ(1.f, pending_layer_->MinimumContentsScale()); |
2481 | 2488 |
2482 // Since the MinContentsScale is 1, the 0.5 tiling should be replaced by a 1.0 | 2489 // Since the MinContentsScale is 1, the 0.5 tiling should be replaced by a 1.0 |
2483 // tiling. | 2490 // tiling. |
2484 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 0.5f, 1.f, 1.f, 1.f, false); | 2491 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 0.5f, 1.f, 1.f, 1.f, 0.f, |
| 2492 false); |
2485 | 2493 |
2486 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 2494 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
2487 PictureLayerTiling* tiling = | 2495 PictureLayerTiling* tiling = |
2488 pending_layer_->tilings()->FindTilingWithScale(1.0f); | 2496 pending_layer_->tilings()->FindTilingWithScale(1.0f); |
2489 ASSERT_TRUE(tiling); | 2497 ASSERT_TRUE(tiling); |
2490 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution()); | 2498 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution()); |
2491 } | 2499 } |
2492 | 2500 |
2493 TEST_F(PictureLayerImplTest, LowResTilingWithoutGpuRasterization) { | 2501 TEST_F(PictureLayerImplTest, LowResTilingWithoutGpuRasterization) { |
2494 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 2502 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 EXPECT_EQ(64u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 2543 EXPECT_EQ(64u, active_layer_->HighResTiling()->AllTilesForTesting().size()); |
2536 | 2544 |
2537 // Visible viewport should be covered by 4 tiles. No other | 2545 // Visible viewport should be covered by 4 tiles. No other |
2538 // tiles should be required for activation. | 2546 // tiles should be required for activation. |
2539 EXPECT_EQ(4u, NumberOfTilesRequired(active_layer_->HighResTiling())); | 2547 EXPECT_EQ(4u, NumberOfTilesRequired(active_layer_->HighResTiling())); |
2540 } | 2548 } |
2541 | 2549 |
2542 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { | 2550 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
2543 // Set up layers with tilings. | 2551 // Set up layers with tilings. |
2544 SetupDefaultTrees(gfx::Size(10, 10)); | 2552 SetupDefaultTrees(gfx::Size(10, 10)); |
2545 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); | 2553 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, 0.f, false); |
2546 pending_layer_->PushPropertiesTo(active_layer_); | 2554 pending_layer_->PushPropertiesTo(active_layer_); |
2547 EXPECT_TRUE(pending_layer_->DrawsContent()); | 2555 EXPECT_TRUE(pending_layer_->DrawsContent()); |
2548 EXPECT_TRUE(pending_layer_->CanHaveTilings()); | 2556 EXPECT_TRUE(pending_layer_->CanHaveTilings()); |
2549 EXPECT_GE(pending_layer_->num_tilings(), 0u); | 2557 EXPECT_GE(pending_layer_->num_tilings(), 0u); |
2550 EXPECT_GE(active_layer_->num_tilings(), 0u); | 2558 EXPECT_GE(active_layer_->num_tilings(), 0u); |
2551 | 2559 |
2552 // Set content to false, which should make CanHaveTilings return false. | 2560 // Set content to false, which should make CanHaveTilings return false. |
2553 pending_layer_->SetDrawsContent(false); | 2561 pending_layer_->SetDrawsContent(false); |
2554 EXPECT_FALSE(pending_layer_->DrawsContent()); | 2562 EXPECT_FALSE(pending_layer_->DrawsContent()); |
2555 EXPECT_FALSE(pending_layer_->CanHaveTilings()); | 2563 EXPECT_FALSE(pending_layer_->CanHaveTilings()); |
2556 | 2564 |
2557 // No tilings should be pushed to active layer. | 2565 // No tilings should be pushed to active layer. |
2558 pending_layer_->PushPropertiesTo(active_layer_); | 2566 pending_layer_->PushPropertiesTo(active_layer_); |
2559 EXPECT_EQ(0u, active_layer_->num_tilings()); | 2567 EXPECT_EQ(0u, active_layer_->num_tilings()); |
2560 } | 2568 } |
2561 | 2569 |
2562 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { | 2570 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { |
2563 SetupDefaultTrees(gfx::Size(10, 10)); | 2571 SetupDefaultTrees(gfx::Size(10, 10)); |
2564 | 2572 |
2565 // We start with a tiling at scale 1. | 2573 // We start with a tiling at scale 1. |
2566 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 2574 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
2567 | 2575 |
2568 // When we scale up by 2.3, we get a new tiling that is a power of 2, in this | 2576 // When we scale up by 2.3, we get a new tiling that is a power of 2, in this |
2569 // case 4. | 2577 // case 4. |
2570 host_impl_.PinchGestureBegin(); | 2578 host_impl_.PinchGestureBegin(); |
2571 float high_res_scale = 2.3f; | 2579 float high_res_scale = 2.3f; |
2572 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, false); | 2580 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, 0.f, false); |
2573 EXPECT_EQ(4.f, pending_layer_->HighResTiling()->contents_scale()); | 2581 EXPECT_EQ(4.f, pending_layer_->HighResTiling()->contents_scale()); |
2574 } | 2582 } |
2575 | 2583 |
2576 TEST_F(PictureLayerImplTest, PinchingTooSmall) { | 2584 TEST_F(PictureLayerImplTest, PinchingTooSmall) { |
2577 SetupDefaultTrees(gfx::Size(10, 10)); | 2585 SetupDefaultTrees(gfx::Size(10, 10)); |
2578 | 2586 |
2579 // We start with a tiling at scale 1. | 2587 // We start with a tiling at scale 1. |
2580 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 2588 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
2581 | 2589 |
2582 host_impl_.PinchGestureBegin(); | 2590 host_impl_.PinchGestureBegin(); |
2583 float high_res_scale = 0.0001f; | 2591 float high_res_scale = 0.0001f; |
2584 EXPECT_LT(high_res_scale, pending_layer_->MinimumContentsScale()); | 2592 EXPECT_LT(high_res_scale, pending_layer_->MinimumContentsScale()); |
2585 | 2593 |
2586 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, false); | 2594 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, 0.f, |
| 2595 false); |
2587 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), | 2596 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
2588 pending_layer_->HighResTiling()->contents_scale()); | 2597 pending_layer_->HighResTiling()->contents_scale()); |
2589 } | 2598 } |
2590 | 2599 |
2591 TEST_F(PictureLayerImplTest, PinchingTooSmallWithContentsScale) { | 2600 TEST_F(PictureLayerImplTest, PinchingTooSmallWithContentsScale) { |
2592 SetupDefaultTrees(gfx::Size(10, 10)); | 2601 SetupDefaultTrees(gfx::Size(10, 10)); |
2593 | 2602 |
2594 ResetTilingsAndRasterScales(); | 2603 ResetTilingsAndRasterScales(); |
2595 | 2604 |
2596 float contents_scale = 0.15f; | 2605 float contents_scale = 0.15f; |
2597 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, false); | 2606 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, 0.f, false); |
2598 | 2607 |
2599 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 2608 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
2600 EXPECT_FLOAT_EQ(contents_scale, | 2609 EXPECT_FLOAT_EQ(contents_scale, |
2601 pending_layer_->HighResTiling()->contents_scale()); | 2610 pending_layer_->HighResTiling()->contents_scale()); |
2602 | 2611 |
2603 host_impl_.PinchGestureBegin(); | 2612 host_impl_.PinchGestureBegin(); |
2604 | 2613 |
2605 float page_scale = 0.0001f; | 2614 float page_scale = 0.0001f; |
2606 EXPECT_LT(page_scale * contents_scale, | 2615 EXPECT_LT(page_scale * contents_scale, |
2607 pending_layer_->MinimumContentsScale()); | 2616 pending_layer_->MinimumContentsScale()); |
2608 | 2617 |
2609 SetContentsScaleOnBothLayers(contents_scale * page_scale, 1.f, page_scale, | 2618 SetContentsScaleOnBothLayers(contents_scale * page_scale, 1.f, page_scale, |
2610 1.f, false); | 2619 1.f, 0.f, false); |
2611 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 2620 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
2612 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), | 2621 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
2613 pending_layer_->HighResTiling()->contents_scale()); | 2622 pending_layer_->HighResTiling()->contents_scale()); |
2614 } | 2623 } |
2615 | 2624 |
| 2625 TEST_F(PictureLayerImplTest, ConsiderAnimationStartScaleForRasterScale) { |
| 2626 gfx::Size viewport_size(1000, 1000); |
| 2627 host_impl_.SetViewportSize(viewport_size); |
| 2628 |
| 2629 gfx::Size layer_bounds(100, 100); |
| 2630 SetupDefaultTrees(layer_bounds); |
| 2631 |
| 2632 float contents_scale = 2.f; |
| 2633 float device_scale = 1.f; |
| 2634 float page_scale = 1.f; |
| 2635 float maximum_animation_scale = 3.f; |
| 2636 float starting_animation_scale = 1.f; |
| 2637 bool animating_transform = true; |
| 2638 |
| 2639 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 2640 |
| 2641 // Maximum animation scale is greater than starting animation scale |
| 2642 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2643 maximum_animation_scale, |
| 2644 starting_animation_scale, animating_transform); |
| 2645 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
| 2646 |
| 2647 animating_transform = false; |
| 2648 |
| 2649 // Once we stop animating, a new high-res tiling should be created. |
| 2650 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2651 maximum_animation_scale, |
| 2652 starting_animation_scale, animating_transform); |
| 2653 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
| 2654 |
| 2655 // Starting animation scale greater than maximum animation scale |
| 2656 // Bounds at starting scale within the viewport |
| 2657 animating_transform = true; |
| 2658 starting_animation_scale = 5.f; |
| 2659 |
| 2660 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2661 maximum_animation_scale, |
| 2662 starting_animation_scale, animating_transform); |
| 2663 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 5.f); |
| 2664 |
| 2665 // Once we stop animating, a new high-res tiling should be created. |
| 2666 animating_transform = false; |
| 2667 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2668 maximum_animation_scale, |
| 2669 starting_animation_scale, animating_transform); |
| 2670 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
| 2671 |
| 2672 // Starting Animation scale greater than maximum animation scale |
| 2673 // Bounds at starting scale outisde the viewport |
| 2674 animating_transform = true; |
| 2675 starting_animation_scale = 11.f; |
| 2676 |
| 2677 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 2678 maximum_animation_scale, |
| 2679 starting_animation_scale, animating_transform); |
| 2680 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
| 2681 } |
| 2682 |
2616 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { | 2683 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { |
2617 gfx::Size viewport_size(1000, 1000); | 2684 gfx::Size viewport_size(1000, 1000); |
2618 host_impl_.SetViewportSize(viewport_size); | 2685 host_impl_.SetViewportSize(viewport_size); |
2619 | 2686 |
2620 gfx::Size layer_bounds(100, 100); | 2687 gfx::Size layer_bounds(100, 100); |
2621 SetupDefaultTrees(layer_bounds); | 2688 SetupDefaultTrees(layer_bounds); |
2622 | 2689 |
2623 float contents_scale = 1.f; | 2690 float contents_scale = 1.f; |
2624 float device_scale = 1.f; | 2691 float device_scale = 1.f; |
2625 float page_scale = 1.f; | 2692 float page_scale = 1.f; |
2626 float maximum_animation_scale = 1.f; | 2693 float maximum_animation_scale = 1.f; |
| 2694 float starting_animation_scale = 0.f; |
2627 bool animating_transform = false; | 2695 bool animating_transform = false; |
2628 | 2696 |
2629 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2697 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
2630 | 2698 |
2631 // Since we're CPU-rasterizing, starting an animation should cause tiling | 2699 // Since we're CPU-rasterizing, starting an animation should cause tiling |
2632 // resolution to get set to the maximum animation scale factor. | 2700 // resolution to get set to the maximum animation scale factor. |
2633 animating_transform = true; | 2701 animating_transform = true; |
2634 maximum_animation_scale = 3.f; | 2702 maximum_animation_scale = 3.f; |
2635 contents_scale = 2.f; | 2703 contents_scale = 2.f; |
2636 | 2704 |
2637 SetContentsScaleOnBothLayers(contents_scale, | 2705 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2638 device_scale, | |
2639 page_scale, | |
2640 maximum_animation_scale, | 2706 maximum_animation_scale, |
2641 animating_transform); | 2707 starting_animation_scale, animating_transform); |
2642 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 2708 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
2643 | 2709 |
2644 // Further changes to scale during the animation should not cause a new | 2710 // Further changes to scale during the animation should not cause a new |
2645 // high-res tiling to get created. | 2711 // high-res tiling to get created. |
2646 contents_scale = 4.f; | 2712 contents_scale = 4.f; |
2647 maximum_animation_scale = 5.f; | 2713 maximum_animation_scale = 5.f; |
2648 | 2714 |
2649 SetContentsScaleOnBothLayers(contents_scale, | 2715 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2650 device_scale, | |
2651 page_scale, | |
2652 maximum_animation_scale, | 2716 maximum_animation_scale, |
2653 animating_transform); | 2717 starting_animation_scale, animating_transform); |
2654 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 2718 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
2655 | 2719 |
2656 // Once we stop animating, a new high-res tiling should be created. | 2720 // Once we stop animating, a new high-res tiling should be created. |
2657 animating_transform = false; | 2721 animating_transform = false; |
2658 | 2722 |
2659 SetContentsScaleOnBothLayers(contents_scale, | 2723 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2660 device_scale, | |
2661 page_scale, | |
2662 maximum_animation_scale, | 2724 maximum_animation_scale, |
2663 animating_transform); | 2725 starting_animation_scale, animating_transform); |
2664 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2726 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
2665 | 2727 |
2666 // When animating with an unknown maximum animation scale factor, a new | 2728 // When animating with an unknown maximum animation scale factor, a new |
2667 // high-res tiling should be created at a source scale of 1. | 2729 // high-res tiling should be created at a source scale of 1. |
2668 animating_transform = true; | 2730 animating_transform = true; |
2669 contents_scale = 2.f; | 2731 contents_scale = 2.f; |
2670 maximum_animation_scale = 0.f; | 2732 maximum_animation_scale = 0.f; |
2671 | 2733 |
2672 SetContentsScaleOnBothLayers(contents_scale, | 2734 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2673 device_scale, | |
2674 page_scale, | |
2675 maximum_animation_scale, | 2735 maximum_animation_scale, |
2676 animating_transform); | 2736 starting_animation_scale, animating_transform); |
2677 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); | 2737 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
2678 | 2738 |
2679 // Further changes to scale during the animation should not cause a new | 2739 // Further changes to scale during the animation should not cause a new |
2680 // high-res tiling to get created. | 2740 // high-res tiling to get created. |
2681 contents_scale = 3.f; | 2741 contents_scale = 3.f; |
2682 | 2742 |
2683 SetContentsScaleOnBothLayers(contents_scale, | 2743 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2684 device_scale, | |
2685 page_scale, | |
2686 maximum_animation_scale, | 2744 maximum_animation_scale, |
2687 animating_transform); | 2745 starting_animation_scale, animating_transform); |
2688 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); | 2746 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
2689 | 2747 |
2690 // Once we stop animating, a new high-res tiling should be created. | 2748 // Once we stop animating, a new high-res tiling should be created. |
2691 animating_transform = false; | 2749 animating_transform = false; |
2692 contents_scale = 4.f; | 2750 contents_scale = 4.f; |
2693 | 2751 |
2694 SetContentsScaleOnBothLayers(contents_scale, | 2752 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2695 device_scale, | |
2696 page_scale, | |
2697 maximum_animation_scale, | 2753 maximum_animation_scale, |
2698 animating_transform); | 2754 starting_animation_scale, animating_transform); |
2699 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2755 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
2700 | 2756 |
2701 // When animating with a maxmium animation scale factor that is so large | 2757 // When animating with a maxmium animation scale factor that is so large |
2702 // that the layer grows larger than the viewport at this scale, a new | 2758 // that the layer grows larger than the viewport at this scale, a new |
2703 // high-res tiling should get created at a source scale of 1, not at its | 2759 // high-res tiling should get created at a source scale of 1, not at its |
2704 // maximum scale. | 2760 // maximum scale. |
2705 animating_transform = true; | 2761 animating_transform = true; |
2706 contents_scale = 2.f; | 2762 contents_scale = 2.f; |
2707 maximum_animation_scale = 11.f; | 2763 maximum_animation_scale = 11.f; |
2708 | 2764 |
2709 SetContentsScaleOnBothLayers(contents_scale, | 2765 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2710 device_scale, | |
2711 page_scale, | |
2712 maximum_animation_scale, | 2766 maximum_animation_scale, |
2713 animating_transform); | 2767 starting_animation_scale, animating_transform); |
2714 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); | 2768 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
2715 | 2769 |
2716 // Once we stop animating, a new high-res tiling should be created. | 2770 // Once we stop animating, a new high-res tiling should be created. |
2717 animating_transform = false; | 2771 animating_transform = false; |
2718 contents_scale = 11.f; | 2772 contents_scale = 11.f; |
2719 | 2773 |
2720 SetContentsScaleOnBothLayers(contents_scale, | 2774 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2721 device_scale, | |
2722 page_scale, | |
2723 maximum_animation_scale, | 2775 maximum_animation_scale, |
2724 animating_transform); | 2776 starting_animation_scale, animating_transform); |
2725 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); | 2777 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); |
2726 | 2778 |
2727 // When animating with a maxmium animation scale factor that is so large | 2779 // When animating with a maxmium animation scale factor that is so large |
2728 // that the layer grows larger than the viewport at this scale, and where | 2780 // that the layer grows larger than the viewport at this scale, and where |
2729 // the intial source scale is < 1, a new high-res tiling should get created | 2781 // the intial source scale is < 1, a new high-res tiling should get created |
2730 // at source scale 1. | 2782 // at source scale 1. |
2731 animating_transform = true; | 2783 animating_transform = true; |
2732 contents_scale = 0.1f; | 2784 contents_scale = 0.1f; |
2733 maximum_animation_scale = 11.f; | 2785 maximum_animation_scale = 11.f; |
2734 | 2786 |
2735 SetContentsScaleOnBothLayers(contents_scale, | 2787 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2736 device_scale, | |
2737 page_scale, | |
2738 maximum_animation_scale, | 2788 maximum_animation_scale, |
2739 animating_transform); | 2789 starting_animation_scale, animating_transform); |
2740 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); | 2790 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); |
2741 | 2791 |
2742 // Once we stop animating, a new high-res tiling should be created. | 2792 // Once we stop animating, a new high-res tiling should be created. |
2743 animating_transform = false; | 2793 animating_transform = false; |
2744 contents_scale = 12.f; | 2794 contents_scale = 12.f; |
2745 | 2795 |
2746 SetContentsScaleOnBothLayers(contents_scale, | 2796 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2747 device_scale, | |
2748 page_scale, | |
2749 maximum_animation_scale, | 2797 maximum_animation_scale, |
2750 animating_transform); | 2798 starting_animation_scale, animating_transform); |
2751 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 12.f); | 2799 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 12.f); |
2752 | 2800 |
2753 // When animating toward a smaller scale, but that is still so large that the | 2801 // When animating toward a smaller scale, but that is still so large that the |
2754 // layer grows larger than the viewport at this scale, a new high-res tiling | 2802 // layer grows larger than the viewport at this scale, a new high-res tiling |
2755 // should get created at source scale 1. | 2803 // should get created at source scale 1. |
2756 animating_transform = true; | 2804 animating_transform = true; |
2757 contents_scale = 11.f; | 2805 contents_scale = 11.f; |
2758 maximum_animation_scale = 11.f; | 2806 maximum_animation_scale = 11.f; |
2759 | 2807 |
2760 SetContentsScaleOnBothLayers(contents_scale, | 2808 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2761 device_scale, | |
2762 page_scale, | |
2763 maximum_animation_scale, | 2809 maximum_animation_scale, |
2764 animating_transform); | 2810 starting_animation_scale, animating_transform); |
2765 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); | 2811 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); |
2766 | 2812 |
2767 // Once we stop animating, a new high-res tiling should be created. | 2813 // Once we stop animating, a new high-res tiling should be created. |
2768 animating_transform = false; | 2814 animating_transform = false; |
2769 contents_scale = 11.f; | 2815 contents_scale = 11.f; |
2770 | 2816 |
2771 SetContentsScaleOnBothLayers(contents_scale, | 2817 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2772 device_scale, | |
2773 page_scale, | |
2774 maximum_animation_scale, | 2818 maximum_animation_scale, |
2775 animating_transform); | 2819 starting_animation_scale, animating_transform); |
2776 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); | 2820 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); |
2777 } | 2821 } |
2778 | 2822 |
2779 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForGpuRasterization) { | 2823 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForGpuRasterization) { |
2780 gfx::Size layer_bounds(100, 100); | 2824 gfx::Size layer_bounds(100, 100); |
2781 gfx::Size viewport_size(1000, 1000); | 2825 gfx::Size viewport_size(1000, 1000); |
2782 SetupDefaultTrees(layer_bounds); | 2826 SetupDefaultTrees(layer_bounds); |
2783 host_impl_.SetViewportSize(viewport_size); | 2827 host_impl_.SetViewportSize(viewport_size); |
2784 host_impl_.SetUseGpuRasterization(true); | 2828 host_impl_.SetUseGpuRasterization(true); |
2785 | 2829 |
2786 float contents_scale = 1.f; | 2830 float contents_scale = 1.f; |
2787 float device_scale = 1.3f; | 2831 float device_scale = 1.3f; |
2788 float page_scale = 1.4f; | 2832 float page_scale = 1.4f; |
2789 float maximum_animation_scale = 1.f; | 2833 float maximum_animation_scale = 1.f; |
| 2834 float starting_animation_scale = 0.f; |
2790 bool animating_transform = false; | 2835 bool animating_transform = false; |
2791 | 2836 |
2792 SetContentsScaleOnBothLayers(contents_scale, | 2837 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2793 device_scale, | |
2794 page_scale, | |
2795 maximum_animation_scale, | 2838 maximum_animation_scale, |
2796 animating_transform); | 2839 starting_animation_scale, animating_transform); |
2797 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2840 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
2798 | 2841 |
2799 // Since we're GPU-rasterizing, starting an animation should cause tiling | 2842 // Since we're GPU-rasterizing, starting an animation should cause tiling |
2800 // resolution to get set to the current contents scale. | 2843 // resolution to get set to the current contents scale. |
2801 animating_transform = true; | 2844 animating_transform = true; |
2802 contents_scale = 2.f; | 2845 contents_scale = 2.f; |
2803 maximum_animation_scale = 4.f; | 2846 maximum_animation_scale = 4.f; |
2804 | 2847 |
2805 SetContentsScaleOnBothLayers(contents_scale, | 2848 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2806 device_scale, | |
2807 page_scale, | |
2808 maximum_animation_scale, | 2849 maximum_animation_scale, |
2809 animating_transform); | 2850 starting_animation_scale, animating_transform); |
2810 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2851 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
2811 | 2852 |
2812 // Further changes to scale during the animation should cause a new high-res | 2853 // Further changes to scale during the animation should cause a new high-res |
2813 // tiling to get created. | 2854 // tiling to get created. |
2814 contents_scale = 3.f; | 2855 contents_scale = 3.f; |
2815 | 2856 |
2816 SetContentsScaleOnBothLayers(contents_scale, | 2857 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2817 device_scale, | |
2818 page_scale, | |
2819 maximum_animation_scale, | 2858 maximum_animation_scale, |
2820 animating_transform); | 2859 starting_animation_scale, animating_transform); |
2821 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 2860 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
2822 | 2861 |
2823 // Since we're re-rasterizing during the animation, scales smaller than 1 | 2862 // Since we're re-rasterizing during the animation, scales smaller than 1 |
2824 // should be respected. | 2863 // should be respected. |
2825 contents_scale = 0.25f; | 2864 contents_scale = 0.25f; |
2826 | 2865 |
2827 SetContentsScaleOnBothLayers(contents_scale, | 2866 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2828 device_scale, | |
2829 page_scale, | |
2830 maximum_animation_scale, | 2867 maximum_animation_scale, |
2831 animating_transform); | 2868 starting_animation_scale, animating_transform); |
2832 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.25f); | 2869 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.25f); |
2833 | 2870 |
2834 // Once we stop animating, a new high-res tiling should be created. | 2871 // Once we stop animating, a new high-res tiling should be created. |
2835 contents_scale = 4.f; | 2872 contents_scale = 4.f; |
2836 animating_transform = false; | 2873 animating_transform = false; |
2837 | 2874 |
2838 SetContentsScaleOnBothLayers(contents_scale, | 2875 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
2839 device_scale, | |
2840 page_scale, | |
2841 maximum_animation_scale, | 2876 maximum_animation_scale, |
2842 animating_transform); | 2877 starting_animation_scale, animating_transform); |
2843 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2878 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
2844 } | 2879 } |
2845 | 2880 |
2846 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { | 2881 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { |
2847 base::TimeTicks time_ticks; | 2882 base::TimeTicks time_ticks; |
2848 time_ticks += base::TimeDelta::FromMilliseconds(1); | 2883 time_ticks += base::TimeDelta::FromMilliseconds(1); |
2849 host_impl_.SetCurrentBeginFrameArgs( | 2884 host_impl_.SetCurrentBeginFrameArgs( |
2850 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2885 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
2851 | 2886 |
2852 host_impl_.SetViewportSize(gfx::Size(500, 500)); | 2887 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3256 TEST_F(PictureLayerImplTest, RasterScaleChangeWithoutAnimation) { | 3291 TEST_F(PictureLayerImplTest, RasterScaleChangeWithoutAnimation) { |
3257 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 3292 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
3258 SetupDefaultTrees(tile_size); | 3293 SetupDefaultTrees(tile_size); |
3259 | 3294 |
3260 ResetTilingsAndRasterScales(); | 3295 ResetTilingsAndRasterScales(); |
3261 | 3296 |
3262 float contents_scale = 2.f; | 3297 float contents_scale = 2.f; |
3263 float device_scale = 1.f; | 3298 float device_scale = 1.f; |
3264 float page_scale = 1.f; | 3299 float page_scale = 1.f; |
3265 float maximum_animation_scale = 1.f; | 3300 float maximum_animation_scale = 1.f; |
| 3301 float starting_animation_scale = 0.f; |
3266 bool animating_transform = false; | 3302 bool animating_transform = false; |
3267 | 3303 |
3268 SetContentsScaleOnBothLayers(contents_scale, | 3304 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3269 device_scale, | |
3270 page_scale, | |
3271 maximum_animation_scale, | 3305 maximum_animation_scale, |
3272 animating_transform); | 3306 starting_animation_scale, animating_transform); |
3273 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 3307 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
3274 | 3308 |
3275 // Changing the source scale without being in an animation will cause | 3309 // Changing the source scale without being in an animation will cause |
3276 // the layer to reset its source scale to 1.f. | 3310 // the layer to reset its source scale to 1.f. |
3277 contents_scale = 3.f; | 3311 contents_scale = 3.f; |
3278 | 3312 |
3279 SetContentsScaleOnBothLayers(contents_scale, | 3313 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3280 device_scale, | |
3281 page_scale, | |
3282 maximum_animation_scale, | 3314 maximum_animation_scale, |
3283 animating_transform); | 3315 starting_animation_scale, animating_transform); |
3284 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 3316 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
3285 | 3317 |
3286 // Further changes to the source scale will no longer be reflected in the | 3318 // Further changes to the source scale will no longer be reflected in the |
3287 // contents scale. | 3319 // contents scale. |
3288 contents_scale = 0.5f; | 3320 contents_scale = 0.5f; |
3289 | 3321 |
3290 SetContentsScaleOnBothLayers(contents_scale, | 3322 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
3291 device_scale, | |
3292 page_scale, | |
3293 maximum_animation_scale, | 3323 maximum_animation_scale, |
3294 animating_transform); | 3324 starting_animation_scale, animating_transform); |
3295 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 3325 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
3296 } | 3326 } |
3297 | 3327 |
3298 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3328 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
3299 gfx::Size tile_size(100, 100); | 3329 gfx::Size tile_size(100, 100); |
3300 gfx::Size layer_bounds(1000, 1000); | 3330 gfx::Size layer_bounds(1000, 1000); |
3301 | 3331 |
3302 // Make sure pending tree has tiles. | 3332 // Make sure pending tree has tiles. |
3303 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3333 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3304 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3334 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3394 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 3424 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
3395 EXPECT_LT(low_res_factor, 1.f); | 3425 EXPECT_LT(low_res_factor, 1.f); |
3396 | 3426 |
3397 ResetTilingsAndRasterScales(); | 3427 ResetTilingsAndRasterScales(); |
3398 | 3428 |
3399 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 3429 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
3400 6.f, // ideal contents scale | 3430 6.f, // ideal contents scale |
3401 3.f, // device scale | 3431 3.f, // device scale |
3402 2.f, // page scale | 3432 2.f, // page scale |
3403 1.f, // maximum animation scale | 3433 1.f, // maximum animation scale |
| 3434 0.f, // starting animation scale |
3404 false); | 3435 false); |
3405 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3436 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3406 EXPECT_FLOAT_EQ(6.f, | 3437 EXPECT_FLOAT_EQ(6.f, |
3407 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 3438 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
3408 | 3439 |
3409 // If we change the page scale factor, then we should get new tilings. | 3440 // If we change the page scale factor, then we should get new tilings. |
3410 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 3441 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
3411 6.6f, // ideal contents scale | 3442 6.6f, // ideal contents scale |
3412 3.f, // device scale | 3443 3.f, // device scale |
3413 2.2f, // page scale | 3444 2.2f, // page scale |
3414 1.f, // maximum animation scale | 3445 1.f, // maximum animation scale |
| 3446 0.f, // starting animation scale |
3415 false); | 3447 false); |
3416 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3448 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3417 EXPECT_FLOAT_EQ(6.6f, | 3449 EXPECT_FLOAT_EQ(6.6f, |
3418 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 3450 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
3419 | 3451 |
3420 // If we change the device scale factor, then we should get new tilings. | 3452 // If we change the device scale factor, then we should get new tilings. |
3421 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 3453 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
3422 7.26f, // ideal contents scale | 3454 7.26f, // ideal contents scale |
3423 3.3f, // device scale | 3455 3.3f, // device scale |
3424 2.2f, // page scale | 3456 2.2f, // page scale |
3425 1.f, // maximum animation scale | 3457 1.f, // maximum animation scale |
| 3458 0.f, // starting animation scale |
3426 false); | 3459 false); |
3427 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 3460 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
3428 EXPECT_FLOAT_EQ(7.26f, | 3461 EXPECT_FLOAT_EQ(7.26f, |
3429 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 3462 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
3430 | 3463 |
3431 // If we change the device scale factor, but end up at the same total scale | 3464 // If we change the device scale factor, but end up at the same total scale |
3432 // factor somehow, then we don't get new tilings. | 3465 // factor somehow, then we don't get new tilings. |
3433 SetupDrawPropertiesAndUpdateTiles(active_layer_, | 3466 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
3434 7.26f, // ideal contents scale | 3467 7.26f, // ideal contents scale |
3435 2.2f, // device scale | 3468 2.2f, // device scale |
3436 3.3f, // page scale | 3469 3.3f, // page scale |
3437 1.f, // maximum animation scale | 3470 1.f, // maximum animation scale |
| 3471 0.f, // starting animation scale |
3438 false); | 3472 false); |
3439 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 3473 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
3440 EXPECT_FLOAT_EQ(7.26f, | 3474 EXPECT_FLOAT_EQ(7.26f, |
3441 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 3475 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
3442 } | 3476 } |
3443 | 3477 |
3444 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { | 3478 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { |
3445 gfx::Size tile_size(400, 400); | 3479 gfx::Size tile_size(400, 400); |
3446 gfx::Size layer_bounds(1300, 1900); | 3480 gfx::Size layer_bounds(1300, 1900); |
3447 | 3481 |
3448 scoped_refptr<FakePicturePileImpl> pending_pile = | 3482 scoped_refptr<FakePicturePileImpl> pending_pile = |
3449 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3483 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3450 scoped_refptr<FakePicturePileImpl> active_pile = | 3484 scoped_refptr<FakePicturePileImpl> active_pile = |
3451 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3485 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3452 | 3486 |
3453 SetupTrees(pending_pile, active_pile); | 3487 SetupTrees(pending_pile, active_pile); |
3454 | 3488 |
3455 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 3489 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
3456 EXPECT_LT(low_res_factor, 1.f); | 3490 EXPECT_LT(low_res_factor, 1.f); |
3457 | 3491 |
3458 ResetTilingsAndRasterScales(); | 3492 ResetTilingsAndRasterScales(); |
3459 | 3493 |
3460 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3494 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3461 6.f, // ideal contents scale | 3495 6.f, // ideal contents scale |
3462 3.f, // device scale | 3496 3.f, // device scale |
3463 2.f, // page scale | 3497 2.f, // page scale |
3464 1.f, // maximum animation scale | 3498 1.f, // maximum animation scale |
| 3499 0.f, // starting animation scale |
3465 false); | 3500 false); |
3466 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3501 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3467 EXPECT_FLOAT_EQ(6.f, | 3502 EXPECT_FLOAT_EQ(6.f, |
3468 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3503 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
3469 | 3504 |
3470 // If we change the page scale factor, then we should get new tilings. | 3505 // If we change the page scale factor, then we should get new tilings. |
3471 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3506 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3472 6.6f, // ideal contents scale | 3507 6.6f, // ideal contents scale |
3473 3.f, // device scale | 3508 3.f, // device scale |
3474 2.2f, // page scale | 3509 2.2f, // page scale |
3475 1.f, // maximum animation scale | 3510 1.f, // maximum animation scale |
| 3511 0.f, // starting animation scale |
3476 false); | 3512 false); |
3477 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3513 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3478 EXPECT_FLOAT_EQ(6.6f, | 3514 EXPECT_FLOAT_EQ(6.6f, |
3479 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3515 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
3480 | 3516 |
3481 // If we change the device scale factor, then we should get new tilings. | 3517 // If we change the device scale factor, then we should get new tilings. |
3482 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3518 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3483 7.26f, // ideal contents scale | 3519 7.26f, // ideal contents scale |
3484 3.3f, // device scale | 3520 3.3f, // device scale |
3485 2.2f, // page scale | 3521 2.2f, // page scale |
3486 1.f, // maximum animation scale | 3522 1.f, // maximum animation scale |
| 3523 0.f, // starting animation scale |
3487 false); | 3524 false); |
3488 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3525 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3489 EXPECT_FLOAT_EQ(7.26f, | 3526 EXPECT_FLOAT_EQ(7.26f, |
3490 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3527 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
3491 | 3528 |
3492 // If we change the device scale factor, but end up at the same total scale | 3529 // If we change the device scale factor, but end up at the same total scale |
3493 // factor somehow, then we don't get new tilings. | 3530 // factor somehow, then we don't get new tilings. |
3494 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3531 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3495 7.26f, // ideal contents scale | 3532 7.26f, // ideal contents scale |
3496 2.2f, // device scale | 3533 2.2f, // device scale |
3497 3.3f, // page scale | 3534 3.3f, // page scale |
3498 1.f, // maximum animation scale | 3535 1.f, // maximum animation scale |
| 3536 0.f, // starting animation scale |
3499 false); | 3537 false); |
3500 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3538 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3501 EXPECT_FLOAT_EQ(7.26f, | 3539 EXPECT_FLOAT_EQ(7.26f, |
3502 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3540 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
3503 } | 3541 } |
3504 | 3542 |
3505 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { | 3543 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) { |
3506 gfx::Size layer_bounds(400, 400); | 3544 gfx::Size layer_bounds(400, 400); |
3507 gfx::Size tile_size(100, 100); | 3545 gfx::Size tile_size(100, 100); |
3508 | 3546 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3569 gfx::Size tile_size(100, 100); | 3607 gfx::Size tile_size(100, 100); |
3570 gfx::Size layer_bounds(400, 400); | 3608 gfx::Size layer_bounds(400, 400); |
3571 | 3609 |
3572 scoped_refptr<FakePicturePileImpl> pending_pile = | 3610 scoped_refptr<FakePicturePileImpl> pending_pile = |
3573 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3611 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3574 scoped_refptr<FakePicturePileImpl> active_pile = | 3612 scoped_refptr<FakePicturePileImpl> active_pile = |
3575 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3613 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3576 | 3614 |
3577 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); | 3615 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
3578 | 3616 |
3579 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 3617 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 3618 false); |
3580 | 3619 |
3581 // UpdateTiles with valid viewport. Should update tile viewport. | 3620 // UpdateTiles with valid viewport. Should update tile viewport. |
3582 // Note viewport is considered invalid if and only if in resourceless | 3621 // Note viewport is considered invalid if and only if in resourceless |
3583 // software draw. | 3622 // software draw. |
3584 bool resourceless_software_draw = false; | 3623 bool resourceless_software_draw = false; |
3585 gfx::Rect viewport = gfx::Rect(layer_bounds); | 3624 gfx::Rect viewport = gfx::Rect(layer_bounds); |
3586 gfx::Transform transform; | 3625 gfx::Transform transform; |
3587 host_impl_.SetExternalDrawConstraints(transform, | 3626 host_impl_.SetExternalDrawConstraints(transform, |
3588 viewport, | 3627 viewport, |
3589 viewport, | 3628 viewport, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3658 | 3697 |
3659 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 3698 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
3660 EXPECT_LT(low_res_factor, 1.f); | 3699 EXPECT_LT(low_res_factor, 1.f); |
3661 | 3700 |
3662 float device_scale = 1.7f; | 3701 float device_scale = 1.7f; |
3663 float page_scale = 3.2f; | 3702 float page_scale = 3.2f; |
3664 float scale = 1.f; | 3703 float scale = 1.f; |
3665 | 3704 |
3666 ResetTilingsAndRasterScales(); | 3705 ResetTilingsAndRasterScales(); |
3667 | 3706 |
3668 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); | 3707 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, 0.f, |
| 3708 false); |
3669 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3709 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3670 | 3710 |
3671 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to | 3711 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to |
3672 // |used_tilings| variable, and it's here only to ensure that active_layer_ | 3712 // |used_tilings| variable, and it's here only to ensure that active_layer_ |
3673 // won't remove tilings before the test has a chance to verify behavior. | 3713 // won't remove tilings before the test has a chance to verify behavior. |
3674 active_layer_->MarkAllTilingsUsed(); | 3714 active_layer_->MarkAllTilingsUsed(); |
3675 | 3715 |
3676 // We only have ideal tilings, so they aren't removed. | 3716 // We only have ideal tilings, so they aren't removed. |
3677 used_tilings.clear(); | 3717 used_tilings.clear(); |
3678 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3718 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3679 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3719 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3680 | 3720 |
3681 host_impl_.PinchGestureBegin(); | 3721 host_impl_.PinchGestureBegin(); |
3682 | 3722 |
3683 // Changing the ideal but not creating new tilings. | 3723 // Changing the ideal but not creating new tilings. |
3684 scale *= 1.5f; | 3724 scale *= 1.5f; |
3685 page_scale *= 1.5f; | 3725 page_scale *= 1.5f; |
3686 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); | 3726 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, 0.f, |
| 3727 false); |
3687 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3728 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3688 | 3729 |
3689 // The tilings are still our target scale, so they aren't removed. | 3730 // The tilings are still our target scale, so they aren't removed. |
3690 used_tilings.clear(); | 3731 used_tilings.clear(); |
3691 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3732 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3692 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3733 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3693 | 3734 |
3694 host_impl_.PinchGestureEnd(); | 3735 host_impl_.PinchGestureEnd(); |
3695 | 3736 |
3696 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 3737 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
3697 scale /= 4.f; | 3738 scale /= 4.f; |
3698 page_scale /= 4.f; | 3739 page_scale /= 4.f; |
3699 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, false); | 3740 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, 0.f, false); |
3700 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3741 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3701 EXPECT_FLOAT_EQ(1.f, | 3742 EXPECT_FLOAT_EQ(1.f, |
3702 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 3743 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
3703 | 3744 |
3704 // Ensure UpdateTiles won't remove any tilings. | 3745 // Ensure UpdateTiles won't remove any tilings. |
3705 active_layer_->MarkAllTilingsUsed(); | 3746 active_layer_->MarkAllTilingsUsed(); |
3706 | 3747 |
3707 // Mark the non-ideal tilings as used. They won't be removed. | 3748 // Mark the non-ideal tilings as used. They won't be removed. |
3708 used_tilings.clear(); | 3749 used_tilings.clear(); |
3709 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 3750 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
3710 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3751 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3711 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3752 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3712 | 3753 |
3713 // Now move the ideal scale to 0.5. Our target stays 1.2. | 3754 // Now move the ideal scale to 0.5. Our target stays 1.2. |
3714 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, false); | 3755 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, 0.f, false); |
3715 | 3756 |
3716 // The high resolution tiling is between target and ideal, so is not | 3757 // The high resolution tiling is between target and ideal, so is not |
3717 // removed. The low res tiling for the old ideal=1.0 scale is removed. | 3758 // removed. The low res tiling for the old ideal=1.0 scale is removed. |
3718 used_tilings.clear(); | 3759 used_tilings.clear(); |
3719 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3760 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3720 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3761 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3721 | 3762 |
3722 // Now move the ideal scale to 1.0. Our target stays 1.2. | 3763 // Now move the ideal scale to 1.0. Our target stays 1.2. |
3723 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); | 3764 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, 0.f, false); |
3724 | 3765 |
3725 // All the tilings are between are target and the ideal, so they are not | 3766 // All the tilings are between are target and the ideal, so they are not |
3726 // removed. | 3767 // removed. |
3727 used_tilings.clear(); | 3768 used_tilings.clear(); |
3728 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3769 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3729 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3770 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3730 | 3771 |
3731 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 3772 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
3732 SetupDrawPropertiesAndUpdateTiles( | 3773 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.1f, device_scale, |
3733 active_layer_, 1.1f, device_scale, page_scale, 1.f, false); | 3774 page_scale, 1.f, 0.f, false); |
3734 | 3775 |
3735 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 3776 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
3736 // in the range [1.0,1.2] and are kept. | 3777 // in the range [1.0,1.2] and are kept. |
3737 used_tilings.clear(); | 3778 used_tilings.clear(); |
3738 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3779 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3739 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3780 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3740 | 3781 |
3741 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 3782 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
3742 // 1.2 still. | 3783 // 1.2 still. |
3743 SetupDrawPropertiesAndUpdateTiles( | 3784 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.1f, device_scale, |
3744 pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); | 3785 page_scale, 1.f, 0.f, false); |
3745 | 3786 |
3746 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 3787 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
3747 // target raster scale. But it is in our used tilings set, so nothing is | 3788 // target raster scale. But it is in our used tilings set, so nothing is |
3748 // deleted. | 3789 // deleted. |
3749 used_tilings.clear(); | 3790 used_tilings.clear(); |
3750 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 3791 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
3751 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3792 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3752 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3793 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3753 | 3794 |
3754 // If we remove it from our used tilings set, it is outside the range to keep | 3795 // If we remove it from our used tilings set, it is outside the range to keep |
(...skipping 25 matching lines...) Expand all Loading... |
3780 EXPECT_FALSE(pending_layer_->tilings()); | 3821 EXPECT_FALSE(pending_layer_->tilings()); |
3781 pending_layer_->RecreateResources(); | 3822 pending_layer_->RecreateResources(); |
3782 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 3823 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
3783 | 3824 |
3784 // This should create new tilings. | 3825 // This should create new tilings. |
3785 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3826 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3786 1.3f, // ideal contents scale | 3827 1.3f, // ideal contents scale |
3787 2.7f, // device scale | 3828 2.7f, // device scale |
3788 3.2f, // page scale | 3829 3.2f, // page scale |
3789 1.f, // maximum animation scale | 3830 1.f, // maximum animation scale |
| 3831 0.f, // starting animation scale |
3790 false); | 3832 false); |
3791 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3833 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3792 } | 3834 } |
3793 | 3835 |
3794 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { | 3836 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { |
3795 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 3837 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
3796 | 3838 |
3797 gfx::Size tile_size(400, 400); | 3839 gfx::Size tile_size(400, 400); |
3798 gfx::Size layer_bounds(1000, 2000); | 3840 gfx::Size layer_bounds(1000, 2000); |
3799 | 3841 |
3800 host_impl_.SetViewportSize(gfx::Size(10000, 20000)); | 3842 host_impl_.SetViewportSize(gfx::Size(10000, 20000)); |
3801 | 3843 |
3802 scoped_refptr<FakePicturePileImpl> pending_pile = | 3844 scoped_refptr<FakePicturePileImpl> pending_pile = |
3803 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3845 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3804 scoped_refptr<FakePicturePileImpl> active_pile = | 3846 scoped_refptr<FakePicturePileImpl> active_pile = |
3805 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3847 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3806 | 3848 |
3807 SetupTrees(pending_pile, active_pile); | 3849 SetupTrees(pending_pile, active_pile); |
3808 | 3850 |
3809 ResetTilingsAndRasterScales(); | 3851 ResetTilingsAndRasterScales(); |
3810 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, false); | 3852 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, 0.f, |
| 3853 false); |
3811 | 3854 |
3812 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); | 3855 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); |
3813 EXPECT_EQ(2.5f, max_contents_scale); | 3856 EXPECT_EQ(2.5f, max_contents_scale); |
3814 | 3857 |
3815 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); | 3858 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); |
3816 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | 3859 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
3817 SK_MScalar1 / max_contents_scale); | 3860 SK_MScalar1 / max_contents_scale); |
3818 | 3861 |
3819 AppendQuadsData data; | 3862 AppendQuadsData data; |
3820 active_layer_->AppendQuads(render_pass.get(), &data); | 3863 active_layer_->AppendQuads(render_pass.get(), &data); |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4689 | 4732 |
4690 Region invalidation; | 4733 Region invalidation; |
4691 gfx::Rect viewport = gfx::Rect(0, 0, 100, 100); | 4734 gfx::Rect viewport = gfx::Rect(0, 0, 100, 100); |
4692 gfx::Transform transform; | 4735 gfx::Transform transform; |
4693 | 4736 |
4694 host_impl_.SetRequiresHighResToDraw(); | 4737 host_impl_.SetRequiresHighResToDraw(); |
4695 | 4738 |
4696 // Update tiles. | 4739 // Update tiles. |
4697 pending_layer_->draw_properties().visible_content_rect = viewport; | 4740 pending_layer_->draw_properties().visible_content_rect = viewport; |
4698 pending_layer_->draw_properties().screen_space_transform = transform; | 4741 pending_layer_->draw_properties().screen_space_transform = transform; |
4699 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 4742 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 4743 false); |
4700 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 4744 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
4701 | 4745 |
4702 // Ensure we can't activate. | 4746 // Ensure we can't activate. |
4703 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); | 4747 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
4704 | 4748 |
4705 // Now in the same frame, move the viewport (this can happen during | 4749 // Now in the same frame, move the viewport (this can happen during |
4706 // animation). | 4750 // animation). |
4707 viewport = gfx::Rect(0, 2000, 100, 100); | 4751 viewport = gfx::Rect(0, 2000, 100, 100); |
4708 | 4752 |
4709 // Update tiles. | 4753 // Update tiles. |
4710 pending_layer_->draw_properties().visible_content_rect = viewport; | 4754 pending_layer_->draw_properties().visible_content_rect = viewport; |
4711 pending_layer_->draw_properties().screen_space_transform = transform; | 4755 pending_layer_->draw_properties().screen_space_transform = transform; |
4712 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 4756 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 4757 false); |
4713 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 4758 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
4714 | 4759 |
4715 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. | 4760 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. |
4716 std::vector<Tile*> tiles; | 4761 std::vector<Tile*> tiles; |
4717 for (PictureLayerTiling::CoverageIterator iter( | 4762 for (PictureLayerTiling::CoverageIterator iter( |
4718 pending_layer_->HighResTiling(), | 4763 pending_layer_->HighResTiling(), |
4719 1.f, | 4764 1.f, |
4720 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); | 4765 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
4721 iter; | 4766 iter; |
4722 ++iter) { | 4767 ++iter) { |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4957 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 5002 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4958 EXPECT_EQ(result.width(), 448); | 5003 EXPECT_EQ(result.width(), 448); |
4959 EXPECT_EQ(result.height(), 448); | 5004 EXPECT_EQ(result.height(), 448); |
4960 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 5005 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4961 EXPECT_EQ(result.width(), 512); | 5006 EXPECT_EQ(result.width(), 512); |
4962 EXPECT_EQ(result.height(), 500 + 2); | 5007 EXPECT_EQ(result.height(), 500 + 2); |
4963 } | 5008 } |
4964 | 5009 |
4965 } // namespace | 5010 } // namespace |
4966 } // namespace cc | 5011 } // namespace cc |
OLD | NEW |