diff options
author | caseq@chromium.org <caseq@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 11:33:57 +0000 |
---|---|---|
committer | caseq@chromium.org <caseq@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 11:33:57 +0000 |
commit | 2c6998cac676a0aca999274f03b05f9d069263f5 (patch) | |
tree | 8244cab75d4cb96d7d19dc12d6d45ad285fdcc05 /cc | |
parent | af967b95557a35cfccd8c342501e79b1211743a2 (diff) | |
download | chromium_src-2c6998cac676a0aca999274f03b05f9d069263f5.zip chromium_src-2c6998cac676a0aca999274f03b05f9d069263f5.tar.gz chromium_src-2c6998cac676a0aca999274f03b05f9d069263f5.tar.bz2 |
cc: fix continuous paint mode
Request another commit after drawing layers if we're in continuous paint mode.
BUG=346886
Review URL: https://codereview.chromium.org/181393002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/scheduler/scheduler.h | 3 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine.cc | 7 | ||||
-rw-r--r-- | cc/scheduler/scheduler_state_machine.h | 5 | ||||
-rw-r--r-- | cc/test/fake_proxy.h | 1 | ||||
-rw-r--r-- | cc/test/layer_tree_test.cc | 6 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 79 | ||||
-rw-r--r-- | cc/trees/proxy.h | 3 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.h | 1 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 14 | ||||
-rw-r--r-- | cc/trees/thread_proxy.h | 3 |
11 files changed, 120 insertions, 3 deletions
diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h index 7d577b0..b69fba9 100644 --- a/cc/scheduler/scheduler.h +++ b/cc/scheduler/scheduler.h @@ -121,6 +121,9 @@ class CC_EXPORT Scheduler { } bool IsBeginMainFrameSent() const; + void SetContinuousPainting(bool continuous_painting) { + state_machine_.SetContinuousPainting(continuous_painting); + } private: Scheduler(SchedulerClient* client, diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc index 2bbf256..94a9b94 100644 --- a/cc/scheduler/scheduler_state_machine.cc +++ b/cc/scheduler/scheduler_state_machine.cc @@ -44,7 +44,8 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) did_create_and_initialize_first_output_surface_(false), smoothness_takes_priority_(false), skip_next_begin_main_frame_to_reduce_latency_(false), - skip_begin_main_frame_to_reduce_latency_(false) {} + skip_begin_main_frame_to_reduce_latency_(false), + continuous_painting_(false) {} const char* SchedulerStateMachine::OutputSurfaceStateToString( OutputSurfaceState state) { @@ -273,6 +274,7 @@ scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { skip_begin_main_frame_to_reduce_latency_); minor_state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", skip_next_begin_main_frame_to_reduce_latency_); + minor_state->SetBoolean("continuous_painting", continuous_painting_); state->Set("minor_state", minor_state.release()); return state.PassAs<base::Value>(); @@ -739,6 +741,9 @@ void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) { texture_state_ = LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD; else texture_state_ = LAYER_TEXTURE_STATE_UNLOCKED; + + if (continuous_painting_) + needs_commit_ = true; } void SchedulerStateMachine::UpdateStateOnActivation() { diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h index 40a054f..8fe25c2 100644 --- a/cc/scheduler/scheduler_state_machine.h +++ b/cc/scheduler/scheduler_state_machine.h @@ -247,6 +247,10 @@ class CC_EXPORT SchedulerStateMachine { bool SupportsProactiveBeginImplFrame() const; + void SetContinuousPainting(bool continuous_painting) { + continuous_painting_ = continuous_painting; + } + protected: bool BeginImplFrameNeededToDraw() const; bool ProactiveBeginImplFrameWanted() const; @@ -315,6 +319,7 @@ class CC_EXPORT SchedulerStateMachine { bool smoothness_takes_priority_; bool skip_next_begin_main_frame_to_reduce_latency_; bool skip_begin_main_frame_to_reduce_latency_; + bool continuous_painting_; private: DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h index cda4e72..f91082e 100644 --- a/cc/test/fake_proxy.h +++ b/cc/test/fake_proxy.h @@ -44,6 +44,7 @@ class FakeProxy : public Proxy { virtual void ForceSerializeOnSwapBuffers() OVERRIDE {} virtual size_t MaxPartialTextureUpdates() const OVERRIDE; virtual void AcquireLayerTextures() OVERRIDE {} + virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} virtual bool CommitPendingForTesting() OVERRIDE; virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index d6eac97..0063c80 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -374,8 +374,10 @@ void LayerTreeTest::EndTest() { } void LayerTreeTest::EndTestAfterDelay(int delay_milliseconds) { - main_task_runner_->PostTask( - FROM_HERE, base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_)); + main_task_runner_->PostDelayedTask( + FROM_HERE, + base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_), + base::TimeDelta::FromMilliseconds(delay_milliseconds)); } void LayerTreeTest::PostAddAnimationToMainThread( diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 2177280..ee73aba 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -626,6 +626,7 @@ void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { debug_state_.RecordRenderingStats()); SetNeedsCommit(); + proxy_->SetDebugState(debug_state); } void LayerTreeHost::SetViewportSize(const gfx::Size& device_viewport_size) { diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 785f7d1..391f7c0 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -5209,4 +5209,83 @@ class LayerTreeHostTestGpuRasterizationSetting : public LayerTreeHostTest { MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationSetting); +class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { + public: + LayerTreeHostTestContinuousPainting() + : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} + + protected: + enum { kExpectedNumCommits = 10 }; + + virtual void SetupTree() OVERRIDE { + scoped_refptr<Layer> root_layer = Layer::Create(); + root_layer->SetBounds(bounds_); + + if (layer_tree_host()->settings().impl_side_painting) { + picture_layer_ = FakePictureLayer::Create(&client_); + child_layer_ = picture_layer_.get(); + } else { + content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); + child_layer_ = content_layer_.get(); + } + child_layer_->SetBounds(bounds_); + child_layer_->SetIsDrawable(true); + root_layer->AddChild(child_layer_); + + layer_tree_host()->SetRootLayer(root_layer); + layer_tree_host()->SetViewportSize(bounds_); + LayerTreeHostTest::SetupTree(); + } + + virtual void BeginTest() OVERRIDE { + // Wait 50x longer than expected. + double milliseconds_per_frame = + 1000 / layer_tree_host()->settings().refresh_rate; + EndTestAfterDelay(50 * kExpectedNumCommits * milliseconds_per_frame); + MainThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind( + &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, + base::Unretained(this))); + } + + virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { + child_layer_->SetNeedsDisplay(); + } + + virtual void AfterTest() OVERRIDE { + EXPECT_LE(kExpectedNumCommits, num_commits_); + EXPECT_LE(kExpectedNumCommits, num_draws_); + int update_count = content_layer_ ? content_layer_->PaintContentsCount() + : picture_layer_->update_count(); + EXPECT_LE(kExpectedNumCommits, update_count); + } + + virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { + if (++num_draws_ == kExpectedNumCommits) + EndTest(); + } + + virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { + ++num_commits_; + } + + private: + void EnableContinuousPainting() { + LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); + debug_state.continuous_painting = true; + layer_tree_host()->SetDebugState(debug_state); + } + + int num_commits_; + int num_draws_; + const gfx::Size bounds_; + FakeContentLayerClient client_; + scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; + scoped_refptr<FakePictureLayer> picture_layer_; + Layer* child_layer_; +}; + +MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); + } // namespace cc diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h index 4ec4f6e..310e3a1 100644 --- a/cc/trees/proxy.h +++ b/cc/trees/proxy.h @@ -24,6 +24,7 @@ class Vector2d; namespace cc { +class LayerTreeDebugState; class OutputSurface; struct RendererCapabilities; @@ -98,6 +99,8 @@ class CC_EXPORT Proxy { virtual scoped_ptr<base::Value> AsValue() const = 0; + virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0; + // Testing hooks virtual bool CommitPendingForTesting() = 0; virtual scoped_ptr<base::Value> SchedulerStateAsValueForTesting(); diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 462bdd2..a600699 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -80,6 +80,7 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { OVERRIDE {} virtual void DidActivatePendingTree() OVERRIDE {} virtual void DidManageTiles() OVERRIDE {} + virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} // Called by the legacy path where RenderWidget does the scheduling. void CompositeImmediately(base::TimeTicks frame_begin_time); diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index 0c0ff9a..3a6c29b 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -759,6 +759,20 @@ void ThreadProxy::ForceSerializeOnSwapBuffersOnImplThread( completion->Signal(); } +void ThreadProxy::SetDebugState(const LayerTreeDebugState& debug_state) { + Proxy::ImplThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&ThreadProxy::SetDebugStateOnImplThread, + impl_thread_weak_ptr_, + debug_state)); +} + +void ThreadProxy::SetDebugStateOnImplThread( + const LayerTreeDebugState& debug_state) { + DCHECK(IsImplThread()); + impl().scheduler->SetContinuousPainting(debug_state.continuous_painting); +} + void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); DCHECK(IsImplThread()); diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index c0203af1..a494da3 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -66,6 +66,7 @@ class ThreadProxy : public Proxy, virtual size_t MaxPartialTextureUpdates() const OVERRIDE; virtual void AcquireLayerTextures() OVERRIDE; virtual void ForceSerializeOnSwapBuffers() OVERRIDE; + virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE; virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; virtual bool CommitPendingForTesting() OVERRIDE; virtual scoped_ptr<base::Value> SchedulerStateAsValueForTesting() OVERRIDE; @@ -198,6 +199,8 @@ class ThreadProxy : public Proxy, void StartScrollbarAnimationOnImplThread(); void MainThreadHasStoppedFlingingOnImplThread(); void SetInputThrottledUntilCommitOnImplThread(bool is_throttled); + void SetDebugStateOnImplThread(const LayerTreeDebugState& debug_state); + LayerTreeHost* layer_tree_host(); const LayerTreeHost* layer_tree_host() const; |