Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: cc/layers/surface_layer_unittest.cc

Issue 1783613004: CC Animation: Erase cc::LayerSettings everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseandroid
Patch Set: Rebase. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/surface_layer.cc ('k') | cc/layers/texture_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
52 LayerSettings layer_settings_;
53 }; 52 };
54 53
55 void SatisfyCallback(SurfaceSequence* out, SurfaceSequence in) { 54 void SatisfyCallback(SurfaceSequence* out, SurfaceSequence in) {
56 *out = in; 55 *out = in;
57 } 56 }
58 57
59 void RequireCallback(SurfaceId* out_id, 58 void RequireCallback(SurfaceId* out_id,
60 std::set<SurfaceSequence>* out, 59 std::set<SurfaceSequence>* out,
61 SurfaceId in_id, 60 SurfaceId in_id,
62 SurfaceSequence in) { 61 SurfaceSequence in) {
63 *out_id = in_id; 62 *out_id = in_id;
64 out->insert(in); 63 out->insert(in);
65 } 64 }
66 65
67 // Check that one surface can be referenced by multiple LayerTreeHosts, and 66 // Check that one surface can be referenced by multiple LayerTreeHosts, and
68 // each will create its own SurfaceSequence that's satisfied on destruction. 67 // each will create its own SurfaceSequence that's satisfied on destruction.
69 TEST_F(SurfaceLayerTest, MultipleFramesOneSurface) { 68 TEST_F(SurfaceLayerTest, MultipleFramesOneSurface) {
70 SurfaceSequence blank_change; // Receives sequence if commit doesn't happen. 69 SurfaceSequence blank_change; // Receives sequence if commit doesn't happen.
71 70
72 SurfaceId required_id; 71 SurfaceId required_id;
73 std::set<SurfaceSequence> required_seq; 72 std::set<SurfaceSequence> required_seq;
74 scoped_refptr<SurfaceLayer> layer(SurfaceLayer::Create( 73 scoped_refptr<SurfaceLayer> layer(SurfaceLayer::Create(
75 layer_settings_, base::Bind(&SatisfyCallback, &blank_change), 74 base::Bind(&SatisfyCallback, &blank_change),
76 base::Bind(&RequireCallback, &required_id, &required_seq))); 75 base::Bind(&RequireCallback, &required_id, &required_seq)));
77 layer->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1)); 76 layer->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1));
78 layer_tree_host_->set_surface_id_namespace(1); 77 layer_tree_host_->set_surface_id_namespace(1);
79 layer_tree_host_->SetRootLayer(layer); 78 layer_tree_host_->SetRootLayer(layer);
80 79
81 scoped_ptr<FakeLayerTreeHost> layer_tree_host2 = 80 scoped_ptr<FakeLayerTreeHost> layer_tree_host2 =
82 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); 81 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_);
83 scoped_refptr<SurfaceLayer> layer2(SurfaceLayer::Create( 82 scoped_refptr<SurfaceLayer> layer2(SurfaceLayer::Create(
84 layer_settings_, base::Bind(&SatisfyCallback, &blank_change), 83 base::Bind(&SatisfyCallback, &blank_change),
85 base::Bind(&RequireCallback, &required_id, &required_seq))); 84 base::Bind(&RequireCallback, &required_id, &required_seq)));
86 layer2->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1)); 85 layer2->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1));
87 layer_tree_host2->set_surface_id_namespace(2); 86 layer_tree_host2->set_surface_id_namespace(2);
88 layer_tree_host2->SetRootLayer(layer2); 87 layer_tree_host2->SetRootLayer(layer2);
89 88
90 // Layers haven't been removed, so no sequence should be satisfied. 89 // Layers haven't been removed, so no sequence should be satisfied.
91 EXPECT_TRUE(blank_change.is_null()); 90 EXPECT_TRUE(blank_change.is_null());
92 91
93 SurfaceSequence expected1(1u, 1u); 92 SurfaceSequence expected1(1u, 1u);
94 SurfaceSequence expected2(2u, 1u); 93 SurfaceSequence expected2(2u, 1u);
(...skipping 26 matching lines...) Expand all
121 120
122 // Check that SurfaceSequence is sent through swap promise. 121 // Check that SurfaceSequence is sent through swap promise.
123 class SurfaceLayerSwapPromise : public LayerTreeTest { 122 class SurfaceLayerSwapPromise : public LayerTreeTest {
124 public: 123 public:
125 SurfaceLayerSwapPromise() 124 SurfaceLayerSwapPromise()
126 : commit_count_(0), sequence_was_satisfied_(false) {} 125 : commit_count_(0), sequence_was_satisfied_(false) {}
127 126
128 void BeginTest() override { 127 void BeginTest() override {
129 layer_tree_host()->set_surface_id_namespace(1); 128 layer_tree_host()->set_surface_id_namespace(1);
130 layer_ = SurfaceLayer::Create( 129 layer_ = SurfaceLayer::Create(
131 layer_settings(), base::Bind(&SatisfyCallback, &satisfied_sequence_), 130 base::Bind(&SatisfyCallback, &satisfied_sequence_),
132 base::Bind(&RequireCallback, &required_id_, &required_set_)); 131 base::Bind(&RequireCallback, &required_id_, &required_set_));
133 layer_->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1)); 132 layer_->SetSurfaceId(SurfaceId(1), 1.f, gfx::Size(1, 1));
134 133
135 // Layer hasn't been added to tree so no SurfaceSequence generated yet. 134 // Layer hasn't been added to tree so no SurfaceSequence generated yet.
136 EXPECT_EQ(0u, required_set_.size()); 135 EXPECT_EQ(0u, required_set_.size());
137 136
138 layer_tree_host()->SetRootLayer(layer_); 137 layer_tree_host()->SetRootLayer(layer_);
139 138
140 // Should have SurfaceSequence from first tree. 139 // Should have SurfaceSequence from first tree.
141 SurfaceSequence expected(1u, 1u); 140 SurfaceSequence expected(1u, 1u);
142 EXPECT_TRUE(required_id_ == SurfaceId(1)); 141 EXPECT_TRUE(required_id_ == SurfaceId(1));
143 EXPECT_EQ(1u, required_set_.size()); 142 EXPECT_EQ(1u, required_set_.size());
144 EXPECT_TRUE(required_set_.count(expected)); 143 EXPECT_TRUE(required_set_.count(expected));
145 144
146 gfx::Size bounds(100, 100); 145 gfx::Size bounds(100, 100);
147 layer_tree_host()->SetViewportSize(bounds); 146 layer_tree_host()->SetViewportSize(bounds);
148 147
149 blank_layer_ = SolidColorLayer::Create(layer_settings()); 148 blank_layer_ = SolidColorLayer::Create();
150 blank_layer_->SetIsDrawable(true); 149 blank_layer_->SetIsDrawable(true);
151 blank_layer_->SetBounds(gfx::Size(10, 10)); 150 blank_layer_->SetBounds(gfx::Size(10, 10));
152 151
153 PostSetNeedsCommitToMainThread(); 152 PostSetNeedsCommitToMainThread();
154 } 153 }
155 154
156 virtual void ChangeTree() = 0; 155 virtual void ChangeTree() = 0;
157 156
158 void DidCommitAndDrawFrame() override { 157 void DidCommitAndDrawFrame() override {
159 base::ThreadTaskRunnerHandle::Get()->PostTask( 158 base::ThreadTaskRunnerHandle::Get()->PostTask(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 EXPECT_EQ(1u, required_set_.size()); 253 EXPECT_EQ(1u, required_set_.size());
255 // Sequence should have been satisfied with the callback. 254 // Sequence should have been satisfied with the callback.
256 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); 255 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u));
257 } 256 }
258 }; 257 };
259 258
260 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); 259 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw);
261 260
262 } // namespace 261 } // namespace
263 } // namespace cc 262 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/surface_layer.cc ('k') | cc/layers/texture_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698