| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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); \ | 31 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES); \ |
| 32 code_to_test; \ | 32 code_to_test; \ |
| 33 EXPECT_TRUE( \ | 33 EXPECT_TRUE( \ |
| 34 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ | 34 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ |
| 35 EXPECT_FALSE( \ | 35 EXPECT_FALSE( \ |
| 36 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ | 36 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ |
| 37 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ | 37 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ |
| 38 grand_child)); \ | 38 grand_child)); \ |
| 39 EXPECT_TRUE(root->LayerPropertyChanged()); \ | 39 EXPECT_TRUE(root->LayerPropertyChanged()); \ |
| 40 EXPECT_TRUE(child->LayerPropertyChanged()); \ | 40 EXPECT_TRUE(child->LayerPropertyChanged()); \ |
| 41 EXPECT_TRUE(grand_child->LayerPropertyChanged()); | 41 EXPECT_TRUE(grand_child->LayerPropertyChanged()); |
| 42 | 42 |
| 43 #define EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(code_to_test) \ | 43 #define EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(code_to_test) \ |
| 44 root->layer_tree_impl()->ResetAllChangeTracking( \ | 44 root->layer_tree_impl()->ResetAllChangeTracking( \ |
| 45 PropertyTrees::ResetFlags::ALL_TREES); \ | 45 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES); \ |
| 46 code_to_test; \ | 46 code_to_test; \ |
| 47 EXPECT_FALSE( \ | 47 EXPECT_FALSE( \ |
| 48 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ | 48 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ |
| 49 EXPECT_FALSE( \ | 49 EXPECT_FALSE( \ |
| 50 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ | 50 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ |
| 51 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ | 51 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ |
| 52 grand_child)); \ | 52 grand_child)); \ |
| 53 EXPECT_FALSE(root->LayerPropertyChanged()); \ | 53 EXPECT_FALSE(root->LayerPropertyChanged()); \ |
| 54 EXPECT_FALSE(child->LayerPropertyChanged()); \ | 54 EXPECT_FALSE(child->LayerPropertyChanged()); \ |
| 55 EXPECT_FALSE(grand_child->LayerPropertyChanged()); | 55 EXPECT_FALSE(grand_child->LayerPropertyChanged()); |
| 56 | 56 |
| 57 #define EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( \ | 57 #define EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( \ |
| 58 code_to_test) \ | 58 code_to_test) \ |
| 59 root->layer_tree_impl()->ResetAllChangeTracking( \ | 59 root->layer_tree_impl()->ResetAllChangeTracking( \ |
| 60 PropertyTrees::ResetFlags::ALL_TREES); \ | 60 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES); \ |
| 61 code_to_test; \ | 61 code_to_test; \ |
| 62 EXPECT_TRUE( \ | 62 EXPECT_TRUE( \ |
| 63 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ | 63 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ |
| 64 EXPECT_FALSE( \ | 64 EXPECT_FALSE( \ |
| 65 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ | 65 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ |
| 66 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ | 66 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ |
| 67 grand_child)); \ | 67 grand_child)); \ |
| 68 EXPECT_FALSE(root->LayerPropertyChanged()); \ | 68 EXPECT_FALSE(root->LayerPropertyChanged()); \ |
| 69 EXPECT_FALSE(child->LayerPropertyChanged()); \ | 69 EXPECT_FALSE(child->LayerPropertyChanged()); \ |
| 70 EXPECT_FALSE(grand_child->LayerPropertyChanged()); | 70 EXPECT_FALSE(grand_child->LayerPropertyChanged()); |
| 71 | 71 |
| 72 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \ | 72 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \ |
| 73 root->layer_tree_impl()->ResetAllChangeTracking( \ | 73 root->layer_tree_impl()->ResetAllChangeTracking( \ |
| 74 PropertyTrees::ResetFlags::ALL_TREES); \ | 74 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES); \ |
| 75 root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \ | 75 root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \ |
| 76 code_to_test; \ | 76 code_to_test; \ |
| 77 EXPECT_TRUE( \ | 77 EXPECT_TRUE( \ |
| 78 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ | 78 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ |
| 79 EXPECT_FALSE( \ | 79 EXPECT_FALSE( \ |
| 80 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ | 80 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ |
| 81 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ | 81 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ |
| 82 grand_child)); \ | 82 grand_child)); \ |
| 83 EXPECT_TRUE(root->LayerPropertyChanged()); \ | 83 EXPECT_TRUE(root->LayerPropertyChanged()); \ |
| 84 EXPECT_FALSE(child->LayerPropertyChanged()); \ | 84 EXPECT_FALSE(child->LayerPropertyChanged()); \ |
| 85 EXPECT_FALSE(grand_child->LayerPropertyChanged()); | 85 EXPECT_FALSE(grand_child->LayerPropertyChanged()); |
| 86 | 86 |
| 87 #define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ | 87 #define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ |
| 88 root->layer_tree_impl()->ResetAllChangeTracking( \ | 88 root->layer_tree_impl()->ResetAllChangeTracking( \ |
| 89 PropertyTrees::ResetFlags::ALL_TREES); \ | 89 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES); \ |
| 90 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ | 90 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ |
| 91 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ | 91 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ |
| 92 host_impl.ForcePrepareToDraw(); \ | 92 host_impl.ForcePrepareToDraw(); \ |
| 93 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ | 93 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ |
| 94 code_to_test; \ | 94 code_to_test; \ |
| 95 EXPECT_TRUE(host_impl.active_tree()->needs_update_draw_properties()); | 95 EXPECT_TRUE(host_impl.active_tree()->needs_update_draw_properties()); |
| 96 | 96 |
| 97 #define VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ | 97 #define VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ |
| 98 root->layer_tree_impl()->ResetAllChangeTracking( \ | 98 root->layer_tree_impl()->ResetAllChangeTracking( \ |
| 99 PropertyTrees::ResetFlags::ALL_TREES); \ | 99 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES); \ |
| 100 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ | 100 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ |
| 101 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ | 101 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ |
| 102 host_impl.ForcePrepareToDraw(); \ | 102 host_impl.ForcePrepareToDraw(); \ |
| 103 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ | 103 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ |
| 104 code_to_test; \ | 104 code_to_test; \ |
| 105 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); | 105 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); |
| 106 | 106 |
| 107 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { | 107 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { |
| 108 gfx::ScrollOffset delta = | 108 gfx::ScrollOffset delta = |
| 109 layer_impl->layer_tree_impl() | 109 layer_impl->layer_tree_impl() |
| (...skipping 21 matching lines...) Expand all Loading... |
| 131 LayerImpl::Create(host_impl.active_tree(), 1); | 131 LayerImpl::Create(host_impl.active_tree(), 1); |
| 132 LayerImpl* root_clip = root_clip_ptr.get(); | 132 LayerImpl* root_clip = root_clip_ptr.get(); |
| 133 std::unique_ptr<LayerImpl> root_ptr = | 133 std::unique_ptr<LayerImpl> root_ptr = |
| 134 LayerImpl::Create(host_impl.active_tree(), 2); | 134 LayerImpl::Create(host_impl.active_tree(), 2); |
| 135 LayerImpl* root = root_ptr.get(); | 135 LayerImpl* root = root_ptr.get(); |
| 136 root_clip_ptr->AddChild(std::move(root_ptr)); | 136 root_clip_ptr->AddChild(std::move(root_ptr)); |
| 137 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); | 137 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); |
| 138 | 138 |
| 139 root->test_properties()->force_render_surface = true; | 139 root->test_properties()->force_render_surface = true; |
| 140 root->layer_tree_impl()->ResetAllChangeTracking( | 140 root->layer_tree_impl()->ResetAllChangeTracking( |
| 141 PropertyTrees::ResetFlags::ALL_TREES); | 141 PropertyTrees::Types::EFFECT_AND_TRANSFORM_TREES); |
| 142 | 142 |
| 143 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); | 143 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); |
| 144 LayerImpl* child = root->children()[0]; | 144 LayerImpl* child = root->children()[0]; |
| 145 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8)); | 145 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8)); |
| 146 LayerImpl* grand_child = child->children()[0]; | 146 LayerImpl* grand_child = child->children()[0]; |
| 147 root->SetScrollClipLayer(root_clip->id()); | 147 root->SetScrollClipLayer(root_clip->id()); |
| 148 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 148 host_impl.active_tree()->BuildPropertyTreesForTesting(); |
| 149 | 149 |
| 150 // Adding children is an internal operation and should not mark layers as | 150 // Adding children is an internal operation and should not mark layers as |
| 151 // changed. | 151 // changed. |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 578 |
| 579 pending_layer->PushPropertiesTo(layer()); | 579 pending_layer->PushPropertiesTo(layer()); |
| 580 | 580 |
| 581 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); | 581 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); |
| 582 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), | 582 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), |
| 583 pending_layer->CurrentScrollOffset()); | 583 pending_layer->CurrentScrollOffset()); |
| 584 } | 584 } |
| 585 | 585 |
| 586 } // namespace | 586 } // namespace |
| 587 } // namespace cc | 587 } // namespace cc |
| OLD | NEW |