| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/animation/mutable_properties.h" | 7 #include "cc/animation/mutable_properties.h" |
| 8 #include "cc/layers/painted_scrollbar_layer_impl.h" | 8 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 10 #include "cc/output/filter_operation.h" | 10 #include "cc/output/filter_operation.h" |
| 11 #include "cc/output/filter_operations.h" | 11 #include "cc/output/filter_operations.h" |
| 12 #include "cc/test/animation_test_common.h" | 12 #include "cc/test/animation_test_common.h" |
| 13 #include "cc/test/fake_impl_task_runner_provider.h" | 13 #include "cc/test/fake_impl_task_runner_provider.h" |
| 14 #include "cc/test/fake_layer_tree_host_impl.h" | 14 #include "cc/test/fake_layer_tree_host_impl.h" |
| 15 #include "cc/test/fake_output_surface.h" | 15 #include "cc/test/fake_output_surface.h" |
| 16 #include "cc/test/geometry_test_utils.h" | 16 #include "cc/test/geometry_test_utils.h" |
| 17 #include "cc/test/test_shared_bitmap_manager.h" | 17 #include "cc/test/test_shared_bitmap_manager.h" |
| 18 #include "cc/test/test_task_graph_runner.h" | 18 #include "cc/test/test_task_graph_runner.h" |
| 19 #include "cc/trees/layer_tree_impl.h" | 19 #include "cc/trees/layer_tree_impl.h" |
| 20 #include "cc/trees/single_thread_proxy.h" | 20 #include "cc/trees/single_thread_proxy.h" |
| 21 #include "cc/trees/tree_synchronizer.h" | 21 #include "cc/trees/tree_synchronizer.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 24 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 25 | 25 |
| 26 namespace cc { | 26 namespace cc { |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ | 29 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ |
| 30 root->layer_tree_impl()->ResetAllChangeTracking( \ | 30 root->layer_tree_impl()->ResetAllChangeTracking(); \ |
| 31 PropertyTrees::ResetFlags::ALL_TREES); \ | |
| 32 code_to_test; \ | 31 code_to_test; \ |
| 33 EXPECT_TRUE( \ | 32 EXPECT_TRUE( \ |
| 34 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ | 33 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ |
| 35 EXPECT_FALSE( \ | 34 EXPECT_FALSE( \ |
| 36 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ | 35 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ |
| 37 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ | 36 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ |
| 38 grand_child)); \ | 37 grand_child)); \ |
| 39 EXPECT_TRUE(root->LayerPropertyChanged()); \ | 38 EXPECT_TRUE(root->LayerPropertyChanged()); \ |
| 40 EXPECT_TRUE(child->LayerPropertyChanged()); \ | 39 EXPECT_TRUE(child->LayerPropertyChanged()); \ |
| 41 EXPECT_TRUE(grand_child->LayerPropertyChanged()); | 40 EXPECT_TRUE(grand_child->LayerPropertyChanged()); |
| 42 | 41 |
| 43 #define EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(code_to_test) \ | 42 #define EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(code_to_test) \ |
| 44 root->layer_tree_impl()->ResetAllChangeTracking( \ | 43 root->layer_tree_impl()->ResetAllChangeTracking(); \ |
| 45 PropertyTrees::ResetFlags::ALL_TREES); \ | |
| 46 code_to_test; \ | 44 code_to_test; \ |
| 47 EXPECT_FALSE( \ | 45 EXPECT_FALSE( \ |
| 48 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ | 46 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ |
| 49 EXPECT_FALSE( \ | 47 EXPECT_FALSE( \ |
| 50 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ | 48 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ |
| 51 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ | 49 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ |
| 52 grand_child)); \ | 50 grand_child)); \ |
| 53 EXPECT_FALSE(root->LayerPropertyChanged()); \ | 51 EXPECT_FALSE(root->LayerPropertyChanged()); \ |
| 54 EXPECT_FALSE(child->LayerPropertyChanged()); \ | 52 EXPECT_FALSE(child->LayerPropertyChanged()); \ |
| 55 EXPECT_FALSE(grand_child->LayerPropertyChanged()); | 53 EXPECT_FALSE(grand_child->LayerPropertyChanged()); |
| 56 | 54 |
| 57 #define EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( \ | 55 #define EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( \ |
| 58 code_to_test) \ | 56 code_to_test) \ |
| 59 root->layer_tree_impl()->ResetAllChangeTracking( \ | 57 root->layer_tree_impl()->ResetAllChangeTracking(); \ |
| 60 PropertyTrees::ResetFlags::ALL_TREES); \ | |
| 61 code_to_test; \ | 58 code_to_test; \ |
| 62 EXPECT_TRUE( \ | 59 EXPECT_TRUE( \ |
| 63 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ | 60 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ |
| 64 EXPECT_FALSE( \ | 61 EXPECT_FALSE( \ |
| 65 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ | 62 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ |
| 66 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ | 63 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ |
| 67 grand_child)); \ | 64 grand_child)); \ |
| 68 EXPECT_FALSE(root->LayerPropertyChanged()); \ | 65 EXPECT_FALSE(root->LayerPropertyChanged()); \ |
| 69 EXPECT_FALSE(child->LayerPropertyChanged()); \ | 66 EXPECT_FALSE(child->LayerPropertyChanged()); \ |
| 70 EXPECT_FALSE(grand_child->LayerPropertyChanged()); | 67 EXPECT_FALSE(grand_child->LayerPropertyChanged()); |
| 71 | 68 |
| 72 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \ | 69 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \ |
| 73 root->layer_tree_impl()->ResetAllChangeTracking( \ | 70 root->layer_tree_impl()->ResetAllChangeTracking(); \ |
| 74 PropertyTrees::ResetFlags::ALL_TREES); \ | |
| 75 root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \ | 71 root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \ |
| 76 code_to_test; \ | 72 code_to_test; \ |
| 77 EXPECT_TRUE( \ | 73 EXPECT_TRUE( \ |
| 78 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ | 74 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ |
| 79 EXPECT_FALSE( \ | 75 EXPECT_FALSE( \ |
| 80 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ | 76 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ |
| 81 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ | 77 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ |
| 82 grand_child)); \ | 78 grand_child)); \ |
| 83 EXPECT_TRUE(root->LayerPropertyChanged()); \ | 79 EXPECT_TRUE(root->LayerPropertyChanged()); \ |
| 84 EXPECT_FALSE(child->LayerPropertyChanged()); \ | 80 EXPECT_FALSE(child->LayerPropertyChanged()); \ |
| 85 EXPECT_FALSE(grand_child->LayerPropertyChanged()); | 81 EXPECT_FALSE(grand_child->LayerPropertyChanged()); |
| 86 | 82 |
| 87 #define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ | 83 #define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ |
| 88 root->layer_tree_impl()->ResetAllChangeTracking( \ | 84 root->layer_tree_impl()->ResetAllChangeTracking(); \ |
| 89 PropertyTrees::ResetFlags::ALL_TREES); \ | |
| 90 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ | 85 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ |
| 91 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ | 86 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ |
| 92 host_impl.ForcePrepareToDraw(); \ | 87 host_impl.ForcePrepareToDraw(); \ |
| 93 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ | 88 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ |
| 94 code_to_test; \ | 89 code_to_test; \ |
| 95 EXPECT_TRUE(host_impl.active_tree()->needs_update_draw_properties()); | 90 EXPECT_TRUE(host_impl.active_tree()->needs_update_draw_properties()); |
| 96 | 91 |
| 97 #define VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ | 92 #define VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ |
| 98 root->layer_tree_impl()->ResetAllChangeTracking( \ | 93 root->layer_tree_impl()->ResetAllChangeTracking(); \ |
| 99 PropertyTrees::ResetFlags::ALL_TREES); \ | |
| 100 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ | 94 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ |
| 101 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ | 95 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ |
| 102 host_impl.ForcePrepareToDraw(); \ | 96 host_impl.ForcePrepareToDraw(); \ |
| 103 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ | 97 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ |
| 104 code_to_test; \ | 98 code_to_test; \ |
| 105 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); | 99 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); |
| 106 | 100 |
| 107 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { | 101 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { |
| 108 gfx::ScrollOffset delta = | 102 gfx::ScrollOffset delta = |
| 109 layer_impl->layer_tree_impl() | 103 layer_impl->layer_tree_impl() |
| (...skipping 20 matching lines...) Expand all Loading... |
| 130 std::unique_ptr<LayerImpl> root_clip_ptr = | 124 std::unique_ptr<LayerImpl> root_clip_ptr = |
| 131 LayerImpl::Create(host_impl.active_tree(), 1); | 125 LayerImpl::Create(host_impl.active_tree(), 1); |
| 132 LayerImpl* root_clip = root_clip_ptr.get(); | 126 LayerImpl* root_clip = root_clip_ptr.get(); |
| 133 std::unique_ptr<LayerImpl> root_ptr = | 127 std::unique_ptr<LayerImpl> root_ptr = |
| 134 LayerImpl::Create(host_impl.active_tree(), 2); | 128 LayerImpl::Create(host_impl.active_tree(), 2); |
| 135 LayerImpl* root = root_ptr.get(); | 129 LayerImpl* root = root_ptr.get(); |
| 136 root_clip_ptr->AddChild(std::move(root_ptr)); | 130 root_clip_ptr->AddChild(std::move(root_ptr)); |
| 137 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); | 131 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); |
| 138 | 132 |
| 139 root->test_properties()->force_render_surface = true; | 133 root->test_properties()->force_render_surface = true; |
| 140 root->layer_tree_impl()->ResetAllChangeTracking( | 134 root->layer_tree_impl()->ResetAllChangeTracking(); |
| 141 PropertyTrees::ResetFlags::ALL_TREES); | |
| 142 | 135 |
| 143 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); | 136 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); |
| 144 LayerImpl* child = root->children()[0]; | 137 LayerImpl* child = root->children()[0]; |
| 145 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8)); | 138 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8)); |
| 146 LayerImpl* grand_child = child->children()[0]; | 139 LayerImpl* grand_child = child->children()[0]; |
| 147 root->SetScrollClipLayer(root_clip->id()); | 140 root->SetScrollClipLayer(root_clip->id()); |
| 148 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 141 host_impl.active_tree()->BuildPropertyTreesForTesting(); |
| 149 | 142 |
| 150 // Adding children is an internal operation and should not mark layers as | 143 // Adding children is an internal operation and should not mark layers as |
| 151 // changed. | 144 // changed. |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 | 572 |
| 580 pending_layer->PushPropertiesTo(layer()); | 573 pending_layer->PushPropertiesTo(layer()); |
| 581 | 574 |
| 582 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); | 575 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); |
| 583 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), | 576 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), |
| 584 pending_layer->CurrentScrollOffset()); | 577 pending_layer->CurrentScrollOffset()); |
| 585 } | 578 } |
| 586 | 579 |
| 587 } // namespace | 580 } // namespace |
| 588 } // namespace cc | 581 } // namespace cc |
| OLD | NEW |