From dad1528da80b1bcfdeaa9e6df696a731cb51eaee Mon Sep 17 00:00:00 2001 From: "vivek.vg@samsung.com" Date: Wed, 5 Feb 2014 07:09:27 +0000 Subject: [PATCH] Implement DelegatedFrameResourceCollectionClient::UnusedResourcesAreAvailable for Android. Implment UnusedResourcesAreAvailable to send the unused resources back if there are no pending ACKs. Also handle the LoseAllResources from ResourceCollection to send back the resources. R=danakj, sievers Review URL: https://codereview.chromium.org/153683002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248892 0039d316-1c4b-4281-b951-d872f2087c98 --- .../render_widget_host_view_android.cc | 26 +++++++++++++++++----- .../render_widget_host_view_android.h | 1 + 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index e8a67ae40498..9e9148adcd3c 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -734,8 +734,25 @@ void RenderWidgetHostViewAndroid::SendDelegatedFrameAck( ack); } +void RenderWidgetHostViewAndroid::SendReturnedDelegatedResources( + uint32 output_surface_id) { + DCHECK(resource_collection_); + + cc::CompositorFrameAck ack; + resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); + DCHECK(!ack.resources.empty()); + + RenderWidgetHostImpl::SendReclaimCompositorResources( + host_->GetRoutingID(), + output_surface_id, + host_->GetProcess()->GetID(), + ack); +} + void RenderWidgetHostViewAndroid::UnusedResourcesAreAvailable() { - // TODO(danakj): If no ack is pending, collect and send resources now. + if (ack_callbacks_.size()) + return; + SendReturnedDelegatedResources(last_output_surface_id_); } void RenderWidgetHostViewAndroid::DestroyDelegatedContent() { @@ -751,13 +768,12 @@ void RenderWidgetHostViewAndroid::SwapDelegatedFrame( bool has_content = !texture_size_in_layer_.IsEmpty(); if (output_surface_id != last_output_surface_id_) { - // TODO(danakj): Lose all resources and send them back here, such as: - // resource_collection_->LoseAllResources(); - // SendReturnedDelegatedResources(last_output_surface_id_); - // Drop the cc::DelegatedFrameResourceCollection so that we will not return // any resources from the old output surface with the new output surface id. if (resource_collection_.get()) { + if (resource_collection_->LoseAllResources()) + SendReturnedDelegatedResources(last_output_surface_id_); + resource_collection_->SetClient(NULL); resource_collection_ = NULL; } diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index fe7db5a67c2f..3dd03e2d9114 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h @@ -261,6 +261,7 @@ class RenderWidgetHostViewAndroid void SwapDelegatedFrame(uint32 output_surface_id, scoped_ptr frame_data); void SendDelegatedFrameAck(uint32 output_surface_id); + void SendReturnedDelegatedResources(uint32 output_surface_id); void UpdateContentViewCoreFrameMetadata( const cc::CompositorFrameMetadata& frame_metadata); -- 2.11.4.GIT