VideoResourceUpdater: Reuse resources for same frame, even if ResourceProvider has...
commit7a6c2a346104a0269767c7174d09355bd88b752e
authormagjed <magjed@chromium.org>
Thu, 11 Dec 2014 01:23:03 +0000 (10 17:23 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 11 Dec 2014 01:23:31 +0000 (11 01:23 +0000)
treeb1ec4ae7067737cdb792d2e8f02e38b3871880d1
parente9b512747b0e89234415f3fb6a16aab6ecd3c482
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}
cc/resources/video_resource_updater.cc
cc/resources/video_resource_updater.h
cc/resources/video_resource_updater_unittest.cc