Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(930)

Unified Diff: cc/resource_pool.cc

Issue 12197004: cc: Enforce correct recycling in resource pool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to renderer. Addressed feedback. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/resource_pool.cc
diff --git a/cc/resource_pool.cc b/cc/resource_pool.cc
index 91d1503677f8a46959fa1a120774e3221ce2a3d0..89dbb13700e2d4f7d54b27a05e990952f38b0d85 100644
--- a/cc/resource_pool.cc
+++ b/cc/resource_pool.cc
@@ -43,6 +43,12 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource(
it != resources_.end(); ++it) {
Resource* resource = *it;
+ // TODO(epenner): It would be nice to DCHECK that this
+ // doesn't happen two frames in a row for any resource
+ // in this pool.
+ if (!resource_provider_->canLockForWrite(resource->id()))
+ continue;
+
if (resource->size() != size)
continue;
if (resource->format() != format)
@@ -55,6 +61,12 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource(
// Create new resource.
Resource* resource = new Resource(
resource_provider_, size, format);
+
+ // Extend all read locks on all resources until the resource is
+ // finished being used, such that we know when resources are
+ // truly safe to recycle.
+ resource_provider_->enableReadLockFences(resource->id(), true);
+
memory_usage_bytes_ += resource->bytes();
return make_scoped_ptr(resource);
}
« cc/gl_renderer.cc ('K') | « cc/gl_renderer.cc ('k') | cc/resource_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698