diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-25 02:33:45 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-25 02:33:45 +0000 |
commit | da8e3b72ba4c8d1d35c92217ddad7f86a810e210 (patch) | |
tree | a2092182f652a893859df064aae41a5d931e9860 /cc | |
parent | 1fec713d518f340a81bd837b86a290004407a9a7 (diff) | |
download | chromium_src-da8e3b72ba4c8d1d35c92217ddad7f86a810e210.zip chromium_src-da8e3b72ba4c8d1d35c92217ddad7f86a810e210.tar.gz chromium_src-da8e3b72ba4c8d1d35c92217ddad7f86a810e210.tar.bz2 |
cc: Remove the capability to give up and leave compositing mode.
The request to create a fallback OutputSurface should always succeed
and there's no way to leave compositing mode. So remove this capability
from cc and instead just LOG(FATAL) if the fallback OutputSurface
ends up being NULL.
The only case where the fallback OutputSurface isn't created is in the
ChromeOS browser compositor, and in this case the
GpuProcessTransportFactory will LOG(FATAL) before cc even finds out,
so this new LOG(FATAL) should never be hit in practice, but documents
our expectations.
This removes the call to WebWidget::didExitCompositingMode.
R=enne
BUG=366130,266666
Review URL: https://codereview.chromium.org/256573003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/tiled_layer_unittest.cc | 6 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_client.h | 2 | ||||
-rw-r--r-- | cc/test/layer_tree_test.cc | 4 | ||||
-rw-r--r-- | cc/test/layer_tree_test.h | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 54 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_client.h | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_context.cc | 105 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_delegated.cc | 2 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.cc | 27 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.h | 1 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 39 | ||||
-rw-r--r-- | cc/trees/thread_proxy.h | 4 |
13 files changed, 57 insertions, 199 deletions
diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc index a0c469f..35450b9 100644 --- a/cc/layers/tiled_layer_unittest.cc +++ b/cc/layers/tiled_layer_unittest.cc @@ -68,13 +68,11 @@ class SynchronousOutputSurfaceLayerTreeHost : public LayerTreeHost { return output_surface_created_; } - virtual CreateResult OnCreateAndInitializeOutputSurfaceAttempted( + virtual void OnCreateAndInitializeOutputSurfaceAttempted( bool success) OVERRIDE { - CreateResult result = - LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(success); + LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(success); output_surface_created_ = success; run_loop_.Quit(); - return result; } private: diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h index 1b0ec1f..f928453 100644 --- a/cc/test/fake_layer_tree_host_client.h +++ b/cc/test/fake_layer_tree_host_client.h @@ -35,7 +35,7 @@ class FakeLayerTreeHostClient : public LayerTreeHostClient, float page_scale) OVERRIDE {} virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE; - virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} + virtual void DidInitializeOutputSurface() OVERRIDE {} virtual void WillCommit() OVERRIDE {} virtual void DidCommit() OVERRIDE {} virtual void DidCommitAndDrawFrame() OVERRIDE {} diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index f67ee7c..23b5276 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -240,8 +240,8 @@ class LayerTreeHostClientForTesting : public LayerTreeHostClient, return test_hooks_->CreateOutputSurface(fallback); } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - test_hooks_->DidInitializeOutputSurface(succeeded); + virtual void DidInitializeOutputSurface() OVERRIDE { + test_hooks_->DidInitializeOutputSurface(); } virtual void DidFailToInitializeOutputSurface() OVERRIDE { diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index 42ef53f..a4a32d2 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -64,7 +64,7 @@ class TestHooks : public AnimationDelegate { virtual void WillBeginMainFrame() {} virtual void DidBeginMainFrame() {} virtual void Layout() {} - virtual void DidInitializeOutputSurface(bool succeeded) {} + virtual void DidInitializeOutputSurface() {} virtual void DidFailToInitializeOutputSurface() {} virtual void DidAddAnimation() {} virtual void WillCommit() {} diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 4cdd97d..cf79492 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -177,50 +177,38 @@ static void LayerTreeHostOnOutputSurfaceCreatedCallback(Layer* layer) { layer->OnOutputSurfaceCreated(); } -LayerTreeHost::CreateResult -LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(bool success) { +void LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(bool success) { + DCHECK(output_surface_lost_); TRACE_EVENT1("cc", "LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted", "success", success); - DCHECK(output_surface_lost_); - if (success) { - output_surface_lost_ = false; - - if (!contents_texture_manager_ && !settings_.impl_side_painting) { - contents_texture_manager_ = - PrioritizedResourceManager::Create(proxy_.get()); - surface_memory_placeholder_ = - contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); - } - - if (root_layer()) { - LayerTreeHostCommon::CallFunctionForSubtree( - root_layer(), - base::Bind(&LayerTreeHostOnOutputSurfaceCreatedCallback)); - } - - client_->DidInitializeOutputSurface(true); - return CreateSucceeded; + if (!success) { + // Tolerate a certain number of recreation failures to work around races + // in the output-surface-lost machinery. + ++num_failed_recreate_attempts_; + if (num_failed_recreate_attempts_ >= 5) + LOG(FATAL) << "Failed to create a fallback OutputSurface."; + client_->DidFailToInitializeOutputSurface(); + return; } - // Failure path. + output_surface_lost_ = false; - client_->DidFailToInitializeOutputSurface(); + if (!contents_texture_manager_ && !settings_.impl_side_painting) { + contents_texture_manager_ = + PrioritizedResourceManager::Create(proxy_.get()); + surface_memory_placeholder_ = + contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); + } - // Tolerate a certain number of recreation failures to work around races - // in the output-surface-lost machinery. - ++num_failed_recreate_attempts_; - if (num_failed_recreate_attempts_ >= 5) { - // We have tried too many times to recreate the output surface. Tell the - // host to fall back to software rendering. - output_surface_can_be_initialized_ = false; - client_->DidInitializeOutputSurface(false); - return CreateFailedAndGaveUp; + if (root_layer()) { + LayerTreeHostCommon::CallFunctionForSubtree( + root_layer(), base::Bind(&LayerTreeHostOnOutputSurfaceCreatedCallback)); } - return CreateFailedButTryAgain; + client_->DidInitializeOutputSurface(); } void LayerTreeHost::DeleteContentsTexturesOnImplThread( diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 17dacc8..90bcc25 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -114,13 +114,7 @@ class CC_EXPORT LayerTreeHost { LayerTreeHostImplClient* client); void DidLoseOutputSurface(); bool output_surface_lost() const { return output_surface_lost_; } - enum CreateResult { - CreateSucceeded, - CreateFailedButTryAgain, - CreateFailedAndGaveUp, - }; - virtual CreateResult OnCreateAndInitializeOutputSurfaceAttempted( - bool success); + virtual void OnCreateAndInitializeOutputSurfaceAttempted(bool success); void DidCommitAndDrawFrame() { client_->DidCommitAndDrawFrame(); } void DidCompleteSwapBuffers() { client_->DidCompleteSwapBuffers(); } void DeleteContentsTexturesOnImplThread(ResourceProvider* resource_provider); diff --git a/cc/trees/layer_tree_host_client.h b/cc/trees/layer_tree_host_client.h index bd185e8..74dcbc0 100644 --- a/cc/trees/layer_tree_host_client.h +++ b/cc/trees/layer_tree_host_client.h @@ -31,7 +31,7 @@ class LayerTreeHostClient { // Creates an OutputSurface. If fallback is true, it should attempt to // create an OutputSurface that is guaranteed to initialize correctly. virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) = 0; - virtual void DidInitializeOutputSurface(bool success) = 0; + virtual void DidInitializeOutputSurface() = 0; virtual void WillCommit() = 0; virtual void DidCommit() = 0; virtual void DidCommitAndDrawFrame() = 0; diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index a441d8a..84e324b 100644 --- a/cc/trees/layer_tree_host_unittest_context.cc +++ b/cc/trees/layer_tree_host_unittest_context.cc @@ -162,9 +162,7 @@ class LayerTreeHostContextTestLostContextSucceeds virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - EXPECT_TRUE(succeeded); - + virtual void DidInitializeOutputSurface() OVERRIDE { if (first_initialized_) ++num_losses_; else @@ -296,9 +294,7 @@ class LayerTreeHostClientNotReadyDoesNotCreateOutputSurface return scoped_ptr<OutputSurface>(); } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - EXPECT_TRUE(false); - } + virtual void DidInitializeOutputSurface() OVERRIDE { EXPECT_TRUE(false); } virtual void AfterTest() OVERRIDE { } @@ -360,11 +356,9 @@ class LayerTreeHostContextTestCreateOutputSurfaceFails // times. If |expect_fallback_attempt| is |true|, an attempt to create a // fallback/software OutputSurface is expected to occur. LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, - bool expect_fallback_attempt, - bool expect_to_give_up) + bool expect_fallback_attempt) : times_to_fail_(times_to_fail), expect_fallback_attempt_(expect_fallback_attempt), - expect_to_give_up_(expect_to_give_up), did_attempt_fallback_(false), times_initialized_(0) {} @@ -385,12 +379,7 @@ class LayerTreeHostContextTestCreateOutputSurfaceFails return surface.Pass(); } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - if (succeeded) - times_initialized_++; - else - EndTest(); - } + virtual void DidInitializeOutputSurface() OVERRIDE { times_initialized_++; } virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { EndTest(); @@ -398,14 +387,13 @@ class LayerTreeHostContextTestCreateOutputSurfaceFails virtual void AfterTest() OVERRIDE { EXPECT_EQ(times_to_fail_, times_create_failed_); - EXPECT_EQ(expect_to_give_up_, times_initialized_ == 0); + EXPECT_NE(0, times_initialized_); EXPECT_EQ(expect_fallback_attempt_, did_attempt_fallback_); } private: int times_to_fail_; bool expect_fallback_attempt_; - bool expect_to_give_up_; bool did_attempt_fallback_; int times_initialized_; }; @@ -414,7 +402,7 @@ class LayerTreeHostContextTestCreateOutputSurfaceFailsOnce : public LayerTreeHostContextTestCreateOutputSurfaceFails { public: LayerTreeHostContextTestCreateOutputSurfaceFailsOnce() - : LayerTreeHostContextTestCreateOutputSurfaceFails(1, false, false) {} + : LayerTreeHostContextTestCreateOutputSurfaceFails(1, false) {} }; SINGLE_AND_MULTI_THREAD_TEST_F( @@ -426,67 +414,12 @@ class LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback : public LayerTreeHostContextTestCreateOutputSurfaceFails { public: LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback() - : LayerTreeHostContextTestCreateOutputSurfaceFails(4, true, false) {} + : LayerTreeHostContextTestCreateOutputSurfaceFails(4, true) {} }; SINGLE_AND_MULTI_THREAD_TEST_F( LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback); -// If we fail that often, we should be giving up cleanly. -class LayerTreeHostContextTestCreateOutputSurfaceIsHopeless - : public LayerTreeHostContextTestCreateOutputSurfaceFails { - public: - LayerTreeHostContextTestCreateOutputSurfaceIsHopeless() - : LayerTreeHostContextTestCreateOutputSurfaceFails(5, true, true) {} -}; - -SINGLE_AND_MULTI_THREAD_TEST_F( - LayerTreeHostContextTestCreateOutputSurfaceIsHopeless); - -class LayerTreeHostContextTestLostContextFails - : public LayerTreeHostContextTest { - public: - LayerTreeHostContextTestLostContextFails() - : LayerTreeHostContextTest(), num_commits_(0), first_initialized_(false) { - times_to_lose_during_commit_ = 1; - } - - virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } - - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - if (first_initialized_) { - EXPECT_FALSE(succeeded); - EndTest(); - } else { - first_initialized_ = true; - } - } - - virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { - LayerTreeHostContextTest::CommitCompleteOnThread(host_impl); - - ++num_commits_; - if (num_commits_ == 1) { - // When the context is ok, we should have these things. - EXPECT_TRUE(host_impl->output_surface()); - EXPECT_TRUE(host_impl->renderer()); - EXPECT_TRUE(host_impl->resource_provider()); - return; - } - - // When context recreation fails we shouldn't be left with any of them. - EXPECT_FALSE(host_impl->output_surface()); - EXPECT_FALSE(host_impl->renderer()); - EXPECT_FALSE(host_impl->resource_provider()); - } - - virtual void AfterTest() OVERRIDE {} - - private: - int num_commits_; - bool first_initialized_; -}; - class LayerTreeHostContextTestLostContextAndEvictTextures : public LayerTreeHostContextTest { public: @@ -540,10 +473,7 @@ class LayerTreeHostContextTestLostContextAndEvictTextures impl_host_ = impl; } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - EXPECT_TRUE(succeeded); - EndTest(); - } + virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); } virtual void AfterTest() OVERRIDE {} @@ -662,10 +592,6 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources EndTest(); } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - EXPECT_TRUE(succeeded); - } - virtual void AfterTest() OVERRIDE { EXPECT_EQ(0, times_to_lose_on_end_query_); } @@ -1010,8 +936,7 @@ class LayerTreeHostContextTestCompositeAndReadbackBeforeOutputSurfaceInit EXPECT_EQ(1, times_output_surface_created_); } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - EXPECT_TRUE(succeeded); + virtual void DidInitializeOutputSurface() OVERRIDE { ++times_output_surface_created_; } @@ -1176,8 +1101,7 @@ class LayerTreeHostContextTestReadbackWithForcedDrawAndOutputSurfaceInit return DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - EXPECT_TRUE(succeeded); + virtual void DidInitializeOutputSurface() OVERRIDE { if (layer_tree_host()->source_frame_number() > 0) { // Perform a readback right after the second output surface // initialization. @@ -1255,10 +1179,7 @@ class LayerTreeHostContextTestImplSidePainting virtual void AfterTest() OVERRIDE {} - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - EXPECT_TRUE(succeeded); - EndTest(); - } + virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); } private: FakeContentLayerClient client_; @@ -1788,10 +1709,6 @@ class LayerTreeHostContextTestSurfaceCreateCallback } } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { - EXPECT_TRUE(succeeded); - } - virtual void AfterTest() OVERRIDE {} protected: diff --git a/cc/trees/layer_tree_host_unittest_delegated.cc b/cc/trees/layer_tree_host_unittest_delegated.cc index 360ddd0..a6562ae 100644 --- a/cc/trees/layer_tree_host_unittest_delegated.cc +++ b/cc/trees/layer_tree_host_unittest_delegated.cc @@ -405,7 +405,7 @@ class LayerTreeHostDelegatedTestInvalidFrameAfterContextLost SetFrameData(frame1.Pass()); } - virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE { + virtual void DidInitializeOutputSurface() OVERRIDE { if (!num_output_surfaces_initialized_++) return; diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index b5968fe..a70e08f 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -116,34 +116,21 @@ void SingleThreadProxy::CreateAndInitializeOutputSurface() { scoped_ptr<OutputSurface> output_surface = layer_tree_host_->CreateOutputSurface(); - if (!output_surface) { - OnOutputSurfaceInitializeAttempted(false); - return; - } - { + renderer_capabilities_for_main_thread_ = RendererCapabilities(); + + bool success = !!output_surface; + if (success) { DebugScopedSetMainThreadBlocked main_thread_blocked(this); DebugScopedSetImplThread impl(this); layer_tree_host_->DeleteContentsTexturesOnImplThread( layer_tree_host_impl_->resource_provider()); + success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); } - bool initialized; - { - DebugScopedSetImplThread impl(this); - - DCHECK(output_surface); - initialized = layer_tree_host_impl_->InitializeRenderer( - output_surface.Pass()); - } - - OnOutputSurfaceInitializeAttempted(initialized); -} + layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); -void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { - LayerTreeHost::CreateResult result = - layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); - if (result == LayerTreeHost::CreateFailedButTryAgain) { + if (!success) { // Force another recreation attempt to happen by requesting another commit. SetNeedsCommit(); } diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index df1113e..2882551 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -88,7 +88,6 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { SingleThreadProxy(LayerTreeHost* layer_tree_host, LayerTreeHostSingleThreadClient* client); - void OnOutputSurfaceInitializeAttempted(bool success); bool CommitAndComposite(base::TimeTicks frame_begin_time, const gfx::Rect& device_viewport_damage_rect, bool for_readback, diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index df350b8..9e9abd3 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -288,13 +288,7 @@ void ThreadProxy::DoCreateAndInitializeOutputSurface() { RendererCapabilities capabilities; bool success = !!output_surface; - if (!success) { - OnOutputSurfaceInitializeAttempted(false, capabilities); - return; - } - - success = false; - { + if (success) { // Make a blocking call to InitializeOutputSurfaceOnImplThread. The results // of that call are pushed into the success and capabilities local // variables. @@ -311,8 +305,15 @@ void ThreadProxy::DoCreateAndInitializeOutputSurface() { &capabilities)); completion.Wait(); } + main().renderer_capabilities_main_thread_copy = capabilities; + layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(success); - OnOutputSurfaceInitializeAttempted(success, capabilities); + if (success) { + main().output_surface_creation_callback.Cancel(); + } else if (!main().output_surface_creation_callback.IsCancelled()) { + Proxy::MainThreadTaskRunner()->PostTask( + FROM_HERE, main().output_surface_creation_callback.callback()); + } } void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( @@ -320,28 +321,6 @@ void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( main().renderer_capabilities_main_thread_copy = capabilities; } -void ThreadProxy::OnOutputSurfaceInitializeAttempted( - bool success, - const RendererCapabilities& capabilities) { - DCHECK(IsMainThread()); - DCHECK(layer_tree_host()); - - if (success) { - main().renderer_capabilities_main_thread_copy = capabilities; - } - - LayerTreeHost::CreateResult result = - layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(success); - if (result == LayerTreeHost::CreateFailedButTryAgain) { - if (!main().output_surface_creation_callback.callback().is_null()) { - Proxy::MainThreadTaskRunner()->PostTask( - FROM_HERE, main().output_surface_creation_callback.callback()); - } - } else { - main().output_surface_creation_callback.Cancel(); - } -} - void ThreadProxy::SendCommitRequestToImplThreadIfNeeded() { DCHECK(IsMainThread()); if (main().commit_request_sent_to_impl_thread) diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index 8bdd7b6..60e5416 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -146,10 +146,6 @@ class ThreadProxy : public Proxy, void DidCompleteSwapBuffers(); void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); void DoCreateAndInitializeOutputSurface(); - // |capabilities| is set only when |success| is true. - void OnOutputSurfaceInitializeAttempted( - bool success, - const RendererCapabilities& capabilities); void SendCommitRequestToImplThreadIfNeeded(); // Called on impl thread. |