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/location.h" | 10 #include "base/location.h" |
(...skipping 4511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4522 EndTest(); | 4522 EndTest(); |
4523 } | 4523 } |
4524 | 4524 |
4525 void AfterTest() override {} | 4525 void AfterTest() override {} |
4526 | 4526 |
4527 FakeContentLayerClient layer_client_; | 4527 FakeContentLayerClient layer_client_; |
4528 }; | 4528 }; |
4529 | 4529 |
4530 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); | 4530 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); |
4531 | 4531 |
4532 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { | |
4533 public: | |
4534 LayerTreeHostTestContinuousPainting() | |
4535 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | |
4536 | |
4537 protected: | |
4538 enum { kExpectedNumCommits = 10 }; | |
4539 | |
4540 void SetupTree() override { | |
4541 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); | |
4542 root_layer->SetBounds(bounds_); | |
4543 | |
4544 child_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | |
4545 child_layer_->SetBounds(bounds_); | |
4546 child_layer_->SetIsDrawable(true); | |
4547 root_layer->AddChild(child_layer_); | |
4548 | |
4549 layer_tree_host()->SetRootLayer(root_layer); | |
4550 layer_tree_host()->SetViewportSize(bounds_); | |
4551 LayerTreeHostTest::SetupTree(); | |
4552 } | |
4553 | |
4554 void BeginTest() override { | |
4555 MainThreadTaskRunner()->PostTask( | |
4556 FROM_HERE, | |
4557 base::Bind( | |
4558 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, | |
4559 base::Unretained(this))); | |
4560 // Wait 50x longer than expected. | |
4561 double milliseconds_per_frame = | |
4562 1000.0 / layer_tree_host()->settings().renderer_settings.refresh_rate; | |
4563 MainThreadTaskRunner()->PostDelayedTask( | |
4564 FROM_HERE, | |
4565 base::Bind( | |
4566 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, | |
4567 base::Unretained(this)), | |
4568 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * | |
4569 milliseconds_per_frame)); | |
4570 } | |
4571 | |
4572 void BeginMainFrame(const BeginFrameArgs& args) override { | |
4573 child_layer_->SetNeedsDisplay(); | |
4574 } | |
4575 | |
4576 void AfterTest() override { | |
4577 EXPECT_LE(kExpectedNumCommits, num_commits_); | |
4578 EXPECT_LE(kExpectedNumCommits, num_draws_); | |
4579 EXPECT_LE(kExpectedNumCommits, child_layer_->update_count()); | |
4580 } | |
4581 | |
4582 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | |
4583 if (++num_draws_ == kExpectedNumCommits) | |
4584 EndTest(); | |
4585 } | |
4586 | |
4587 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | |
4588 ++num_commits_; | |
4589 } | |
4590 | |
4591 private: | |
4592 void EnableContinuousPainting() { | |
4593 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); | |
4594 debug_state.continuous_painting = true; | |
4595 layer_tree_host()->SetDebugState(debug_state); | |
4596 } | |
4597 | |
4598 void DisableContinuousPainting() { | |
4599 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); | |
4600 debug_state.continuous_painting = false; | |
4601 layer_tree_host()->SetDebugState(debug_state); | |
4602 EndTest(); | |
4603 } | |
4604 | |
4605 int num_commits_; | |
4606 int num_draws_; | |
4607 const gfx::Size bounds_; | |
4608 FakeContentLayerClient client_; | |
4609 scoped_refptr<FakePictureLayer> child_layer_; | |
4610 }; | |
4611 | |
4612 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | |
4613 | |
4614 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame | 4532 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame |
4615 : public LayerTreeHostTest { | 4533 : public LayerTreeHostTest { |
4616 public: | 4534 public: |
4617 enum { kExpectedNumImplFrames = 10 }; | 4535 enum { kExpectedNumImplFrames = 10 }; |
4618 | 4536 |
4619 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() | 4537 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() |
4620 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} | 4538 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} |
4621 | 4539 |
4622 void BeginTest() override { | 4540 void BeginTest() override { |
4623 // Kick off the test with a commit. | 4541 // Kick off the test with a commit. |
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6251 ScrollAndScaleSet scale_info_; | 6169 ScrollAndScaleSet scale_info_; |
6252 ScrollAndScaleSet no_op_info_; | 6170 ScrollAndScaleSet no_op_info_; |
6253 bool requested_update_layers_; | 6171 bool requested_update_layers_; |
6254 int commit_count_; | 6172 int commit_count_; |
6255 }; | 6173 }; |
6256 | 6174 |
6257 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); | 6175 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); |
6258 | 6176 |
6259 } // namespace | 6177 } // namespace |
6260 } // namespace cc | 6178 } // namespace cc |
OLD | NEW |