| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 tilings = active_layer_->tilings(); | 539 tilings = active_layer_->tilings(); |
| 540 for (size_t i = 0; i < tilings->num_tilings(); i++) { | 540 for (size_t i = 0; i < tilings->num_tilings(); i++) { |
| 541 PictureLayerTiling* tiling = tilings->tiling_at(i); | 541 PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 542 EXPECT_EQ( | 542 EXPECT_EQ( |
| 543 tiling->GetCurrentVisibleRectForTesting(), | 543 tiling->GetCurrentVisibleRectForTesting(), |
| 544 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, | 544 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, |
| 545 tiling->contents_scale())); | 545 tiling->contents_scale())); |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 /* |
| 549 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 550 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
| 550 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 551 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 551 gfx::Size layer_bounds(400, 400); | 552 gfx::Size layer_bounds(400, 400); |
| 552 SetupDefaultTrees(layer_bounds); | 553 SetupDefaultTrees(layer_bounds); |
| 553 | 554 |
| 554 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 555 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 555 false); | 556 false); |
| 556 | 557 |
| 557 // UpdateTiles with valid viewport. Should update tile viewport. | 558 // UpdateTiles with valid viewport. Should update tile viewport. |
| 558 // Note viewport is considered invalid if and only if in resourceless | 559 // Note viewport is considered invalid if and only if in resourceless |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 inverse_tile_priority_transform, visible_rect_in_content_space); | 622 inverse_tile_priority_transform, visible_rect_in_content_space); |
| 622 visible_rect_in_content_space = MathUtil::ProjectClippedRect( | 623 visible_rect_in_content_space = MathUtil::ProjectClippedRect( |
| 623 inverse_draw_transform, visible_rect_in_content_space); | 624 inverse_draw_transform, visible_rect_in_content_space); |
| 624 | 625 |
| 625 ASSERT_GT(active_layer_->picture_layer_tiling_set()->num_tilings(), 0u); | 626 ASSERT_GT(active_layer_->picture_layer_tiling_set()->num_tilings(), 0u); |
| 626 EXPECT_EQ(gfx::ToEnclosingRect(visible_rect_in_content_space), | 627 EXPECT_EQ(gfx::ToEnclosingRect(visible_rect_in_content_space), |
| 627 active_layer_->picture_layer_tiling_set() | 628 active_layer_->picture_layer_tiling_set() |
| 628 ->tiling_at(0) | 629 ->tiling_at(0) |
| 629 ->GetCurrentVisibleRectForTesting()); | 630 ->GetCurrentVisibleRectForTesting()); |
| 630 } | 631 } |
| 632 */ |
| 631 | 633 |
| 632 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { | 634 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { |
| 633 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 635 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 634 gfx::Size layer_bounds(400, 400); | 636 gfx::Size layer_bounds(400, 400); |
| 635 SetupDefaultTrees(layer_bounds); | 637 SetupDefaultTrees(layer_bounds); |
| 636 | 638 |
| 637 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 639 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 638 false); | 640 false); |
| 639 | 641 |
| 640 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 642 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
| (...skipping 3021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3662 // need content in order to activate. | 3664 // need content in order to activate. |
| 3663 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); | 3665 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); |
| 3664 if (host_impl_.settings().create_low_res_tiling) | 3666 if (host_impl_.settings().create_low_res_tiling) |
| 3665 pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); | 3667 pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); |
| 3666 | 3668 |
| 3667 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 3669 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
| 3668 if (host_impl_.settings().create_low_res_tiling) | 3670 if (host_impl_.settings().create_low_res_tiling) |
| 3669 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 3671 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| 3670 } | 3672 } |
| 3671 | 3673 |
| 3674 /* |
| 3672 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 3675 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
| 3673 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 3676 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 3674 gfx::Size layer_bounds(400, 400); | 3677 gfx::Size layer_bounds(400, 400); |
| 3675 SetupDefaultTrees(layer_bounds); | 3678 SetupDefaultTrees(layer_bounds); |
| 3676 | 3679 |
| 3677 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 3680 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 3678 false); | 3681 false); |
| 3679 | 3682 |
| 3680 // UpdateTiles with valid viewport. Should update tile viewport. | 3683 // UpdateTiles with valid viewport. Should update tile viewport. |
| 3681 // Note viewport is considered invalid if and only if in resourceless | 3684 // Note viewport is considered invalid if and only if in resourceless |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3715 // Keep expanded viewport but mark it valid. Should update tile viewport. | 3718 // Keep expanded viewport but mark it valid. Should update tile viewport. |
| 3716 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); | 3719 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); |
| 3717 resourceless_software_draw = false; | 3720 resourceless_software_draw = false; |
| 3718 host_impl_.SetExternalTilePriorityConstraints(viewport, transform); | 3721 host_impl_.SetExternalTilePriorityConstraints(viewport, transform); |
| 3719 active_layer_->UpdateTiles(resourceless_software_draw); | 3722 active_layer_->UpdateTiles(resourceless_software_draw); |
| 3720 | 3723 |
| 3721 EXPECT_TRANSFORMATION_MATRIX_EQ( | 3724 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 3722 transform, active_layer_->draw_properties().screen_space_transform); | 3725 transform, active_layer_->draw_properties().screen_space_transform); |
| 3723 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); | 3726 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); |
| 3724 } | 3727 } |
| 3728 */ |
| 3725 | 3729 |
| 3726 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { | 3730 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { |
| 3727 gfx::Size layer_bounds(1300, 1900); | 3731 gfx::Size layer_bounds(1300, 1900); |
| 3728 std::vector<PictureLayerTiling*> used_tilings; | 3732 std::vector<PictureLayerTiling*> used_tilings; |
| 3729 SetupDefaultTrees(layer_bounds); | 3733 SetupDefaultTrees(layer_bounds); |
| 3730 | 3734 |
| 3731 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 3735 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 3732 EXPECT_LT(low_res_factor, 1.f); | 3736 EXPECT_LT(low_res_factor, 1.f); |
| 3733 | 3737 |
| 3734 float device_scale = 1.7f; | 3738 float device_scale = 1.7f; |
| (...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5116 // New low res tiling. | 5120 // New low res tiling. |
| 5117 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 5121 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
| 5118 | 5122 |
| 5119 // This tiling will be high res now, it won't contain low res content since it | 5123 // This tiling will be high res now, it won't contain low res content since it |
| 5120 // was all destroyed. | 5124 // was all destroyed. |
| 5121 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 5125 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
| 5122 } | 5126 } |
| 5123 | 5127 |
| 5124 } // namespace | 5128 } // namespace |
| 5125 } // namespace cc | 5129 } // namespace cc |
| OLD | NEW |