Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: cc/layers/layer_impl_unittest.cc

Issue 2840433002: Move LayerImpl's bounds_delta to property trees (Closed)
Patch Set: Document ViewportBoundsDelta better Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/layer_position_constraint_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/filter_operation.h" 7 #include "cc/base/filter_operation.h"
8 #include "cc/base/filter_operations.h" 8 #include "cc/base/filter_operations.h"
9 #include "cc/layers/painted_scrollbar_layer_impl.h" 9 #include "cc/layers/painted_scrollbar_layer_impl.h"
10 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 10 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); 131 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
132 std::unique_ptr<LayerImpl> root_clip_ptr = 132 std::unique_ptr<LayerImpl> root_clip_ptr =
133 LayerImpl::Create(host_impl.active_tree(), 1); 133 LayerImpl::Create(host_impl.active_tree(), 1);
134 LayerImpl* root_clip = root_clip_ptr.get(); 134 LayerImpl* root_clip = root_clip_ptr.get();
135 std::unique_ptr<LayerImpl> root_ptr = 135 std::unique_ptr<LayerImpl> root_ptr =
136 LayerImpl::Create(host_impl.active_tree(), 2); 136 LayerImpl::Create(host_impl.active_tree(), 2);
137 LayerImpl* root = root_ptr.get(); 137 LayerImpl* root = root_ptr.get();
138 root_clip_ptr->test_properties()->AddChild(std::move(root_ptr)); 138 root_clip_ptr->test_properties()->AddChild(std::move(root_ptr));
139 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_clip_ptr)); 139 host_impl.active_tree()->SetRootLayerForTesting(std::move(root_clip_ptr));
140 140
141 // Make root the inner viewport scroll layer. This ensures the later call to
142 // |SetViewportBoundsDelta| will be on a viewport layer.
143 host_impl.active_tree()->SetViewportLayersFromIds(
144 Layer::INVALID_ID, Layer::INVALID_ID, root->id(), Layer::INVALID_ID);
145
141 root->test_properties()->force_render_surface = true; 146 root->test_properties()->force_render_surface = true;
142 root->SetMasksToBounds(true); 147 root->SetMasksToBounds(true);
143 root->layer_tree_impl()->ResetAllChangeTracking(); 148 root->layer_tree_impl()->ResetAllChangeTracking();
144 149
145 root->test_properties()->AddChild( 150 root->test_properties()->AddChild(
146 LayerImpl::Create(host_impl.active_tree(), 7)); 151 LayerImpl::Create(host_impl.active_tree(), 7));
147 LayerImpl* child = root->test_properties()->children[0]; 152 LayerImpl* child = root->test_properties()->children[0];
148 child->test_properties()->AddChild( 153 child->test_properties()->AddChild(
149 LayerImpl::Create(host_impl.active_tree(), 8)); 154 LayerImpl::Create(host_impl.active_tree(), 8));
150 LayerImpl* grand_child = child->test_properties()->children[0]; 155 LayerImpl* grand_child = child->test_properties()->children[0];
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 host_impl.active_tree()->SetFilterMutated(root->element_id(), 190 host_impl.active_tree()->SetFilterMutated(root->element_id(),
186 FilterOperations())); 191 FilterOperations()));
187 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED( 192 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED(
188 host_impl.active_tree()->SetOpacityMutated(root->element_id(), 193 host_impl.active_tree()->SetOpacityMutated(root->element_id(),
189 arbitrary_number)); 194 arbitrary_number));
190 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED( 195 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED(
191 host_impl.active_tree()->SetTransformMutated(root->element_id(), 196 host_impl.active_tree()->SetTransformMutated(root->element_id(),
192 arbitrary_transform)); 197 arbitrary_transform));
193 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d); 198 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d);
194 root->SetNeedsPushProperties()); 199 root->SetNeedsPushProperties());
195 // SetBoundsDelta changes subtree only when masks_to_bounds is true and it 200 // SetViewportBoundsDelta changes subtree only when masks_to_bounds is true
196 // doesn't set needs_push_properties as it is always called on active tree. 201 // and it doesn't set needs_push_properties as it is always called on active
202 // tree.
197 root->SetMasksToBounds(true); 203 root->SetMasksToBounds(true);
198 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBoundsDelta(arbitrary_vector2d); 204 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
199 root->SetNeedsPushProperties()); 205 root->SetViewportBoundsDelta(arbitrary_vector2d);
206 root->SetNeedsPushProperties());
200 207
201 // Changing these properties only affects the layer itself. 208 // Changing these properties only affects the layer itself.
202 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true)); 209 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true));
203 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 210 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
204 root->SetBackgroundColor(arbitrary_color)); 211 root->SetBackgroundColor(arbitrary_color));
205 212
206 // Special case: check that SetBounds changes behavior depending on 213 // Special case: check that SetBounds changes behavior depending on
207 // masksToBounds. 214 // masksToBounds.
208 gfx::Size bounds_size(135, 246); 215 gfx::Size bounds_size(135, 246);
209 root->SetMasksToBounds(false); 216 root->SetMasksToBounds(false);
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 569
563 pending_layer->PushPropertiesTo(layer()); 570 pending_layer->PushPropertiesTo(layer());
564 571
565 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 572 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
566 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 573 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
567 pending_layer->CurrentScrollOffset()); 574 pending_layer->CurrentScrollOffset());
568 } 575 }
569 576
570 } // namespace 577 } // namespace
571 } // namespace cc 578 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/layer_position_constraint_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698