summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-06 13:05:22 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-06 13:05:22 +0000
commit8003aafdf6c47e69002c6f987018d16aa79151d2 (patch)
tree12c119fce434cf39c517915fdb656b4c7b6f2b1a
parentb3a4d2b12b448f15fa2f0f412a6484dacb466812 (diff)
downloadchromium_src-8003aafdf6c47e69002c6f987018d16aa79151d2.zip
chromium_src-8003aafdf6c47e69002c6f987018d16aa79151d2.tar.gz
chromium_src-8003aafdf6c47e69002c6f987018d16aa79151d2.tar.bz2
Revert 287747 "Make SingleThreadProxy a SchedulerClient"
This is a speculative revert to see if issues on Mac bots get resolved. BrowserTest.WindowOpenClose is e.g. failing on this assert: ASSERTION FAILED: !active || m_layerTreeView > Make SingleThreadProxy a SchedulerClient > > This makes ui::Compositor no longer in charge of > scheduling commits and draws, deferring it to cc::Scheduler. > > Other compositors that use SingleThreadProxy are left calling composite > synchronously and now pass a flag to indicate that this is their > intention. This patch doesn't remove synchronous composite, but now > makes it mutually exclusive with scheduling. > > BUG=329552, 287250 > > Review URL: https://codereview.chromium.org/134623005 TBR=enne@chromium.org Review URL: https://codereview.chromium.org/441343002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287766 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/browser/hardware_renderer.cc7
-rw-r--r--android_webview/browser/hardware_renderer.h2
-rw-r--r--cc/scheduler/scheduler.cc27
-rw-r--r--cc/scheduler/scheduler.h15
-rw-r--r--cc/scheduler/scheduler_state_machine.cc4
-rw-r--r--cc/test/fake_layer_tree_host_client.h2
-rw-r--r--cc/test/layer_tree_test.cc48
-rw-r--r--cc/test/layer_tree_test.h6
-rw-r--r--cc/trees/layer_tree_host.cc4
-rw-r--r--cc/trees/layer_tree_host_single_thread_client.h4
-rw-r--r--cc/trees/layer_tree_host_unittest.cc10
-rw-r--r--cc/trees/layer_tree_host_unittest_animation.cc9
-rw-r--r--cc/trees/layer_tree_host_unittest_context.cc80
-rw-r--r--cc/trees/layer_tree_host_unittest_no_message_loop.cc3
-rw-r--r--cc/trees/layer_tree_settings.cc1
-rw-r--r--cc/trees/layer_tree_settings.h1
-rw-r--r--cc/trees/single_thread_proxy.cc341
-rw-r--r--cc/trees/single_thread_proxy.h46
-rw-r--r--cc/trees/thread_proxy.cc5
-rw-r--r--content/browser/renderer_host/compositor_impl_android.cc11
-rw-r--r--content/public/common/content_switches.cc4
-rw-r--r--content/public/common/content_switches.h1
-rw-r--r--content/renderer/gpu/render_widget_compositor.cc36
-rw-r--r--content/renderer/gpu/render_widget_compositor.h4
-rw-r--r--content/renderer/render_widget.cc26
-rw-r--r--content/renderer/render_widget.h7
-rw-r--r--content/shell/renderer/test_runner/web_test_proxy.cc6
-rw-r--r--content/test/web_layer_tree_view_impl_for_testing.h2
-rw-r--r--ui/compositor/compositor.cc127
-rw-r--r--ui/compositor/compositor.h24
-rw-r--r--ui/compositor/layer_unittest.cc40
-rw-r--r--ui/compositor/test/draw_waiter_for_test.cc29
-rw-r--r--ui/compositor/test/draw_waiter_for_test.h15
-rw-r--r--ui/compositor/test/test_compositor_host_mac.mm2
-rw-r--r--ui/compositor/test/test_compositor_host_ozone.cc7
-rw-r--r--ui/compositor/test/test_compositor_host_win.cc2
-rw-r--r--ui/compositor/test/test_compositor_host_x11.cc7
-rw-r--r--ui/snapshot/snapshot_aura_unittest.cc3
-rw-r--r--ui/views/view_unittest.cc60
39 files changed, 456 insertions, 572 deletions
diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc
index 86dd667..818d3c5 100644
--- a/android_webview/browser/hardware_renderer.cc
+++ b/android_webview/browser/hardware_renderer.cc
@@ -93,11 +93,8 @@ HardwareRenderer::HardwareRenderer(SharedRendererState* state)
// Webview does not own the surface so should not clear it.
settings.should_clear_root_render_pass = false;
- // TODO(enne): Update this this compositor to use a synchronous scheduler.
- settings.single_thread_proxy_scheduler = false;
-
- layer_tree_host_ =
- cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings, NULL);
+ layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(
+ this, this, NULL, settings, NULL);
layer_tree_host_->SetRootLayer(root_layer_);
layer_tree_host_->SetLayerTreeHostClientReady();
layer_tree_host_->set_has_transparent_background(true);
diff --git a/android_webview/browser/hardware_renderer.h b/android_webview/browser/hardware_renderer.h
index b07d36d..f87890b 100644
--- a/android_webview/browser/hardware_renderer.h
+++ b/android_webview/browser/hardware_renderer.h
@@ -54,6 +54,8 @@ class HardwareRenderer : public cc::LayerTreeHostClient,
virtual void DidCompleteSwapBuffers() OVERRIDE {}
// cc::LayerTreeHostSingleThreadClient overrides.
+ virtual void ScheduleComposite() OVERRIDE {}
+ virtual void ScheduleAnimation() OVERRIDE {}
virtual void DidPostSwapBuffers() OVERRIDE {}
virtual void DidAbortSwapBuffers() OVERRIDE {}
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index a20bfd2b..1451237 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -79,11 +79,11 @@ Scheduler::Scheduler(
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
+ const scoped_refptr<base::SingleThreadTaskRunner>& impl_task_runner)
: settings_(scheduler_settings),
client_(client),
layer_tree_host_id_(layer_tree_host_id),
- task_runner_(task_runner),
+ impl_task_runner_(impl_task_runner),
vsync_interval_(BeginFrameArgs::DefaultInterval()),
last_set_needs_begin_frame_(false),
begin_unthrottled_frame_posted_(false),
@@ -128,7 +128,7 @@ Scheduler::~Scheduler() {
void Scheduler::SetupSyntheticBeginFrames() {
DCHECK(!synthetic_begin_frame_source_);
synthetic_begin_frame_source_.reset(
- new SyntheticBeginFrameSource(this, task_runner_.get()));
+ new SyntheticBeginFrameSource(this, impl_task_runner_.get()));
}
void Scheduler::CommitVSyncParameters(base::TimeTicks timebase,
@@ -274,9 +274,6 @@ base::TimeTicks Scheduler::LastBeginImplFrameTime() {
}
void Scheduler::SetupNextBeginFrameIfNeeded() {
- if (!task_runner_)
- return;
-
bool needs_begin_frame = state_machine_.BeginFrameNeeded();
if (settings_.throttle_frame_production) {
@@ -331,7 +328,7 @@ void Scheduler::SetupNextBeginFrameWhenVSyncThrottlingDisabled(
}
begin_unthrottled_frame_posted_ = true;
- task_runner_->PostTask(FROM_HERE, begin_unthrottled_frame_closure_);
+ impl_task_runner_->PostTask(FROM_HERE, begin_unthrottled_frame_closure_);
}
// BeginUnthrottledFrame is used when we aren't throttling frame production.
@@ -365,7 +362,7 @@ void Scheduler::SetupPollingMechanisms(bool needs_begin_frame) {
base::TimeDelta delay = begin_impl_frame_args_.IsValid()
? begin_impl_frame_args_.interval
: BeginFrameArgs::DefaultInterval();
- task_runner_->PostDelayedTask(
+ impl_task_runner_->PostDelayedTask(
FROM_HERE, poll_for_draw_triggers_task_.callback(), delay);
}
} else {
@@ -390,9 +387,9 @@ void Scheduler::SetupPollingMechanisms(bool needs_begin_frame) {
// Since we'd rather get a BeginImplFrame by the normal mechanism, we
// set the interval to twice the interval from the previous frame.
advance_commit_state_task_.Reset(advance_commit_state_closure_);
- task_runner_->PostDelayedTask(FROM_HERE,
- advance_commit_state_task_.callback(),
- begin_impl_frame_args_.interval * 2);
+ impl_task_runner_->PostDelayedTask(FROM_HERE,
+ advance_commit_state_task_.callback(),
+ begin_impl_frame_args_.interval * 2);
}
} else {
advance_commit_state_task_.Cancel();
@@ -494,7 +491,7 @@ void Scheduler::PostBeginRetroFrameIfNeeded() {
return;
begin_retro_frame_posted_ = true;
- task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_);
+ impl_task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_);
}
// BeginImplFrame starts a compositor frame that will wait up until a deadline
@@ -502,8 +499,8 @@ void Scheduler::PostBeginRetroFrameIfNeeded() {
// any asynchronous animation and scroll/pinch updates.
void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
TRACE_EVENT1("cc", "Scheduler::BeginImplFrame", "args", args.AsValue());
- DCHECK_EQ(state_machine_.begin_impl_frame_state(),
- SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
+ DCHECK(state_machine_.begin_impl_frame_state() ==
+ SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
DCHECK(state_machine_.HasInitializedOutputSurface());
advance_commit_state_task_.Cancel();
@@ -570,7 +567,7 @@ void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) {
base::TimeDelta delta = deadline - gfx::FrameTime::Now();
if (delta <= base::TimeDelta())
delta = base::TimeDelta();
- task_runner_->PostDelayedTask(
+ impl_task_runner_->PostDelayedTask(
FROM_HERE, begin_impl_frame_deadline_task_.callback(), delta);
}
diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h
index 311a71d..afb9e9d 100644
--- a/cc/scheduler/scheduler.h
+++ b/cc/scheduler/scheduler.h
@@ -57,9 +57,9 @@ class CC_EXPORT Scheduler {
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
+ const scoped_refptr<base::SingleThreadTaskRunner>& impl_task_runner) {
return make_scoped_ptr(new Scheduler(
- client, scheduler_settings, layer_tree_host_id, task_runner));
+ client, scheduler_settings, layer_tree_host_id, impl_task_runner));
}
virtual ~Scheduler();
@@ -173,15 +173,16 @@ class CC_EXPORT Scheduler {
scoped_refptr<DelayBasedTimeSource> time_source_;
};
- Scheduler(SchedulerClient* client,
- const SchedulerSettings& scheduler_settings,
- int layer_tree_host_id,
- const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
+ Scheduler(
+ SchedulerClient* client,
+ const SchedulerSettings& scheduler_settings,
+ int layer_tree_host_id,
+ const scoped_refptr<base::SingleThreadTaskRunner>& impl_task_runner);
const SchedulerSettings settings_;
SchedulerClient* client_;
int layer_tree_host_id_;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_;
base::TimeDelta vsync_interval_;
base::TimeDelta estimated_parent_draw_time_;
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
index 723c40c..a37a74a 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -1006,9 +1006,7 @@ void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
}
}
-void SchedulerStateMachine::SetNeedsCommit() {
- needs_commit_ = true;
-}
+void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; }
void SchedulerStateMachine::NotifyReadyToCommit() {
DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED)
diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h
index 7f7bd35..f928453 100644
--- a/cc/test/fake_layer_tree_host_client.h
+++ b/cc/test/fake_layer_tree_host_client.h
@@ -42,6 +42,8 @@ class FakeLayerTreeHostClient : public LayerTreeHostClient,
virtual void DidCompleteSwapBuffers() OVERRIDE {}
// LayerTreeHostSingleThreadClient implementation.
+ virtual void ScheduleComposite() OVERRIDE {}
+ virtual void ScheduleAnimation() OVERRIDE {}
virtual void DidPostSwapBuffers() OVERRIDE {}
virtual void DidAbortSwapBuffers() OVERRIDE {}
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 312f643..d72860d 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -312,6 +312,14 @@ class LayerTreeHostClientForTesting : public LayerTreeHostClient,
test_hooks_->DidCompleteSwapBuffers();
}
+ virtual void ScheduleComposite() OVERRIDE {
+ test_hooks_->ScheduleComposite();
+ }
+
+ virtual void ScheduleAnimation() OVERRIDE {
+ test_hooks_->ScheduleAnimation();
+ }
+
virtual void DidPostSwapBuffers() OVERRIDE {}
virtual void DidAbortSwapBuffers() OVERRIDE {}
@@ -386,6 +394,7 @@ LayerTreeTest::LayerTreeTest()
end_when_begin_returns_(false),
timed_out_(false),
scheduled_(false),
+ schedule_when_set_visible_true_(false),
started_(false),
ended_(false),
delegating_renderer_(false),
@@ -549,6 +558,15 @@ void LayerTreeTest::Timeout() {
EndTest();
}
+void LayerTreeTest::ScheduleComposite() {
+ if (!started_ || scheduled_)
+ return;
+ scheduled_ = true;
+ main_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&LayerTreeTest::DispatchComposite, main_thread_weak_ptr_));
+}
+
void LayerTreeTest::RealEndTest() {
if (layer_tree_host_ && proxy()->CommitPendingForTesting()) {
main_task_runner_->PostTask(
@@ -600,8 +618,16 @@ void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) {
void LayerTreeTest::DispatchSetVisible(bool visible) {
DCHECK(!proxy() || proxy()->IsMainThread());
- if (layer_tree_host_)
- layer_tree_host_->SetVisible(visible);
+
+ if (!layer_tree_host_)
+ return;
+
+ layer_tree_host_->SetVisible(visible);
+
+ // If the LTH is being made visible and a previous ScheduleComposite() was
+ // deferred because the LTH was not visible, re-schedule the composite now.
+ if (layer_tree_host_->visible() && schedule_when_set_visible_true_)
+ ScheduleComposite();
}
void LayerTreeTest::DispatchSetNextCommitForcesRedraw() {
@@ -611,6 +637,24 @@ void LayerTreeTest::DispatchSetNextCommitForcesRedraw() {
layer_tree_host_->SetNextCommitForcesRedraw();
}
+void LayerTreeTest::DispatchComposite() {
+ scheduled_ = false;
+
+ if (!layer_tree_host_)
+ return;
+
+ // If the LTH is not visible, defer the composite until the LTH is made
+ // visible.
+ if (!layer_tree_host_->visible()) {
+ schedule_when_set_visible_true_ = true;
+ return;
+ }
+
+ schedule_when_set_visible_true_ = false;
+ base::TimeTicks now = gfx::FrameTime::Now();
+ layer_tree_host_->Composite(now);
+}
+
void LayerTreeTest::RunTest(bool threaded,
bool delegating_renderer,
bool impl_side_painting) {
diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h
index 619ae96..8f38dda 100644
--- a/cc/test/layer_tree_test.h
+++ b/cc/test/layer_tree_test.h
@@ -71,6 +71,8 @@ class TestHooks : public AnimationDelegate {
virtual void DidCommit() {}
virtual void DidCommitAndDrawFrame() {}
virtual void DidCompleteSwapBuffers() {}
+ virtual void ScheduleComposite() {}
+ virtual void ScheduleAnimation() {}
virtual void DidDeferCommit() {}
virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl,
bool visible) {}
@@ -137,6 +139,8 @@ class LayerTreeTest : public testing::Test, public TestHooks {
virtual void InitializeSettings(LayerTreeSettings* settings) {}
+ virtual void ScheduleComposite() OVERRIDE;
+
void RealEndTest();
virtual void DispatchAddAnimation(Layer* layer_to_receive_animation,
@@ -147,6 +151,7 @@ class LayerTreeTest : public testing::Test, public TestHooks {
void DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect);
void DispatchSetVisible(bool visible);
void DispatchSetNextCommitForcesRedraw();
+ void DispatchComposite();
void DispatchDidAddAnimation();
virtual void AfterTest() = 0;
@@ -199,6 +204,7 @@ class LayerTreeTest : public testing::Test, public TestHooks {
bool end_when_begin_returns_;
bool timed_out_;
bool scheduled_;
+ bool schedule_when_set_visible_true_;
bool started_;
bool ended_;
bool delegating_renderer_;
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 03969f2..ed7472d 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -697,12 +697,8 @@ void LayerTreeHost::NotifyInputThrottledUntilCommit() {
void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) {
DCHECK(!proxy_->HasImplThread());
- // This function is only valid when not using the scheduler.
- DCHECK(!settings_.single_thread_proxy_scheduler);
SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
- SetLayerTreeHostClientReady();
-
if (output_surface_lost_)
proxy->CreateAndInitializeOutputSurface();
if (output_surface_lost_)
diff --git a/cc/trees/layer_tree_host_single_thread_client.h b/cc/trees/layer_tree_host_single_thread_client.h
index dbca28c..cb61450 100644
--- a/cc/trees/layer_tree_host_single_thread_client.h
+++ b/cc/trees/layer_tree_host_single_thread_client.h
@@ -10,10 +10,10 @@ namespace cc {
class LayerTreeHostSingleThreadClient {
public:
// Request that the client schedule a composite.
- virtual void ScheduleComposite() {}
+ virtual void ScheduleComposite() = 0;
// Request that the client schedule a composite now, and calculate appropriate
// delay for potential future frame.
- virtual void ScheduleAnimation() {}
+ virtual void ScheduleAnimation() = 0;
// Called whenever the compositor posts a SwapBuffers (either full or
// partial). After DidPostSwapBuffers(), exactly one of
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 69cccfa..5c69225 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -91,8 +91,8 @@ class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest {
}
virtual void AfterTest() OVERRIDE {
- EXPECT_LE(1, num_commits_);
- EXPECT_LE(1, num_draws_);
+ EXPECT_GE(1, num_commits_);
+ EXPECT_GE(1, num_draws_);
}
private:
@@ -1967,7 +1967,7 @@ class LayerTreeHostTestDeferCommits : public LayerTreeHostTest {
int num_complete_commits_;
};
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits);
+MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits);
class LayerTreeHostWithProxy : public LayerTreeHost {
public:
@@ -2040,7 +2040,6 @@ TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
LayerTreeSettings settings;
settings.max_partial_texture_updates = 4;
- settings.single_thread_proxy_scheduler = false;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
new TestSharedBitmapManager());
@@ -2060,7 +2059,6 @@ TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) {
LayerTreeSettings settings;
settings.max_partial_texture_updates = 4;
- settings.single_thread_proxy_scheduler = false;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
new TestSharedBitmapManager());
@@ -2080,7 +2078,6 @@ TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) {
LayerTreeSettings settings;
settings.max_partial_texture_updates = 4;
- settings.single_thread_proxy_scheduler = false;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
new TestSharedBitmapManager());
@@ -2101,7 +2098,6 @@ TEST(LayerTreeHostTest,
LayerTreeSettings settings;
settings.max_partial_texture_updates = 4;
- settings.single_thread_proxy_scheduler = false;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
new TestSharedBitmapManager());
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc
index 1853bfc..f717c2a 100644
--- a/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/cc/trees/layer_tree_host_unittest_animation.cc
@@ -726,7 +726,9 @@ class LayerTreeHostAnimationTestContinuousAnimate
: public LayerTreeHostAnimationTest {
public:
LayerTreeHostAnimationTestContinuousAnimate()
- : num_commit_complete_(0), num_draw_layers_(0), have_animated_(false) {}
+ : num_commit_complete_(0),
+ num_draw_layers_(0) {
+ }
virtual void SetupTree() OVERRIDE {
LayerTreeHostAnimationTest::SetupTree();
@@ -745,7 +747,6 @@ class LayerTreeHostAnimationTestContinuousAnimate
if (num_draw_layers_ == 2)
return;
layer_tree_host()->SetNeedsAnimate();
- have_animated_ = true;
}
virtual void Layout() OVERRIDE {
@@ -766,18 +767,16 @@ class LayerTreeHostAnimationTestContinuousAnimate
virtual void AfterTest() OVERRIDE {
// Check that we didn't commit twice between first and second draw.
EXPECT_EQ(1, num_commit_complete_);
- EXPECT_TRUE(have_animated_);
}
private:
int num_commit_complete_;
int num_draw_layers_;
- bool have_animated_;
FakeContentLayerClient client_;
scoped_refptr<FakeContentLayer> content_;
};
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate);
+MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate);
class LayerTreeHostAnimationTestCancelAnimateCommit
: public LayerTreeHostAnimationTest {
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 548ff36..879e534 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -65,9 +65,6 @@ class LayerTreeHostContextTest : public LayerTreeTest {
}
void LoseContext() {
- // For sanity-checking tests, they should only call this when the
- // context is not lost.
- CHECK(context3d_);
context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
GL_INNOCENT_CONTEXT_RESET_ARB);
context3d_ = NULL;
@@ -203,53 +200,45 @@ class LayerTreeHostContextTestLostContextSucceeds
static const TestCase kTests[] = {
// Losing the context and failing to recreate it (or losing it again
// immediately) a small number of times should succeed.
- {
- 1, // times_to_lose_during_commit
+ {1, // times_to_lose_during_commit
0, // times_to_lose_during_draw
0, // times_to_fail_recreate
false, // fallback_context_works
},
- {
- 0, // times_to_lose_during_commit
+ {0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
0, // times_to_fail_recreate
false, // fallback_context_works
},
- {
- 1, // times_to_lose_during_commit
+ {1, // times_to_lose_during_commit
0, // times_to_lose_during_draw
3, // times_to_fail_recreate
false, // fallback_context_works
},
- {
- 0, // times_to_lose_during_commit
+ {0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
3, // times_to_fail_recreate
false, // fallback_context_works
},
// Losing the context and recreating it any number of times should
// succeed.
- {
- 10, // times_to_lose_during_commit
+ {10, // times_to_lose_during_commit
0, // times_to_lose_during_draw
0, // times_to_fail_recreate
false, // fallback_context_works
},
- {
- 0, // times_to_lose_during_commit
+ {0, // times_to_lose_during_commit
10, // times_to_lose_during_draw
0, // times_to_fail_recreate
false, // fallback_context_works
},
// Losing the context, failing to reinitialize it, and making a fallback
// context should work.
- {
- 0, // times_to_lose_during_commit
+ {0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
0, // times_to_fail_recreate
true, // fallback_context_works
- },
- };
+ }, };
if (test_case_ >= arraysize(kTests))
return false;
@@ -311,8 +300,7 @@ class LayerTreeHostClientNotReadyDoesNotCreateOutputSurface
}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostClientNotReadyDoesNotCreateOutputSurface);
+MULTI_THREAD_TEST_F(LayerTreeHostClientNotReadyDoesNotCreateOutputSurface);
class LayerTreeHostContextTestLostContextSucceedsWithContent
: public LayerTreeHostContextTestLostContextSucceeds {
@@ -370,11 +358,10 @@ class LayerTreeHostContextTestCreateOutputSurfaceFails
: times_to_fail_(times_to_fail),
expect_fallback_attempt_(expect_fallback_attempt),
did_attempt_fallback_(false),
- times_initialized_(0) {
- times_to_fail_create_ = times_to_fail_;
- }
+ times_initialized_(0) {}
virtual void BeginTest() OVERRIDE {
+ times_to_fail_create_ = times_to_fail_;
PostSetNeedsCommitToMainThread();
}
@@ -988,6 +975,12 @@ class ScrollbarLayerLostContext : public LayerTreeHostContextTest {
EXPECT_EQ(2, scrollbar_layer_->update_count());
EndTest();
break;
+ case 3:
+ // Single thread proxy issues extra commits after context lost.
+ // http://crbug.com/287250
+ if (HasImplThread())
+ NOTREACHED();
+ break;
default:
NOTREACHED();
}
@@ -1031,10 +1024,12 @@ class UIResourceLostTest : public LayerTreeHostContextTest {
void PostLoseContextToImplThread() {
EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
- ImplThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&LayerTreeHostContextTest::LoseContext,
- base::Unretained(this)));
+ base::SingleThreadTaskRunner* task_runner =
+ HasImplThread() ? ImplThreadTaskRunner()
+ : base::MessageLoopProxy::current();
+ task_runner->PostTask(FROM_HERE,
+ base::Bind(&LayerTreeHostContextTest::LoseContext,
+ base::Unretained(this)));
}
protected:
@@ -1089,8 +1084,13 @@ class UIResourceLostAfterCommit : public UIResourceLostTestSimple {
EndTest();
break;
case 5:
- NOTREACHED();
+ // Single thread proxy issues extra commits after context lost.
+ // http://crbug.com/287250
+ if (HasImplThread())
+ NOTREACHED();
break;
+ case 6:
+ NOTREACHED();
}
}
@@ -1178,8 +1178,13 @@ class UIResourceLostBeforeCommit : public UIResourceLostTestSimple {
EndTest();
break;
case 6:
- NOTREACHED();
+ // Single thread proxy issues extra commits after context lost.
+ // http://crbug.com/287250
+ if (HasImplThread())
+ NOTREACHED();
break;
+ case 8:
+ NOTREACHED();
}
}
@@ -1200,8 +1205,15 @@ class UIResourceLostBeforeCommit : public UIResourceLostTestSimple {
// Sequence 2 (continued):
// The previous resource should have been deleted.
EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_));
- // The second resource should have been created.
- EXPECT_NE(0u, impl->ResourceIdForUIResource(test_id1_));
+ if (HasImplThread()) {
+ // The second resource should have been created.
+ EXPECT_NE(0u, impl->ResourceIdForUIResource(test_id1_));
+ } else {
+ // The extra commit that happens at context lost in the single thread
+ // proxy changes the timing so that the resource has been destroyed.
+ // http://crbug.com/287250
+ EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id1_));
+ }
// The second resource called the resource callback once and since the
// context is lost, a "resource lost" callback was also issued.
EXPECT_EQ(2, ui_resource_->resource_create_count);
@@ -1517,8 +1529,8 @@ class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame
bool deferred_;
};
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostContextTestLoseAfterSendingBeginMainFrame);
+// TODO(danakj): We don't use scheduler with SingleThreadProxy yet.
+MULTI_THREAD_TEST_F(LayerTreeHostContextTestLoseAfterSendingBeginMainFrame);
} // namespace
} // namespace cc
diff --git a/cc/trees/layer_tree_host_unittest_no_message_loop.cc b/cc/trees/layer_tree_host_unittest_no_message_loop.cc
index ea3bfc6..1a24ba5 100644
--- a/cc/trees/layer_tree_host_unittest_no_message_loop.cc
+++ b/cc/trees/layer_tree_host_unittest_no_message_loop.cc
@@ -74,6 +74,8 @@ class LayerTreeHostNoMessageLoopTest
virtual void DidCompleteSwapBuffers() OVERRIDE {}
// LayerTreeHostSingleThreadClient overrides.
+ virtual void ScheduleComposite() OVERRIDE {}
+ virtual void ScheduleAnimation() OVERRIDE {}
virtual void DidPostSwapBuffers() OVERRIDE {}
virtual void DidAbortSwapBuffers() OVERRIDE {}
@@ -94,7 +96,6 @@ class LayerTreeHostNoMessageLoopTest
void SetupLayerTreeHost() {
LayerTreeSettings settings;
- settings.single_thread_proxy_scheduler = false;
layer_tree_host_ =
LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings, NULL);
layer_tree_host_->SetViewportSize(size_);
diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc
index 56e18a2..bf72893 100644
--- a/cc/trees/layer_tree_settings.cc
+++ b/cc/trees/layer_tree_settings.cc
@@ -16,7 +16,6 @@ LayerTreeSettings::LayerTreeSettings()
: impl_side_painting(false),
allow_antialiasing(true),
throttle_frame_production(true),
- single_thread_proxy_scheduler(true),
begin_frame_scheduling_enabled(false),
main_frame_before_draw_enabled(true),
main_frame_before_activation_enabled(false),
diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h
index bad3bf4..14cec67 100644
--- a/cc/trees/layer_tree_settings.h
+++ b/cc/trees/layer_tree_settings.h
@@ -21,7 +21,6 @@ class CC_EXPORT LayerTreeSettings {
bool impl_side_painting;
bool allow_antialiasing;
bool throttle_frame_production;
- bool single_thread_proxy_scheduler;
bool begin_frame_scheduling_enabled;
bool main_frame_before_draw_enabled;
bool main_frame_before_activation_enabled;
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index fe9c34f8..2f67740 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -36,13 +36,8 @@ SingleThreadProxy::SingleThreadProxy(
: Proxy(main_task_runner, NULL),
layer_tree_host_(layer_tree_host),
client_(client),
- timing_history_(layer_tree_host->rendering_stats_instrumentation()),
next_frame_is_newly_committed_frame_(false),
- inside_draw_(false),
- defer_commits_(false),
- commit_was_deferred_(false),
- commit_requested_(false),
- weak_factory_(this) {
+ inside_draw_(false) {
TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
DCHECK(Proxy::IsMainThread());
DCHECK(layer_tree_host);
@@ -82,26 +77,13 @@ void SingleThreadProxy::SetLayerTreeHostClientReady() {
TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady");
// Scheduling is controlled by the embedder in the single thread case, so
// nothing to do.
- DCHECK(Proxy::IsMainThread());
- DebugScopedSetImplThread impl(this);
- if (layer_tree_host_->settings().single_thread_proxy_scheduler &&
- !scheduler_on_impl_thread_) {
- SchedulerSettings scheduler_settings(layer_tree_host_->settings());
- scheduler_on_impl_thread_ = Scheduler::Create(this,
- scheduler_settings,
- layer_tree_host_->id(),
- MainThreadTaskRunner());
- scheduler_on_impl_thread_->SetCanStart();
- scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
- }
}
void SingleThreadProxy::SetVisible(bool visible) {
TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible");
DebugScopedSetImplThread impl(this);
layer_tree_host_impl_->SetVisible(visible);
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
+
// Changing visibility could change ShouldComposite().
UpdateBackgroundAnimateTicking();
}
@@ -128,14 +110,9 @@ void SingleThreadProxy::CreateAndInitializeOutputSurface() {
layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success);
- if (success) {
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface();
- } else if (Proxy::MainThreadTaskRunner()) {
- MainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface,
- weak_factory_.GetWeakPtr()));
+ if (!success) {
+ // Force another recreation attempt to happen by requesting another commit.
+ SetNeedsCommit();
}
}
@@ -149,40 +126,17 @@ void SingleThreadProxy::SetNeedsAnimate() {
TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate");
DCHECK(Proxy::IsMainThread());
client_->ScheduleAnimation();
- SetNeedsCommit();
}
void SingleThreadProxy::SetNeedsUpdateLayers() {
TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers");
DCHECK(Proxy::IsMainThread());
- SetNeedsCommit();
+ client_->ScheduleComposite();
}
-void SingleThreadProxy::DoCommit(base::TimeTicks frame_begin_time) {
+void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) {
TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit");
DCHECK(Proxy::IsMainThread());
- layer_tree_host_->WillBeginMainFrame();
- layer_tree_host_->UpdateClientAnimations(frame_begin_time);
- layer_tree_host_->AnimateLayers(frame_begin_time);
- layer_tree_host_->Layout();
- commit_requested_ = false;
-
- if (PrioritizedResourceManager* contents_texture_manager =
- layer_tree_host_->contents_texture_manager()) {
- contents_texture_manager->UnlinkAndClearEvictedBackings();
- contents_texture_manager->SetMaxMemoryLimitBytes(
- layer_tree_host_impl_->memory_allocation_limit_bytes());
- contents_texture_manager->SetExternalPriorityCutoff(
- layer_tree_host_impl_->memory_allocation_priority_cutoff());
- }
-
- scoped_ptr<ResourceUpdateQueue> queue =
- make_scoped_ptr(new ResourceUpdateQueue);
-
- layer_tree_host_->UpdateLayers(queue.get());
-
- layer_tree_host_->WillCommit();
-
// Commit immediately.
{
DebugScopedSetMainThreadBlocked main_thread_blocked(this);
@@ -204,7 +158,7 @@ void SingleThreadProxy::DoCommit(base::TimeTicks frame_begin_time) {
scoped_ptr<ResourceUpdateController> update_controller =
ResourceUpdateController::Create(
NULL,
- MainThreadTaskRunner(),
+ Proxy::MainThreadTaskRunner(),
queue.Pass(),
layer_tree_host_impl_->resource_provider());
update_controller->Finalize();
@@ -216,8 +170,6 @@ void SingleThreadProxy::DoCommit(base::TimeTicks frame_begin_time) {
layer_tree_host_impl_->CommitComplete();
- UpdateBackgroundAnimateTicking();
-
#if DCHECK_IS_ON
// In the single-threaded case, the scale and scroll deltas should never be
// touched on the impl layer tree.
@@ -234,64 +186,30 @@ void SingleThreadProxy::DoCommit(base::TimeTicks frame_begin_time) {
stats_instrumentation->AccumulateAndClearMainThreadStats();
}
layer_tree_host_->CommitComplete();
- layer_tree_host_->DidBeginMainFrame();
- timing_history_.DidCommit();
-
next_frame_is_newly_committed_frame_ = true;
}
void SingleThreadProxy::SetNeedsCommit() {
DCHECK(Proxy::IsMainThread());
- DebugScopedSetImplThread impl(this);
client_->ScheduleComposite();
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->SetNeedsCommit();
- commit_requested_ = true;
}
void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) {
TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw");
- DCHECK(Proxy::IsMainThread());
- DebugScopedSetImplThread impl(this);
- client_->ScheduleComposite();
SetNeedsRedrawRectOnImplThread(damage_rect);
+ client_->ScheduleComposite();
}
void SingleThreadProxy::SetNextCommitWaitsForActivation() {
// There is no activation here other than commit. So do nothing.
- DCHECK(Proxy::IsMainThread());
}
void SingleThreadProxy::SetDeferCommits(bool defer_commits) {
- DCHECK(Proxy::IsMainThread());
- // Deferring commits only makes sense if there's a scheduler.
- if (!scheduler_on_impl_thread_)
- return;
- if (defer_commits_ == defer_commits)
- return;
-
- if (defer_commits)
- TRACE_EVENT_ASYNC_BEGIN0("cc", "SingleThreadProxy::SetDeferCommits", this);
- else
- TRACE_EVENT_ASYNC_END0("cc", "SingleThreadProxy::SetDeferCommits", this);
-
- defer_commits_ = defer_commits;
- if (!defer_commits_ && commit_was_deferred_) {
- scheduler_on_impl_thread_->NotifyBeginMainFrameStarted();
- scheduler_on_impl_thread_->NotifyReadyToCommit();
- commit_was_deferred_ = false;
- }
}
-bool SingleThreadProxy::CommitRequested() const {
- DCHECK(Proxy::IsMainThread());
- return commit_requested_;
-}
+bool SingleThreadProxy::CommitRequested() const { return false; }
-bool SingleThreadProxy::BeginMainFrameRequested() const {
- DCHECK(Proxy::IsMainThread());
- return commit_requested_;
-}
+bool SingleThreadProxy::BeginMainFrameRequested() const { return false; }
size_t SingleThreadProxy::MaxPartialTextureUpdates() const {
return std::numeric_limits<size_t>::max();
@@ -307,7 +225,6 @@ void SingleThreadProxy::Stop() {
BlockingTaskRunner::CapturePostTasks blocked;
layer_tree_host_->DeleteContentsTexturesOnImplThread(
layer_tree_host_impl_->resource_provider());
- scheduler_on_impl_thread_.reset();
layer_tree_host_impl_.reset();
}
layer_tree_host_ = NULL;
@@ -318,19 +235,15 @@ void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) {
"cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
DCHECK(Proxy::IsImplThread());
UpdateBackgroundAnimateTicking();
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->SetCanDraw(can_draw);
}
void SingleThreadProxy::NotifyReadyToActivate() {
- // Impl-side painting only.
+ // Thread-only feature.
NOTREACHED();
}
void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
client_->ScheduleComposite();
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->SetNeedsRedraw();
}
void SingleThreadProxy::SetNeedsAnimateOnImplThread() {
@@ -338,14 +251,17 @@ void SingleThreadProxy::SetNeedsAnimateOnImplThread() {
}
void SingleThreadProxy::SetNeedsManageTilesOnImplThread() {
- // Impl-side painting only.
+ // Thread-only/Impl-side-painting-only feature.
NOTREACHED();
}
void SingleThreadProxy::SetNeedsRedrawRectOnImplThread(
const gfx::Rect& damage_rect) {
+ // TODO(brianderson): Once we move render_widget scheduling into this class,
+ // we can treat redraw requests more efficiently than CommitAndRedraw
+ // requests.
layer_tree_host_impl_->SetViewportDamage(damage_rect);
- SetNeedsRedrawOnImplThread();
+ SetNeedsCommit();
}
void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() {
@@ -355,8 +271,6 @@ void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() {
void SingleThreadProxy::SetNeedsCommitOnImplThread() {
client_->ScheduleComposite();
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->SetNeedsCommit();
}
void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
@@ -393,53 +307,66 @@ void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() {
layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities();
}
-void SingleThreadProxy::DidManageTiles() {
- // Impl-side painting only.
- NOTREACHED();
-}
-
void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() {
TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread");
- {
- DebugScopedSetMainThread main(this);
- // This must happen before we notify the scheduler as it may try to recreate
- // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE.
- layer_tree_host_->DidLoseOutputSurface();
- }
+ // Cause a commit so we can notice the lost context.
+ SetNeedsCommitOnImplThread();
client_->DidAbortSwapBuffers();
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->DidLoseOutputSurface();
}
void SingleThreadProxy::DidSwapBuffersOnImplThread() {
- TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersOnImplThread");
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->DidSwapBuffers();
client_->DidPostSwapBuffers();
}
void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() {
TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread");
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->DidSwapBuffersComplete();
- layer_tree_host_->DidCompleteSwapBuffers();
-}
-
-void SingleThreadProxy::BeginFrame(const BeginFrameArgs& args) {
- TRACE_EVENT0("cc", "SingleThreadProxy::BeginFrame");
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->BeginImplFrame(args);
+ client_->DidCompleteSwapBuffers();
}
+// Called by the legacy scheduling path (e.g. where render_widget does the
+// scheduling)
void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately");
DCHECK(Proxy::IsMainThread());
DCHECK(!layer_tree_host_->output_surface_lost());
- DoCommit(frame_begin_time);
+ layer_tree_host_->AnimateLayers(frame_begin_time);
+
+ if (PrioritizedResourceManager* contents_texture_manager =
+ layer_tree_host_->contents_texture_manager()) {
+ contents_texture_manager->UnlinkAndClearEvictedBackings();
+ contents_texture_manager->SetMaxMemoryLimitBytes(
+ layer_tree_host_impl_->memory_allocation_limit_bytes());
+ contents_texture_manager->SetExternalPriorityCutoff(
+ layer_tree_host_impl_->memory_allocation_priority_cutoff());
+ }
+
+ scoped_ptr<ResourceUpdateQueue> queue =
+ make_scoped_ptr(new ResourceUpdateQueue);
+ layer_tree_host_->UpdateLayers(queue.get());
+ layer_tree_host_->WillCommit();
+ DoCommit(queue.Pass());
+ layer_tree_host_->DidBeginMainFrame();
LayerTreeHostImpl::FrameData frame;
- DoComposite(frame_begin_time, &frame);
+ if (DoComposite(frame_begin_time, &frame)) {
+ {
+ DebugScopedSetMainThreadBlocked main_thread_blocked(this);
+ DebugScopedSetImplThread impl(this);
+
+ // This CapturePostTasks should be destroyed before
+ // DidCommitAndDrawFrame() is called since that goes out to the embedder,
+ // and we want the embedder to receive its callbacks before that.
+ // NOTE: This maintains consistent ordering with the ThreadProxy since
+ // the DidCommitAndDrawFrame() must be post-tasked from the impl thread
+ // there as the main thread is not blocked, so any posted tasks inside
+ // the swap buffers will execute first.
+ BlockingTaskRunner::CapturePostTasks blocked;
+
+ layer_tree_host_impl_->SwapBuffers(frame);
+ }
+ DidSwapFrame();
+ }
}
void SingleThreadProxy::AsValueInto(base::debug::TracedValue* state) const {
@@ -479,11 +406,13 @@ void SingleThreadProxy::UpdateBackgroundAnimateTicking() {
!ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer());
}
-DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time,
- LayerTreeHostImpl::FrameData* frame) {
+bool SingleThreadProxy::DoComposite(
+ base::TimeTicks frame_begin_time,
+ LayerTreeHostImpl::FrameData* frame) {
TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite");
DCHECK(!layer_tree_host_->output_surface_lost());
+ bool lost_output_surface = false;
{
DebugScopedSetImplThread impl(this);
base::AutoReset<bool> mark_inside(&inside_draw_, true);
@@ -494,11 +423,9 @@ DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time,
// CanDraw() as well.
if (!ShouldComposite()) {
UpdateBackgroundAnimateTicking();
- return DRAW_ABORTED_CANT_DRAW;
+ return false;
}
- timing_history_.DidStartDrawing();
-
layer_tree_host_impl_->Animate(
layer_tree_host_impl_->CurrentFrameTimeTicks());
UpdateBackgroundAnimateTicking();
@@ -508,43 +435,24 @@ DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time,
layer_tree_host_impl_->DrawLayers(frame, frame_begin_time);
layer_tree_host_impl_->DidDrawAllLayers(*frame);
}
+ lost_output_surface = layer_tree_host_impl_->IsContextLost();
bool start_ready_animations = true;
layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
-
- timing_history_.DidFinishDrawing();
}
- {
- DebugScopedSetImplThread impl(this);
-
- if (layer_tree_host_impl_->IsContextLost()) {
- DidLoseOutputSurfaceOnImplThread();
- } else {
- // This CapturePostTasks should be destroyed before
- // DidCommitAndDrawFrame() is called since that goes out to the
- // embedder,
- // and we want the embedder to receive its callbacks before that.
- // NOTE: This maintains consistent ordering with the ThreadProxy since
- // the DidCommitAndDrawFrame() must be post-tasked from the impl thread
- // there as the main thread is not blocked, so any posted tasks inside
- // the swap buffers will execute first.
- DebugScopedSetMainThreadBlocked main_thread_blocked(this);
-
- BlockingTaskRunner::CapturePostTasks blocked;
- layer_tree_host_impl_->SwapBuffers(*frame);
- }
+ if (lost_output_surface) {
+ layer_tree_host_->DidLoseOutputSurface();
+ return false;
}
- DidCommitAndDrawFrame();
- return DRAW_SUCCESS;
+ return true;
}
-void SingleThreadProxy::DidCommitAndDrawFrame() {
+void SingleThreadProxy::DidSwapFrame() {
if (next_frame_is_newly_committed_frame_) {
- DebugScopedSetMainThread main(this);
next_frame_is_newly_committed_frame_ = false;
layer_tree_host_->DidCommitAndDrawFrame();
}
@@ -552,117 +460,4 @@ void SingleThreadProxy::DidCommitAndDrawFrame() {
bool SingleThreadProxy::CommitPendingForTesting() { return false; }
-void SingleThreadProxy::SetNeedsBeginFrame(bool enable) {
- layer_tree_host_impl_->SetNeedsBeginFrame(enable);
-}
-
-void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
- layer_tree_host_impl_->WillBeginImplFrame(args);
-}
-
-void SingleThreadProxy::ScheduledActionSendBeginMainFrame() {
- TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame");
- // Although this proxy is single-threaded, it's problematic to synchronously
- // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This
- // could cause a commit to occur in between a series of SetNeedsCommit calls
- // (i.e. property modifications) causing some to fall on one frame and some to
- // fall on the next. Doing it asynchronously instead matches the semantics of
- // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a
- // synchronous commit.
- MainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&SingleThreadProxy::BeginMainFrame,
- weak_factory_.GetWeakPtr()));
-}
-
-void SingleThreadProxy::BeginMainFrame() {
- if (defer_commits_) {
- DCHECK(!commit_was_deferred_);
- commit_was_deferred_ = true;
- layer_tree_host_->DidDeferCommit();
- return;
- }
- timing_history_.DidBeginMainFrame();
-
- DCHECK(scheduler_on_impl_thread_);
- scheduler_on_impl_thread_->NotifyBeginMainFrameStarted();
- scheduler_on_impl_thread_->NotifyReadyToCommit();
-}
-
-DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() {
- DebugScopedSetImplThread impl(this);
- if (layer_tree_host_impl_->IsContextLost()) {
- DidCommitAndDrawFrame();
- return DRAW_SUCCESS;
- }
-
- LayerTreeHostImpl::FrameData frame;
- return DoComposite(layer_tree_host_impl_->CurrentFrameTimeTicks(), &frame);
-}
-
-DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() {
- NOTREACHED();
- return INVALID_RESULT;
-}
-
-void SingleThreadProxy::ScheduledActionCommit() {
- DebugScopedSetMainThread main(this);
- DoCommit(layer_tree_host_impl_->CurrentFrameTimeTicks());
-}
-
-void SingleThreadProxy::ScheduledActionAnimate() {
- TRACE_EVENT0("cc", "ScheduledActionAnimate");
- layer_tree_host_impl_->Animate(
- layer_tree_host_impl_->CurrentFrameTimeTicks());
-}
-
-void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() {
- // Impl-side painting only.
- NOTREACHED();
-}
-
-void SingleThreadProxy::ScheduledActionActivateSyncTree() {
-}
-
-void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() {
- DebugScopedSetMainThread main(this);
- DCHECK(scheduler_on_impl_thread_);
- // If possible, create the output surface in a post task. Synchronously
- // creating the output surface makes tests more awkward since this differs
- // from the ThreadProxy behavior. However, sometimes there is no
- // task runner.
- if (Proxy::MainThreadTaskRunner()) {
- MainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface,
- weak_factory_.GetWeakPtr()));
- } else {
- CreateAndInitializeOutputSurface();
- }
-}
-
-void SingleThreadProxy::ScheduledActionManageTiles() {
- // Impl-side painting only.
- NOTREACHED();
-}
-
-void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
-}
-
-base::TimeDelta SingleThreadProxy::DrawDurationEstimate() {
- return timing_history_.DrawDurationEstimate();
-}
-
-base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() {
- return timing_history_.BeginMainFrameToCommitDurationEstimate();
-}
-
-base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
- return timing_history_.CommitToActivateDurationEstimate();
-}
-
-void SingleThreadProxy::DidBeginImplFrameDeadline() {
- layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
-}
-
} // namespace cc
diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h
index 2444650..2b70d70 100644
--- a/cc/trees/single_thread_proxy.h
+++ b/cc/trees/single_thread_proxy.h
@@ -10,10 +10,8 @@
#include "base/time/time.h"
#include "cc/animation/animation_events.h"
#include "cc/output/begin_frame_args.h"
-#include "cc/scheduler/scheduler.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/proxy.h"
-#include "cc/trees/proxy_timing_history.h"
namespace cc {
@@ -22,8 +20,7 @@ class LayerTreeHost;
class LayerTreeHostSingleThreadClient;
class CC_EXPORT SingleThreadProxy : public Proxy,
- NON_EXPORTED_BASE(LayerTreeHostImplClient),
- SchedulerClient {
+ NON_EXPORTED_BASE(LayerTreeHostImplClient) {
public:
static scoped_ptr<Proxy> Create(
LayerTreeHost* layer_tree_host,
@@ -55,24 +52,6 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
virtual void AsValueInto(base::debug::TracedValue* state) const OVERRIDE;
virtual bool CommitPendingForTesting() OVERRIDE;
- // SchedulerClient implementation
- virtual void SetNeedsBeginFrame(bool enable) OVERRIDE;
- virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE;
- virtual void ScheduledActionSendBeginMainFrame() OVERRIDE;
- virtual DrawResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE;
- virtual DrawResult ScheduledActionDrawAndSwapForced() OVERRIDE;
- virtual void ScheduledActionCommit() OVERRIDE;
- virtual void ScheduledActionAnimate() OVERRIDE;
- virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE;
- virtual void ScheduledActionActivateSyncTree() OVERRIDE;
- virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE;
- virtual void ScheduledActionManageTiles() OVERRIDE;
- virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE;
- virtual base::TimeDelta DrawDurationEstimate() OVERRIDE;
- virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE;
- virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE;
- virtual void DidBeginImplFrameDeadline() OVERRIDE;
-
// LayerTreeHostImplClient implementation
virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE;
virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE;
@@ -82,7 +61,7 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {}
virtual void DidSwapBuffersOnImplThread() OVERRIDE;
virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE;
- virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE;
+ virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {}
virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE;
virtual void NotifyReadyToActivate() OVERRIDE;
virtual void SetNeedsRedrawOnImplThread() OVERRIDE;
@@ -103,7 +82,7 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
const base::Closure& start_fade,
base::TimeDelta delay) OVERRIDE {}
virtual void DidActivateSyncTree() OVERRIDE {}
- virtual void DidManageTiles() OVERRIDE;
+ virtual void DidManageTiles() OVERRIDE {}
virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {}
// Attempts to create the context and renderer synchronously. Calls
@@ -119,12 +98,10 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
LayerTreeHostSingleThreadClient* client,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
- void BeginMainFrame();
- void DoCommit(base::TimeTicks frame_begin_time);
- DrawResult DoComposite(base::TimeTicks frame_begin_time,
- LayerTreeHostImpl::FrameData* frame);
- void DoSwap();
- void DidCommitAndDrawFrame();
+ void DoCommit(scoped_ptr<ResourceUpdateQueue> queue);
+ bool DoComposite(base::TimeTicks frame_begin_time,
+ LayerTreeHostImpl::FrameData* frame);
+ void DidSwapFrame();
bool ShouldComposite() const;
void UpdateBackgroundAnimateTicking();
@@ -138,18 +115,9 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_;
RendererCapabilities renderer_capabilities_for_main_thread_;
- // Accessed from both threads.
- scoped_ptr<Scheduler> scheduler_on_impl_thread_;
- ProxyTimingHistory timing_history_;
-
bool next_frame_is_newly_committed_frame_;
bool inside_draw_;
- bool defer_commits_;
- bool commit_was_deferred_;
- bool commit_requested_;
-
- base::WeakPtrFactory<SingleThreadProxy> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy);
};
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index 1145ad4..b18b93a 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -466,10 +466,9 @@ void ThreadProxy::SetNextCommitWaitsForActivation() {
void ThreadProxy::SetDeferCommits(bool defer_commits) {
DCHECK(IsMainThread());
- if (main().defer_commits == defer_commits)
- return;
-
+ DCHECK_NE(main().defer_commits, defer_commits);
main().defer_commits = defer_commits;
+
if (main().defer_commits)
TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
else
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index d01e6bf..70ebbfe 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -314,6 +314,7 @@ void CompositorImpl::Composite(CompositingTrigger trigger) {
// animation updates that will already be reflected in the current frame
// we are about to draw.
ignore_schedule_composite_ = true;
+ client_->Layout();
const base::TimeTicks frame_time = gfx::FrameTime::Now();
if (needs_animate_) {
@@ -421,6 +422,7 @@ void CompositorImpl::SetVisible(bool visible) {
} else if (!host_) {
DCHECK(!WillComposite());
needs_composite_ = false;
+ needs_animate_ = false;
pending_swapbuffers_ = 0;
cc::LayerTreeSettings settings;
settings.refresh_rate = 60.0;
@@ -435,8 +437,6 @@ void CompositorImpl::SetVisible(bool visible) {
command_line->HasSwitch(cc::switches::kEnableGpuBenchmarking));
settings.initial_debug_state.show_fps_counter =
command_line->HasSwitch(cc::switches::kUIShowFPSCounter);
- // TODO(enne): Update this this compositor to use the scheduler.
- settings.single_thread_proxy_scheduler = false;
host_ = cc::LayerTreeHost::CreateSingleThreaded(
this,
@@ -519,9 +519,10 @@ CreateGpuProcessViewContext(
}
void CompositorImpl::Layout() {
- ignore_schedule_composite_ = true;
+ // TODO: If we get this callback from the SingleThreadProxy, we need
+ // to stop calling it ourselves in CompositorImpl::Composite().
+ NOTREACHED();
client_->Layout();
- ignore_schedule_composite_ = false;
}
scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface(
@@ -570,6 +571,7 @@ void CompositorImpl::ScheduleComposite() {
}
void CompositorImpl::ScheduleAnimation() {
+ DCHECK(!needs_animate_ || needs_composite_);
DCHECK(!needs_composite_ || WillComposite());
needs_animate_ = true;
@@ -599,7 +601,6 @@ void CompositorImpl::DidAbortSwapBuffers() {
// This really gets called only once from
// SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() when the
// context was lost.
- ScheduleComposite();
client_->OnSwapBuffersCompleted(0);
}
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 23598b7..1bc2a24 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -246,10 +246,6 @@ const char kDisableSetuidSandbox[] = "disable-setuid-sandbox";
// Disable shared workers.
const char kDisableSharedWorkers[] = "disable-shared-workers";
-// For tests, disable single thread scheduler and only manually composite.
-const char kDisableSingleThreadProxyScheduler[] =
- "disable-single-thread-proxy-scheduler";
-
// Disables site-specific tailoring to compatibility issues in WebKit.
const char kDisableSiteSpecificQuirks[] = "disable-site-specific-quirks";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index c2d6855..47b5fdc 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -79,7 +79,6 @@ CONTENT_EXPORT extern const char kDisableSeccompFilterSandbox[];
extern const char kDisableSessionStorage[];
CONTENT_EXPORT extern const char kDisableSetuidSandbox[];
CONTENT_EXPORT extern const char kDisableSharedWorkers[];
-CONTENT_EXPORT extern const char kDisableSingleThreadProxyScheduler[];
extern const char kDisableSiteSpecificQuirks[];
CONTENT_EXPORT extern const char kDisableSmoothScrolling[];
CONTENT_EXPORT extern const char kDisableSoftwareRasterizer[];
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc
index baf1ac1..64e0982 100644
--- a/content/renderer/gpu/render_widget_compositor.cc
+++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -277,8 +277,6 @@ scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create(
cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport);
settings.allow_antialiasing &=
!cmd->HasSwitch(cc::switches::kDisableCompositedAntialiasing);
- settings.single_thread_proxy_scheduler =
- !cmd->HasSwitch(switches::kDisableSingleThreadProxyScheduler);
// These flags should be mirrored by UI versions in ui/compositor/.
settings.initial_debug_state.show_debug_borders =
@@ -411,6 +409,7 @@ scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create(
RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget,
bool threaded)
: threaded_(threaded),
+ suppress_schedule_composite_(false),
widget_(widget) {
}
@@ -421,10 +420,27 @@ RenderWidgetCompositor::GetInputHandler() {
return layer_tree_host_->GetInputHandler();
}
+void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) {
+ if (suppress_schedule_composite_ == suppress)
+ return;
+
+ if (suppress)
+ TRACE_EVENT_ASYNC_BEGIN0("gpu",
+ "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
+ else
+ TRACE_EVENT_ASYNC_END0("gpu",
+ "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
+ suppress_schedule_composite_ = suppress;
+}
+
bool RenderWidgetCompositor::BeginMainFrameRequested() const {
return layer_tree_host_->BeginMainFrameRequested();
}
+void RenderWidgetCompositor::UpdateAnimations(base::TimeTicks time) {
+ layer_tree_host_->UpdateClientAnimations(time);
+}
+
void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() {
layer_tree_host_->SetNeedsDisplayOnAllLayers();
}
@@ -533,10 +549,7 @@ void RenderWidgetCompositor::Initialize(cc::LayerTreeSettings settings) {
}
void RenderWidgetCompositor::setSurfaceReady() {
- // In tests without a RenderThreadImpl, don't set ready as this kicks
- // off creating output surfaces that the test can't create.
- if (RenderThreadImpl::current())
- layer_tree_host_->SetLayerTreeHostClientReady();
+ layer_tree_host_->SetLayerTreeHostClientReady();
}
void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) {
@@ -689,9 +702,9 @@ void RenderWidgetCompositor::compositeAndReadbackAsync(
cc::CopyOutputRequest::CreateBitmapRequest(
base::Bind(&CompositeAndReadbackAsyncCallback, callback));
layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass());
-
- if (!threaded_ &&
- !layer_tree_host_->settings().single_thread_proxy_scheduler) {
+ if (!threaded_) {
+ widget_->webwidget()->animate(0.0);
+ widget_->webwidget()->layout();
layer_tree_host_->Composite(gfx::FrameTime::Now());
}
}
@@ -787,6 +800,11 @@ void RenderWidgetCompositor::DidCompleteSwapBuffers() {
widget_->OnSwapBuffersComplete();
}
+void RenderWidgetCompositor::ScheduleComposite() {
+ if (!suppress_schedule_composite_)
+ widget_->scheduleComposite();
+}
+
void RenderWidgetCompositor::ScheduleAnimation() {
widget_->scheduleAnimation();
}
diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h
index 79a03b4..e0541ec 100644
--- a/content/renderer/gpu/render_widget_compositor.h
+++ b/content/renderer/gpu/render_widget_compositor.h
@@ -44,7 +44,9 @@ class RenderWidgetCompositor : public blink::WebLayerTreeView,
virtual ~RenderWidgetCompositor();
const base::WeakPtr<cc::InputHandler>& GetInputHandler();
+ void SetSuppressScheduleComposite(bool suppress);
bool BeginMainFrameRequested() const;
+ void UpdateAnimations(base::TimeTicks time);
void SetNeedsDisplayOnAllLayers();
void SetRasterizeOnlyVisibleContent();
void UpdateTopControlsState(cc::TopControlsState constraints,
@@ -141,6 +143,7 @@ class RenderWidgetCompositor : public blink::WebLayerTreeView,
virtual void RateLimitSharedMainThreadContext() OVERRIDE;
// cc::LayerTreeHostSingleThreadClient implementation.
+ virtual void ScheduleComposite() OVERRIDE;
virtual void ScheduleAnimation() OVERRIDE;
virtual void DidPostSwapBuffers() OVERRIDE;
virtual void DidAbortSwapBuffers() OVERRIDE;
@@ -151,6 +154,7 @@ class RenderWidgetCompositor : public blink::WebLayerTreeView,
void Initialize(cc::LayerTreeSettings settings);
bool threaded_;
+ bool suppress_schedule_composite_;
RenderWidget* widget_;
scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
};
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 4f379cf..226512f 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -393,7 +393,6 @@ RenderWidget::RenderWidget(blink::WebPopupType popup_type,
handling_event_type_(WebInputEvent::Undefined),
ignore_ack_for_mouse_move_from_debugger_(false),
closing_(false),
- host_closing_(false),
is_swapped_out_(swapped_out),
input_method_is_active_(false),
text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
@@ -1197,8 +1196,6 @@ void RenderWidget::AutoResizeCompositor() {
}
void RenderWidget::initializeLayerTreeView() {
- DCHECK(!host_closing_);
-
compositor_ =
RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled());
compositor_->setViewportSize(size_, physical_backing_size_);
@@ -1206,20 +1203,20 @@ void RenderWidget::initializeLayerTreeView() {
StartCompositor();
}
-void RenderWidget::DestroyLayerTreeView() {
- // Always send this notification to prevent new layer tree views from
- // being created, even if one hasn't been created yet.
- webwidget_->willCloseLayerTreeView();
- compositor_.reset();
-}
-
blink::WebLayerTreeView* RenderWidget::layerTreeView() {
return compositor_.get();
}
+void RenderWidget::suppressCompositorScheduling(bool enable) {
+ if (compositor_)
+ compositor_->SetSuppressScheduleComposite(enable);
+}
+
void RenderWidget::willBeginCompositorFrame() {
TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
+ DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get());
+
// The following two can result in further layout and possibly
// enable GPU acceleration so they need to be called before any painting
// is done.
@@ -1376,12 +1373,6 @@ void RenderWidget::didBlur() {
}
void RenderWidget::DoDeferredClose() {
- // No more compositing is possible. This prevents shutdown races between
- // previously posted CreateOutputSurface tasks and the host being unable to
- // create them because the close message was handled.
- DestroyLayerTreeView();
- // Also prevent new compositors from being created.
- host_closing_ = true;
Send(new ViewHostMsg_Close(routing_id_));
}
@@ -1422,7 +1413,8 @@ void RenderWidget::QueueSyntheticGesture(
void RenderWidget::Close() {
screen_metrics_emulator_.reset();
if (webwidget_) {
- DestroyLayerTreeView();
+ webwidget_->willCloseLayerTreeView();
+ compositor_.reset();
webwidget_->close();
webwidget_ = NULL;
}
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index 3d9f382..e8b4489 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -142,6 +142,7 @@ class CONTENT_EXPORT RenderWidget
virtual bool Send(IPC::Message* msg) OVERRIDE;
// blink::WebWidgetClient
+ virtual void suppressCompositorScheduling(bool enable);
virtual void willBeginCompositorFrame();
virtual void didAutoResize(const blink::WebSize& new_size);
virtual void initializeLayerTreeView();
@@ -172,9 +173,6 @@ class CONTENT_EXPORT RenderWidget
// Begins the compositor's scheduler to start producing frames.
void StartCompositor();
- // Stop compositing.
- void DestroyLayerTreeView();
-
// Called when a plugin is moved. These events are queued up and sent with
// the next paint or scroll message to the host.
void SchedulePluginMove(const WebPluginGeometry& move);
@@ -625,9 +623,6 @@ class CONTENT_EXPORT RenderWidget
// be sent, except for a Close.
bool closing_;
- // True if it is known that the host is in the process of being shut down.
- bool host_closing_;
-
// Whether this RenderWidget is currently swapped out, such that the view is
// being rendered by another process. If all RenderWidgets in a process are
// swapped out, the process can exit.
diff --git a/content/shell/renderer/test_runner/web_test_proxy.cc b/content/shell/renderer/test_runner/web_test_proxy.cc
index 4177b25..d4524ee 100644
--- a/content/shell/renderer/test_runner/web_test_proxy.cc
+++ b/content/shell/renderer/test_runner/web_test_proxy.cc
@@ -7,11 +7,9 @@
#include <cctype>
#include "base/callback_helpers.h"
-#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
-#include "content/public/common/content_switches.h"
#include "content/shell/renderer/test_runner/TestInterfaces.h"
#include "content/shell/renderer/test_runner/TestPlugin.h"
#include "content/shell/renderer/test_runner/WebTestDelegate.h"
@@ -314,10 +312,6 @@ WebTestProxyBase::WebTestProxyBase()
web_widget_(NULL),
spellcheck_(new SpellCheckClient(this)),
chooser_count_(0) {
- // TODO(enne): using the scheduler introduces additional composite steps
- // that create flakiness. This should go away eventually.
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kDisableSingleThreadProxyScheduler);
Reset();
}
diff --git a/content/test/web_layer_tree_view_impl_for_testing.h b/content/test/web_layer_tree_view_impl_for_testing.h
index 730c210..13d6ee4 100644
--- a/content/test/web_layer_tree_view_impl_for_testing.h
+++ b/content/test/web_layer_tree_view_impl_for_testing.h
@@ -80,6 +80,8 @@ class WebLayerTreeViewImplForTesting
virtual void DidCompleteSwapBuffers() OVERRIDE {}
// cc::LayerTreeHostSingleThreadClient implementation.
+ virtual void ScheduleComposite() OVERRIDE {}
+ virtual void ScheduleAnimation() OVERRIDE {}
virtual void DidPostSwapBuffers() OVERRIDE {}
virtual void DidAbortSwapBuffers() OVERRIDE {}
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 9c0a5134..43a88a6 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -61,6 +61,14 @@ void CompositorLock::CancelLock() {
compositor_ = NULL;
}
+} // namespace ui
+
+namespace {
+
+} // namespace
+
+namespace ui {
+
Compositor::Compositor(gfx::AcceleratedWidget widget,
ui::ContextFactory* context_factory,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
@@ -71,9 +79,16 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
task_runner_(task_runner),
vsync_manager_(new CompositorVSyncManager()),
device_scale_factor_(0.0f),
+ last_started_frame_(0),
+ last_ended_frame_(0),
disable_schedule_composite_(false),
compositor_lock_(NULL),
- layer_animator_collection_(this) {
+ defer_draw_scheduling_(false),
+ waiting_on_compositing_end_(false),
+ draw_on_compositing_end_(false),
+ swap_state_(SWAP_NONE),
+ layer_animator_collection_(this),
+ schedule_draw_factory_(this) {
root_web_layer_ = cc::Layer::Create();
CommandLine* command_line = CommandLine::ForCurrentProcess();
@@ -162,7 +177,14 @@ Compositor::~Compositor() {
}
void Compositor::ScheduleDraw() {
- host_->SetNeedsCommit();
+ if (compositor_thread_loop_) {
+ host_->SetNeedsCommit();
+ } else if (!defer_draw_scheduling_) {
+ defer_draw_scheduling_ = true;
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr()));
+ }
}
void Compositor::SetRootLayer(Layer* root_layer) {
@@ -183,19 +205,42 @@ void Compositor::SetHostHasTransparentBackground(
host_->set_has_transparent_background(host_has_transparent_background);
}
+void Compositor::Draw() {
+ DCHECK(!compositor_thread_loop_);
+
+ defer_draw_scheduling_ = false;
+ if (waiting_on_compositing_end_) {
+ draw_on_compositing_end_ = true;
+ return;
+ }
+ if (!root_layer_)
+ return;
+
+ TRACE_EVENT_ASYNC_BEGIN0("ui", "Compositor::Draw", last_started_frame_ + 1);
+
+ DCHECK_NE(swap_state_, SWAP_POSTED);
+ swap_state_ = SWAP_NONE;
+
+ waiting_on_compositing_end_ = true;
+ last_started_frame_++;
+ if (!IsLocked()) {
+ // TODO(nduca): Temporary while compositor calls
+ // compositeImmediately() directly.
+ base::TimeTicks now = gfx::FrameTime::Now();
+ Animate(now);
+ Layout();
+ host_->Composite(now);
+ }
+ if (swap_state_ == SWAP_NONE)
+ NotifyEnd();
+}
+
void Compositor::ScheduleFullRedraw() {
- // TODO(enne): Some callers (mac) call this function expecting that it
- // will also commit. This should probably just redraw the screen
- // from damage and not commit. ScheduleDraw/ScheduleRedraw need
- // better names.
host_->SetNeedsRedraw();
- host_->SetNeedsCommit();
}
void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) {
- // TODO(enne): Make this not commit. See ScheduleFullRedraw.
host_->SetNeedsRedrawRect(damage_rect);
- host_->SetNeedsCommit();
}
void Compositor::FinishAllRendering() {
@@ -287,30 +332,45 @@ void Compositor::DidCommit() {
}
void Compositor::DidCommitAndDrawFrame() {
+ base::TimeTicks start_time = gfx::FrameTime::Now();
+ FOR_EACH_OBSERVER(CompositorObserver,
+ observer_list_,
+ OnCompositingStarted(this, start_time));
}
void Compositor::DidCompleteSwapBuffers() {
- // DidPostSwapBuffers is a SingleThreadProxy-only feature. Synthetically
- // generate OnCompositingStarted messages for the threaded case so that
- // OnCompositingStarted/OnCompositingEnded messages match.
if (compositor_thread_loop_) {
- base::TimeTicks start_time = gfx::FrameTime::Now();
- FOR_EACH_OBSERVER(CompositorObserver,
- observer_list_,
- OnCompositingStarted(this, start_time));
+ NotifyEnd();
+ } else {
+ DCHECK_EQ(swap_state_, SWAP_POSTED);
+ NotifyEnd();
+ swap_state_ = SWAP_COMPLETED;
}
- FOR_EACH_OBSERVER(
- CompositorObserver, observer_list_, OnCompositingEnded(this));
+}
+
+void Compositor::ScheduleComposite() {
+ if (!disable_schedule_composite_)
+ ScheduleDraw();
+}
+
+void Compositor::ScheduleAnimation() {
+ ScheduleComposite();
}
void Compositor::DidPostSwapBuffers() {
- base::TimeTicks start_time = gfx::FrameTime::Now();
- FOR_EACH_OBSERVER(CompositorObserver,
- observer_list_,
- OnCompositingStarted(this, start_time));
+ DCHECK(!compositor_thread_loop_);
+ DCHECK_EQ(swap_state_, SWAP_NONE);
+ swap_state_ = SWAP_POSTED;
}
void Compositor::DidAbortSwapBuffers() {
+ if (!compositor_thread_loop_) {
+ if (swap_state_ == SWAP_POSTED) {
+ NotifyEnd();
+ swap_state_ = SWAP_COMPLETED;
+ }
+ }
+
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingAborted(this));
@@ -328,7 +388,8 @@ void Compositor::SetLayerTreeDebugState(
scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
if (!compositor_lock_) {
compositor_lock_ = new CompositorLock(this);
- host_->SetDeferCommits(true);
+ if (compositor_thread_loop_)
+ host_->SetDeferCommits(true);
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingLockStateChanged(this));
@@ -339,7 +400,8 @@ scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
void Compositor::UnlockCompositor() {
DCHECK(compositor_lock_);
compositor_lock_ = NULL;
- host_->SetDeferCommits(false);
+ if (compositor_thread_loop_)
+ host_->SetDeferCommits(false);
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingLockStateChanged(this));
@@ -350,4 +412,21 @@ void Compositor::CancelCompositorLock() {
compositor_lock_->CancelLock();
}
+void Compositor::NotifyEnd() {
+ last_ended_frame_++;
+ TRACE_EVENT_ASYNC_END0("ui", "Compositor::Draw", last_ended_frame_);
+ waiting_on_compositing_end_ = false;
+ if (draw_on_compositing_end_) {
+ draw_on_compositing_end_ = false;
+
+ // Call ScheduleDraw() instead of Draw() in order to allow other
+ // CompositorObservers to be notified before starting another
+ // draw cycle.
+ ScheduleDraw();
+ }
+ FOR_EACH_OBSERVER(CompositorObserver,
+ observer_list_,
+ OnCompositingEnded(this));
+}
+
} // namespace ui
diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h
index b2d2779..0e4ac8a 100644
--- a/ui/compositor/compositor.h
+++ b/ui/compositor/compositor.h
@@ -24,6 +24,8 @@
#include "ui/gfx/size.h"
#include "ui/gfx/vector2d.h"
+class SkBitmap;
+
namespace base {
class MessageLoopProxy;
class RunLoop;
@@ -157,6 +159,9 @@ class COMPOSITOR_EXPORT Compositor
// compositing layers on.
float device_scale_factor() const { return device_scale_factor_; }
+ // Draws the scene created by the layer tree and any visual effects.
+ void Draw();
+
// Where possible, draws are scissored to a damage region calculated from
// changes to layer properties. This bypasses that and indicates that
// the whole frame needs to be drawn.
@@ -229,9 +234,14 @@ class COMPOSITOR_EXPORT Compositor
virtual void DidCompleteSwapBuffers() OVERRIDE;
// cc::LayerTreeHostSingleThreadClient implementation.
+ virtual void ScheduleComposite() OVERRIDE;
+ virtual void ScheduleAnimation() OVERRIDE;
virtual void DidPostSwapBuffers() OVERRIDE;
virtual void DidAbortSwapBuffers() OVERRIDE;
+ int last_started_frame() { return last_started_frame_; }
+ int last_ended_frame() { return last_ended_frame_; }
+
bool IsLocked() { return compositor_lock_ != NULL; }
const cc::LayerTreeDebugState& GetLayerTreeDebugState() const;
@@ -251,6 +261,9 @@ class COMPOSITOR_EXPORT Compositor
// Called to release any pending CompositorLock
void CancelCompositorLock();
+ // Notifies the compositor that compositing is complete.
+ void NotifyEnd();
+
gfx::Size size_;
ui::ContextFactory* context_factory_;
@@ -281,8 +294,19 @@ class COMPOSITOR_EXPORT Compositor
CompositorLock* compositor_lock_;
+ // Prevent more than one draw from being scheduled.
+ bool defer_draw_scheduling_;
+
+ // Used to prevent Draw()s while a composite is in progress.
+ bool waiting_on_compositing_end_;
+ bool draw_on_compositing_end_;
+ enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED };
+ SwapState swap_state_;
+
LayerAnimatorCollection layer_animator_collection_;
+ base::WeakPtrFactory<Compositor> schedule_draw_factory_;
+
DISALLOW_COPY_AND_ASSIGN(Compositor);
};
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index b5c473c..ac1a47b 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -95,8 +95,8 @@ class LayerWithRealCompositorTest : public testing::Test {
InitializeContextFactoryForTests(enable_pixel_output);
const gfx::Rect host_bounds(10, 10, 500, 500);
- compositor_host_.reset(
- TestCompositorHost::Create(host_bounds, context_factory));
+ compositor_host_.reset(TestCompositorHost::Create(
+ host_bounds, context_factory));
compositor_host_->Show();
}
@@ -126,7 +126,7 @@ class LayerWithRealCompositorTest : public testing::Test {
void DrawTree(Layer* root) {
GetCompositor()->SetRootLayer(root);
GetCompositor()->ScheduleDraw();
- WaitForSwap();
+ WaitForDraw();
}
bool ReadPixels(SkBitmap* bitmap) {
@@ -142,13 +142,11 @@ class LayerWithRealCompositorTest : public testing::Test {
GetCompositor()->root_layer()->RequestCopyOfOutput(request.Pass());
- // Wait for copy response. The copy output request will get committed
- // before the first draw, but may not be part of the first draw's frame.
- // The second draw will perform the async copy request, post the callback.
- // The second loop finishes before the callback is run, so a third
- // loop is needed.
- for (int i = 0; i < 3; i++) {
- GetCompositor()->ScheduleFullRedraw();
+ // Wait for copy response. This needs to wait as the compositor could
+ // be in the middle of a draw right now, and the commit with the
+ // copy output request may not be done on the first draw.
+ for (int i = 0; i < 2; i++) {
+ GetCompositor()->ScheduleDraw();
WaitForDraw();
}
@@ -163,11 +161,7 @@ class LayerWithRealCompositorTest : public testing::Test {
}
void WaitForDraw() {
- ui::DrawWaiterForTest::WaitForCompositingStarted(GetCompositor());
- }
-
- void WaitForSwap() {
- DrawWaiterForTest::WaitForCompositingEnded(GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetCompositor());
}
void WaitForCommit() {
@@ -456,7 +450,7 @@ class LayerWithDelegateTest : public testing::Test {
}
void WaitForDraw() {
- DrawWaiterForTest::WaitForCompositingStarted(compositor());
+ DrawWaiterForTest::Wait(compositor());
}
void WaitForCommit() {
@@ -951,25 +945,25 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
// Moving, but not resizing, a layer should alert the observers.
observer.Reset();
l2->SetBounds(gfx::Rect(0, 0, 350, 350));
- WaitForSwap();
+ WaitForDraw();
EXPECT_TRUE(observer.notified());
// So should resizing a layer.
observer.Reset();
l2->SetBounds(gfx::Rect(0, 0, 400, 400));
- WaitForSwap();
+ WaitForDraw();
EXPECT_TRUE(observer.notified());
// Opacity changes should alert the observers.
observer.Reset();
l2->SetOpacity(0.5f);
- WaitForSwap();
+ WaitForDraw();
EXPECT_TRUE(observer.notified());
// So should setting the opacity back.
observer.Reset();
l2->SetOpacity(1.0f);
- WaitForSwap();
+ WaitForDraw();
EXPECT_TRUE(observer.notified());
// Setting the transform of a layer should alert the observers.
@@ -979,7 +973,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
transform.Rotate(90.0);
transform.Translate(-200.0, -200.0);
l2->SetTransform(transform);
- WaitForSwap();
+ WaitForDraw();
EXPECT_TRUE(observer.notified());
// A change resulting in an aborted swap buffer should alert the observer
@@ -987,7 +981,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
observer.Reset();
l2->SetOpacity(0.1f);
GetCompositor()->DidAbortSwapBuffers();
- WaitForSwap();
+ WaitForDraw();
EXPECT_TRUE(observer.notified());
EXPECT_TRUE(observer.aborted());
@@ -996,7 +990,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
// Opacity changes should no longer alert the removed observer.
observer.Reset();
l2->SetOpacity(0.5f);
- WaitForSwap();
+ WaitForDraw();
EXPECT_FALSE(observer.notified());
}
diff --git a/ui/compositor/test/draw_waiter_for_test.cc b/ui/compositor/test/draw_waiter_for_test.cc
index f256ecc..c471a6f 100644
--- a/ui/compositor/test/draw_waiter_for_test.cc
+++ b/ui/compositor/test/draw_waiter_for_test.cc
@@ -9,25 +9,20 @@
namespace ui {
// static
-void DrawWaiterForTest::WaitForCompositingStarted(Compositor* compositor) {
- DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_STARTED);
- waiter.WaitImpl(compositor);
-}
-
-void DrawWaiterForTest::WaitForCompositingEnded(Compositor* compositor) {
- DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_ENDED);
+void DrawWaiterForTest::Wait(Compositor* compositor) {
+ DrawWaiterForTest waiter;
+ waiter.wait_for_commit_ = false;
waiter.WaitImpl(compositor);
}
// static
void DrawWaiterForTest::WaitForCommit(Compositor* compositor) {
- DrawWaiterForTest waiter(WAIT_FOR_COMMIT);
+ DrawWaiterForTest waiter;
+ waiter.wait_for_commit_ = true;
waiter.WaitImpl(compositor);
}
-DrawWaiterForTest::DrawWaiterForTest(WaitEvent wait_event)
- : wait_event_(wait_event) {
-}
+DrawWaiterForTest::DrawWaiterForTest() {}
DrawWaiterForTest::~DrawWaiterForTest() {}
@@ -39,23 +34,19 @@ void DrawWaiterForTest::WaitImpl(Compositor* compositor) {
}
void DrawWaiterForTest::OnCompositingDidCommit(Compositor* compositor) {
- if (wait_event_ == WAIT_FOR_COMMIT)
+ if (wait_for_commit_)
wait_run_loop_->Quit();
}
void DrawWaiterForTest::OnCompositingStarted(Compositor* compositor,
- base::TimeTicks start_time) {
- if (wait_event_ == WAIT_FOR_COMPOSITING_STARTED)
- wait_run_loop_->Quit();
-}
+ base::TimeTicks start_time) {}
void DrawWaiterForTest::OnCompositingEnded(Compositor* compositor) {
- if (wait_event_ == WAIT_FOR_COMPOSITING_ENDED)
+ if (!wait_for_commit_)
wait_run_loop_->Quit();
}
-void DrawWaiterForTest::OnCompositingAborted(Compositor* compositor) {
-}
+void DrawWaiterForTest::OnCompositingAborted(Compositor* compositor) {}
void DrawWaiterForTest::OnCompositingLockStateChanged(Compositor* compositor) {}
diff --git a/ui/compositor/test/draw_waiter_for_test.h b/ui/compositor/test/draw_waiter_for_test.h
index e1d63ff..051c58f 100644
--- a/ui/compositor/test/draw_waiter_for_test.h
+++ b/ui/compositor/test/draw_waiter_for_test.h
@@ -20,22 +20,13 @@ class DrawWaiterForTest : public CompositorObserver {
// Waits for a draw to be issued by the compositor. If the test times out
// here, there may be a logic error in the compositor code causing it
// not to draw.
- static void WaitForCompositingStarted(Compositor* compositor);
-
- // Waits for a swap to be completed from the compositor.
- static void WaitForCompositingEnded(Compositor* compositor);
+ static void Wait(Compositor* compositor);
// Waits for a commit instead of a draw.
static void WaitForCommit(Compositor* compositor);
private:
- enum WaitEvent {
- WAIT_FOR_COMMIT,
- WAIT_FOR_COMPOSITING_STARTED,
- WAIT_FOR_COMPOSITING_ENDED,
- };
-
- DrawWaiterForTest(WaitEvent wait_event);
+ DrawWaiterForTest();
virtual ~DrawWaiterForTest();
void WaitImpl(Compositor* compositor);
@@ -50,7 +41,7 @@ class DrawWaiterForTest : public CompositorObserver {
scoped_ptr<base::RunLoop> wait_run_loop_;
- WaitEvent wait_event_;
+ bool wait_for_commit_;
DISALLOW_COPY_AND_ASSIGN(DrawWaiterForTest);
};
diff --git a/ui/compositor/test/test_compositor_host_mac.mm b/ui/compositor/test/test_compositor_host_mac.mm
index 7201fde..8d533d0 100644
--- a/ui/compositor/test/test_compositor_host_mac.mm
+++ b/ui/compositor/test/test_compositor_host_mac.mm
@@ -40,7 +40,7 @@
- (void)drawRect:(NSRect)rect {
DCHECK(compositor_) << "Drawing with no compositor set.";
- compositor_->ScheduleFullRedraw();
+ compositor_->Draw();
}
@end
diff --git a/ui/compositor/test/test_compositor_host_ozone.cc b/ui/compositor/test/test_compositor_host_ozone.cc
index 903c3b6..1c4b0cc 100644
--- a/ui/compositor/test/test_compositor_host_ozone.cc
+++ b/ui/compositor/test/test_compositor_host_ozone.cc
@@ -27,6 +27,8 @@ class TestCompositorHostOzone : public TestCompositorHost {
virtual void Show() OVERRIDE;
virtual ui::Compositor* GetCompositor() OVERRIDE;
+ void Draw();
+
gfx::Rect bounds_;
ui::ContextFactory* context_factory_;
@@ -62,6 +64,11 @@ ui::Compositor* TestCompositorHostOzone::GetCompositor() {
return compositor_.get();
}
+void TestCompositorHostOzone::Draw() {
+ if (compositor_.get())
+ compositor_->Draw();
+}
+
// static
TestCompositorHost* TestCompositorHost::Create(
const gfx::Rect& bounds,
diff --git a/ui/compositor/test/test_compositor_host_win.cc b/ui/compositor/test/test_compositor_host_win.cc
index 80db4ae..9c732f6 100644
--- a/ui/compositor/test/test_compositor_host_win.cc
+++ b/ui/compositor/test/test_compositor_host_win.cc
@@ -42,7 +42,7 @@ class TestCompositorHostWin : public TestCompositorHost,
CR_END_MSG_MAP()
void OnPaint(HDC dc) {
- compositor_->ScheduleFullRedraw();
+ compositor_->Draw();
ValidateRect(hwnd(), NULL);
}
diff --git a/ui/compositor/test/test_compositor_host_x11.cc b/ui/compositor/test/test_compositor_host_x11.cc
index 1c3f674..9b2d265 100644
--- a/ui/compositor/test/test_compositor_host_x11.cc
+++ b/ui/compositor/test/test_compositor_host_x11.cc
@@ -30,6 +30,8 @@ class TestCompositorHostX11 : public TestCompositorHost {
virtual void Show() OVERRIDE;
virtual ui::Compositor* GetCompositor() OVERRIDE;
+ void Draw();
+
gfx::Rect bounds_;
ui::ContextFactory* context_factory_;
@@ -83,6 +85,11 @@ ui::Compositor* TestCompositorHostX11::GetCompositor() {
return compositor_.get();
}
+void TestCompositorHostX11::Draw() {
+ if (compositor_.get())
+ compositor_->Draw();
+}
+
// static
TestCompositorHost* TestCompositorHost::Create(
const gfx::Rect& bounds,
diff --git a/ui/snapshot/snapshot_aura_unittest.cc b/ui/snapshot/snapshot_aura_unittest.cc
index 018394b..5fe05a8 100644
--- a/ui/snapshot/snapshot_aura_unittest.cc
+++ b/ui/snapshot/snapshot_aura_unittest.cc
@@ -115,8 +115,7 @@ class SnapshotAuraTest : public testing::Test {
void WaitForDraw() {
helper_->host()->compositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- helper_->host()->compositor());
+ ui::DrawWaiterForTest::Wait(helper_->host()->compositor());
}
void SetupTestWindow(const gfx::Rect& window_bounds) {
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index da2b349..544e999 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -3024,23 +3024,20 @@ TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) {
widget()->SetContentsView(content_view);
content_view->SetPaintToLayer(true);
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10));
content_view->set_painted(false);
// content_view no longer has a dirty rect. Paint from the root and make sure
// PaintTrackingView isn't painted.
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_FALSE(content_view->painted());
// Make content_view have a dirty rect, paint the layers and make sure
// PaintTrackingView is painted.
content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10));
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_TRUE(content_view->painted());
}
@@ -3280,15 +3277,13 @@ TEST_F(ViewLayerTest, BoundsTreePaintUpdatesCullSet) {
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Now we have test_view - v1 - v2. Damage to only test_view should only
// return root_view and test_view.
test_view->SchedulePaintInRect(gfx::Rect(0, 0, 1, 1));
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(2U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
@@ -3296,8 +3291,7 @@ TEST_F(ViewLayerTest, BoundsTreePaintUpdatesCullSet) {
// Damage to v1 only should only return root_view, test_view, and v1.
test_view->SchedulePaintInRect(gfx::Rect(11, 16, 1, 1));
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(3U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
@@ -3307,8 +3301,7 @@ TEST_F(ViewLayerTest, BoundsTreePaintUpdatesCullSet) {
// on call to TestView::Paint(), along with the widget root view.
test_view->SchedulePaintInRect(gfx::Rect(31, 49, 1, 1));
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(4U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
@@ -3335,15 +3328,13 @@ TEST_F(ViewLayerTest, BoundsTreeWithRTL) {
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Damage to the right side of the parent view should touch both child views.
gfx::Rect rtl_damage(test_view->bounds().width() - 16, 18, 1, 1);
test_view->SchedulePaintInRect(rtl_damage);
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(4U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
@@ -3355,8 +3346,7 @@ TEST_F(ViewLayerTest, BoundsTreeWithRTL) {
gfx::Rect ltr_damage(16, 18, 1, 1);
test_view->SchedulePaintInRect(ltr_damage);
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(2U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
@@ -3380,21 +3370,18 @@ TEST_F(ViewLayerTest, BoundsTreeSetBoundsChangesCullSet) {
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Move v1 to a new origin out of the way of our next query.
v1->SetBoundsRect(gfx::Rect(50, 60, 100, 101));
// The move will force a repaint.
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Schedule a paint with damage rect where v1 used to be.
test_view->SchedulePaintInRect(gfx::Rect(5, 6, 10, 11));
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Should only have picked up root_view and test_view.
EXPECT_EQ(2U, test_view->last_cull_set_.size());
@@ -3417,8 +3404,7 @@ TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) {
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Set v1 to paint to its own layer, it should remove itself from the
// test_view heiarchy and no longer intersect with damage rects in that cull
@@ -3428,8 +3414,7 @@ TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) {
// Schedule another full-view paint.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// v1 and v2 should no longer be present in the test_view cull_set.
EXPECT_EQ(2U, test_view->last_cull_set_.size());
EXPECT_EQ(0U, test_view->last_cull_set_.count(v1));
@@ -3440,8 +3425,7 @@ TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) {
// Schedule another full-view paint.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// We should be back to the full cull set including v1 and v2.
EXPECT_EQ(4U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
@@ -3465,8 +3449,7 @@ TEST_F(ViewLayerTest, BoundsTreeRemoveChildRemovesBounds) {
// Schedule a full-view paint to get everyone's rectangles updated.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Now remove v1 from the root view.
test_view->RemoveChildView(v1);
@@ -3474,8 +3457,7 @@ TEST_F(ViewLayerTest, BoundsTreeRemoveChildRemovesBounds) {
// Schedule another full-view paint.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// v1 and v2 should no longer be present in the test_view cull_set.
EXPECT_EQ(2U, test_view->last_cull_set_.size());
EXPECT_EQ(0U, test_view->last_cull_set_.count(v1));
@@ -3506,8 +3488,7 @@ TEST_F(ViewLayerTest, BoundsTreeMoveViewMovesBounds) {
// Schedule a full-view paint and ensure all views are present in the cull.
test_view->SchedulePaintInRect(test_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
EXPECT_EQ(5U, test_view->last_cull_set_.size());
EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
@@ -3530,8 +3511,7 @@ TEST_F(ViewLayerTest, BoundsTreeMoveViewMovesBounds) {
test_view->SchedulePaintInRect(test_view->bounds());
widget_view->SchedulePaintInRect(widget_view->bounds());
GetRootLayer()->GetCompositor()->ScheduleDraw();
- ui::DrawWaiterForTest::WaitForCompositingEnded(
- GetRootLayer()->GetCompositor());
+ ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor());
// Only v1 should be present in the first cull set.
EXPECT_EQ(3U, test_view->last_cull_set_.size());