VideoResourceUpdater: Reuse resources for same frame, even if ResourceProvider has references to it
This CL is a follow up to https://codereview.chromium.org/
759143003/.
The problem with the previous CL is that it doesn't always reuse the
resources, because they may still be in use by ResourceProvider. When
VideoLayerImpl::DidDraw is called, it will try to free the resources by
calling:
for (size_t i = 0; i < frame_resources_.size(); ++i)
resource_provider->DeleteResource(frame_resources_[i]);
...
void ResourceProvider::DeleteResource(ResourceId id) {
...
if (resource->exported_count > 0 || resource->lock_for_read_count > 0) {
resource->marked_for_deletion = true;
return;
} else {
DeleteResourceInternal(it, Normal);
}
}
It is common that the "marked_for_deletion" path is used, and subsequent
calls to VideoLayerImpl::WillDraw may be forced to upload the data
again. This CL refactors VideoResourceUpdater so it can reuse the
uploaded data in those cases.
BUG=437653
Review URL: https://codereview.chromium.org/
787723002
Cr-Commit-Position: refs/heads/master@{#307823}