OLD | NEW |
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/layers/painted_scrollbar_layer_impl.h" | 7 #include "cc/layers/painted_scrollbar_layer_impl.h" |
8 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 8 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
9 #include "cc/output/filter_operation.h" | 9 #include "cc/output/filter_operation.h" |
10 #include "cc/output/filter_operations.h" | 10 #include "cc/output/filter_operations.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { | 82 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { |
83 // | 83 // |
84 // This test checks that layerPropertyChanged() has the correct behavior. | 84 // This test checks that layerPropertyChanged() has the correct behavior. |
85 // | 85 // |
86 | 86 |
87 // The constructor on this will fake that we are on the correct thread. | 87 // The constructor on this will fake that we are on the correct thread. |
88 // Create a simple LayerImpl tree: | 88 // Create a simple LayerImpl tree: |
89 FakeImplProxy proxy; | 89 FakeImplProxy proxy; |
90 TestSharedBitmapManager shared_bitmap_manager; | 90 TestSharedBitmapManager shared_bitmap_manager; |
91 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); | 91 TestTaskGraphRunner task_graph_runner; |
| 92 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 93 &task_graph_runner); |
92 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); | 94 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); |
93 scoped_ptr<LayerImpl> root_clip = | 95 scoped_ptr<LayerImpl> root_clip = |
94 LayerImpl::Create(host_impl.active_tree(), 1); | 96 LayerImpl::Create(host_impl.active_tree(), 1); |
95 scoped_ptr<LayerImpl> root_ptr = | 97 scoped_ptr<LayerImpl> root_ptr = |
96 LayerImpl::Create(host_impl.active_tree(), 2); | 98 LayerImpl::Create(host_impl.active_tree(), 2); |
97 LayerImpl* root = root_ptr.get(); | 99 LayerImpl* root = root_ptr.get(); |
98 root_clip->AddChild(root_ptr.Pass()); | 100 root_clip->AddChild(root_ptr.Pass()); |
99 scoped_ptr<LayerImpl> scroll_parent = | 101 scoped_ptr<LayerImpl> scroll_parent = |
100 LayerImpl::Create(host_impl.active_tree(), 3); | 102 LayerImpl::Create(host_impl.active_tree(), 3); |
101 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); | 103 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 root->SetScrollChildren(scroll_children)); | 246 root->SetScrollChildren(scroll_children)); |
245 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 247 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
246 root->SetClipParent(clip_parent.get())); | 248 root->SetClipParent(clip_parent.get())); |
247 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 249 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
248 root->SetClipChildren(clip_children)); | 250 root->SetClipChildren(clip_children)); |
249 } | 251 } |
250 | 252 |
251 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { | 253 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { |
252 FakeImplProxy proxy; | 254 FakeImplProxy proxy; |
253 TestSharedBitmapManager shared_bitmap_manager; | 255 TestSharedBitmapManager shared_bitmap_manager; |
254 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); | 256 TestTaskGraphRunner task_graph_runner; |
| 257 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 258 &task_graph_runner); |
255 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); | 259 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); |
256 host_impl.active_tree()->SetRootLayer( | 260 host_impl.active_tree()->SetRootLayer( |
257 LayerImpl::Create(host_impl.active_tree(), 1)); | 261 LayerImpl::Create(host_impl.active_tree(), 1)); |
258 LayerImpl* root = host_impl.active_tree()->root_layer(); | 262 LayerImpl* root = host_impl.active_tree()->root_layer(); |
259 root->SetHasRenderSurface(true); | 263 root->SetHasRenderSurface(true); |
260 scoped_ptr<LayerImpl> layer_ptr = | 264 scoped_ptr<LayerImpl> layer_ptr = |
261 LayerImpl::Create(host_impl.active_tree(), 2); | 265 LayerImpl::Create(host_impl.active_tree(), 2); |
262 LayerImpl* layer = layer_ptr.get(); | 266 LayerImpl* layer = layer_ptr.get(); |
263 root->AddChild(layer_ptr.Pass()); | 267 root->AddChild(layer_ptr.Pass()); |
264 layer->SetScrollClipLayer(root->id()); | 268 layer->SetScrollClipLayer(root->id()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 366 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
363 layer->SetIsRootForIsolatedGroup(true)); | 367 layer->SetIsRootForIsolatedGroup(true)); |
364 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 368 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
365 layer->SetTransform(arbitrary_transform)); | 369 layer->SetTransform(arbitrary_transform)); |
366 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); | 370 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); |
367 } | 371 } |
368 | 372 |
369 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { | 373 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { |
370 FakeImplProxy proxy; | 374 FakeImplProxy proxy; |
371 TestSharedBitmapManager shared_bitmap_manager; | 375 TestSharedBitmapManager shared_bitmap_manager; |
372 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); | 376 TestTaskGraphRunner task_graph_runner; |
| 377 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 378 &task_graph_runner); |
373 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); | 379 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); |
374 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); | 380 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); |
375 | 381 |
376 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 382 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
377 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 383 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
378 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { | 384 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
379 layer->SetContentsOpaque(!!contents_opaque); | 385 layer->SetContentsOpaque(!!contents_opaque); |
380 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED | 386 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED |
381 : SK_ColorTRANSPARENT); | 387 : SK_ColorTRANSPARENT); |
382 host_impl.active_tree()->set_background_color( | 388 host_impl.active_tree()->set_background_color( |
(...skipping 10 matching lines...) Expand all Loading... |
393 << host_opaque << "\n"; | 399 << host_opaque << "\n"; |
394 } | 400 } |
395 } | 401 } |
396 } | 402 } |
397 } | 403 } |
398 } | 404 } |
399 | 405 |
400 TEST(LayerImplTest, TransformInvertibility) { | 406 TEST(LayerImplTest, TransformInvertibility) { |
401 FakeImplProxy proxy; | 407 FakeImplProxy proxy; |
402 TestSharedBitmapManager shared_bitmap_manager; | 408 TestSharedBitmapManager shared_bitmap_manager; |
403 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr); | 409 TestTaskGraphRunner task_graph_runner; |
| 410 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 411 &task_graph_runner); |
404 | 412 |
405 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); | 413 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); |
406 EXPECT_TRUE(layer->transform().IsInvertible()); | 414 EXPECT_TRUE(layer->transform().IsInvertible()); |
407 EXPECT_TRUE(layer->transform_is_invertible()); | 415 EXPECT_TRUE(layer->transform_is_invertible()); |
408 | 416 |
409 gfx::Transform transform; | 417 gfx::Transform transform; |
410 transform.Scale3d( | 418 transform.Scale3d( |
411 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); | 419 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); |
412 layer->SetTransform(transform); | 420 layer->SetTransform(transform); |
413 EXPECT_FALSE(layer->transform().IsInvertible()); | 421 EXPECT_FALSE(layer->transform().IsInvertible()); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 | 734 |
727 ASSERT_TRUE(layer(IV_SCROLL, ACTIVE)->scrollable()); | 735 ASSERT_TRUE(layer(IV_SCROLL, ACTIVE)->scrollable()); |
728 | 736 |
729 ASSERT_TRUE(LayerHasScrollbar(OV_SCROLL, ACTIVE)); | 737 ASSERT_TRUE(LayerHasScrollbar(OV_SCROLL, ACTIVE)); |
730 ASSERT_TRUE(LayerHasScrollbar(IV_CLIP, ACTIVE)); | 738 ASSERT_TRUE(LayerHasScrollbar(IV_CLIP, ACTIVE)); |
731 ASSERT_TRUE(LayerHasScrollbar(IV_SCROLL, ACTIVE)); | 739 ASSERT_TRUE(LayerHasScrollbar(IV_SCROLL, ACTIVE)); |
732 } | 740 } |
733 | 741 |
734 } // namespace | 742 } // namespace |
735 } // namespace cc | 743 } // namespace cc |
OLD | NEW |