| 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 11 matching lines...) Expand all Loading... |
| 22 #include "cc/trees/layer_tree_host.h" | 22 #include "cc/trees/layer_tree_host.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 25 |
| 26 namespace cc { | 26 namespace cc { |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 static constexpr uint32_t kArbitraryClientId = 0; | 29 static constexpr uint32_t kArbitraryClientId = 0; |
| 30 | 30 |
| 31 class SurfaceLayerTest : public testing::Test { | 31 class SurfaceLayerTest : public testing::Test { |
| 32 public: | |
| 33 SurfaceLayerTest() | |
| 34 : fake_client_( | |
| 35 FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {} | |
| 36 | |
| 37 protected: | 32 protected: |
| 38 void SetUp() override { | 33 void SetUp() override { |
| 39 layer_tree_host_ = | 34 layer_tree_host_ = |
| 40 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); | 35 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); |
| 41 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); | 36 layer_tree_host_->SetViewportSize(gfx::Size(10, 10)); |
| 42 } | 37 } |
| 43 | 38 |
| 44 void TearDown() override { | 39 void TearDown() override { |
| 45 if (layer_tree_host_) { | 40 if (layer_tree_host_) { |
| 46 layer_tree_host_->SetRootLayer(nullptr); | 41 layer_tree_host_->SetRootLayer(nullptr); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 SurfaceId required_id_; | 170 SurfaceId required_id_; |
| 176 std::set<SurfaceSequence> required_set_; | 171 std::set<SurfaceSequence> required_set_; |
| 177 }; | 172 }; |
| 178 | 173 |
| 179 // Check that SurfaceSequence is sent through swap promise. | 174 // Check that SurfaceSequence is sent through swap promise. |
| 180 class SurfaceLayerSwapPromiseWithDraw : public SurfaceLayerSwapPromise { | 175 class SurfaceLayerSwapPromiseWithDraw : public SurfaceLayerSwapPromise { |
| 181 public: | 176 public: |
| 182 SurfaceLayerSwapPromiseWithDraw() : SurfaceLayerSwapPromise() {} | 177 SurfaceLayerSwapPromiseWithDraw() : SurfaceLayerSwapPromise() {} |
| 183 | 178 |
| 184 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 179 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 185 auto ret = delegating_renderer() ? FakeOutputSurface::CreateDelegating3d() | 180 auto ret = FakeOutputSurface::CreateDelegating3d(); |
| 186 : FakeOutputSurface::Create3d(); | |
| 187 output_surface_ = ret.get(); | 181 output_surface_ = ret.get(); |
| 188 return std::move(ret); | 182 return std::move(ret); |
| 189 } | 183 } |
| 190 | 184 |
| 191 void ChangeTree() override { | 185 void ChangeTree() override { |
| 192 ++commit_count_; | 186 ++commit_count_; |
| 193 switch (commit_count_) { | 187 switch (commit_count_) { |
| 194 case 1: | 188 case 1: |
| 195 // Remove SurfaceLayer from tree to cause SwapPromise to be created. | 189 // Remove SurfaceLayer from tree to cause SwapPromise to be created. |
| 196 layer_tree_host()->SetRootLayer(blank_layer_); | 190 layer_tree_host()->SetRootLayer(blank_layer_); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 222 EXPECT_TRUE(required_id_ == SurfaceId(kArbitraryClientId, 1, 0)); | 216 EXPECT_TRUE(required_id_ == SurfaceId(kArbitraryClientId, 1, 0)); |
| 223 EXPECT_EQ(1u, required_set_.size()); | 217 EXPECT_EQ(1u, required_set_.size()); |
| 224 // Sequence should have been satisfied through Swap, not with the | 218 // Sequence should have been satisfied through Swap, not with the |
| 225 // callback. | 219 // callback. |
| 226 EXPECT_TRUE(satisfied_sequence_.is_null()); | 220 EXPECT_TRUE(satisfied_sequence_.is_null()); |
| 227 } | 221 } |
| 228 | 222 |
| 229 FakeOutputSurface* output_surface_; | 223 FakeOutputSurface* output_surface_; |
| 230 }; | 224 }; |
| 231 | 225 |
| 232 // TODO(jbauman): Reenable on single thread once http://crbug.com/421923 is | 226 SINGLE_AND_MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithDraw); |
| 233 // fixed. | |
| 234 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithDraw); | |
| 235 | 227 |
| 236 // Check that SurfaceSequence is sent through swap promise and resolved when | 228 // Check that SurfaceSequence is sent through swap promise and resolved when |
| 237 // swap fails. | 229 // swap fails. |
| 238 class SurfaceLayerSwapPromiseWithoutDraw : public SurfaceLayerSwapPromise { | 230 class SurfaceLayerSwapPromiseWithoutDraw : public SurfaceLayerSwapPromise { |
| 239 public: | 231 public: |
| 240 SurfaceLayerSwapPromiseWithoutDraw() : SurfaceLayerSwapPromise() {} | 232 SurfaceLayerSwapPromiseWithoutDraw() : SurfaceLayerSwapPromise() {} |
| 241 | 233 |
| 242 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 234 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 243 LayerTreeHostImpl::FrameData* frame, | 235 LayerTreeHostImpl::FrameData* frame, |
| 244 DrawResult draw_result) override { | 236 DrawResult draw_result) override { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 266 EXPECT_EQ(1u, required_set_.size()); | 258 EXPECT_EQ(1u, required_set_.size()); |
| 267 // Sequence should have been satisfied with the callback. | 259 // Sequence should have been satisfied with the callback. |
| 268 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); | 260 EXPECT_TRUE(satisfied_sequence_ == SurfaceSequence(1u, 1u)); |
| 269 } | 261 } |
| 270 }; | 262 }; |
| 271 | 263 |
| 272 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); | 264 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); |
| 273 | 265 |
| 274 } // namespace | 266 } // namespace |
| 275 } // namespace cc | 267 } // namespace cc |
| OLD | NEW |