diff options
author | weiliangc <weiliangc@chromium.org> | 2014-10-08 21:44:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-09 04:45:11 +0000 |
commit | 36b7fc7f8b05ea627873e58a162c1c26784e472d (patch) | |
tree | c8f7315374ec3fded78e1154a15f91a5ffeecb00 /ui | |
parent | 7fd01193848852fb76c3d8324e58dc4086e6b463 (diff) | |
download | chromium_src-36b7fc7f8b05ea627873e58a162c1c26784e472d.zip chromium_src-36b7fc7f8b05ea627873e58a162c1c26784e472d.tar.gz chromium_src-36b7fc7f8b05ea627873e58a162c1c26784e472d.tar.bz2 |
Make ui::Compositor use ui::Scheduler
Taken from enne's CL 535733002 and rebased. It has been taken out of CL 134623005.
BUG=329552
Review URL: https://codereview.chromium.org/638653003
Cr-Commit-Position: refs/heads/master@{#298779}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/compositor/compositor.cc | 127 | ||||
-rw-r--r-- | ui/compositor/compositor.h | 24 | ||||
-rw-r--r-- | ui/compositor/layer_unittest.cc | 30 | ||||
-rw-r--r-- | ui/compositor/test/draw_waiter_for_test.cc | 22 | ||||
-rw-r--r-- | ui/compositor/test/draw_waiter_for_test.h | 15 | ||||
-rw-r--r-- | ui/compositor/test/test_compositor_host_mac.mm | 2 | ||||
-rw-r--r-- | ui/compositor/test/test_compositor_host_ozone.cc | 7 | ||||
-rw-r--r-- | ui/compositor/test/test_compositor_host_win.cc | 2 | ||||
-rw-r--r-- | ui/compositor/test/test_compositor_host_x11.cc | 7 | ||||
-rw-r--r-- | ui/snapshot/snapshot_aura_unittest.cc | 3 | ||||
-rw-r--r-- | ui/views/view_unittest.cc | 60 |
11 files changed, 113 insertions, 186 deletions
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 1b6f342..19cf689 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -62,12 +62,6 @@ 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) @@ -78,16 +72,9 @@ 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), - 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) { + layer_animator_collection_(this) { root_web_layer_ = cc::Layer::Create(); CommandLine* command_line = CommandLine::ForCurrentProcess(); @@ -135,7 +122,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, settings.impl_side_painting = IsUIImplSidePaintingEnabled(); settings.use_zero_copy = IsUIZeroCopyEnabled(); - settings.single_thread_proxy_scheduler = false; base::TimeTicks before_create = base::TimeTicks::Now(); if (compositor_thread_loop_.get()) { @@ -176,14 +162,7 @@ Compositor::~Compositor() { } void Compositor::ScheduleDraw() { - if (compositor_thread_loop_.get()) { - host_->SetNeedsCommit(); - } else if (!defer_draw_scheduling_) { - defer_draw_scheduling_ = true; - task_runner_->PostTask( - FROM_HERE, - base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr())); - } + host_->SetNeedsCommit(); } void Compositor::SetRootLayer(Layer* root_layer) { @@ -204,44 +183,19 @@ void Compositor::SetHostHasTransparentBackground( host_->set_has_transparent_background(host_has_transparent_background); } -void Compositor::Draw() { - DCHECK(!compositor_thread_loop_.get()); - - 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. - cc::BeginFrameArgs args = - cc::BeginFrameArgs::Create(gfx::FrameTime::Now(), - base::TimeTicks(), - cc::BeginFrameArgs::DefaultInterval()); - BeginMainFrame(args); - host_->Composite(args.frame_time); - } - 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() { @@ -353,45 +307,30 @@ 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_.get()) { - NotifyEnd(); - } else { - DCHECK_EQ(swap_state_, SWAP_POSTED); - NotifyEnd(); - swap_state_ = SWAP_COMPLETED; + base::TimeTicks start_time = gfx::FrameTime::Now(); + FOR_EACH_OBSERVER(CompositorObserver, + observer_list_, + OnCompositingStarted(this, start_time)); } -} - -void Compositor::ScheduleComposite() { - if (!disable_schedule_composite_) - ScheduleDraw(); -} - -void Compositor::ScheduleAnimation() { - ScheduleComposite(); + FOR_EACH_OBSERVER( + CompositorObserver, observer_list_, OnCompositingEnded(this)); } void Compositor::DidPostSwapBuffers() { - DCHECK(!compositor_thread_loop_.get()); - DCHECK_EQ(swap_state_, SWAP_NONE); - swap_state_ = SWAP_POSTED; + base::TimeTicks start_time = gfx::FrameTime::Now(); + FOR_EACH_OBSERVER(CompositorObserver, + observer_list_, + OnCompositingStarted(this, start_time)); } void Compositor::DidAbortSwapBuffers() { - if (!compositor_thread_loop_.get()) { - if (swap_state_ == SWAP_POSTED) { - NotifyEnd(); - swap_state_ = SWAP_COMPLETED; - } - } - FOR_EACH_OBSERVER(CompositorObserver, observer_list_, OnCompositingAborted(this)); @@ -409,8 +348,7 @@ void Compositor::SetLayerTreeDebugState( scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { if (!compositor_lock_) { compositor_lock_ = new CompositorLock(this); - if (compositor_thread_loop_.get()) - host_->SetDeferCommits(true); + host_->SetDeferCommits(true); FOR_EACH_OBSERVER(CompositorObserver, observer_list_, OnCompositingLockStateChanged(this)); @@ -421,8 +359,7 @@ scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { void Compositor::UnlockCompositor() { DCHECK(compositor_lock_); compositor_lock_ = NULL; - if (compositor_thread_loop_.get()) - host_->SetDeferCommits(false); + host_->SetDeferCommits(false); FOR_EACH_OBSERVER(CompositorObserver, observer_list_, OnCompositingLockStateChanged(this)); @@ -433,20 +370,4 @@ 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 541f19d..72390d0 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -24,8 +24,6 @@ #include "ui/gfx/size.h" #include "ui/gfx/vector2d.h" -class SkBitmap; - namespace base { class MessageLoopProxy; class RunLoop; @@ -159,9 +157,6 @@ 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. @@ -249,14 +244,9 @@ 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; @@ -276,9 +266,6 @@ 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_; @@ -309,19 +296,8 @@ 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 e83eb33..c74d5c8 100644 --- a/ui/compositor/layer_unittest.cc +++ b/ui/compositor/layer_unittest.cc @@ -129,7 +129,7 @@ class LayerWithRealCompositorTest : public testing::Test { void DrawTree(Layer* root) { GetCompositor()->SetRootLayer(root); GetCompositor()->ScheduleDraw(); - WaitForDraw(); + WaitForSwap(); } void ReadPixels(SkBitmap* bitmap) { @@ -149,7 +149,7 @@ class LayerWithRealCompositorTest : public testing::Test { // 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(); + GetCompositor()->ScheduleFullRedraw(); WaitForDraw(); } @@ -159,7 +159,13 @@ class LayerWithRealCompositorTest : public testing::Test { *bitmap = holder->result(); } - void WaitForDraw() { ui::DrawWaiterForTest::Wait(GetCompositor()); } + void WaitForDraw() { + ui::DrawWaiterForTest::WaitForCompositingStarted(GetCompositor()); + } + + void WaitForSwap() { + DrawWaiterForTest::WaitForCompositingEnded(GetCompositor()); + } void WaitForCommit() { ui::DrawWaiterForTest::WaitForCommit(GetCompositor()); @@ -450,7 +456,9 @@ class LayerWithDelegateTest : public testing::Test { WaitForDraw(); } - void WaitForDraw() { DrawWaiterForTest::Wait(compositor()); } + void WaitForDraw() { + DrawWaiterForTest::WaitForCompositingStarted(compositor()); + } void WaitForCommit() { DrawWaiterForTest::WaitForCommit(compositor()); @@ -1027,25 +1035,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)); - WaitForDraw(); + WaitForSwap(); EXPECT_TRUE(observer.notified()); // So should resizing a layer. observer.Reset(); l2->SetBounds(gfx::Rect(0, 0, 400, 400)); - WaitForDraw(); + WaitForSwap(); EXPECT_TRUE(observer.notified()); // Opacity changes should alert the observers. observer.Reset(); l2->SetOpacity(0.5f); - WaitForDraw(); + WaitForSwap(); EXPECT_TRUE(observer.notified()); // So should setting the opacity back. observer.Reset(); l2->SetOpacity(1.0f); - WaitForDraw(); + WaitForSwap(); EXPECT_TRUE(observer.notified()); // Setting the transform of a layer should alert the observers. @@ -1055,7 +1063,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) { transform.Rotate(90.0); transform.Translate(-200.0, -200.0); l2->SetTransform(transform); - WaitForDraw(); + WaitForSwap(); EXPECT_TRUE(observer.notified()); // A change resulting in an aborted swap buffer should alert the observer @@ -1063,7 +1071,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) { observer.Reset(); l2->SetOpacity(0.1f); GetCompositor()->DidAbortSwapBuffers(); - WaitForDraw(); + WaitForSwap(); EXPECT_TRUE(observer.notified()); EXPECT_TRUE(observer.aborted()); @@ -1072,7 +1080,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) { // Opacity changes should no longer alert the removed observer. observer.Reset(); l2->SetOpacity(0.5f); - WaitForDraw(); + WaitForSwap(); 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 7687d66..f256ecc 100644 --- a/ui/compositor/test/draw_waiter_for_test.cc +++ b/ui/compositor/test/draw_waiter_for_test.cc @@ -9,20 +9,24 @@ namespace ui { // static -void DrawWaiterForTest::Wait(Compositor* compositor) { - DrawWaiterForTest waiter; - waiter.wait_for_commit_ = false; +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); waiter.WaitImpl(compositor); } // static void DrawWaiterForTest::WaitForCommit(Compositor* compositor) { - DrawWaiterForTest waiter; - waiter.wait_for_commit_ = true; + DrawWaiterForTest waiter(WAIT_FOR_COMMIT); waiter.WaitImpl(compositor); } -DrawWaiterForTest::DrawWaiterForTest() { +DrawWaiterForTest::DrawWaiterForTest(WaitEvent wait_event) + : wait_event_(wait_event) { } DrawWaiterForTest::~DrawWaiterForTest() {} @@ -35,16 +39,18 @@ void DrawWaiterForTest::WaitImpl(Compositor* compositor) { } void DrawWaiterForTest::OnCompositingDidCommit(Compositor* compositor) { - if (wait_for_commit_) + if (wait_event_ == 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(); } void DrawWaiterForTest::OnCompositingEnded(Compositor* compositor) { - if (!wait_for_commit_) + if (wait_event_ == WAIT_FOR_COMPOSITING_ENDED) wait_run_loop_->Quit(); } diff --git a/ui/compositor/test/draw_waiter_for_test.h b/ui/compositor/test/draw_waiter_for_test.h index 051c58f..e1d63ff 100644 --- a/ui/compositor/test/draw_waiter_for_test.h +++ b/ui/compositor/test/draw_waiter_for_test.h @@ -20,13 +20,22 @@ 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 Wait(Compositor* compositor); + static void WaitForCompositingStarted(Compositor* compositor); + + // Waits for a swap to be completed from the compositor. + static void WaitForCompositingEnded(Compositor* compositor); // Waits for a commit instead of a draw. static void WaitForCommit(Compositor* compositor); private: - DrawWaiterForTest(); + enum WaitEvent { + WAIT_FOR_COMMIT, + WAIT_FOR_COMPOSITING_STARTED, + WAIT_FOR_COMPOSITING_ENDED, + }; + + DrawWaiterForTest(WaitEvent wait_event); virtual ~DrawWaiterForTest(); void WaitImpl(Compositor* compositor); @@ -41,7 +50,7 @@ class DrawWaiterForTest : public CompositorObserver { scoped_ptr<base::RunLoop> wait_run_loop_; - bool wait_for_commit_; + WaitEvent wait_event_; 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 d7b4ab2..c85f743 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_->Draw(); + compositor_->ScheduleFullRedraw(); } @end diff --git a/ui/compositor/test/test_compositor_host_ozone.cc b/ui/compositor/test/test_compositor_host_ozone.cc index de4721e..f520b4a 100644 --- a/ui/compositor/test/test_compositor_host_ozone.cc +++ b/ui/compositor/test/test_compositor_host_ozone.cc @@ -27,8 +27,6 @@ class TestCompositorHostOzone : public TestCompositorHost { virtual void Show() OVERRIDE; virtual ui::Compositor* GetCompositor() OVERRIDE; - void Draw(); - gfx::Rect bounds_; ui::ContextFactory* context_factory_; @@ -64,11 +62,6 @@ 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 4693a03..a6278f6 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_->Draw(); + compositor_->ScheduleFullRedraw(); ValidateRect(hwnd(), NULL); } diff --git a/ui/compositor/test/test_compositor_host_x11.cc b/ui/compositor/test/test_compositor_host_x11.cc index 43b7429..ff1097c 100644 --- a/ui/compositor/test/test_compositor_host_x11.cc +++ b/ui/compositor/test/test_compositor_host_x11.cc @@ -30,8 +30,6 @@ class TestCompositorHostX11 : public TestCompositorHost { virtual void Show() OVERRIDE; virtual ui::Compositor* GetCompositor() OVERRIDE; - void Draw(); - gfx::Rect bounds_; ui::ContextFactory* context_factory_; @@ -85,11 +83,6 @@ 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 5fe05a8..018394b 100644 --- a/ui/snapshot/snapshot_aura_unittest.cc +++ b/ui/snapshot/snapshot_aura_unittest.cc @@ -115,7 +115,8 @@ class SnapshotAuraTest : public testing::Test { void WaitForDraw() { helper_->host()->compositor()->ScheduleDraw(); - ui::DrawWaiterForTest::Wait(helper_->host()->compositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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 fccb4fc..97b1643 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -3087,20 +3087,23 @@ TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { widget()->SetContentsView(content_view); content_view->SetPaintToLayer(true); GetRootLayer()->GetCompositor()->ScheduleDraw(); - ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + GetRootLayer()->GetCompositor()); EXPECT_TRUE(content_view->painted()); } @@ -3340,13 +3343,15 @@ 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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)); @@ -3354,7 +3359,8 @@ 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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)); @@ -3364,7 +3370,8 @@ 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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)); @@ -3391,13 +3398,15 @@ 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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)); @@ -3409,7 +3418,8 @@ TEST_F(ViewLayerTest, BoundsTreeWithRTL) { gfx::Rect ltr_damage(16, 18, 1, 1); test_view->SchedulePaintInRect(ltr_damage); GetRootLayer()->GetCompositor()->ScheduleDraw(); - ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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)); @@ -3433,18 +3443,21 @@ 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + GetRootLayer()->GetCompositor()); // Should only have picked up root_view and test_view. EXPECT_EQ(2U, test_view->last_cull_set_.size()); @@ -3467,7 +3480,8 @@ 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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 @@ -3477,7 +3491,8 @@ TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) { // Schedule another full-view paint. test_view->SchedulePaintInRect(test_view->bounds()); GetRootLayer()->GetCompositor()->ScheduleDraw(); - ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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)); @@ -3488,7 +3503,8 @@ TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) { // Schedule another full-view paint. test_view->SchedulePaintInRect(test_view->bounds()); GetRootLayer()->GetCompositor()->ScheduleDraw(); - ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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())); @@ -3512,7 +3528,8 @@ 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + GetRootLayer()->GetCompositor()); // Now remove v1 from the root view. test_view->RemoveChildView(v1); @@ -3520,7 +3537,8 @@ TEST_F(ViewLayerTest, BoundsTreeRemoveChildRemovesBounds) { // Schedule another full-view paint. test_view->SchedulePaintInRect(test_view->bounds()); GetRootLayer()->GetCompositor()->ScheduleDraw(); - ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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)); @@ -3551,7 +3569,8 @@ 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::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + 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)); @@ -3574,7 +3593,8 @@ TEST_F(ViewLayerTest, BoundsTreeMoveViewMovesBounds) { test_view->SchedulePaintInRect(test_view->bounds()); widget_view->SchedulePaintInRect(widget_view->bounds()); GetRootLayer()->GetCompositor()->ScheduleDraw(); - ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); + ui::DrawWaiterForTest::WaitForCompositingEnded( + GetRootLayer()->GetCompositor()); // Only v1 should be present in the first cull set. EXPECT_EQ(3U, test_view->last_cull_set_.size()); |