diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-22 23:29:51 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-22 23:29:51 +0000 |
commit | 819b9f5580eea88e9d1610a4b7903062cc5a89d4 (patch) | |
tree | b63d391d27dc4e8e63c2e4d96822059ee795bbb2 /cc/test/fake_delegated_renderer_layer_impl.cc | |
parent | 29834b67f21ae4d72157d4374312a96cb265024b (diff) | |
download | chromium_src-819b9f5580eea88e9d1610a4b7903062cc5a89d4.zip chromium_src-819b9f5580eea88e9d1610a4b7903062cc5a89d4.tar.gz chromium_src-819b9f5580eea88e9d1610a4b7903062cc5a89d4.tar.bz2 |
cc: Return resources to child compositor via a Callback.
Currently resources in the ResourceProvider are returned for release
back to a child compositor by explicitly calling the method
ResourceProvider::PrepareSendReturnsToChild(). This is problematic
because we want to return resources immediately if the last reference
on the resource is released when a parent compositor gives the resource
back to us.
TextureMailboxes deal with this gracefully by using a ReleaseCallback
in the ResourceProvider that is called when the mailbox is no longer in
use. We follow this example to release resources back to child
compositors by introducing a ReturnCallback in the ResourceProvider.
The ReturnCallback receives an array of resources instead of a single
resource per call, allowing us to save on post tasks and Run()
invocations.
The PrepareSendReturnsToChild is completely replaced by the new callback
mechanism. Resources are returned when they are no longer in use in the
current frame, and their exported reference count reaches zero (or lost
if the child compositor's connection is destroyed).
When the DelegatedRendererLayerImpl recieves a new frame, it will always
add all the resources into the ResourceProvider so that it can map the
resource ids correctly into its own compositor's namespace. Then it will
decide if the frame is valid or not. At that point, the DRLI must decide
to use the new frame, or continue using the old frame. It does this by
calling DeclareUsedResourcesFromChild() on the provider. Any resource
not listed in the declaration will become unused and returned to the
child as soon as possible. This changes the contract on ResourceProvider
such that every call to ReceiveFromChild() should be followed by a
DeclareUsedResourcesFromChild() call.
For now, DelegatedRendererLayer receives the callbacks about returned
resources and just inserts them in its list of resources for the
embedder to grab via TakeUnusedResourcesForChildCompositor(). A
follow-up step will be to move this callback out into the embedder
itself, similar to ReleaseCallback for mailboxes, so that the
RenderWidgetHostViewAura can promptly return resources instead of
waiting until the next commit to know resources are available.
Since resources are now returned to the main thread during commit, we
no longer have an extra pending frame of resources sitting on the impl
side, and can eliminate all the TODOs in our unit tests about this.
Covered by our many existing tests, but also added some new ones:
ResourceProviderTest.DeleteExportedResources
ResourceProviderTest.DestroyChildWithExportedResources
R=piman
BUG=263069
Review URL: https://chromiumcodereview.appspot.com/24078024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224640 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/fake_delegated_renderer_layer_impl.cc')
-rw-r--r-- | cc/test/fake_delegated_renderer_layer_impl.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cc/test/fake_delegated_renderer_layer_impl.cc b/cc/test/fake_delegated_renderer_layer_impl.cc index 782bc1c..1420ae2 100644 --- a/cc/test/fake_delegated_renderer_layer_impl.cc +++ b/cc/test/fake_delegated_renderer_layer_impl.cc @@ -32,6 +32,18 @@ static ResourceProvider::ResourceId AddResourceToFrame( return resource_id; } +ResourceProvider::ResourceIdSet FakeDelegatedRendererLayerImpl::Resources() + const { + ResourceProvider::ResourceIdSet set; + ResourceProvider::ResourceIdArray array; + array = ResourcesForTesting(); + for (size_t i = 0; i < array.size(); ++i) + set.insert(array[i]); + return set; +} + +void NoopReturnCallback(const ReturnedResourceArray& returned) {} + void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses( ScopedPtrVector<RenderPass>* pass_list) { scoped_ptr<DelegatedFrameData> delegated_frame(new DelegatedFrameData); @@ -46,9 +58,8 @@ void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses( pass->quad_list[j]->IterateResources(add_resource_to_frame_callback); } - ReturnedResourceArray resources_for_ack; + CreateChildIdIfNeeded(base::Bind(&NoopReturnCallback)); SetFrameData(delegated_frame.Pass(), gfx::RectF()); - CollectUnusedResources(&resources_for_ack); } } // namespace cc |