diff options
author | skyostil <skyostil@chromium.org> | 2015-08-12 05:00:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-12 12:00:51 +0000 |
commit | 51d1575b2df2fc681299c84e415cc078677b95e4 (patch) | |
tree | 881db86c384e81312dd6762aceb71eee6356231a /cc/trees/layer_tree_host_unittest_proxy.cc | |
parent | c24635036139d941db318145b96fda64aeeda02b (diff) | |
download | chromium_src-51d1575b2df2fc681299c84e415cc078677b95e4.zip chromium_src-51d1575b2df2fc681299c84e415cc078677b95e4.tar.gz chromium_src-51d1575b2df2fc681299c84e415cc078677b95e4.tar.bz2 |
cc: Make layer updating optional in BeginMainFrame
If no-one has requested a layer update, either by calling
Proxy::SetNeedsUpdateLayers() or Proxy::SetNeedsCommit(), skip computing
the layer update in BeginMainFrame. This reduces the static overhead of
a BeginMainFrame/Commit operation when the layer tree doesn't change.
This change improves efficiency, for example, when a page has a
requestAnimationFrame callback which does not modify the DOM.
BUG=490465
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1255863004
Cr-Commit-Position: refs/heads/master@{#343004}
Diffstat (limited to 'cc/trees/layer_tree_host_unittest_proxy.cc')
-rw-r--r-- | cc/trees/layer_tree_host_unittest_proxy.cc | 183 |
1 files changed, 176 insertions, 7 deletions
diff --git a/cc/trees/layer_tree_host_unittest_proxy.cc b/cc/trees/layer_tree_host_unittest_proxy.cc index 66340e7..d4057cf 100644 --- a/cc/trees/layer_tree_host_unittest_proxy.cc +++ b/cc/trees/layer_tree_host_unittest_proxy.cc @@ -4,6 +4,8 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "cc/test/fake_content_layer_client.h" +#include "cc/test/fake_picture_layer.h" #include "cc/test/layer_tree_test.h" #include "cc/trees/thread_proxy.h" @@ -71,9 +73,16 @@ PROXY_TEST_SCHEDULED_ACTION(ProxyTestScheduledActionsBasic); class ThreadProxyTest : public ProxyTest { protected: - ThreadProxyTest() {} + ThreadProxyTest() + : update_check_layer_( + FakePictureLayer::Create(layer_settings(), &client_)) {} ~ThreadProxyTest() override {} + void SetupTree() override { + layer_tree_host()->SetRootLayer(update_check_layer_); + ProxyTest::SetupTree(); + } + const ThreadProxy::MainThreadOnly& ThreadProxyMainOnly() const { DCHECK(proxy()); DCHECK(proxy()->HasImplThread()); @@ -86,6 +95,10 @@ class ThreadProxyTest : public ProxyTest { return static_cast<const ThreadProxy*>(proxy())->impl(); } + protected: + FakeContentLayerClient client_; + scoped_refptr<FakePictureLayer> update_check_layer_; + private: DISALLOW_COPY_AND_ASSIGN(ThreadProxyTest); }; @@ -96,19 +109,26 @@ class ThreadProxyTestSetNeedsCommit : public ThreadProxyTest { ~ThreadProxyTestSetNeedsCommit() override {} void BeginTest() override { - EXPECT_FALSE(ThreadProxyMainOnly().commit_requested); - EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread); + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); proxy()->SetNeedsCommit(); - EXPECT_TRUE(ThreadProxyMainOnly().commit_requested); - EXPECT_TRUE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread); + EXPECT_EQ(ThreadProxy::COMMIT_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); } void DidBeginMainFrame() override { - EXPECT_FALSE(ThreadProxyMainOnly().commit_requested); - EXPECT_FALSE(ThreadProxyMainOnly().commit_request_sent_to_impl_thread); + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().current_pipeline_stage); + } + void DidCommit() override { + EXPECT_EQ(1, update_check_layer_->update_count()); + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().current_pipeline_stage); EndTest(); } @@ -118,4 +138,153 @@ class ThreadProxyTestSetNeedsCommit : public ThreadProxyTest { THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommit); +class ThreadProxyTestSetNeedsAnimate : public ThreadProxyTest { + protected: + ThreadProxyTestSetNeedsAnimate() {} + ~ThreadProxyTestSetNeedsAnimate() override {} + + void BeginTest() override { + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + + proxy()->SetNeedsAnimate(); + + EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + } + + void DidBeginMainFrame() override { + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().current_pipeline_stage); + } + + void DidCommit() override { + EXPECT_EQ(0, update_check_layer_->update_count()); + EndTest(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsAnimate); +}; + +THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsAnimate); + +class ThreadProxyTestSetNeedsUpdateLayers : public ThreadProxyTest { + protected: + ThreadProxyTestSetNeedsUpdateLayers() {} + ~ThreadProxyTestSetNeedsUpdateLayers() override {} + + void BeginTest() override { + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + + proxy()->SetNeedsUpdateLayers(); + + EXPECT_EQ(ThreadProxy::UPDATE_LAYERS_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + } + + void DidBeginMainFrame() override { + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().current_pipeline_stage); + } + + void DidCommit() override { + EXPECT_EQ(1, update_check_layer_->update_count()); + EndTest(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsUpdateLayers); +}; + +THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsUpdateLayers); + +class ThreadProxyTestSetNeedsUpdateLayersWhileAnimating + : public ThreadProxyTest { + protected: + ThreadProxyTestSetNeedsUpdateLayersWhileAnimating() {} + ~ThreadProxyTestSetNeedsUpdateLayersWhileAnimating() override {} + + void BeginTest() override { proxy()->SetNeedsAnimate(); } + + void WillBeginMainFrame() override { + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, + ThreadProxyMainOnly().current_pipeline_stage); + EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, + ThreadProxyMainOnly().final_pipeline_stage); + + proxy()->SetNeedsUpdateLayers(); + + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::UPDATE_LAYERS_PIPELINE_STAGE, + ThreadProxyMainOnly().final_pipeline_stage); + } + + void DidBeginMainFrame() override { + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().current_pipeline_stage); + } + + void DidCommit() override { + EXPECT_EQ(1, update_check_layer_->update_count()); + EndTest(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsUpdateLayersWhileAnimating); +}; + +THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsUpdateLayersWhileAnimating); + +class ThreadProxyTestSetNeedsCommitWhileAnimating : public ThreadProxyTest { + protected: + ThreadProxyTestSetNeedsCommitWhileAnimating() {} + ~ThreadProxyTestSetNeedsCommitWhileAnimating() override {} + + void BeginTest() override { proxy()->SetNeedsAnimate(); } + + void WillBeginMainFrame() override { + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, + ThreadProxyMainOnly().current_pipeline_stage); + EXPECT_EQ(ThreadProxy::ANIMATE_PIPELINE_STAGE, + ThreadProxyMainOnly().final_pipeline_stage); + + proxy()->SetNeedsCommit(); + + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::COMMIT_PIPELINE_STAGE, + ThreadProxyMainOnly().final_pipeline_stage); + } + + void DidBeginMainFrame() override { + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().max_requested_pipeline_stage); + EXPECT_EQ(ThreadProxy::NO_PIPELINE_STAGE, + ThreadProxyMainOnly().current_pipeline_stage); + } + + void DidCommit() override { + EXPECT_EQ(1, update_check_layer_->update_count()); + EndTest(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ThreadProxyTestSetNeedsCommitWhileAnimating); +}; + +THREAD_PROXY_TEST_F(ThreadProxyTestSetNeedsCommitWhileAnimating); + } // namespace cc |