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 4465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4476 EndTest(); | 4476 EndTest(); |
4477 } | 4477 } |
4478 | 4478 |
4479 void AfterTest() override {} | 4479 void AfterTest() override {} |
4480 | 4480 |
4481 FakeContentLayerClient layer_client_; | 4481 FakeContentLayerClient layer_client_; |
4482 }; | 4482 }; |
4483 | 4483 |
4484 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); | 4484 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); |
4485 | 4485 |
4486 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { | |
4487 public: | |
4488 LayerTreeHostTestContinuousPainting() | |
4489 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | |
4490 | |
4491 protected: | |
4492 enum { kExpectedNumCommits = 10 }; | |
4493 | |
4494 void SetupTree() override { | |
4495 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); | |
4496 root_layer->SetBounds(bounds_); | |
4497 | |
4498 child_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | |
4499 child_layer_->SetBounds(bounds_); | |
4500 child_layer_->SetIsDrawable(true); | |
4501 root_layer->AddChild(child_layer_); | |
4502 | |
4503 layer_tree_host()->SetRootLayer(root_layer); | |
4504 layer_tree_host()->SetViewportSize(bounds_); | |
4505 LayerTreeHostTest::SetupTree(); | |
4506 } | |
4507 | |
4508 void BeginTest() override { | |
4509 MainThreadTaskRunner()->PostTask( | |
4510 FROM_HERE, | |
4511 base::Bind( | |
4512 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, | |
4513 base::Unretained(this))); | |
4514 // Wait 50x longer than expected. | |
4515 double milliseconds_per_frame = | |
4516 1000.0 / layer_tree_host()->settings().renderer_settings.refresh_rate; | |
4517 MainThreadTaskRunner()->PostDelayedTask( | |
4518 FROM_HERE, | |
4519 base::Bind( | |
4520 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, | |
4521 base::Unretained(this)), | |
4522 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * | |
4523 milliseconds_per_frame)); | |
4524 } | |
4525 | |
4526 void BeginMainFrame(const BeginFrameArgs& args) override { | |
4527 child_layer_->SetNeedsDisplay(); | |
4528 } | |
4529 | |
4530 void AfterTest() override { | |
4531 EXPECT_LE(kExpectedNumCommits, num_commits_); | |
4532 EXPECT_LE(kExpectedNumCommits, num_draws_); | |
4533 EXPECT_LE(kExpectedNumCommits, child_layer_->update_count()); | |
4534 } | |
4535 | |
4536 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | |
4537 if (++num_draws_ == kExpectedNumCommits) | |
4538 EndTest(); | |
4539 } | |
4540 | |
4541 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | |
4542 ++num_commits_; | |
4543 } | |
4544 | |
4545 private: | |
4546 void EnableContinuousPainting() { | |
4547 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); | |
4548 debug_state.continuous_painting = true; | |
4549 layer_tree_host()->SetDebugState(debug_state); | |
4550 } | |
4551 | |
4552 void DisableContinuousPainting() { | |
4553 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); | |
4554 debug_state.continuous_painting = false; | |
4555 layer_tree_host()->SetDebugState(debug_state); | |
4556 EndTest(); | |
4557 } | |
4558 | |
4559 int num_commits_; | |
4560 int num_draws_; | |
4561 const gfx::Size bounds_; | |
4562 FakeContentLayerClient client_; | |
4563 scoped_refptr<FakePictureLayer> child_layer_; | |
4564 }; | |
4565 | |
4566 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | |
4567 | |
4568 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame | 4486 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame |
4569 : public LayerTreeHostTest { | 4487 : public LayerTreeHostTest { |
4570 public: | 4488 public: |
4571 enum { kExpectedNumImplFrames = 10 }; | 4489 enum { kExpectedNumImplFrames = 10 }; |
4572 | 4490 |
4573 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() | 4491 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() |
4574 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} | 4492 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} |
4575 | 4493 |
4576 void BeginTest() override { | 4494 void BeginTest() override { |
4577 // Kick off the test with a commit. | 4495 // Kick off the test with a commit. |
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6205 ScrollAndScaleSet scale_info_; | 6123 ScrollAndScaleSet scale_info_; |
6206 ScrollAndScaleSet no_op_info_; | 6124 ScrollAndScaleSet no_op_info_; |
6207 bool requested_update_layers_; | 6125 bool requested_update_layers_; |
6208 int commit_count_; | 6126 int commit_count_; |
6209 }; | 6127 }; |
6210 | 6128 |
6211 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); | 6129 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); |
6212 | 6130 |
6213 } // namespace | 6131 } // namespace |
6214 } // namespace cc | 6132 } // namespace cc |
OLD | NEW |