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 67411aa4468b5b5a26c04d65cb15c8292294fe01..de597f3cfa3219c995ca822e8cbf69f89da66f92 100644 |
--- a/cc/trees/layer_tree_host_unittest.cc |
+++ b/cc/trees/layer_tree_host_unittest.cc |
@@ -86,8 +86,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: |
@@ -622,7 +622,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); |
@@ -701,7 +701,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)); |
@@ -710,9 +711,16 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails |
PostSetNeedsCommitToMainThread(); |
} |
+ virtual void WillBeginFrameOnThread(LayerTreeHostImpl* host_impl, |
+ const BeginFrameArgs &args) OVERRIDE { |
+ 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; |
} |
@@ -722,33 +730,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_; |
}; |
@@ -830,8 +839,8 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { |
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()) { |
@@ -841,7 +850,6 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { |
break; |
case 1: |
EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); |
- PostSetNeedsRedrawToMainThread(); |
break; |
case 2: |
EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor()); |
@@ -852,7 +860,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); |
@@ -1263,7 +1271,7 @@ class LayerTreeHostTestAtomicCommitWithPartialUpdate |
PostSetNeedsCommitToMainThread(); |
} |
- virtual void DidCommitAndDrawFrame() OVERRIDE { |
+ virtual void DidCommit() OVERRIDE { |
switch (layer_tree_host()->source_frame_number()) { |
case 1: |
parent_->SetNeedsDisplay(); |
@@ -1394,7 +1402,7 @@ class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest { |
PostSetNeedsCommitToMainThread(); |
} |
- virtual void DidCommitAndDrawFrame() OVERRIDE { |
+ virtual void DidCommit() OVERRIDE { |
if (once_) |
return; |
once_ = true; |
@@ -1482,6 +1490,16 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit |
PostSetNeedsCommitToMainThread(); |
} |
+ virtual void DidActivateTreeOnThread(LayerTreeHostImpl *host_impl) OVERRIDE { |
+ if (host_impl->active_tree()->source_frame_number() == 0) { |
+ // 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)); |
+ host_impl->SetDiscardBackBufferWhenNotVisible(true); |
+ } |
+ } |
+ |
virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
Renderer* renderer = host_impl->renderer(); |
RenderPass::Id surface1_render_pass_id = host_impl->active_tree() |
@@ -1496,25 +1514,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)); |
- host_impl->SetDiscardBackBufferWhenNotVisible(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(); |
} |
@@ -1820,7 +1831,7 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
PostSetNeedsCommitToMainThread(); |
} |
- virtual void DidCommitAndDrawFrame() OVERRIDE { |
+ virtual void DidCommit() OVERRIDE { |
if (num_draw_layers_ == 2) |
return; |
content_layer_->SetNeedsDisplay(); |
@@ -2217,9 +2228,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 {} |
@@ -2471,7 +2482,7 @@ class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest { |
PostSetNeedsCommitToMainThread(); |
} |
- virtual void DidCommitAndDrawFrame() OVERRIDE { |
+ virtual void DidCommit() OVERRIDE { |
WaitForCallback(); |
} |
@@ -3013,6 +3024,10 @@ class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest { |
// Round 4 done. |
EXPECT_EQ(2, frame_); |
layer_tree_host()->SetNeedsCommit(); |
+ // We can't SetNeedsRedraw immediately because it will race the commit. |
+ break; |
+ case 5: |
+ EXPECT_EQ(2, frame_); |
layer_tree_host()->SetNeedsRedraw(); |
break; |
} |
@@ -3327,7 +3342,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()); |
@@ -3509,7 +3524,7 @@ class LayerTreeHostTestPropertyChangesDuringUpdateArePushed |
LayerTreeHostTest::SetupTree(); |
} |
- virtual void DidCommitAndDrawFrame() OVERRIDE { |
+ virtual void DidCommit() OVERRIDE { |
switch (layer_tree_host()->source_frame_number()) { |
case 0: |
break; |
@@ -3592,7 +3607,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: |
@@ -3632,7 +3647,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: |
@@ -3715,7 +3730,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: |
@@ -3763,7 +3778,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: |
@@ -3831,7 +3846,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: |
@@ -3895,7 +3910,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: |