| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 4414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4425 } | 4425 } |
| 4426 | 4426 |
| 4427 virtual void DidNotSwap(DidNotSwapReason reason) OVERRIDE { | 4427 virtual void DidNotSwap(DidNotSwapReason reason) OVERRIDE { |
| 4428 base::AutoLock lock(result_->lock); | 4428 base::AutoLock lock(result_->lock); |
| 4429 EXPECT_FALSE(result_->did_swap_called); | 4429 EXPECT_FALSE(result_->did_swap_called); |
| 4430 EXPECT_FALSE(result_->did_not_swap_called); | 4430 EXPECT_FALSE(result_->did_not_swap_called); |
| 4431 result_->did_not_swap_called = true; | 4431 result_->did_not_swap_called = true; |
| 4432 result_->reason = reason; | 4432 result_->reason = reason; |
| 4433 } | 4433 } |
| 4434 | 4434 |
| 4435 virtual int64 TraceId() const OVERRIDE { return 0; } |
| 4436 |
| 4435 private: | 4437 private: |
| 4436 // Not owned. | 4438 // Not owned. |
| 4437 TestSwapPromiseResult* result_; | 4439 TestSwapPromiseResult* result_; |
| 4438 }; | 4440 }; |
| 4439 | 4441 |
| 4440 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { | 4442 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { |
| 4441 protected: | 4443 protected: |
| 4442 LayerTreeHostTestBreakSwapPromise() | 4444 LayerTreeHostTestBreakSwapPromise() |
| 4443 : commit_count_(0), commit_complete_count_(0) {} | 4445 : commit_count_(0), commit_complete_count_(0) {} |
| 4444 | 4446 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4510 | 4512 |
| 4511 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); | 4513 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); |
| 4512 | 4514 |
| 4513 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { | 4515 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { |
| 4514 public: | 4516 public: |
| 4515 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, | 4517 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, |
| 4516 LayerTreeHostImpl* layer_tree_host_impl, | 4518 LayerTreeHostImpl* layer_tree_host_impl, |
| 4517 int* set_needs_commit_count, | 4519 int* set_needs_commit_count, |
| 4518 int* set_needs_redraw_count) | 4520 int* set_needs_redraw_count) |
| 4519 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), | 4521 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), |
| 4520 set_needs_commit_count_(set_needs_commit_count), | 4522 set_needs_commit_count_(set_needs_commit_count) {} |
| 4521 set_needs_redraw_count_(set_needs_redraw_count) {} | |
| 4522 | 4523 |
| 4523 virtual ~SimpleSwapPromiseMonitor() {} | 4524 virtual ~SimpleSwapPromiseMonitor() {} |
| 4524 | 4525 |
| 4525 virtual void OnSetNeedsCommitOnMain() OVERRIDE { | 4526 virtual void OnSetNeedsCommitOnMain() OVERRIDE { |
| 4526 (*set_needs_commit_count_)++; | 4527 (*set_needs_commit_count_)++; |
| 4527 } | 4528 } |
| 4528 | 4529 |
| 4529 virtual void OnSetNeedsRedrawOnImpl() OVERRIDE { | 4530 virtual void OnSetNeedsRedrawOnImpl() OVERRIDE { |
| 4530 (*set_needs_redraw_count_)++; | 4531 ADD_FAILURE() << "Should not get called on main thread."; |
| 4532 } |
| 4533 |
| 4534 virtual void OnForwardScrollUpdateToMainThreadOnImpl() OVERRIDE { |
| 4535 ADD_FAILURE() << "Should not get called on main thread."; |
| 4531 } | 4536 } |
| 4532 | 4537 |
| 4533 private: | 4538 private: |
| 4534 int* set_needs_commit_count_; | 4539 int* set_needs_commit_count_; |
| 4535 int* set_needs_redraw_count_; | |
| 4536 }; | 4540 }; |
| 4537 | 4541 |
| 4538 class LayerTreeHostTestSimpleSwapPromiseMonitor : public LayerTreeHostTest { | 4542 class LayerTreeHostTestSimpleSwapPromiseMonitor : public LayerTreeHostTest { |
| 4539 public: | 4543 public: |
| 4540 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 4544 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 4541 | 4545 |
| 4542 virtual void WillBeginMainFrame() OVERRIDE { | 4546 virtual void WillBeginMainFrame() OVERRIDE { |
| 4543 int set_needs_commit_count = 0; | 4547 int set_needs_commit_count = 0; |
| 4544 int set_needs_redraw_count = 0; | 4548 int set_needs_redraw_count = 0; |
| 4545 | 4549 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4894 const gfx::Size bounds_; | 4898 const gfx::Size bounds_; |
| 4895 FakeContentLayerClient client_; | 4899 FakeContentLayerClient client_; |
| 4896 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4900 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 4897 scoped_refptr<FakePictureLayer> picture_layer_; | 4901 scoped_refptr<FakePictureLayer> picture_layer_; |
| 4898 Layer* child_layer_; | 4902 Layer* child_layer_; |
| 4899 }; | 4903 }; |
| 4900 | 4904 |
| 4901 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4905 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 4902 | 4906 |
| 4903 } // namespace cc | 4907 } // namespace cc |
| OLD | NEW |