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

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

Issue 1918593002: cc : Stop pushing properties not used by LayerImpl to LayerImpl (3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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_test_properties.h ('k') | cc/layers/layer_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/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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 host_impl.active_tree()->property_trees()->needs_rebuild = true; 219 host_impl.active_tree()->property_trees()->needs_rebuild = true;
220 host_impl.active_tree()->BuildPropertyTreesForTesting(); 220 host_impl.active_tree()->BuildPropertyTreesForTesting();
221 221
222 root->SetMasksToBounds(true); 222 root->SetMasksToBounds(true);
223 host_impl.active_tree()->property_trees()->needs_rebuild = true; 223 host_impl.active_tree()->property_trees()->needs_rebuild = true;
224 host_impl.active_tree()->BuildPropertyTreesForTesting(); 224 host_impl.active_tree()->BuildPropertyTreesForTesting();
225 225
226 // Changing these properties does not cause the layer to be marked as changed 226 // Changing these properties does not cause the layer to be marked as changed
227 // but does cause the layer to need to push properties. 227 // but does cause the layer to need to push properties.
228 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 228 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
229 root->SetIsRootForIsolatedGroup(true));
230 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
231 root->SetElementId(2)); 229 root->SetElementId(2));
232 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 230 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
233 root->SetMutableProperties(MutableProperty::kOpacity)); 231 root->SetMutableProperties(MutableProperty::kOpacity));
234 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 232 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
235 root->SetScrollParent(scroll_parent.get())); 233 root->SetScrollParent(scroll_parent.get()));
236 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 234 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
237 root->SetScrollChildren(scroll_children)); 235 root->SetScrollChildren(scroll_children));
238 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 236 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
239 root->SetClipParent(clip_parent.get())); 237 root->SetClipParent(clip_parent.get()));
240 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 238 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
241 root->SetClipChildren(clip_children)); 239 root->SetClipChildren(clip_children));
242 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
243 root->SetNumDescendantsThatDrawContent(10));
244 240
245 // After setting all these properties already, setting to the exact same 241 // After setting all these properties already, setting to the exact same
246 // values again should not cause any change. 242 // values again should not cause any change.
247 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true)); 243 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true));
248 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 244 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
249 root->SetPosition(arbitrary_point_f)); 245 root->SetPosition(arbitrary_point_f));
250 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
251 root->SetShouldFlattenTransform(false));
252 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1)); 246 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1));
253 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 247 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
254 root->SetTransform(arbitrary_transform)); 248 root->SetTransform(arbitrary_transform));
255 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true)); 249 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true));
256 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetOpacity(arbitrary_number)); 250 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetOpacity(arbitrary_number));
257 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 251 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
258 root->SetBlendMode(arbitrary_blend_mode)); 252 root->SetBlendMode(arbitrary_blend_mode));
259 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
260 root->SetIsRootForIsolatedGroup(true));
261 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true)); 253 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true));
262 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size)); 254 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size));
263 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 255 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
264 root->SetScrollParent(scroll_parent.get())); 256 root->SetScrollParent(scroll_parent.get()));
265 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 257 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
266 root->SetScrollChildren(scroll_children)); 258 root->SetScrollChildren(scroll_children));
267 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 259 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
268 root->SetClipParent(clip_parent.get())); 260 root->SetClipParent(clip_parent.get()));
269 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 261 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
270 root->SetClipChildren(clip_children)); 262 root->SetClipChildren(clip_children));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 host_impl.active_tree()->BuildPropertyTreesForTesting(); 349 host_impl.active_tree()->BuildPropertyTreesForTesting();
358 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true); 350 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true);
359 layer->NoteLayerPropertyChanged()); 351 layer->NoteLayerPropertyChanged());
360 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true); 352 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true);
361 layer->NoteLayerPropertyChanged()); 353 layer->NoteLayerPropertyChanged());
362 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 354 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
363 layer->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5)); 355 layer->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5));
364 layer->NoteLayerPropertyChanged()); 356 layer->NoteLayerPropertyChanged());
365 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f); 357 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f);
366 layer->NoteLayerPropertyChanged()); 358 layer->NoteLayerPropertyChanged());
367 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetShouldFlattenTransform(false);
368 layer->NoteLayerPropertyChanged());
369 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1); 359 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1);
370 layer->NoteLayerPropertyChanged()); 360 layer->NoteLayerPropertyChanged());
371 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 361 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
372 layer->SetBackgroundColor(arbitrary_color)); 362 layer->SetBackgroundColor(arbitrary_color));
373 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 363 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
374 layer->SetBackgroundFilters(arbitrary_filters)); 364 layer->SetBackgroundFilters(arbitrary_filters));
375 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 365 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
376 layer->OnOpacityAnimated(arbitrary_number)); 366 layer->OnOpacityAnimated(arbitrary_number));
377 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBlendMode(arbitrary_blend_mode); 367 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBlendMode(arbitrary_blend_mode);
378 layer->NoteLayerPropertyChanged()); 368 layer->NoteLayerPropertyChanged());
379 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 369 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
380 layer->OnTransformAnimated(arbitrary_transform)); 370 layer->OnTransformAnimated(arbitrary_transform));
381 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size); 371 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size);
382 layer->NoteLayerPropertyChanged()); 372 layer->NoteLayerPropertyChanged());
383 373
384 // Unrelated functions, set to the same values, no needs update. 374 // Unrelated functions, set to the same values, no needs update.
385 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
386 layer->SetIsRootForIsolatedGroup(true));
387 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 375 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters));
388 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); 376 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true));
389 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); 377 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true));
390 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 378 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
391 layer2->SetPosition(arbitrary_point_f)); 379 layer2->SetPosition(arbitrary_point_f));
392 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1)); 380 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1));
393 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); 381 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
394 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 382 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
395 layer->SetBackgroundColor(arbitrary_color)); 383 layer->SetBackgroundColor(arbitrary_color));
396 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 384 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
397 layer->SetBackgroundFilters(arbitrary_filters)); 385 layer->SetBackgroundFilters(arbitrary_filters));
398 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetOpacity(arbitrary_number)); 386 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetOpacity(arbitrary_number));
399 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 387 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
400 layer->SetBlendMode(arbitrary_blend_mode)); 388 layer->SetBlendMode(arbitrary_blend_mode));
401 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 389 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
402 layer->SetIsRootForIsolatedGroup(true));
403 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
404 layer->SetTransform(arbitrary_transform)); 390 layer->SetTransform(arbitrary_transform));
405 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); 391 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size));
406 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(2)); 392 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(2));
407 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 393 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
408 layer->SetMutableProperties(MutableProperty::kTransform)); 394 layer->SetMutableProperties(MutableProperty::kTransform));
409 } 395 }
410 396
411 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { 397 TEST(LayerImplTest, SafeOpaqueBackgroundColor) {
412 FakeImplTaskRunnerProvider task_runner_provider; 398 FakeImplTaskRunnerProvider task_runner_provider;
413 TestSharedBitmapManager shared_bitmap_manager; 399 TestSharedBitmapManager shared_bitmap_manager;
(...skipping 26 matching lines...) Expand all
440 } else { 426 } else {
441 EXPECT_NE(SkColorGetA(safe_color), 255u) 427 EXPECT_NE(SkColorGetA(safe_color), 255u)
442 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " 428 << "Flags: " << contents_opaque << ", " << layer_opaque << ", "
443 << host_opaque << "\n"; 429 << host_opaque << "\n";
444 } 430 }
445 } 431 }
446 } 432 }
447 } 433 }
448 } 434 }
449 435
450 TEST(LayerImplTest, TransformInvertibility) {
451 FakeImplTaskRunnerProvider task_runner_provider;
452 TestSharedBitmapManager shared_bitmap_manager;
453 TestTaskGraphRunner task_graph_runner;
454 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
455 &task_graph_runner);
456
457 std::unique_ptr<LayerImpl> layer =
458 LayerImpl::Create(host_impl.active_tree(), 1);
459 EXPECT_TRUE(layer->transform().IsInvertible());
460 EXPECT_TRUE(layer->transform_is_invertible());
461
462 gfx::Transform transform;
463 transform.Scale3d(
464 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0));
465 layer->SetTransform(transform);
466 EXPECT_FALSE(layer->transform().IsInvertible());
467 EXPECT_FALSE(layer->transform_is_invertible());
468
469 transform.MakeIdentity();
470 transform.ApplyPerspectiveDepth(SkDoubleToMScalar(100.0));
471 transform.RotateAboutZAxis(75.0);
472 transform.RotateAboutXAxis(32.2);
473 transform.RotateAboutZAxis(-75.0);
474 transform.Translate3d(SkDoubleToMScalar(50.5),
475 SkDoubleToMScalar(42.42),
476 SkDoubleToMScalar(-100.25));
477
478 layer->SetTransform(transform);
479 EXPECT_TRUE(layer->transform().IsInvertible());
480 EXPECT_TRUE(layer->transform_is_invertible());
481 }
482
483 class LayerImplScrollTest : public testing::Test { 436 class LayerImplScrollTest : public testing::Test {
484 public: 437 public:
485 LayerImplScrollTest() 438 LayerImplScrollTest()
486 : host_impl_(settings(), 439 : host_impl_(settings(),
487 &task_runner_provider_, 440 &task_runner_provider_,
488 &shared_bitmap_manager_, 441 &shared_bitmap_manager_,
489 &task_graph_runner_), 442 &task_graph_runner_),
490 root_id_(7) { 443 root_id_(7) {
491 host_impl_.active_tree()->SetRootLayer( 444 host_impl_.active_tree()->SetRootLayer(
492 LayerImpl::Create(host_impl_.active_tree(), root_id_)); 445 LayerImpl::Create(host_impl_.active_tree(), root_id_));
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 606
654 pending_layer->PushPropertiesTo(layer()); 607 pending_layer->PushPropertiesTo(layer());
655 608
656 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 609 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
657 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 610 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
658 pending_layer->CurrentScrollOffset()); 611 pending_layer->CurrentScrollOffset());
659 } 612 }
660 613
661 } // namespace 614 } // namespace
662 } // namespace cc 615 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl_test_properties.h ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698