OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "cc/test/fake_content_layer_client.h" | 7 #include "cc/test/fake_content_layer_client.h" |
8 #include "cc/test/fake_picture_layer.h" | 8 #include "cc/test/fake_picture_layer.h" |
9 #include "cc/test/fake_picture_layer_impl.h" | 9 #include "cc/test/fake_picture_layer_impl.h" |
10 #include "cc/test/layer_tree_test.h" | 10 #include "cc/test/layer_tree_test.h" |
11 #include "cc/trees/layer_tree_impl.h" | 11 #include "cc/trees/layer_tree_impl.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 namespace { | 14 namespace { |
15 | 15 |
16 // These tests deal with picture layers. | 16 // These tests deal with picture layers. |
17 class LayerTreeHostPictureTest : public LayerTreeTest { | 17 class LayerTreeHostPictureTest : public LayerTreeTest { |
18 protected: | 18 protected: |
19 void InitializeSettings(LayerTreeSettings* settings) override { | 19 void SetupTreeWithSinglePictureLayer(const gfx::Size& size) { |
20 // PictureLayer can only be used with impl side painting enabled. | 20 scoped_refptr<Layer> root = Layer::Create(); |
21 settings->impl_side_painting = true; | 21 root->SetBounds(size); |
| 22 |
| 23 root_picture_layer_ = FakePictureLayer::Create(&client_); |
| 24 root_picture_layer_->SetBounds(size); |
| 25 root->AddChild(root_picture_layer_); |
| 26 |
| 27 layer_tree_host()->SetRootLayer(root); |
22 } | 28 } |
| 29 |
| 30 scoped_refptr<FakePictureLayer> root_picture_layer_; |
| 31 FakeContentLayerClient client_; |
23 }; | 32 }; |
24 | 33 |
25 class LayerTreeHostPictureTestTwinLayer | 34 class LayerTreeHostPictureTestTwinLayer |
26 : public LayerTreeHostPictureTest { | 35 : public LayerTreeHostPictureTest { |
27 void SetupTree() override { | 36 void SetupTree() override { |
28 LayerTreeHostPictureTest::SetupTree(); | 37 SetupTreeWithSinglePictureLayer(gfx::Size(1, 1)); |
29 | |
30 scoped_refptr<FakePictureLayer> picture = | |
31 FakePictureLayer::Create(&client_); | |
32 layer_tree_host()->root_layer()->AddChild(picture); | |
33 } | 38 } |
34 | 39 |
35 void BeginTest() override { | 40 void BeginTest() override { |
36 activates_ = 0; | 41 activates_ = 0; |
37 PostSetNeedsCommitToMainThread(); | 42 PostSetNeedsCommitToMainThread(); |
38 } | 43 } |
39 | 44 |
40 void DidCommit() override { | 45 void DidCommit() override { |
41 switch (layer_tree_host()->source_frame_number()) { | 46 switch (layer_tree_host()->source_frame_number()) { |
42 case 2: | 47 case 2: |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 115 |
111 ++activates_; | 116 ++activates_; |
112 if (activates_ <= 4) | 117 if (activates_ <= 4) |
113 PostSetNeedsCommitToMainThread(); | 118 PostSetNeedsCommitToMainThread(); |
114 else | 119 else |
115 EndTest(); | 120 EndTest(); |
116 } | 121 } |
117 | 122 |
118 void AfterTest() override {} | 123 void AfterTest() override {} |
119 | 124 |
120 FakeContentLayerClient client_; | |
121 int activates_; | 125 int activates_; |
122 }; | 126 }; |
123 | 127 |
124 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestTwinLayer); | 128 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestTwinLayer); |
125 | 129 |
126 class LayerTreeHostPictureTestResizeViewportWithGpuRaster | 130 class LayerTreeHostPictureTestResizeViewportWithGpuRaster |
127 : public LayerTreeHostPictureTest { | 131 : public LayerTreeHostPictureTest { |
128 void InitializeSettings(LayerTreeSettings* settings) override { | 132 void InitializeSettings(LayerTreeSettings* settings) override { |
129 settings->gpu_rasterization_forced = true; | 133 settings->gpu_rasterization_forced = true; |
130 } | 134 } |
131 | 135 |
132 void SetupTree() override { | 136 void SetupTree() override { |
133 scoped_refptr<Layer> root = Layer::Create(); | 137 scoped_refptr<Layer> root = Layer::Create(); |
134 root->SetBounds(gfx::Size(768, 960)); | 138 root->SetBounds(gfx::Size(768, 960)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 gfx::Size tile_size_; | 186 gfx::Size tile_size_; |
183 FakeContentLayerClient client_; | 187 FakeContentLayerClient client_; |
184 scoped_refptr<FakePictureLayer> picture_; | 188 scoped_refptr<FakePictureLayer> picture_; |
185 }; | 189 }; |
186 | 190 |
187 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( | 191 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( |
188 LayerTreeHostPictureTestResizeViewportWithGpuRaster); | 192 LayerTreeHostPictureTestResizeViewportWithGpuRaster); |
189 | 193 |
190 } // namespace | 194 } // namespace |
191 } // namespace cc | 195 } // namespace cc |
OLD | NEW |