| 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 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2301 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate); | 2301 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate); |
| 2302 | 2302 |
| 2303 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { | 2303 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { |
| 2304 public: | 2304 public: |
| 2305 LayerTreeHostTestDeferCommits() | 2305 LayerTreeHostTestDeferCommits() |
| 2306 : num_will_begin_impl_frame_(0), | 2306 : num_will_begin_impl_frame_(0), |
| 2307 num_send_begin_main_frame_(0) {} | 2307 num_send_begin_main_frame_(0) {} |
| 2308 | 2308 |
| 2309 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 2309 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 2310 | 2310 |
| 2311 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, | 2311 void WillBeginImplFrame(const BeginFrameArgs& args) override { |
| 2312 const BeginFrameArgs& args) override { | |
| 2313 num_will_begin_impl_frame_++; | 2312 num_will_begin_impl_frame_++; |
| 2314 switch (num_will_begin_impl_frame_) { | 2313 switch (num_will_begin_impl_frame_) { |
| 2315 case 1: | 2314 case 1: |
| 2316 break; | 2315 break; |
| 2317 case 2: | 2316 case 2: |
| 2318 case 3: | 2317 case 3: |
| 2319 case 4: | 2318 case 4: |
| 2320 // Post a number of frames to increase the chance that, if there exist | 2319 // Post a number of frames to increase the chance that, if there exist |
| 2321 // bugs, an unexpected BeginMainFrame will be issued. | 2320 // bugs, an unexpected BeginMainFrame will be issued. |
| 2322 PostSetNeedsCommitToMainThread(); | 2321 PostSetNeedsCommitToMainThread(); |
| (...skipping 3183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5506 int num_draws_; | 5505 int num_draws_; |
| 5507 const gfx::Size bounds_; | 5506 const gfx::Size bounds_; |
| 5508 FakeContentLayerClient client_; | 5507 FakeContentLayerClient client_; |
| 5509 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5508 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 5510 scoped_refptr<FakePictureLayer> picture_layer_; | 5509 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5511 Layer* child_layer_; | 5510 Layer* child_layer_; |
| 5512 }; | 5511 }; |
| 5513 | 5512 |
| 5514 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5513 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 5515 | 5514 |
| 5516 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame | |
| 5517 : public LayerTreeHostTest { | |
| 5518 public: | |
| 5519 enum { kExpectedNumImplFrames = 10 }; | |
| 5520 | |
| 5521 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() | |
| 5522 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} | |
| 5523 | |
| 5524 void BeginTest() override { | |
| 5525 // Kick off the test with a commit. | |
| 5526 PostSetNeedsCommitToMainThread(); | |
| 5527 } | |
| 5528 | |
| 5529 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, | |
| 5530 const BeginFrameArgs& args) override { | |
| 5531 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); | |
| 5532 EXPECT_FALSE(TestEnded()); | |
| 5533 will_begin_impl_frame_count_++; | |
| 5534 } | |
| 5535 | |
| 5536 void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override { | |
| 5537 did_finish_impl_frame_count_++; | |
| 5538 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); | |
| 5539 | |
| 5540 // Request a number of commits to cause multiple impl frames. We expect to | |
| 5541 // get one more impl frames than the number of commits requested because | |
| 5542 // after a commit it takes one frame to become idle. | |
| 5543 if (did_finish_impl_frame_count_ < kExpectedNumImplFrames - 1) | |
| 5544 PostSetNeedsCommitToMainThread(); | |
| 5545 } | |
| 5546 | |
| 5547 void SendBeginMainFrameNotExpectedSoon() override { EndTest(); } | |
| 5548 | |
| 5549 void AfterTest() override { | |
| 5550 EXPECT_GT(will_begin_impl_frame_count_, 0); | |
| 5551 EXPECT_GT(did_finish_impl_frame_count_, 0); | |
| 5552 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); | |
| 5553 | |
| 5554 // TODO(mithro): Figure out why the multithread version of this test | |
| 5555 // sometimes has one more frame then expected. Possibly related to | |
| 5556 // http://crbug.com/443185 | |
| 5557 if (!HasImplThread()) { | |
| 5558 EXPECT_EQ(will_begin_impl_frame_count_, kExpectedNumImplFrames); | |
| 5559 EXPECT_EQ(did_finish_impl_frame_count_, kExpectedNumImplFrames); | |
| 5560 } | |
| 5561 } | |
| 5562 | |
| 5563 private: | |
| 5564 int will_begin_impl_frame_count_; | |
| 5565 int did_finish_impl_frame_count_; | |
| 5566 }; | |
| 5567 | |
| 5568 SINGLE_AND_MULTI_THREAD_TEST_F( | |
| 5569 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame); | |
| 5570 | |
| 5571 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { | 5515 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { |
| 5572 public: | 5516 public: |
| 5573 LayerTreeHostTestSendBeginFramesToChildren() | 5517 LayerTreeHostTestSendBeginFramesToChildren() |
| 5574 : begin_frame_sent_to_children_(false) { | 5518 : begin_frame_sent_to_children_(false) { |
| 5575 } | 5519 } |
| 5576 | 5520 |
| 5577 void BeginTest() override { | 5521 void BeginTest() override { |
| 5578 // Kick off the test with a commit. | 5522 // Kick off the test with a commit. |
| 5579 PostSetNeedsCommitToMainThread(); | 5523 PostSetNeedsCommitToMainThread(); |
| 5580 } | 5524 } |
| (...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7106 void AfterTest() override {} | 7050 void AfterTest() override {} |
| 7107 | 7051 |
| 7108 scoped_refptr<FakePictureLayer> content_child_layer_; | 7052 scoped_refptr<FakePictureLayer> content_child_layer_; |
| 7109 FakeContentLayerClient client_; | 7053 FakeContentLayerClient client_; |
| 7110 }; | 7054 }; |
| 7111 | 7055 |
| 7112 SINGLE_AND_MULTI_THREAD_TEST_F( | 7056 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 7113 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); | 7057 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); |
| 7114 | 7058 |
| 7115 } // namespace cc | 7059 } // namespace cc |
| OLD | NEW |