diff options
author | mithro <mithro@mithis.com> | 2015-05-06 19:50:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-07 02:51:49 +0000 |
commit | 2caee4f89de17858822c11379da9c6cd80f90708 (patch) | |
tree | 775c42f5e389c195af036484c59f38e1563f7935 /cc/trees/layer_tree_host_unittest.cc | |
parent | c463ab98438668e8e824f0ae3fa9a462b7724996 (diff) | |
download | chromium_src-2caee4f89de17858822c11379da9c6cd80f90708.zip chromium_src-2caee4f89de17858822c11379da9c6cd80f90708.tar.gz chromium_src-2caee4f89de17858822c11379da9c6cd80f90708.tar.bz2 |
cc: Adding DidFinishImplFrame to LTHI.
This change moves the responsibility of clearing state inside the LTHI after an
impl frame is finished from the thread proxies to the LTHI class. This makes
WillBeginImplFrame and DidFinishImplFrame a logical pair.
This CL also;
* Adds a test that checks the number of WillBeginImplFrame
calls matches the DidFinishImplFrame calls.
* Cleans up classes in cc/test/layer_tree_test.h around WillBeginImplFrame.
* Removes the UpdateCurrentBeginFrameArgs / ResetCurrentBeginFrameArgs methods.
* Fixes a bug where STP was calling ResetCurrentBeginFrameArgs twice every frame.
BUG=346230,481810
R=brianderson,enne
Review URL: https://codereview.chromium.org/1111743002
Cr-Commit-Position: refs/heads/master@{#328689}
Diffstat (limited to 'cc/trees/layer_tree_host_unittest.cc')
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index f2ed38e..ab40684 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -2308,7 +2308,8 @@ class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { void BeginTest() override { PostSetNeedsCommitToMainThread(); } - void WillBeginImplFrame(const BeginFrameArgs& args) override { + void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, + const BeginFrameArgs& args) override { num_will_begin_impl_frame_++; switch (num_will_begin_impl_frame_) { case 1: @@ -5512,6 +5513,61 @@ class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); +class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame + : public LayerTreeHostTest { + public: + enum { kExpectedNumImplFrames = 10 }; + + LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() + : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} + + void BeginTest() override { + // Kick off the test with a commit. + PostSetNeedsCommitToMainThread(); + } + + void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, + const BeginFrameArgs& args) override { + EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); + EXPECT_FALSE(TestEnded()); + will_begin_impl_frame_count_++; + } + + void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override { + did_finish_impl_frame_count_++; + EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); + + // Request a number of commits to cause multiple impl frames. We expect to + // get one more impl frames than the number of commits requested because + // after a commit it takes one frame to become idle. + if (did_finish_impl_frame_count_ < kExpectedNumImplFrames - 1) + PostSetNeedsCommitToMainThread(); + } + + void SendBeginMainFrameNotExpectedSoon() override { EndTest(); } + + void AfterTest() override { + EXPECT_GT(will_begin_impl_frame_count_, 0); + EXPECT_GT(did_finish_impl_frame_count_, 0); + EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); + + // TODO(mithro): Figure out why the multithread version of this test + // sometimes has one more frame then expected. Possibly related to + // http://crbug.com/443185 + if (!HasImplThread()) { + EXPECT_EQ(will_begin_impl_frame_count_, kExpectedNumImplFrames); + EXPECT_EQ(did_finish_impl_frame_count_, kExpectedNumImplFrames); + } + } + + private: + int will_begin_impl_frame_count_; + int did_finish_impl_frame_count_; +}; + +SINGLE_AND_MULTI_THREAD_TEST_F( + LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame); + class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { public: LayerTreeHostTestSendBeginFramesToChildren() |