Index: cc/trees/layer_tree_host_unittest_context.cc |
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc |
index 57f901bdb6a34ca95bef0d5d2c9784f8b20e8d79..3128f47fd4e2e00675161652365887b9f272c0be 100644 |
--- a/cc/trees/layer_tree_host_unittest_context.cc |
+++ b/cc/trees/layer_tree_host_unittest_context.cc |
@@ -915,237 +915,6 @@ class LayerTreeHostContextTestDontUseLostResources |
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources); |
-class LayerTreeHostContextTestCompositeAndReadbackBeforeOutputSurfaceInit |
- : public LayerTreeHostContextTest { |
- public: |
- virtual void BeginTest() OVERRIDE { |
- // This must be called immediately after creating LTH, before the first |
- // OutputSurface is initialized. |
- ASSERT_TRUE(layer_tree_host()->output_surface_lost()); |
- |
- times_output_surface_created_ = 0; |
- |
- // Post the SetNeedsCommit before the readback to make sure it is run |
- // on the main thread before the readback's replacement commit when |
- // we have a threaded compositor. |
- PostSetNeedsCommitToMainThread(); |
- |
- char pixels[4]; |
- bool result = |
- layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(1, 1)); |
- EXPECT_EQ(!delegating_renderer(), result); |
- EXPECT_EQ(1, times_output_surface_created_); |
- } |
- |
- virtual void DidInitializeOutputSurface() OVERRIDE { |
- ++times_output_surface_created_; |
- } |
- |
- virtual void DidCommitAndDrawFrame() OVERRIDE { EndTest(); } |
- |
- virtual void AfterTest() OVERRIDE { |
- // Should not try to create output surface again after successfully |
- // created by CompositeAndReadback. |
- EXPECT_EQ(1, times_output_surface_created_); |
- } |
- |
- virtual DrawResult PrepareToDrawOnThread( |
- LayerTreeHostImpl* host_impl, |
- LayerTreeHostImpl::FrameData* frame_data, |
- DrawResult draw_result) OVERRIDE { |
- EXPECT_GE(host_impl->active_tree()->source_frame_number(), 0); |
- EXPECT_LE(host_impl->active_tree()->source_frame_number(), 1); |
- return draw_result; |
- } |
- |
- virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
- // We should only draw for the readback and the replacement commit. |
- // The replacement commit will also be the first commit after output |
- // surface initialization. |
- EXPECT_GE(host_impl->active_tree()->source_frame_number(), 0); |
- EXPECT_LE(host_impl->active_tree()->source_frame_number(), 1); |
- } |
- |
- virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
- bool result) OVERRIDE { |
- // We should only swap for the replacement commit. |
- EXPECT_EQ(host_impl->active_tree()->source_frame_number(), 1); |
- EndTest(); |
- } |
- |
- private: |
- int times_output_surface_created_; |
-}; |
- |
-SINGLE_AND_MULTI_THREAD_TEST_F( |
- LayerTreeHostContextTestCompositeAndReadbackBeforeOutputSurfaceInit); |
- |
-// This test verifies that losing an output surface during a |
-// simultaneous readback and forced redraw works and does not deadlock. |
-class LayerTreeHostContextTestLoseOutputSurfaceDuringReadbackAndForcedDraw |
- : public LayerTreeHostContextTest { |
- protected: |
- static const int kFirstOutputSurfaceInitSourceFrameNumber = 0; |
- static const int kReadbackSourceFrameNumber = 1; |
- static const int kReadbackReplacementSourceFrameNumber = 2; |
- static const int kSecondOutputSurfaceInitSourceFrameNumber = 3; |
- |
- LayerTreeHostContextTestLoseOutputSurfaceDuringReadbackAndForcedDraw() |
- : did_react_to_first_commit_(false) {} |
- |
- virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
- // This enables forced draws after a single prepare to draw failure. |
- settings->timeout_and_draw_when_animation_checkerboards = true; |
- settings->maximum_number_of_failed_draws_before_draw_is_forced_ = 1; |
- } |
- |
- virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
- |
- virtual DrawResult PrepareToDrawOnThread( |
- LayerTreeHostImpl* host_impl, |
- LayerTreeHostImpl::FrameData* frame_data, |
- DrawResult draw_result) OVERRIDE { |
- int sfn = host_impl->active_tree()->source_frame_number(); |
- EXPECT_TRUE(sfn == kFirstOutputSurfaceInitSourceFrameNumber || |
- sfn == kSecondOutputSurfaceInitSourceFrameNumber || |
- sfn == kReadbackSourceFrameNumber) |
- << sfn; |
- |
- // Before we react to the failed draw by initiating the forced draw |
- // sequence, start a readback on the main thread and then lose the context |
- // to start output surface initialization all at the same time. |
- if (sfn == kFirstOutputSurfaceInitSourceFrameNumber && |
- !did_react_to_first_commit_) { |
- did_react_to_first_commit_ = true; |
- PostReadbackToMainThread(); |
- LoseContext(); |
- } |
- |
- return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
- } |
- |
- virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, |
- bool success) OVERRIDE { |
- // -1 is for the first output surface initialization. |
- int sfn = host_impl->active_tree()->source_frame_number(); |
- EXPECT_TRUE(sfn == -1 || sfn == kReadbackReplacementSourceFrameNumber) |
- << sfn; |
- } |
- |
- virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
- // We should only draw the first commit after output surface initialization |
- // and attempt to draw the readback commit (which will fail). |
- // All others should abort because the output surface is lost. |
- int sfn = host_impl->active_tree()->source_frame_number(); |
- EXPECT_TRUE(sfn == kSecondOutputSurfaceInitSourceFrameNumber || |
- sfn == kReadbackSourceFrameNumber) |
- << sfn; |
- } |
- |
- virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
- bool result) OVERRIDE { |
- // We should only swap the first commit after the second output surface |
- // initialization. |
- int sfn = host_impl->active_tree()->source_frame_number(); |
- EXPECT_TRUE(sfn == kSecondOutputSurfaceInitSourceFrameNumber) << sfn; |
- EndTest(); |
- } |
- |
- virtual void AfterTest() OVERRIDE {} |
- |
- int did_react_to_first_commit_; |
-}; |
- |
-MULTI_THREAD_TEST_F( |
- LayerTreeHostContextTestLoseOutputSurfaceDuringReadbackAndForcedDraw); |
- |
-// This test verifies that losing an output surface right before a |
-// simultaneous readback and forced redraw works and does not deadlock. |
-class LayerTreeHostContextTestReadbackWithForcedDrawAndOutputSurfaceInit |
- : public LayerTreeHostContextTest { |
- protected: |
- static const int kFirstOutputSurfaceInitSourceFrameNumber = 0; |
- static const int kReadbackSourceFrameNumber = 1; |
- static const int kForcedDrawCommitSourceFrameNumber = 2; |
- static const int kSecondOutputSurfaceInitSourceFrameNumber = 2; |
- |
- LayerTreeHostContextTestReadbackWithForcedDrawAndOutputSurfaceInit() |
- : did_lose_context_(false) {} |
- |
- virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
- // This enables forced draws after a single prepare to draw failure. |
- settings->timeout_and_draw_when_animation_checkerboards = true; |
- settings->maximum_number_of_failed_draws_before_draw_is_forced_ = 1; |
- } |
- |
- virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
- |
- virtual DrawResult PrepareToDrawOnThread( |
- LayerTreeHostImpl* host_impl, |
- LayerTreeHostImpl::FrameData* frame_data, |
- DrawResult draw_result) OVERRIDE { |
- int sfn = host_impl->active_tree()->source_frame_number(); |
- EXPECT_TRUE(sfn == kFirstOutputSurfaceInitSourceFrameNumber || |
- sfn == kSecondOutputSurfaceInitSourceFrameNumber || |
- sfn == kReadbackSourceFrameNumber) |
- << sfn; |
- |
- // Before we react to the failed draw by initiating the forced draw |
- // sequence, start a readback on the main thread and then lose the context |
- // to start output surface initialization all at the same time. |
- if (sfn == kFirstOutputSurfaceInitSourceFrameNumber && !did_lose_context_) { |
- did_lose_context_ = true; |
- LoseContext(); |
- } |
- |
- // Returning false will result in a forced draw. |
- return DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
- } |
- |
- virtual void DidInitializeOutputSurface() OVERRIDE { |
- if (layer_tree_host()->source_frame_number() > 0) { |
- // Perform a readback right after the second output surface |
- // initialization. |
- char pixels[4]; |
- layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); |
- } |
- } |
- |
- virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, |
- bool success) OVERRIDE { |
- // -1 is for the first output surface initialization. |
- int sfn = host_impl->active_tree()->source_frame_number(); |
- EXPECT_TRUE(sfn == -1 || sfn == kFirstOutputSurfaceInitSourceFrameNumber) |
- << sfn; |
- } |
- |
- virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
- // We should only draw the first commit after output surface initialization |
- // and attempt to draw the readback commit (which will fail). |
- // All others should abort because the output surface is lost. |
- int sfn = host_impl->active_tree()->source_frame_number(); |
- EXPECT_TRUE(sfn == kForcedDrawCommitSourceFrameNumber || |
- sfn == kReadbackSourceFrameNumber) |
- << sfn; |
- } |
- |
- virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
- bool result) OVERRIDE { |
- // We should only swap the first commit after the second output surface |
- // initialization. |
- int sfn = host_impl->active_tree()->source_frame_number(); |
- EXPECT_TRUE(sfn == kForcedDrawCommitSourceFrameNumber) << sfn; |
- EndTest(); |
- } |
- |
- virtual void AfterTest() OVERRIDE {} |
- |
- int did_lose_context_; |
-}; |
- |
-MULTI_THREAD_TEST_F( |
- LayerTreeHostContextTestReadbackWithForcedDrawAndOutputSurfaceInit); |
- |
class ImplSidePaintingLayerTreeHostContextTest |
: public LayerTreeHostContextTest { |
public: |