Descriptioncc: 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
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=224640
Patch Set 1 #Patch Set 2 : deletechild: #
Total comments: 14
Patch Set 3 : deletechild: rebase #Patch Set 4 : deletechild: add missing file #Patch Set 5 : deletechild: piman review #Patch Set 6 : deletechild: selfnits #Patch Set 7 : deletechild: make is_lost a todo since it's unused for this cl #Patch Set 8 : deletechild: rebase #Patch Set 9 : deletechild: fix win #Patch Set 10 : deletechild: No AndReceiveAck needed, change STP #
Messages
Total messages: 10 (0 generated)
|