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

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

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

Powered by Google App Engine
This is Rietveld 408576698