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 4446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4457 EndTest(); | 4457 EndTest(); |
4458 } | 4458 } |
4459 | 4459 |
4460 void AfterTest() override {} | 4460 void AfterTest() override {} |
4461 | 4461 |
4462 FakeContentLayerClient layer_client_; | 4462 FakeContentLayerClient layer_client_; |
4463 }; | 4463 }; |
4464 | 4464 |
4465 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); | 4465 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); |
4466 | 4466 |
4467 class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { | |
4468 public: | |
4469 LayerTreeHostTestContinuousPainting() | |
4470 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | |
4471 | |
4472 protected: | |
4473 enum { kExpectedNumCommits = 10 }; | |
4474 | |
4475 void SetupTree() override { | |
4476 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); | |
4477 root_layer->SetBounds(bounds_); | |
4478 root_layer->CreateRenderSurface(); | |
4479 | |
4480 child_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | |
4481 child_layer_->SetBounds(bounds_); | |
4482 child_layer_->SetIsDrawable(true); | |
4483 root_layer->AddChild(child_layer_); | |
4484 | |
4485 layer_tree_host()->SetRootLayer(root_layer); | |
4486 layer_tree_host()->SetViewportSize(bounds_); | |
4487 LayerTreeHostTest::SetupTree(); | |
4488 } | |
4489 | |
4490 void BeginTest() override { | |
4491 MainThreadTaskRunner()->PostTask( | |
4492 FROM_HERE, | |
4493 base::Bind( | |
4494 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, | |
4495 base::Unretained(this))); | |
4496 // Wait 50x longer than expected. | |
4497 double milliseconds_per_frame = | |
4498 1000.0 / layer_tree_host()->settings().renderer_settings.refresh_rate; | |
4499 MainThreadTaskRunner()->PostDelayedTask( | |
4500 FROM_HERE, | |
4501 base::Bind( | |
4502 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, | |
4503 base::Unretained(this)), | |
4504 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * | |
4505 milliseconds_per_frame)); | |
4506 } | |
4507 | |
4508 void BeginMainFrame(const BeginFrameArgs& args) override { | |
4509 child_layer_->SetNeedsDisplay(); | |
4510 } | |
4511 | |
4512 void AfterTest() override { | |
4513 EXPECT_LE(kExpectedNumCommits, num_commits_); | |
4514 EXPECT_LE(kExpectedNumCommits, num_draws_); | |
4515 EXPECT_LE(kExpectedNumCommits, child_layer_->update_count()); | |
4516 } | |
4517 | |
4518 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | |
4519 if (++num_draws_ == kExpectedNumCommits) | |
4520 EndTest(); | |
4521 } | |
4522 | |
4523 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | |
4524 ++num_commits_; | |
4525 } | |
4526 | |
4527 private: | |
4528 void EnableContinuousPainting() { | |
4529 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); | |
4530 debug_state.continuous_painting = true; | |
4531 layer_tree_host()->SetDebugState(debug_state); | |
4532 } | |
4533 | |
4534 void DisableContinuousPainting() { | |
4535 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); | |
4536 debug_state.continuous_painting = false; | |
4537 layer_tree_host()->SetDebugState(debug_state); | |
4538 EndTest(); | |
4539 } | |
4540 | |
4541 int num_commits_; | |
4542 int num_draws_; | |
4543 const gfx::Size bounds_; | |
4544 FakeContentLayerClient client_; | |
4545 scoped_refptr<FakePictureLayer> child_layer_; | |
4546 }; | |
4547 | |
4548 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | |
4549 | |
4550 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame | 4467 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame |
4551 : public LayerTreeHostTest { | 4468 : public LayerTreeHostTest { |
4552 public: | 4469 public: |
4553 enum { kExpectedNumImplFrames = 10 }; | 4470 enum { kExpectedNumImplFrames = 10 }; |
4554 | 4471 |
4555 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() | 4472 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() |
4556 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} | 4473 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} |
4557 | 4474 |
4558 void BeginTest() override { | 4475 void BeginTest() override { |
4559 // Kick off the test with a commit. | 4476 // Kick off the test with a commit. |
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6130 void AfterTest() override {} | 6047 void AfterTest() override {} |
6131 | 6048 |
6132 std::vector<int> affected_by_page_scale_; | 6049 std::vector<int> affected_by_page_scale_; |
6133 std::vector<int> not_affected_by_page_scale_; | 6050 std::vector<int> not_affected_by_page_scale_; |
6134 }; | 6051 }; |
6135 | 6052 |
6136 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags); | 6053 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags); |
6137 | 6054 |
6138 } // namespace | 6055 } // namespace |
6139 } // namespace cc | 6056 } // namespace cc |
OLD | NEW |