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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 TestTaskGraphRunner task_graph_runner; | 91 TestTaskGraphRunner task_graph_runner; |
92 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 92 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
93 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 93 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
94 &task_graph_runner); | 94 &task_graph_runner); |
| 95 host_impl.SetVisible(true); |
95 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 96 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
96 scoped_ptr<LayerImpl> root_clip = | 97 scoped_ptr<LayerImpl> root_clip = |
97 LayerImpl::Create(host_impl.active_tree(), 1); | 98 LayerImpl::Create(host_impl.active_tree(), 1); |
98 scoped_ptr<LayerImpl> root_ptr = | 99 scoped_ptr<LayerImpl> root_ptr = |
99 LayerImpl::Create(host_impl.active_tree(), 2); | 100 LayerImpl::Create(host_impl.active_tree(), 2); |
100 LayerImpl* root = root_ptr.get(); | 101 LayerImpl* root = root_ptr.get(); |
101 root_clip->AddChild(root_ptr.Pass()); | 102 root_clip->AddChild(root_ptr.Pass()); |
102 scoped_ptr<LayerImpl> scroll_parent = | 103 scoped_ptr<LayerImpl> scroll_parent = |
103 LayerImpl::Create(host_impl.active_tree(), 3); | 104 LayerImpl::Create(host_impl.active_tree(), 3); |
104 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); | 105 LayerImpl* scroll_child = LayerImpl::Create(host_impl.active_tree(), 4).get(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 root->SetClipChildren(clip_children)); | 245 root->SetClipChildren(clip_children)); |
245 } | 246 } |
246 | 247 |
247 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { | 248 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { |
248 FakeImplProxy proxy; | 249 FakeImplProxy proxy; |
249 TestSharedBitmapManager shared_bitmap_manager; | 250 TestSharedBitmapManager shared_bitmap_manager; |
250 TestTaskGraphRunner task_graph_runner; | 251 TestTaskGraphRunner task_graph_runner; |
251 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 252 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
252 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 253 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
253 &task_graph_runner); | 254 &task_graph_runner); |
| 255 host_impl.SetVisible(true); |
254 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 256 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
255 host_impl.active_tree()->SetRootLayer( | 257 host_impl.active_tree()->SetRootLayer( |
256 LayerImpl::Create(host_impl.active_tree(), 1)); | 258 LayerImpl::Create(host_impl.active_tree(), 1)); |
257 LayerImpl* root = host_impl.active_tree()->root_layer(); | 259 LayerImpl* root = host_impl.active_tree()->root_layer(); |
258 root->SetHasRenderSurface(true); | 260 root->SetHasRenderSurface(true); |
259 scoped_ptr<LayerImpl> layer_ptr = | 261 scoped_ptr<LayerImpl> layer_ptr = |
260 LayerImpl::Create(host_impl.active_tree(), 2); | 262 LayerImpl::Create(host_impl.active_tree(), 2); |
261 LayerImpl* layer = layer_ptr.get(); | 263 LayerImpl* layer = layer_ptr.get(); |
262 root->AddChild(layer_ptr.Pass()); | 264 root->AddChild(layer_ptr.Pass()); |
263 layer->SetScrollClipLayer(root->id()); | 265 layer->SetScrollClipLayer(root->id()); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); | 361 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); |
360 } | 362 } |
361 | 363 |
362 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { | 364 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { |
363 FakeImplProxy proxy; | 365 FakeImplProxy proxy; |
364 TestSharedBitmapManager shared_bitmap_manager; | 366 TestSharedBitmapManager shared_bitmap_manager; |
365 TestTaskGraphRunner task_graph_runner; | 367 TestTaskGraphRunner task_graph_runner; |
366 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 368 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
367 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 369 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
368 &task_graph_runner); | 370 &task_graph_runner); |
| 371 host_impl.SetVisible(true); |
369 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 372 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
370 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); | 373 scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1); |
371 | 374 |
372 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 375 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
373 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 376 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
374 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { | 377 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
375 layer->SetContentsOpaque(!!contents_opaque); | 378 layer->SetContentsOpaque(!!contents_opaque); |
376 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED | 379 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED |
377 : SK_ColorTRANSPARENT); | 380 : SK_ColorTRANSPARENT); |
378 host_impl.active_tree()->set_background_color( | 381 host_impl.active_tree()->set_background_color( |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 727 |
725 ASSERT_TRUE(layer(IV_SCROLL, ACTIVE)->scrollable()); | 728 ASSERT_TRUE(layer(IV_SCROLL, ACTIVE)->scrollable()); |
726 | 729 |
727 ASSERT_TRUE(LayerHasScrollbar(OV_SCROLL, ACTIVE)); | 730 ASSERT_TRUE(LayerHasScrollbar(OV_SCROLL, ACTIVE)); |
728 ASSERT_TRUE(LayerHasScrollbar(IV_CLIP, ACTIVE)); | 731 ASSERT_TRUE(LayerHasScrollbar(IV_CLIP, ACTIVE)); |
729 ASSERT_TRUE(LayerHasScrollbar(IV_SCROLL, ACTIVE)); | 732 ASSERT_TRUE(LayerHasScrollbar(IV_SCROLL, ACTIVE)); |
730 } | 733 } |
731 | 734 |
732 } // namespace | 735 } // namespace |
733 } // namespace cc | 736 } // namespace cc |
OLD | NEW |