diff options
author | tkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-07 05:50:49 +0000 |
---|---|---|
committer | tkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-07 05:50:49 +0000 |
commit | 82f3d0b93dfffe25a62ed5afa2015c7d1bbea9ba (patch) | |
tree | a92131d562ab031949d882a17d4ace288a6f4882 /ui | |
parent | 2cca802ed574e16a9042d35634cef5ead7385998 (diff) | |
download | chromium_src-82f3d0b93dfffe25a62ed5afa2015c7d1bbea9ba.zip chromium_src-82f3d0b93dfffe25a62ed5afa2015c7d1bbea9ba.tar.gz chromium_src-82f3d0b93dfffe25a62ed5afa2015c7d1bbea9ba.tar.bz2 |
Revert of Make SingleThreadProxy a SchedulerClient (https://codereview.chromium.org/134623005/)
Reason for revert:
Broke some layout tests
Original issue's description:
> 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
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287950
NOTRY=true
NOTREECHECKS=true
TBR=enne@chromium.org
Review URL: https://codereview.chromium.org/447133002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287968 0039d316-1c4b-4281-b951-d872f2087c98
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 | 40 | ||||
-rw-r--r-- | ui/compositor/test/draw_waiter_for_test.cc | 29 | ||||
-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, 194 insertions, 122 deletions
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()); |