Commit 497edf84 authored by danakj@chromium.org's avatar danakj@chromium.org

cc: Remove CreateAndInitializeOutputSurface from the Proxy interface.

Move it to be non-virtual methods on SingleThreadProxy and ThreadProxy.
LayerTreeHost only needs to call it on the SingleThreadProxy, and make
it do that before calling Composite() instead of having Composite()
early out.

Merge LTH::InitializeOutputSurfaceIfNeeded into LTH::Composite.

NOTRY=true
R=enne
BUG=374287

Review URL: https://codereview.chromium.org/286293002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271769 0039d316-1c4b-4281-b951-d872f2087c98
parent 58250717
...@@ -12,11 +12,6 @@ void FakeProxy::SetLayerTreeHost(LayerTreeHost* host) { ...@@ -12,11 +12,6 @@ void FakeProxy::SetLayerTreeHost(LayerTreeHost* host) {
bool FakeProxy::IsStarted() const { return true; } bool FakeProxy::IsStarted() const { return true; }
void FakeProxy::CreateAndInitializeOutputSurface() {
DCHECK(layer_tree_host_);
layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(true);
}
const RendererCapabilities& FakeProxy::GetRendererCapabilities() const { const RendererCapabilities& FakeProxy::GetRendererCapabilities() const {
return capabilities_; return capabilities_;
} }
......
...@@ -25,7 +25,6 @@ class FakeProxy : public Proxy { ...@@ -25,7 +25,6 @@ class FakeProxy : public Proxy {
virtual bool IsStarted() const OVERRIDE; virtual bool IsStarted() const OVERRIDE;
virtual void SetLayerTreeHostClientReady() OVERRIDE {} virtual void SetLayerTreeHostClientReady() OVERRIDE {}
virtual void SetVisible(bool visible) OVERRIDE {} virtual void SetVisible(bool visible) OVERRIDE {}
virtual void CreateAndInitializeOutputSurface() OVERRIDE;
virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
virtual void SetNeedsAnimate() OVERRIDE {} virtual void SetNeedsAnimate() OVERRIDE {}
virtual void SetNeedsUpdateLayers() OVERRIDE {} virtual void SetNeedsUpdateLayers() OVERRIDE {}
......
...@@ -96,7 +96,6 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, ...@@ -96,7 +96,6 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client,
client_(client), client_(client),
source_frame_number_(0), source_frame_number_(0),
rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
output_surface_can_be_initialized_(true),
output_surface_lost_(true), output_surface_lost_(true),
num_failed_recreate_attempts_(0), num_failed_recreate_attempts_(0),
settings_(settings), settings_(settings),
...@@ -698,16 +697,13 @@ void LayerTreeHost::NotifyInputThrottledUntilCommit() { ...@@ -698,16 +697,13 @@ void LayerTreeHost::NotifyInputThrottledUntilCommit() {
void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) {
DCHECK(!proxy_->HasImplThread()); DCHECK(!proxy_->HasImplThread());
SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
proxy->CompositeImmediately(frame_begin_time);
}
bool LayerTreeHost::InitializeOutputSurfaceIfNeeded() {
if (!output_surface_can_be_initialized_)
return false;
if (output_surface_lost_) if (output_surface_lost_)
proxy_->CreateAndInitializeOutputSurface(); proxy->CreateAndInitializeOutputSurface();
return !output_surface_lost_; if (output_surface_lost_)
return;
proxy->CompositeImmediately(frame_begin_time);
} }
bool LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue) { bool LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue) {
......
...@@ -118,8 +118,6 @@ class CC_EXPORT LayerTreeHost { ...@@ -118,8 +118,6 @@ class CC_EXPORT LayerTreeHost {
void DidCommitAndDrawFrame() { client_->DidCommitAndDrawFrame(); } void DidCommitAndDrawFrame() { client_->DidCommitAndDrawFrame(); }
void DidCompleteSwapBuffers() { client_->DidCompleteSwapBuffers(); } void DidCompleteSwapBuffers() { client_->DidCompleteSwapBuffers(); }
void DeleteContentsTexturesOnImplThread(ResourceProvider* resource_provider); void DeleteContentsTexturesOnImplThread(ResourceProvider* resource_provider);
// Returns false if we should abort this frame due to initialization failure.
bool InitializeOutputSurfaceIfNeeded();
bool UpdateLayers(ResourceUpdateQueue* queue); bool UpdateLayers(ResourceUpdateQueue* queue);
LayerTreeHostClient* client() { return client_; } LayerTreeHostClient* client() { return client_; }
...@@ -364,7 +362,6 @@ class CC_EXPORT LayerTreeHost { ...@@ -364,7 +362,6 @@ class CC_EXPORT LayerTreeHost {
int source_frame_number_; int source_frame_number_;
scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation_; scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation_;
bool output_surface_can_be_initialized_;
bool output_surface_lost_; bool output_surface_lost_;
int num_failed_recreate_attempts_; int num_failed_recreate_attempts_;
......
...@@ -2036,7 +2036,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) { ...@@ -2036,7 +2036,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) {
settings.max_partial_texture_updates = 10; settings.max_partial_texture_updates = 10;
LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); host.OnCreateAndInitializeOutputSurfaceAttempted(true);
EXPECT_EQ(0u, host.MaxPartialTextureUpdates()); EXPECT_EQ(0u, host.MaxPartialTextureUpdates());
} }
...@@ -2054,7 +2054,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) { ...@@ -2054,7 +2054,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) {
settings.max_partial_texture_updates = 10; settings.max_partial_texture_updates = 10;
LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); host.OnCreateAndInitializeOutputSurfaceAttempted(true);
EXPECT_EQ(5u, host.MaxPartialTextureUpdates()); EXPECT_EQ(5u, host.MaxPartialTextureUpdates());
} }
...@@ -2072,7 +2072,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) { ...@@ -2072,7 +2072,7 @@ TEST(LayerTreeHostTest, LimitPartialUpdates) {
settings.max_partial_texture_updates = 10; settings.max_partial_texture_updates = 10;
LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); LayerTreeHostWithProxy host(&client, settings, proxy.Pass());
EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); host.OnCreateAndInitializeOutputSurfaceAttempted(true);
EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); EXPECT_EQ(10u, host.MaxPartialTextureUpdates());
} }
...@@ -2088,7 +2088,8 @@ TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { ...@@ -2088,7 +2088,8 @@ TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) {
new TestSharedBitmapManager()); new TestSharedBitmapManager());
scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded(
&client, &client, shared_bitmap_manager.get(), settings); &client, &client, shared_bitmap_manager.get(), settings);
EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); host->Composite(base::TimeTicks::Now());
EXPECT_EQ(4u, host->settings().max_partial_texture_updates); EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
} }
...@@ -2102,7 +2103,8 @@ TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { ...@@ -2102,7 +2103,8 @@ TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) {
new TestSharedBitmapManager()); new TestSharedBitmapManager());
scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded(
&client, &client, shared_bitmap_manager.get(), settings); &client, &client, shared_bitmap_manager.get(), settings);
EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); host->Composite(base::TimeTicks::Now());
EXPECT_EQ(4u, host->settings().max_partial_texture_updates); EXPECT_EQ(4u, host->settings().max_partial_texture_updates);
} }
...@@ -2116,7 +2118,8 @@ TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { ...@@ -2116,7 +2118,8 @@ TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) {
new TestSharedBitmapManager()); new TestSharedBitmapManager());
scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded(
&client, &client, shared_bitmap_manager.get(), settings); &client, &client, shared_bitmap_manager.get(), settings);
EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); host->Composite(base::TimeTicks::Now());
EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
} }
...@@ -2131,7 +2134,8 @@ TEST(LayerTreeHostTest, ...@@ -2131,7 +2134,8 @@ TEST(LayerTreeHostTest,
new TestSharedBitmapManager()); new TestSharedBitmapManager());
scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded( scoped_ptr<LayerTreeHost> host = LayerTreeHost::CreateSingleThreaded(
&client, &client, shared_bitmap_manager.get(), settings); &client, &client, shared_bitmap_manager.get(), settings);
EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); host->Composite(base::TimeTicks::Now());
EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); EXPECT_EQ(0u, host->MaxPartialTextureUpdates());
} }
......
...@@ -57,11 +57,6 @@ class CC_EXPORT Proxy { ...@@ -57,11 +57,6 @@ class CC_EXPORT Proxy {
virtual void SetVisible(bool visible) = 0; virtual void SetVisible(bool visible) = 0;
// Attempts to recreate the context and renderer synchronously after the
// output surface is lost. Calls
// LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted with the result.
virtual void CreateAndInitializeOutputSurface() = 0;
virtual const RendererCapabilities& GetRendererCapabilities() const = 0; virtual const RendererCapabilities& GetRendererCapabilities() const = 0;
virtual void SetNeedsAnimate() = 0; virtual void SetNeedsAnimate() = 0;
......
...@@ -88,6 +88,7 @@ void SingleThreadProxy::CreateAndInitializeOutputSurface() { ...@@ -88,6 +88,7 @@ void SingleThreadProxy::CreateAndInitializeOutputSurface() {
TRACE_EVENT0( TRACE_EVENT0(
"cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface");
DCHECK(Proxy::IsMainThread()); DCHECK(Proxy::IsMainThread());
DCHECK(layer_tree_host_->output_surface_lost());
scoped_ptr<OutputSurface> output_surface = scoped_ptr<OutputSurface> output_surface =
layer_tree_host_->CreateOutputSurface(); layer_tree_host_->CreateOutputSurface();
...@@ -340,9 +341,7 @@ void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { ...@@ -340,9 +341,7 @@ void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() {
void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately");
DCHECK(Proxy::IsMainThread()); DCHECK(Proxy::IsMainThread());
DCHECK(!layer_tree_host_->output_surface_lost());
if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded())
return;
layer_tree_host_->AnimateLayers(frame_begin_time); layer_tree_host_->AnimateLayers(frame_begin_time);
......
...@@ -31,7 +31,6 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { ...@@ -31,7 +31,6 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient {
virtual bool IsStarted() const OVERRIDE; virtual bool IsStarted() const OVERRIDE;
virtual void SetLayerTreeHostClientReady() OVERRIDE; virtual void SetLayerTreeHostClientReady() OVERRIDE;
virtual void SetVisible(bool visible) OVERRIDE; virtual void SetVisible(bool visible) OVERRIDE;
virtual void CreateAndInitializeOutputSurface() OVERRIDE;
virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
virtual void SetNeedsAnimate() OVERRIDE; virtual void SetNeedsAnimate() OVERRIDE;
virtual void SetNeedsUpdateLayers() OVERRIDE; virtual void SetNeedsUpdateLayers() OVERRIDE;
...@@ -84,6 +83,10 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { ...@@ -84,6 +83,10 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient {
virtual void DidManageTiles() OVERRIDE {} virtual void DidManageTiles() OVERRIDE {}
virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {}
// Attempts to create the context and renderer synchronously. Calls
// LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted with the result.
void CreateAndInitializeOutputSurface();
// Called by the legacy path where RenderWidget does the scheduling. // Called by the legacy path where RenderWidget does the scheduling.
void CompositeImmediately(base::TimeTicks frame_begin_time); void CompositeImmediately(base::TimeTicks frame_begin_time);
......
...@@ -47,7 +47,6 @@ class ThreadProxy : public Proxy, ...@@ -47,7 +47,6 @@ class ThreadProxy : public Proxy,
virtual bool IsStarted() const OVERRIDE; virtual bool IsStarted() const OVERRIDE;
virtual void SetLayerTreeHostClientReady() OVERRIDE; virtual void SetLayerTreeHostClientReady() OVERRIDE;
virtual void SetVisible(bool visible) OVERRIDE; virtual void SetVisible(bool visible) OVERRIDE;
virtual void CreateAndInitializeOutputSurface() OVERRIDE;
virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
virtual void SetNeedsAnimate() OVERRIDE; virtual void SetNeedsAnimate() OVERRIDE;
virtual void SetNeedsUpdateLayers() OVERRIDE; virtual void SetNeedsUpdateLayers() OVERRIDE;
...@@ -148,6 +147,7 @@ class ThreadProxy : public Proxy, ...@@ -148,6 +147,7 @@ class ThreadProxy : public Proxy,
void DidCommitAndDrawFrame(); void DidCommitAndDrawFrame();
void DidCompleteSwapBuffers(); void DidCompleteSwapBuffers();
void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue);
void CreateAndInitializeOutputSurface();
void DoCreateAndInitializeOutputSurface(); void DoCreateAndInitializeOutputSurface();
void SendCommitRequestToImplThreadIfNeeded(); void SendCommitRequestToImplThreadIfNeeded();
......
...@@ -31,7 +31,6 @@ CompositorHost::~CompositorHost() {} ...@@ -31,7 +31,6 @@ CompositorHost::~CompositorHost() {}
void CompositorHost::SetSize(gfx::Size viewport_size) { void CompositorHost::SetSize(gfx::Size viewport_size) {
tree_->SetViewportSize(viewport_size); tree_->SetViewportSize(viewport_size);
tree_->SetLayerTreeHostClientReady(); tree_->SetLayerTreeHostClientReady();
tree_->InitializeOutputSurfaceIfNeeded();
} }
void CompositorHost::SetupScene() { void CompositorHost::SetupScene() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment