OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
6 | 6 |
7 #include "cc/layers/heads_up_display_layer_impl.h" | 7 #include "cc/layers/heads_up_display_layer_impl.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
11 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
12 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
13 #include "cc/test/geometry_test_utils.h" | 13 #include "cc/test/geometry_test_utils.h" |
14 #include "cc/test/layer_tree_host_common_test.h" | 14 #include "cc/test/layer_tree_host_common_test.h" |
15 #include "cc/test/test_shared_bitmap_manager.h" | 15 #include "cc/test/test_shared_bitmap_manager.h" |
16 #include "cc/test/test_task_graph_runner.h" | 16 #include "cc/test/test_task_graph_runner.h" |
17 #include "cc/trees/layer_tree_host_impl.h" | 17 #include "cc/trees/layer_tree_host_impl.h" |
18 #include "ui/gfx/geometry/size_conversions.h" | 18 #include "ui/gfx/geometry/size_conversions.h" |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 namespace { | 21 namespace { |
22 | 22 |
23 class LayerTreeImplTest : public LayerTreeHostCommonTest { | 23 class LayerTreeImplTest : public LayerTreeHostCommonTest { |
24 public: | 24 public: |
25 LayerTreeImplTest() : output_surface_(FakeOutputSurface::Create3d()) { | 25 LayerTreeImplTest() { |
26 LayerTreeSettings settings; | 26 LayerTreeSettings settings; |
27 settings.layer_transforms_should_scale_layer_contents = true; | 27 settings.layer_transforms_should_scale_layer_contents = true; |
28 host_impl_.reset(new FakeLayerTreeHostImpl( | 28 host_impl_.reset(new FakeLayerTreeHostImpl( |
29 settings, &proxy_, &shared_bitmap_manager_, &task_graph_runner_)); | 29 settings, &proxy_, &shared_bitmap_manager_, &task_graph_runner_)); |
30 EXPECT_TRUE(host_impl_->InitializeRenderer(output_surface_.get())); | 30 EXPECT_TRUE(host_impl_->InitializeRenderer(FakeOutputSurface::Create3d())); |
31 } | 31 } |
32 | 32 |
33 FakeLayerTreeHostImpl& host_impl() { return *host_impl_; } | 33 FakeLayerTreeHostImpl& host_impl() { return *host_impl_; } |
34 | 34 |
35 LayerImpl* root_layer() { return host_impl_->active_tree()->root_layer(); } | 35 LayerImpl* root_layer() { return host_impl_->active_tree()->root_layer(); } |
36 | 36 |
37 const LayerImplList& RenderSurfaceLayerList() const { | 37 const LayerImplList& RenderSurfaceLayerList() const { |
38 return host_impl_->active_tree()->RenderSurfaceLayerList(); | 38 return host_impl_->active_tree()->RenderSurfaceLayerList(); |
39 } | 39 } |
40 | 40 |
41 private: | 41 private: |
42 TestSharedBitmapManager shared_bitmap_manager_; | 42 TestSharedBitmapManager shared_bitmap_manager_; |
43 TestTaskGraphRunner task_graph_runner_; | 43 TestTaskGraphRunner task_graph_runner_; |
44 FakeImplProxy proxy_; | 44 FakeImplProxy proxy_; |
45 scoped_ptr<OutputSurface> output_surface_; | |
46 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; | 45 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; |
47 }; | 46 }; |
48 | 47 |
49 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { | 48 TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { |
50 scoped_ptr<LayerImpl> root = | 49 scoped_ptr<LayerImpl> root = |
51 LayerImpl::Create(host_impl().active_tree(), 12345); | 50 LayerImpl::Create(host_impl().active_tree(), 12345); |
52 | 51 |
53 gfx::Transform identity_matrix; | 52 gfx::Transform identity_matrix; |
54 gfx::Point3F transform_origin; | 53 gfx::Point3F transform_origin; |
55 gfx::PointF position; | 54 gfx::PointF position; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 EXPECT_EQ(12345, result_layer->id()); | 90 EXPECT_EQ(12345, result_layer->id()); |
92 } | 91 } |
93 | 92 |
94 TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) { | 93 TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) { |
95 // Ensures that the viewport rect is correctly updated by the clip tree. | 94 // Ensures that the viewport rect is correctly updated by the clip tree. |
96 TestSharedBitmapManager shared_bitmap_manager; | 95 TestSharedBitmapManager shared_bitmap_manager; |
97 TestTaskGraphRunner task_graph_runner; | 96 TestTaskGraphRunner task_graph_runner; |
98 FakeImplProxy proxy; | 97 FakeImplProxy proxy; |
99 LayerTreeSettings settings; | 98 LayerTreeSettings settings; |
100 settings.verify_property_trees = true; | 99 settings.verify_property_trees = true; |
101 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | |
102 scoped_ptr<FakeLayerTreeHostImpl> host_impl; | 100 scoped_ptr<FakeLayerTreeHostImpl> host_impl; |
103 host_impl.reset(new FakeLayerTreeHostImpl( | 101 host_impl.reset(new FakeLayerTreeHostImpl( |
104 settings, &proxy, &shared_bitmap_manager, &task_graph_runner)); | 102 settings, &proxy, &shared_bitmap_manager, &task_graph_runner)); |
105 EXPECT_TRUE(host_impl->InitializeRenderer(output_surface.get())); | 103 EXPECT_TRUE(host_impl->InitializeRenderer(FakeOutputSurface::Create3d())); |
106 scoped_ptr<LayerImpl> root = | 104 scoped_ptr<LayerImpl> root = |
107 LayerImpl::Create(host_impl->active_tree(), 12345); | 105 LayerImpl::Create(host_impl->active_tree(), 12345); |
108 | 106 |
109 gfx::Transform identity_matrix; | 107 gfx::Transform identity_matrix; |
110 gfx::Point3F transform_origin; | 108 gfx::Point3F transform_origin; |
111 gfx::PointF position; | 109 gfx::PointF position; |
112 gfx::Size bounds(100, 100); | 110 gfx::Size bounds(100, 100); |
113 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 111 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
114 position, bounds, true, false, true); | 112 position, bounds, true, false, true); |
115 root->SetDrawsContent(true); | 113 root->SetDrawsContent(true); |
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2017 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2015 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
2018 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2016 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
2019 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2017 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); |
2020 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2018 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); |
2021 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2019 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); |
2022 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2020 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); |
2023 } | 2021 } |
2024 | 2022 |
2025 } // namespace | 2023 } // namespace |
2026 } // namespace cc | 2024 } // namespace cc |
OLD | NEW |