summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-06 10:16:40 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-06 10:16:40 +0000
commitf418ec05d5e2187ce266b2b407755bc01db3acb9 (patch)
tree409da27072bd85fb7569a35361c6fe9e6871187d /ui
parentbb056f59f212a77760a7d508b6417c62d869d201 (diff)
downloadchromium_src-f418ec05d5e2187ce266b2b407755bc01db3acb9.zip
chromium_src-f418ec05d5e2187ce266b2b407755bc01db3acb9.tar.gz
chromium_src-f418ec05d5e2187ce266b2b407755bc01db3acb9.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-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
11 files changed, 122 insertions, 194 deletions
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 43a88a6..9c0a5134 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -61,14 +61,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)
@@ -79,16 +71,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();
@@ -177,14 +162,7 @@ Compositor::~Compositor() {
}
void Compositor::ScheduleDraw() {
- 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()));
- }
+ host_->SetNeedsCommit();
}
void Compositor::SetRootLayer(Layer* root_layer) {
@@ -205,42 +183,19 @@ 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() {
@@ -332,45 +287,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_) {
- 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_);
- 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_) {
- if (swap_state_ == SWAP_POSTED) {
- NotifyEnd();
- swap_state_ = SWAP_COMPLETED;
- }
- }
-
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingAborted(this));
@@ -388,8 +328,7 @@ void Compositor::SetLayerTreeDebugState(
scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
if (!compositor_lock_) {
compositor_lock_ = new CompositorLock(this);
- if (compositor_thread_loop_)
- host_->SetDeferCommits(true);
+ host_->SetDeferCommits(true);
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingLockStateChanged(this));
@@ -400,8 +339,7 @@ scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
void Compositor::UnlockCompositor() {
DCHECK(compositor_lock_);
compositor_lock_ = NULL;
- if (compositor_thread_loop_)
- host_->SetDeferCommits(false);
+ host_->SetDeferCommits(false);
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingLockStateChanged(this));
@@ -412,21 +350,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 0e4ac8a..b2d2779 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.
@@ -234,14 +229,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;
@@ -261,9 +251,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_;
@@ -294,19 +281,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 ac1a47b..b5c473c 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();
- WaitForDraw();
+ WaitForSwap();
}
bool ReadPixels(SkBitmap* bitmap) {
@@ -142,11 +142,13 @@ class LayerWithRealCompositorTest : public testing::Test {
GetCompositor()->root_layer()->RequestCopyOfOutput(request.Pass());
- // 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();
+ // 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();
WaitForDraw();
}
@@ -161,7 +163,11 @@ class LayerWithRealCompositorTest : public testing::Test {
}
void WaitForDraw() {
- ui::DrawWaiterForTest::Wait(GetCompositor());
+ ui::DrawWaiterForTest::WaitForCompositingStarted(GetCompositor());
+ }
+
+ void WaitForSwap() {
+ DrawWaiterForTest::WaitForCompositingEnded(GetCompositor());
}
void WaitForCommit() {
@@ -450,7 +456,7 @@ class LayerWithDelegateTest : public testing::Test {
}
void WaitForDraw() {
- DrawWaiterForTest::Wait(compositor());
+ DrawWaiterForTest::WaitForCompositingStarted(compositor());
}
void WaitForCommit() {
@@ -945,25 +951,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.
@@ -973,7 +979,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
@@ -981,7 +987,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
observer.Reset();
l2->SetOpacity(0.1f);
GetCompositor()->DidAbortSwapBuffers();
- WaitForDraw();
+ WaitForSwap();
EXPECT_TRUE(observer.notified());
EXPECT_TRUE(observer.aborted());
@@ -990,7 +996,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 c471a6f..f256ecc 100644
--- a/ui/compositor/test/draw_waiter_for_test.cc
+++ b/ui/compositor/test/draw_waiter_for_test.cc
@@ -9,20 +9,25 @@
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() {}
@@ -34,19 +39,23 @@ 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) {}
+ 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();
}
-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 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 8d533d0..7201fde 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 1c4b0cc..903c3b6 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 9c732f6..80db4ae 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 9b2d265..1c3f674 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 544e999..da2b349 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -3024,20 +3024,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());
}
@@ -3277,13 +3280,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));
@@ -3291,7 +3296,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));
@@ -3301,7 +3307,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));
@@ -3328,13 +3335,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));
@@ -3346,7 +3355,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));
@@ -3370,18 +3380,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());
@@ -3404,7 +3417,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
@@ -3414,7 +3428,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));
@@ -3425,7 +3440,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()));
@@ -3449,7 +3465,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);
@@ -3457,7 +3474,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));
@@ -3488,7 +3506,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));
@@ -3511,7 +3530,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());