| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 did_reset_child_id_ = true; | 397 did_reset_child_id_ = true; |
| 398 } | 398 } |
| 399 | 399 |
| 400 protected: | 400 protected: |
| 401 int num_activates_; | 401 int num_activates_; |
| 402 bool did_reset_child_id_; | 402 bool did_reset_child_id_; |
| 403 }; | 403 }; |
| 404 | 404 |
| 405 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCreateChildId); | 405 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCreateChildId); |
| 406 | 406 |
| 407 class LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit |
| 408 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { |
| 409 protected: |
| 410 void BeginTest() override { |
| 411 SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); |
| 412 LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::BeginTest(); |
| 413 } |
| 414 |
| 415 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 416 // Act like the context was lost while the layer is in the pending tree. |
| 417 LayerImpl* root_impl = host_impl->sync_tree()->root_layer(); |
| 418 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 419 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 420 delegated_impl->ReleaseResources(); |
| 421 } |
| 422 |
| 423 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 424 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 425 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 426 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 427 |
| 428 // Should not try to activate a frame without a child id. If we did try to |
| 429 // activate we would crash. |
| 430 EXPECT_FALSE(delegated_impl->ChildId()); |
| 431 EndTest(); |
| 432 } |
| 433 }; |
| 434 |
| 435 MULTI_THREAD_IMPL_TEST_F( |
| 436 LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit); |
| 437 |
| 407 // Test that we can gracefully handle invalid frames after the context was lost. | 438 // Test that we can gracefully handle invalid frames after the context was lost. |
| 408 // For example, we might be trying to use the previous frame in that case and | 439 // For example, we might be trying to use the previous frame in that case and |
| 409 // have to make sure we don't crash because our resource accounting goes wrong. | 440 // have to make sure we don't crash because our resource accounting goes wrong. |
| 410 class LayerTreeHostDelegatedTestInvalidFrameAfterContextLost | 441 class LayerTreeHostDelegatedTestInvalidFrameAfterContextLost |
| 411 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | 442 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { |
| 412 public: | 443 public: |
| 413 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost() | 444 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost() |
| 414 : num_activates_(0), num_output_surfaces_initialized_(0) {} | 445 : num_activates_(0), num_output_surfaces_initialized_(0) {} |
| 415 | 446 |
| 416 void DidCommit() override { | 447 void DidCommit() override { |
| (...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2254 ReturnAllResourcesFromParent(host_impl); | 2285 ReturnAllResourcesFromParent(host_impl); |
| 2255 } | 2286 } |
| 2256 | 2287 |
| 2257 bool drew_with_pending_tree_; | 2288 bool drew_with_pending_tree_; |
| 2258 }; | 2289 }; |
| 2259 | 2290 |
| 2260 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid); | 2291 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid); |
| 2261 | 2292 |
| 2262 } // namespace | 2293 } // namespace |
| 2263 } // namespace cc | 2294 } // namespace cc |
| OLD | NEW |