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

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 // SetBounsDelta changes subtree only when masksToBounds is true and it
ajuma 2016/03/02 14:34:09 typos: SetBoundsDelta, masks_to_bounds
jaydasika 2016/03/02 16:27:08 Done.
183 // doesn't set needsPushProperties as it is always called on active tree.
ajuma 2016/03/02 14:34:09 needs_push_properties
jaydasika 2016/03/02 16:27:08 Done.
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.
(...skipping 114 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 311 // Create a render surface, because we must have a render surface if we have
305 // filters. 312 // filters.
306 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); 313 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true));
307 314
308 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(true)); 315 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(true));
309 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(true)); 316 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(true));
310 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(false)); 317 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(false));
311 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(false)); 318 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetForceRenderSurface(false));
312 319
313 // Related filter functions. 320 // Related filter functions.
314 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 321 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
315 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 322 root->OnFilterAnimated(arbitrary_filters));
316 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(FilterOperations())); 323 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
317 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 324 root->OnFilterAnimated(arbitrary_filters));
325 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
326 root->OnFilterAnimated(FilterOperations()));
327 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
328 root->OnFilterAnimated(arbitrary_filters));
318 329
319 // Related scrolling functions. 330 // Related scrolling functions.
320 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 331 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
321 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 332 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
322 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d)); 333 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d));
323 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(gfx::Vector2d())); 334 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(gfx::Vector2d()));
324 layer->SetScrollDelta(gfx::Vector2d(0, 0)); 335 layer->SetScrollDelta(gfx::Vector2d(0, 0));
325 host_impl.ForcePrepareToDraw(); 336 host_impl.ForcePrepareToDraw();
326 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 337 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
327 layer->SetScrollDelta(arbitrary_vector2d)); 338 layer->SetScrollDelta(arbitrary_vector2d));
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 619
609 pending_layer->PushPropertiesTo(layer()); 620 pending_layer->PushPropertiesTo(layer());
610 621
611 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 622 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
612 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 623 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
613 pending_layer->CurrentScrollOffset()); 624 pending_layer->CurrentScrollOffset());
614 } 625 }
615 626
616 } // namespace 627 } // namespace
617 } // namespace cc 628 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698