| 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/output/filter_operation.h" | 8 #include "cc/output/filter_operation.h" |
| 9 #include "cc/output/filter_operations.h" | 9 #include "cc/output/filter_operations.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { | 79 TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { |
| 80 // | 80 // |
| 81 // This test checks that layerPropertyChanged() has the correct behavior. | 81 // This test checks that layerPropertyChanged() has the correct behavior. |
| 82 // | 82 // |
| 83 | 83 |
| 84 // The constructor on this will fake that we are on the correct thread. | 84 // The constructor on this will fake that we are on the correct thread. |
| 85 // Create a simple LayerImpl tree: | 85 // Create a simple LayerImpl tree: |
| 86 FakeImplProxy proxy; | 86 FakeImplProxy proxy; |
| 87 TestSharedBitmapManager shared_bitmap_manager; | 87 TestSharedBitmapManager shared_bitmap_manager; |
| 88 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 88 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 89 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); | 89 EXPECT_TRUE(host_impl.InitializeRenderer( |
| 90 FakeOutputSurface::Create3d().PassAs<OutputSurface>())); |
| 90 scoped_ptr<LayerImpl> root_clip = | 91 scoped_ptr<LayerImpl> root_clip = |
| 91 LayerImpl::Create(host_impl.active_tree(), 1); | 92 LayerImpl::Create(host_impl.active_tree(), 1); |
| 92 scoped_ptr<LayerImpl> root_ptr = | 93 scoped_ptr<LayerImpl> root_ptr = |
| 93 LayerImpl::Create(host_impl.active_tree(), 2); | 94 LayerImpl::Create(host_impl.active_tree(), 2); |
| 94 LayerImpl* root = root_ptr.get(); | 95 LayerImpl* root = root_ptr.get(); |
| 95 root_clip->AddChild(root_ptr.Pass()); | 96 root_clip->AddChild(root_ptr.Pass()); |
| 96 scoped_ptr<LayerImpl> scroll_parent = | 97 scoped_ptr<LayerImpl> scroll_parent = |
| 97 LayerImpl::Create(host_impl.active_tree(), 3); | 98 LayerImpl::Create(host_impl.active_tree(), 3); |
| 98 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); | 99 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); |
| 99 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); | 100 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 240 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 240 root->SetClipParent(clip_parent.get())); | 241 root->SetClipParent(clip_parent.get())); |
| 241 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 242 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 242 root->SetClipChildren(clip_children)); | 243 root->SetClipChildren(clip_children)); |
| 243 } | 244 } |
| 244 | 245 |
| 245 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { | 246 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { |
| 246 FakeImplProxy proxy; | 247 FakeImplProxy proxy; |
| 247 TestSharedBitmapManager shared_bitmap_manager; | 248 TestSharedBitmapManager shared_bitmap_manager; |
| 248 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 249 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 249 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); | 250 EXPECT_TRUE(host_impl.InitializeRenderer( |
| 251 FakeOutputSurface::Create3d().PassAs<OutputSurface>())); |
| 250 host_impl.active_tree()->SetRootLayer( | 252 host_impl.active_tree()->SetRootLayer( |
| 251 LayerImpl::Create(host_impl.active_tree(), 1)); | 253 LayerImpl::Create(host_impl.active_tree(), 1)); |
| 252 LayerImpl* root = host_impl.active_tree()->root_layer(); | 254 LayerImpl* root = host_impl.active_tree()->root_layer(); |
| 253 scoped_ptr<LayerImpl> layer_ptr = | 255 scoped_ptr<LayerImpl> layer_ptr = |
| 254 LayerImpl::Create(host_impl.active_tree(), 2); | 256 LayerImpl::Create(host_impl.active_tree(), 2); |
| 255 LayerImpl* layer = layer_ptr.get(); | 257 LayerImpl* layer = layer_ptr.get(); |
| 256 root->AddChild(layer_ptr.Pass()); | 258 root->AddChild(layer_ptr.Pass()); |
| 257 layer->SetScrollClipLayer(root->id()); | 259 layer->SetScrollClipLayer(root->id()); |
| 258 DCHECK(host_impl.CanDraw()); | 260 DCHECK(host_impl.CanDraw()); |
| 259 | 261 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 layer->SetIsRootForIsolatedGroup(true)); | 350 layer->SetIsRootForIsolatedGroup(true)); |
| 349 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 351 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 350 layer->SetTransform(arbitrary_transform)); | 352 layer->SetTransform(arbitrary_transform)); |
| 351 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); | 353 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); |
| 352 } | 354 } |
| 353 | 355 |
| 354 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { | 356 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { |
| 355 FakeImplProxy proxy; | 357 FakeImplProxy proxy; |
| 356 TestSharedBitmapManager shared_bitmap_manager; | 358 TestSharedBitmapManager shared_bitmap_manager; |
| 357 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 359 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 358 EXPECT_TRUE(host_impl.InitializeRenderer(FakeOutputSurface::Create3d())); | 360 EXPECT_TRUE(host_impl.InitializeRenderer( |
| 361 FakeOutputSurface::Create3d().PassAs<OutputSurface>())); |
| 359 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); | 362 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); |
| 360 | 363 |
| 361 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 364 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
| 362 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 365 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
| 363 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { | 366 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
| 364 layer->SetContentsOpaque(!!contents_opaque); | 367 layer->SetContentsOpaque(!!contents_opaque); |
| 365 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED | 368 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED |
| 366 : SK_ColorTRANSPARENT); | 369 : SK_ColorTRANSPARENT); |
| 367 host_impl.active_tree()->set_background_color( | 370 host_impl.active_tree()->set_background_color( |
| 368 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT); | 371 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 layer()->id(), tree()->root_layer()->id()); | 684 layer()->id(), tree()->root_layer()->id()); |
| 682 | 685 |
| 683 int expected_horizontal_maximum = | 686 int expected_horizontal_maximum = |
| 684 layer()->bounds().width() - tree()->root_layer()->bounds().width(); | 687 layer()->bounds().width() - tree()->root_layer()->bounds().width(); |
| 685 EXPECT_EQ(expected_horizontal_maximum, horizontal_scrollbar->maximum()); | 688 EXPECT_EQ(expected_horizontal_maximum, horizontal_scrollbar->maximum()); |
| 686 EXPECT_EQ(scroll_offset.x(), horizontal_scrollbar->current_pos()); | 689 EXPECT_EQ(scroll_offset.x(), horizontal_scrollbar->current_pos()); |
| 687 } | 690 } |
| 688 | 691 |
| 689 } // namespace | 692 } // namespace |
| 690 } // namespace cc | 693 } // namespace cc |
| OLD | NEW |