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

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

Issue 2762123004: cc: LayerTreeHostImpl uses element id to tick animations (Closed)
Patch Set: review comments 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
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // These properties are internal, and should not be considered "change" when 172 // These properties are internal, and should not be considered "change" when
173 // they are used. 173 // they are used.
174 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 174 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
175 root->SetUpdateRect(arbitrary_rect)); 175 root->SetUpdateRect(arbitrary_rect));
176 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); 176 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size));
177 host_impl.active_tree()->property_trees()->needs_rebuild = true; 177 host_impl.active_tree()->property_trees()->needs_rebuild = true;
178 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 178 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
179 179
180 // Changing these properties affects the entire subtree of layers. 180 // Changing these properties affects the entire subtree of layers.
181 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED( 181 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED(
182 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 182 host_impl.active_tree()->SetFilterMutated(root->element_id(),
183 arbitrary_filters, root->effect_tree_index(), 183 arbitrary_filters));
184 host_impl.active_tree()));
185 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED( 184 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED(
186 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 185 host_impl.active_tree()->SetFilterMutated(root->element_id(),
187 FilterOperations(), root->effect_tree_index(), 186 FilterOperations()));
188 host_impl.active_tree()));
189 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED( 187 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED(
190 host_impl.active_tree()->property_trees()->effect_tree.OnOpacityAnimated( 188 host_impl.active_tree()->SetOpacityMutated(root->element_id(),
191 arbitrary_number, root->effect_tree_index(), 189 arbitrary_number));
192 host_impl.active_tree()));
193 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED( 190 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED(
194 host_impl.active_tree() 191 host_impl.active_tree()->SetTransformMutated(root->element_id(),
195 ->property_trees() 192 arbitrary_transform));
196 ->transform_tree.OnTransformAnimated(arbitrary_transform,
197 root->transform_tree_index(),
198 host_impl.active_tree()));
199 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d); 193 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d);
200 root->SetNeedsPushProperties()); 194 root->SetNeedsPushProperties());
201 // SetBoundsDelta changes subtree only when masks_to_bounds is true and it 195 // SetBoundsDelta changes subtree only when masks_to_bounds is true and it
202 // doesn't set needs_push_properties as it is always called on active tree. 196 // doesn't set needs_push_properties as it is always called on active tree.
203 root->SetMasksToBounds(true); 197 root->SetMasksToBounds(true);
204 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBoundsDelta(arbitrary_vector2d); 198 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBoundsDelta(arbitrary_vector2d);
205 root->SetNeedsPushProperties()); 199 root->SetNeedsPushProperties());
206 200
207 // Changing these properties only affects the layer itself. 201 // Changing these properties only affects the layer itself.
208 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true)); 202 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // verified. 271 // verified.
278 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); 272 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
279 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetDrawsContent(true)); 273 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetDrawsContent(true));
280 274
281 // Create a render surface, because we must have a render surface if we have 275 // Create a render surface, because we must have a render surface if we have
282 // filters. 276 // filters.
283 layer->test_properties()->force_render_surface = true; 277 layer->test_properties()->force_render_surface = true;
284 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 278 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
285 279
286 // Related filter functions. 280 // Related filter functions.
287 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 281 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(host_impl.active_tree()->SetFilterMutated(
288 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 282 root->element_id(), arbitrary_filters));
289 arbitrary_filters, root->effect_tree_index(),
290 host_impl.active_tree()));
291 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 283 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
292 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 284 host_impl.active_tree()->SetFilterMutated(root->element_id(),
293 arbitrary_filters, root->effect_tree_index(), 285 arbitrary_filters));
294 host_impl.active_tree())); 286 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(host_impl.active_tree()->SetFilterMutated(
295 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 287 root->element_id(), FilterOperations()));
296 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 288 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(host_impl.active_tree()->SetFilterMutated(
297 FilterOperations(), root->effect_tree_index(), 289 root->element_id(), arbitrary_filters));
298 host_impl.active_tree()));
299 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
300 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated(
301 arbitrary_filters, root->effect_tree_index(),
302 host_impl.active_tree()));
303 290
304 // Related scrolling functions. 291 // Related scrolling functions.
305 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 292 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
306 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size)); 293 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(large_size));
307 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 294 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
308 host_impl.active_tree()->set_needs_update_draw_properties(); 295 host_impl.active_tree()->set_needs_update_draw_properties();
309 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */); 296 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */);
310 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d)); 297 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(arbitrary_vector2d));
311 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(gfx::Vector2d())); 298 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->ScrollBy(gfx::Vector2d()));
312 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 299 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
(...skipping 13 matching lines...) Expand all
326 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */); 313 host_impl.active_tree()->UpdateDrawProperties(false /* update_lcd_text */);
327 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true); 314 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true);
328 layer->NoteLayerPropertyChanged()); 315 layer->NoteLayerPropertyChanged());
329 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true); 316 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true);
330 layer->NoteLayerPropertyChanged()); 317 layer->NoteLayerPropertyChanged());
331 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f); 318 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f);
332 layer->NoteLayerPropertyChanged()); 319 layer->NoteLayerPropertyChanged());
333 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 320 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
334 layer->SetBackgroundColor(arbitrary_color)); 321 layer->SetBackgroundColor(arbitrary_color));
335 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 322 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
336 host_impl.active_tree()->property_trees()->effect_tree.OnOpacityAnimated( 323 host_impl.active_tree()->SetOpacityMutated(layer->element_id(),
337 arbitrary_number, layer->effect_tree_index(), 324 arbitrary_number));
338 host_impl.active_tree()));
339 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 325 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
340 host_impl.active_tree() 326 host_impl.active_tree()->SetTransformMutated(layer->element_id(),
341 ->property_trees() 327 arbitrary_transform));
342 ->transform_tree.OnTransformAnimated(arbitrary_transform,
343 layer->transform_tree_index(),
344 host_impl.active_tree()));
345 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size); 328 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size);
346 layer->NoteLayerPropertyChanged()); 329 layer->NoteLayerPropertyChanged());
347 330
348 // Unrelated functions, set to the same values, no needs update. 331 // Unrelated functions, set to the same values, no needs update.
349 layer->test_properties()->filters = arbitrary_filters; 332 layer->test_properties()->filters = arbitrary_filters;
350 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 333 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
351 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 334 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
352 host_impl.active_tree()->property_trees()->effect_tree.OnFilterAnimated( 335 host_impl.active_tree()->SetFilterMutated(layer->element_id(),
353 arbitrary_filters, layer->effect_tree_index(), 336 arbitrary_filters));
354 host_impl.active_tree()));
355 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); 337 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true));
356 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); 338 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true));
357 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 339 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
358 layer2->SetPosition(arbitrary_point_f)); 340 layer2->SetPosition(arbitrary_point_f));
359 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); 341 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
360 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 342 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
361 layer->SetBackgroundColor(arbitrary_color)); 343 layer->SetBackgroundColor(arbitrary_color));
362 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); 344 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size));
363 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(ElementId(2, 0))); 345 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(ElementId(2, 0)));
364 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 346 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 562
581 pending_layer->PushPropertiesTo(layer()); 563 pending_layer->PushPropertiesTo(layer());
582 564
583 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 565 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
584 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 566 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
585 pending_layer->CurrentScrollOffset()); 567 pending_layer->CurrentScrollOffset());
586 } 568 }
587 569
588 } // namespace 570 } // namespace
589 } // namespace cc 571 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698