| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 scoped_refptr<Layer> blank_layer_; | 167 scoped_refptr<Layer> blank_layer_; |
| 168 SurfaceSequence satisfied_sequence_; | 168 SurfaceSequence satisfied_sequence_; |
| 169 | 169 |
| 170 SurfaceId required_id_; | 170 SurfaceId required_id_; |
| 171 std::set<SurfaceSequence> required_set_; | 171 std::set<SurfaceSequence> required_set_; |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 // Check that SurfaceSequence is sent through swap promise. | 174 // Check that SurfaceSequence is sent through swap promise. |
| 175 class SurfaceLayerSwapPromiseWithDraw : public SurfaceLayerSwapPromise { | 175 class SurfaceLayerSwapPromiseWithDraw : public SurfaceLayerSwapPromise { |
| 176 public: | 176 public: |
| 177 SurfaceLayerSwapPromiseWithDraw() : SurfaceLayerSwapPromise() {} |
| 178 |
| 179 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 180 auto ret = FakeOutputSurface::CreateDelegating3d(); |
| 181 output_surface_ = ret.get(); |
| 182 return std::move(ret); |
| 183 } |
| 184 |
| 177 void ChangeTree() override { | 185 void ChangeTree() override { |
| 178 ++commit_count_; | 186 ++commit_count_; |
| 179 switch (commit_count_) { | 187 switch (commit_count_) { |
| 180 case 1: | 188 case 1: |
| 181 // Remove SurfaceLayer from tree to cause SwapPromise to be created. | 189 // Remove SurfaceLayer from tree to cause SwapPromise to be created. |
| 182 layer_tree_host()->SetRootLayer(blank_layer_); | 190 layer_tree_host()->SetRootLayer(blank_layer_); |
| 183 break; | 191 break; |
| 184 case 2: | 192 case 2: |
| 185 break; | 193 break; |
| 186 default: | 194 default: |
| 187 NOTREACHED(); | 195 NOTREACHED(); |
| 188 break; | 196 break; |
| 189 } | 197 } |
| 190 } | 198 } |
| 191 | 199 |
| 192 void DisplayReceivedCompositorFrameOnThread( | 200 void SwapBuffersCompleteOnThread() override { |
| 193 const CompositorFrame& frame) override { | 201 std::vector<uint32_t>& satisfied = |
| 194 const std::vector<uint32_t>& satisfied = frame.metadata.satisfies_sequences; | 202 output_surface_->last_sent_frame()->metadata.satisfies_sequences; |
| 195 EXPECT_LE(satisfied.size(), 1u); | 203 EXPECT_LE(satisfied.size(), 1u); |
| 196 if (satisfied.size() == 1) { | 204 if (satisfied.size() == 1) { |
| 197 // Eventually the one SurfaceSequence should be satisfied, but only | 205 // Eventually the one SurfaceSequence should be satisfied, but only |
| 198 // after the layer was removed from the tree, and only once. | 206 // after the layer was removed from the tree, and only once. |
| 199 EXPECT_EQ(1u, satisfied[0]); | 207 EXPECT_EQ(1u, satisfied[0]); |
| 200 EXPECT_LE(1, commit_count_); | 208 EXPECT_LE(1, commit_count_); |
| 201 EXPECT_FALSE(sequence_was_satisfied_); | 209 EXPECT_FALSE(sequence_was_satisfied_); |
| 202 sequence_was_satisfied_ = true; | 210 sequence_was_satisfied_ = true; |
| 203 EndTest(); | 211 EndTest(); |
| 204 } | 212 } |
| 205 } | 213 } |
| 206 | 214 |
| 207 void AfterTest() override { | 215 void AfterTest() override { |
| 208 EXPECT_TRUE(required_id_ == SurfaceId(kArbitraryClientId, 1, 0)); | 216 EXPECT_TRUE(required_id_ == SurfaceId(kArbitraryClientId, 1, 0)); |
| 209 EXPECT_EQ(1u, required_set_.size()); | 217 EXPECT_EQ(1u, required_set_.size()); |
| 210 // Sequence should have been satisfied through Swap, not with the | 218 // Sequence should have been satisfied through Swap, not with the |
| 211 // callback. | 219 // callback. |
| 212 EXPECT_TRUE(satisfied_sequence_.is_null()); | 220 EXPECT_TRUE(satisfied_sequence_.is_null()); |
| 213 } | 221 } |
| 222 |
| 223 FakeOutputSurface* output_surface_; |
| 214 }; | 224 }; |
| 215 | 225 |
| 216 SINGLE_AND_MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithDraw); | 226 SINGLE_AND_MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithDraw); |
| 217 | 227 |
| 218 // Check that SurfaceSequence is sent through swap promise and resolved when | 228 // Check that SurfaceSequence is sent through swap promise and resolved when |
| 219 // swap fails. | 229 // swap fails. |
| 220 class SurfaceLayerSwapPromiseWithoutDraw : public SurfaceLayerSwapPromise { | 230 class SurfaceLayerSwapPromiseWithoutDraw : public SurfaceLayerSwapPromise { |
| 221 public: | 231 public: |
| 222 SurfaceLayerSwapPromiseWithoutDraw() : SurfaceLayerSwapPromise() {} | 232 SurfaceLayerSwapPromiseWithoutDraw() : SurfaceLayerSwapPromise() {} |
| 223 | 233 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 248 EXPECT_EQ(1u, required_set_.size()); | 258 EXPECT_EQ(1u, required_set_.size()); |
| 249 // Sequence should have been satisfied with the callback. | 259 // Sequence should have been satisfied with the callback. |
| 250 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); | 260 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); |
| 251 } | 261 } |
| 252 }; | 262 }; |
| 253 | 263 |
| 254 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); | 264 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); |
| 255 | 265 |
| 256 } // namespace | 266 } // namespace |
| 257 } // namespace cc | 267 } // namespace cc |
| OLD | NEW |