| Index: cc/trees/layer_tree_host_unittest.cc
|
| diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
|
| index 5e823b6b66955d41c62b2cac68fe9c617b401ee2..fe188edc3d6c0fd4516649b67abd92c50a4c7419 100644
|
| --- a/cc/trees/layer_tree_host_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_unittest.cc
|
| @@ -83,8 +83,8 @@ class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest {
|
| }
|
|
|
| virtual void AfterTest() OVERRIDE {
|
| - EXPECT_GE(1, num_commits_);
|
| - EXPECT_GE(1, num_draws_);
|
| + EXPECT_GE(num_commits_, 1);
|
| + EXPECT_GE(num_draws_, 1);
|
| }
|
|
|
| private:
|
| @@ -152,6 +152,7 @@ class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
|
|
|
| virtual void BeginTest() OVERRIDE {
|
| index_ = STARTUP;
|
| + index_impl_ = STARTUP;
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| @@ -164,10 +165,8 @@ class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
|
| VerifyBeforeValues(layer_tree_host()->root_layer());
|
|
|
| ++index_;
|
| - if (index_ == DONE) {
|
| + if (index_ == DONE);
|
| EndTest();
|
| - return;
|
| - }
|
|
|
| SetAfterValues(layer_tree_host()->root_layer());
|
| }
|
| @@ -221,6 +220,7 @@ class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
|
| }
|
|
|
| int index_;
|
| + int index_impl_;
|
| };
|
|
|
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesTo);
|
| @@ -619,7 +619,7 @@ class LayerTreeHostTestCompositeAndReadbackWhileInvisible
|
|
|
| virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| num_commits_++;
|
| if (num_commits_ == 1) {
|
| layer_tree_host()->SetVisible(false);
|
| @@ -698,7 +698,8 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestCommit);
|
| class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
|
| : public LayerTreeHostTest {
|
| public:
|
| - LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {}
|
| + LayerTreeHostTestFrameTimeUpdatesAfterActivationFails()
|
| + : frame_count_with_pending_tree_(0) {}
|
|
|
| virtual void BeginTest() OVERRIDE {
|
| layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
|
| @@ -707,9 +708,17 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| + virtual void WillBeginFrameOnThread(LayerTreeHostImpl* host_impl,
|
| + const BeginFrameArgs &args) OVERRIDE {
|
| + TRACE_EVENT0("cc", "WillBeginFrameOnThreadbca");
|
| + if (host_impl->pending_tree())
|
| + frame_count_with_pending_tree_++;
|
| + }
|
| +
|
| virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
|
| - if (frame_ >= 1) {
|
| - EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks());
|
| + if (frame_count_with_pending_tree_ > 1) {
|
| + EXPECT_NE(first_frame_time_.ToInternalValue(),
|
| + impl->CurrentFrameTimeTicks().ToInternalValue());
|
| EndTest();
|
| return;
|
| }
|
| @@ -719,33 +728,34 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
|
| }
|
|
|
| virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE {
|
| - if (frame_ >= 1)
|
| - return true;
|
| -
|
| - return false;
|
| + return frame_count_with_pending_tree_ > 1;
|
| }
|
|
|
| virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl)
|
| OVERRIDE {
|
| - frame_++;
|
| - if (frame_ == 1) {
|
| + if (frame_count_with_pending_tree_ > 1)
|
| + return true;
|
| +
|
| + if (first_frame_time_.is_null()) {
|
| first_frame_time_ = impl->CurrentFrameTimeTicks();
|
|
|
| // Since base::TimeTicks::Now() uses a low-resolution clock on
|
| // Windows, we need to make sure that the clock has incremented past
|
| // first_frame_time_.
|
| while (first_frame_time_ == base::TimeTicks::Now()) {}
|
| -
|
| - return false;
|
| }
|
| + return false;
|
| + }
|
|
|
| - return true;
|
| + virtual void DidActivateTreeOnThread(LayerTreeHostImpl *impl) OVERRIDE {
|
| + if (impl->settings().impl_side_painting)
|
| + EXPECT_NE(frame_count_with_pending_tree_, 1);
|
| }
|
|
|
| virtual void AfterTest() OVERRIDE {}
|
|
|
| private:
|
| - int frame_;
|
| + int frame_count_with_pending_tree_;
|
| base::TimeTicks first_frame_time_;
|
| };
|
|
|
| @@ -822,13 +832,14 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
|
|
|
| virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale)
|
| OVERRIDE {
|
| + TRACE_EVENT0("cc", "ApplyScrollAndScale9");
|
| gfx::Vector2d offset = scroll_layer_->scroll_offset();
|
| scroll_layer_->SetScrollOffset(offset + scroll_delta);
|
| layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f);
|
| }
|
|
|
| - virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
|
| - impl->ProcessScrollDeltas();
|
| + virtual void SwapBuffersOnThread(LayerTreeHostImpl *impl, bool result)
|
| + OVERRIDE {
|
| // We get one commit before the first draw, and the animation doesn't happen
|
| // until the second draw.
|
| switch (impl->active_tree()->source_frame_number()) {
|
| @@ -838,10 +849,14 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
|
| break;
|
| case 1:
|
| EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
|
| - PostSetNeedsRedrawToMainThread();
|
| break;
|
| case 2:
|
| + case 3:
|
| + case 4:
|
| EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor());
|
| + PostSetNeedsCommitToMainThread();
|
| + break;
|
| + case 5:
|
| EndTest();
|
| break;
|
| default:
|
| @@ -849,7 +864,7 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
|
| }
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 1:
|
| layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f);
|
| @@ -1260,7 +1275,7 @@ class LayerTreeHostTestAtomicCommitWithPartialUpdate
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 1:
|
| parent_->SetNeedsDisplay();
|
| @@ -1391,7 +1406,7 @@ class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest {
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| if (once_)
|
| return;
|
| once_ = true;
|
| @@ -1479,6 +1494,16 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| + virtual void DidActivateTreeOnThread(LayerTreeHostImpl *host_impl) {
|
| + // Reduce the memory limit to only fit the root layer and one render
|
| + // surface. This prevents any contents drawing into surfaces
|
| + // from being allocated.
|
| + if (host_impl->active_tree()->source_frame_number() == 0) {
|
| + host_impl->SetMemoryPolicy(
|
| + ManagedMemoryPolicy(100 * 100 * 4 * 2), true);
|
| + }
|
| + }
|
| +
|
| virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
|
| Renderer* renderer = host_impl->renderer();
|
| RenderPass::Id surface1_render_pass_id = host_impl->active_tree()
|
| @@ -1493,25 +1518,18 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit
|
| surface1_render_pass_id));
|
| EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(
|
| surface2_render_pass_id));
|
| -
|
| - // Reduce the memory limit to only fit the root layer and one render
|
| - // surface. This prevents any contents drawing into surfaces
|
| - // from being allocated.
|
| - host_impl->SetMemoryPolicy(
|
| - ManagedMemoryPolicy(100 * 100 * 4 * 2), true);
|
| break;
|
| case 1:
|
| EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
|
| surface1_render_pass_id));
|
| EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
|
| surface2_render_pass_id));
|
| -
|
| EndTest();
|
| break;
|
| }
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| if (layer_tree_host()->source_frame_number() < 2)
|
| root_layer_->SetNeedsDisplay();
|
| }
|
| @@ -1817,7 +1835,7 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest {
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| if (num_draw_layers_ == 2)
|
| return;
|
| content_layer_->SetNeedsDisplay();
|
| @@ -2213,9 +2231,9 @@ class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled
|
| // The BeginFrame notification is turned off now but will get enabled
|
| // once we return. End test while it's enabled.
|
| ImplThreadTaskRunner()->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest,
|
| - base::Unretained(this)));
|
| + FROM_HERE, base::Bind(
|
| + &LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled::EndTest,
|
| + base::Unretained(this)));
|
| }
|
|
|
| virtual void AfterTest() OVERRIDE {}
|
| @@ -2467,7 +2485,7 @@ class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest {
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| WaitForCallback();
|
| }
|
|
|
| @@ -3009,6 +3027,10 @@ class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest {
|
| // Round 4 done.
|
| EXPECT_EQ(2, frame_);
|
| layer_tree_host()->SetNeedsCommit();
|
| + // We cant SetNeedsRedraw immediately because it will race the commit.
|
| + break;
|
| + case 5:
|
| + EXPECT_EQ(2, frame_);
|
| layer_tree_host()->SetNeedsRedraw();
|
| break;
|
| }
|
| @@ -3323,7 +3345,7 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest {
|
| LayerTreeHostTest::SetupTree();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| ++num_commits_;
|
|
|
| EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
|
| @@ -3505,7 +3527,7 @@ class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
|
| LayerTreeHostTest::SetupTree();
|
| }
|
|
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 0:
|
| break;
|
| @@ -3588,7 +3610,7 @@ class LayerTreeHostTestCasePushPropertiesThreeGrandChildren
|
| class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -3628,7 +3650,7 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush);
|
| class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -3711,7 +3733,7 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion);
|
| class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -3759,7 +3781,7 @@ MULTI_THREAD_TEST_F(
|
| class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -3827,7 +3849,7 @@ MULTI_THREAD_TEST_F(
|
| class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
| @@ -3891,7 +3913,7 @@ MULTI_THREAD_TEST_F(
|
| class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent
|
| : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
|
| protected:
|
| - virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| + virtual void DidCommit() OVERRIDE {
|
| int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
|
| switch (last_source_frame_number) {
|
| case 0:
|
|
|