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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 void TearDown() override { | 42 void TearDown() override { |
43 if (layer_tree_host_) { | 43 if (layer_tree_host_) { |
44 layer_tree_host_->SetRootLayer(nullptr); | 44 layer_tree_host_->SetRootLayer(nullptr); |
45 layer_tree_host_ = nullptr; | 45 layer_tree_host_ = nullptr; |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 FakeLayerTreeHostClient fake_client_; | 49 FakeLayerTreeHostClient fake_client_; |
50 TestTaskGraphRunner task_graph_runner_; | 50 TestTaskGraphRunner task_graph_runner_; |
51 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; | 51 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; |
52 }; | 52 }; |
53 | 53 |
54 void SatisfyCallback(SurfaceSequence* out, SurfaceSequence in) { | 54 void SatisfyCallback(SurfaceSequence* out, SurfaceSequence in) { |
55 *out = in; | 55 *out = in; |
56 } | 56 } |
57 | 57 |
58 void RequireCallback(SurfaceId* out_id, | 58 void RequireCallback(SurfaceId* out_id, |
59 std::set<SurfaceSequence>* out, | 59 std::set<SurfaceSequence>* out, |
60 SurfaceId in_id, | 60 SurfaceId in_id, |
61 SurfaceSequence in) { | 61 SurfaceSequence in) { |
62 *out_id = in_id; | 62 *out_id = in_id; |
63 out->insert(in); | 63 out->insert(in); |
64 } | 64 } |
65 | 65 |
66 // Check that one surface can be referenced by multiple LayerTreeHosts, and | 66 // Check that one surface can be referenced by multiple LayerTreeHosts, and |
67 // each will create its own SurfaceSequence that's satisfied on destruction. | 67 // each will create its own SurfaceSequence that's satisfied on destruction. |
68 TEST_F(SurfaceLayerTest, MultipleFramesOneSurface) { | 68 TEST_F(SurfaceLayerTest, MultipleFramesOneSurface) { |
69 SurfaceSequence blank_change; // Receives sequence if commit doesn't happen. | 69 SurfaceSequence blank_change; // Receives sequence if commit doesn't happen. |
70 | 70 |
71 SurfaceId required_id; | 71 SurfaceId required_id; |
72 std::set<SurfaceSequence> required_seq; | 72 std::set<SurfaceSequence> required_seq; |
73 scoped_refptr<SurfaceLayer> layer(SurfaceLayer::Create( | 73 scoped_refptr<SurfaceLayer> layer(SurfaceLayer::Create( |
74 base::Bind(&SatisfyCallback, &blank_change), | 74 base::Bind(&SatisfyCallback, &blank_change), |
75 base::Bind(&RequireCallback, &required_id, &required_seq))); | 75 base::Bind(&RequireCallback, &required_id, &required_seq))); |
76 layer->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1)); | 76 layer->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1)); |
77 layer_tree_host_->set_surface_id_namespace(1); | 77 layer_tree_host_->set_surface_id_namespace(1); |
78 layer_tree_host_->SetRootLayer(layer); | 78 layer_tree_host_->SetRootLayer(layer); |
79 | 79 |
80 scoped_ptr<FakeLayerTreeHost> layer_tree_host2 = | 80 std::unique_ptr<FakeLayerTreeHost> layer_tree_host2 = |
81 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); | 81 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); |
82 scoped_refptr<SurfaceLayer> layer2(SurfaceLayer::Create( | 82 scoped_refptr<SurfaceLayer> layer2(SurfaceLayer::Create( |
83 base::Bind(&SatisfyCallback, &blank_change), | 83 base::Bind(&SatisfyCallback, &blank_change), |
84 base::Bind(&RequireCallback, &required_id, &required_seq))); | 84 base::Bind(&RequireCallback, &required_id, &required_seq))); |
85 layer2->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1)); | 85 layer2->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1)); |
86 layer_tree_host2->set_surface_id_namespace(2); | 86 layer_tree_host2->set_surface_id_namespace(2); |
87 layer_tree_host2->SetRootLayer(layer2); | 87 layer_tree_host2->SetRootLayer(layer2); |
88 | 88 |
89 // Layers haven't been removed, so no sequence should be satisfied. | 89 // Layers haven't been removed, so no sequence should be satisfied. |
90 EXPECT_TRUE(blank_change.is_null()); | 90 EXPECT_TRUE(blank_change.is_null()); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 EXPECT_EQ(1u, required_set_.size()); | 253 EXPECT_EQ(1u, required_set_.size()); |
254 // Sequence should have been satisfied with the callback. | 254 // Sequence should have been satisfied with the callback. |
255 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); | 255 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); |
256 } | 256 } |
257 }; | 257 }; |
258 | 258 |
259 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); | 259 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); |
260 | 260 |
261 } // namespace | 261 } // namespace |
262 } // namespace cc | 262 } // namespace cc |
OLD | NEW |