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

Unified Diff: cc/resources/resource_provider.cc

Issue 208213003: Plumb overlay processing into DirectRenderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, Build Created 6 years, 9 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
« no previous file with comments | « cc/quads/render_pass_unittest.cc ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 4e7b2c416de288d5ec5afa53bedb7121c619ebd1..1e7c9d783de800b4a776122ed7d97e1f2fe116ab 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -799,12 +799,11 @@ void ResourceProvider::DeleteResource(ResourceId id) {
ResourceMap::iterator it = resources_.find(id);
CHECK(it != resources_.end());
Resource* resource = &it->second;
- DCHECK(!resource->lock_for_read_count);
DCHECK(!resource->marked_for_deletion);
DCHECK_EQ(resource->imported_count, 0);
DCHECK(resource->pending_set_pixels || !resource->locked_for_write);
- if (resource->exported_count > 0) {
+ if (resource->exported_count > 0 || resource->lock_for_read_count > 0) {
resource->marked_for_deletion = true;
return;
} else {
@@ -1087,10 +1086,25 @@ const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
}
void ResourceProvider::UnlockForRead(ResourceId id) {
- Resource* resource = GetResource(id);
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ResourceMap::iterator it = resources_.find(id);
+ CHECK(it != resources_.end());
+
+ Resource* resource = &it->second;
DCHECK_GT(resource->lock_for_read_count, 0);
DCHECK_EQ(resource->exported_count, 0);
resource->lock_for_read_count--;
+ if (resource->marked_for_deletion && !resource->lock_for_read_count) {
+ if (!resource->child_id) {
+ // The resource belongs to this ResourceProvider, so it can be destroyed.
+ DeleteResourceInternal(it, Normal);
+ } else {
+ ChildMap::iterator child_it = children_.find(resource->child_id);
+ ResourceIdArray unused;
+ unused.push_back(id);
+ DeleteAndReturnUnusedResourcesToChild(child_it, Normal, unused);
+ }
+ }
}
const ResourceProvider::Resource* ResourceProvider::LockForWrite(
@@ -1647,7 +1661,6 @@ void ResourceProvider::DeleteAndReturnUnusedResourcesToChild(
Resource& resource = it->second;
DCHECK(!resource.locked_for_write);
- DCHECK(!resource.lock_for_read_count);
DCHECK_EQ(0u, child_info->in_use_resources.count(local_id));
DCHECK(child_info->parent_to_child_map.count(local_id));
@@ -1656,9 +1669,10 @@ void ResourceProvider::DeleteAndReturnUnusedResourcesToChild(
bool is_lost =
resource.lost || (resource.type == GLTexture && lost_output_surface_);
- if (resource.exported_count > 0) {
+ if (resource.exported_count > 0 || resource.lock_for_read_count > 0) {
if (style != ForShutdown) {
- // Defer this until we receive the resource back from the parent.
+ // Defer this until we receive the resource back from the parent or
+ // the read lock is released.
resource.marked_for_deletion = true;
continue;
}
« no previous file with comments | « cc/quads/render_pass_unittest.cc ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698