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

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

Issue 1752993002: cc : Delete LayerImpl::NoteLayerPropertyChangedForSubtree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 code_to_test) \ 56 code_to_test) \
57 root->ResetAllChangeTrackingForSubtree(); \ 57 root->ResetAllChangeTrackingForSubtree(); \
58 code_to_test; \ 58 code_to_test; \
59 EXPECT_TRUE(root->needs_push_properties()); \ 59 EXPECT_TRUE(root->needs_push_properties()); \
60 EXPECT_FALSE(child->needs_push_properties()); \ 60 EXPECT_FALSE(child->needs_push_properties()); \
61 EXPECT_FALSE(grand_child->needs_push_properties()); \ 61 EXPECT_FALSE(grand_child->needs_push_properties()); \
62 EXPECT_FALSE(root->LayerPropertyChanged()); \ 62 EXPECT_FALSE(root->LayerPropertyChanged()); \
63 EXPECT_FALSE(child->LayerPropertyChanged()); \ 63 EXPECT_FALSE(child->LayerPropertyChanged()); \
64 EXPECT_FALSE(grand_child->LayerPropertyChanged()); 64 EXPECT_FALSE(grand_child->LayerPropertyChanged());
65 65
66 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \ 66 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \
67 root->ResetAllChangeTrackingForSubtree(); \ 67 root->ResetAllChangeTrackingForSubtree(); \
68 code_to_test; \ 68 root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \
69 EXPECT_TRUE(root->needs_push_properties()); \ 69 code_to_test; \
70 EXPECT_FALSE(child->needs_push_properties()); \ 70 EXPECT_TRUE(root->needs_push_properties()); \
71 EXPECT_FALSE(grand_child->needs_push_properties()); \ 71 EXPECT_FALSE(child->needs_push_properties()); \
72 EXPECT_TRUE(root->LayerPropertyChanged()); \ 72 EXPECT_FALSE(grand_child->needs_push_properties()); \
73 EXPECT_FALSE(child->LayerPropertyChanged()); \ 73 EXPECT_TRUE(root->LayerPropertyChanged()); \
74 EXPECT_FALSE(child->LayerPropertyChanged()); \
74 EXPECT_FALSE(grand_child->LayerPropertyChanged()); 75 EXPECT_FALSE(grand_child->LayerPropertyChanged());
75 76
76 #define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \ 77 #define VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(code_to_test) \
77 root->ResetAllChangeTrackingForSubtree(); \ 78 root->ResetAllChangeTrackingForSubtree(); \
78 host_impl.active_tree()->property_trees()->needs_rebuild = true; \ 79 host_impl.active_tree()->property_trees()->needs_rebuild = true; \
79 host_impl.active_tree()->BuildPropertyTreesForTesting(); \ 80 host_impl.active_tree()->BuildPropertyTreesForTesting(); \
80 host_impl.ForcePrepareToDraw(); \ 81 host_impl.ForcePrepareToDraw(); \
81 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \ 82 EXPECT_FALSE(host_impl.active_tree()->needs_update_draw_properties()); \
82 code_to_test; \ 83 code_to_test; \
83 EXPECT_TRUE(host_impl.active_tree()->needs_update_draw_properties()); 84 EXPECT_TRUE(host_impl.active_tree()->needs_update_draw_properties());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 162
162 // These properties are internal, and should not be considered "change" when 163 // These properties are internal, and should not be considered "change" when
163 // they are used. 164 // they are used.
164 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 165 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
165 root->SetUpdateRect(arbitrary_rect)); 166 root->SetUpdateRect(arbitrary_rect));
166 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); 167 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size));
167 host_impl.active_tree()->property_trees()->needs_rebuild = true; 168 host_impl.active_tree()->property_trees()->needs_rebuild = true;
168 host_impl.active_tree()->BuildPropertyTreesForTesting(); 169 host_impl.active_tree()->BuildPropertyTreesForTesting();
169 170
170 // Changing these properties affects the entire subtree of layers. 171 // Changing these properties affects the entire subtree of layers.
171 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); 172 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->OnFilterAnimated(arbitrary_filters));
172 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations())); 173 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
174 root->OnFilterAnimated(FilterOperations()));
173 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d)); 175 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d));
174 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetScrollDelta(gfx::Vector2d())); 176 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetScrollDelta(gfx::Vector2d()));
175 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->PushScrollOffsetFromMainThread( 177 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->PushScrollOffsetFromMainThread(
176 gfx::ScrollOffset(arbitrary_vector2d))); 178 gfx::ScrollOffset(arbitrary_vector2d)));
177 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->OnOpacityAnimated(arbitrary_number)); 179 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->OnOpacityAnimated(arbitrary_number));
178 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 180 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
179 root->OnTransformAnimated(arbitrary_transform)); 181 root->OnTransformAnimated(arbitrary_transform));
182 // SetBoundsDelta changes subtree only when masks_to_bounds is true and it
183 // doesn't set needs_push_properties as it is always called on active tree.
184 root->SetMasksToBounds(true);
185 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBoundsDelta(arbitrary_vector2d);
186 root->SetNeedsPushProperties());
180 187
181 // Changing these properties only affects the layer itself. 188 // Changing these properties only affects the layer itself.
182 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true)); 189 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true));
183 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 190 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
184 root->SetBackgroundColor(arbitrary_color)); 191 root->SetBackgroundColor(arbitrary_color));
185 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 192 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
186 root->SetBackgroundFilters(arbitrary_filters)); 193 root->SetBackgroundFilters(arbitrary_filters));
187 194
188 // Special case: check that SetBounds changes behavior depending on 195 // Special case: check that SetBounds changes behavior depending on
189 // masksToBounds. 196 // masksToBounds.
197 gfx::Size bounds_size(135, 246);
190 root->SetMasksToBounds(false); 198 root->SetMasksToBounds(false);
191 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(gfx::Size(135, 246))); 199 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(bounds_size));
192 host_impl.active_tree()->property_trees()->needs_rebuild = true; 200 host_impl.active_tree()->property_trees()->needs_rebuild = true;
193 host_impl.active_tree()->BuildPropertyTreesForTesting(); 201 host_impl.active_tree()->BuildPropertyTreesForTesting();
194 202
195 root->SetMasksToBounds(true); 203 root->SetMasksToBounds(true);
196 host_impl.active_tree()->property_trees()->needs_rebuild = true; 204 host_impl.active_tree()->property_trees()->needs_rebuild = true;
197 host_impl.active_tree()->BuildPropertyTreesForTesting(); 205 host_impl.active_tree()->BuildPropertyTreesForTesting();
198 206
199 // Changing these properties does not cause the layer to be marked as changed 207 // Changing these properties does not cause the layer to be marked as changed
200 // but does cause the layer to need to push properties. 208 // but does cause the layer to need to push properties.
201 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 209 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 242 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
235 root->PushScrollOffsetFromMainThread( 243 root->PushScrollOffsetFromMainThread(
236 gfx::ScrollOffset(arbitrary_vector2d))); 244 gfx::ScrollOffset(arbitrary_vector2d)));
237 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true)); 245 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true));
238 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetOpacity(arbitrary_number)); 246 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetOpacity(arbitrary_number));
239 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 247 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
240 root->SetBlendMode(arbitrary_blend_mode)); 248 root->SetBlendMode(arbitrary_blend_mode));
241 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 249 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
242 root->SetIsRootForIsolatedGroup(true)); 250 root->SetIsRootForIsolatedGroup(true));
243 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true)); 251 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true));
244 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(arbitrary_size)); 252 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size));
245 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 253 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
246 root->SetScrollParent(scroll_parent.get())); 254 root->SetScrollParent(scroll_parent.get()));
247 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 255 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
248 root->SetScrollChildren(scroll_children)); 256 root->SetScrollChildren(scroll_children));
249 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 257 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
250 root->SetClipParent(clip_parent.get())); 258 root->SetClipParent(clip_parent.get()));
251 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 259 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
252 root->SetClipChildren(clip_children)); 260 root->SetClipChildren(clip_children));
253 } 261 }
254 262
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Create a render surface, because we must have a render surface if we have 312 // Create a render surface, because we must have a render surface if we have
305 // filters. 313 // filters.
306 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); 314 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true));
307 315
308 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(true)); 316 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(true));
309 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(true)); 317 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(true));
310 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(false)); 318 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(false));
311 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(false)); 319 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(false));
312 320
313 // Related filter functions. 321 // Related filter functions.
314 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 322 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
315 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 323 root->OnFilterAnimated(arbitrary_filters));
316 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(FilterOperations())); 324 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
317 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 325 root->OnFilterAnimated(arbitrary_filters));
326 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
327 root->OnFilterAnimated(FilterOperations()));
328 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
329 root->OnFilterAnimated(arbitrary_filters));
318 330
319 // Related scrolling functions. 331 // Related scrolling functions.
320 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 332 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
321 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 333 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
322 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d)); 334 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d));
323 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(gfx::Vector2d())); 335 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(gfx::Vector2d()));
324 layer->SetScrollDelta(gfx::Vector2d(0, 0)); 336 layer->SetScrollDelta(gfx::Vector2d(0, 0));
325 host_impl.ForcePrepareToDraw(); 337 host_impl.ForcePrepareToDraw();
326 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 338 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
327 layer->SetScrollDelta(arbitrary_vector2d)); 339 layer->SetScrollDelta(arbitrary_vector2d));
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 620
609 pending_layer->PushPropertiesTo(layer()); 621 pending_layer->PushPropertiesTo(layer());
610 622
611 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 623 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
612 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 624 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
613 pending_layer->CurrentScrollOffset()); 625 pending_layer->CurrentScrollOffset());
614 } 626 }
615 627
616 } // namespace 628 } // namespace
617 } // namespace cc 629 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698