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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 2769573002: Return overlay resources to renderers in larger batches. (Closed)
Patch Set: rename Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 1026
1027 Resource* resource = &it->second; 1027 Resource* resource = &it->second;
1028 DCHECK_GT(resource->lock_for_read_count, 0); 1028 DCHECK_GT(resource->lock_for_read_count, 0);
1029 DCHECK_EQ(resource->exported_count, 0); 1029 DCHECK_EQ(resource->exported_count, 0);
1030 resource->lock_for_read_count--; 1030 resource->lock_for_read_count--;
1031 if (resource->marked_for_deletion && !resource->lock_for_read_count) { 1031 if (resource->marked_for_deletion && !resource->lock_for_read_count) {
1032 if (!resource->child_id) { 1032 if (!resource->child_id) {
1033 // The resource belongs to this ResourceProvider, so it can be destroyed. 1033 // The resource belongs to this ResourceProvider, so it can be destroyed.
1034 DeleteResourceInternal(it, NORMAL); 1034 DeleteResourceInternal(it, NORMAL);
1035 } else { 1035 } else {
1036 ChildMap::iterator child_it = children_.find(resource->child_id); 1036 if (batch_return_resources_) {
1037 ResourceIdArray unused; 1037 batched_returning_resources_[resource->child_id].push_back(id);
1038 unused.push_back(id); 1038 } else {
1039 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused); 1039 ChildMap::iterator child_it = children_.find(resource->child_id);
1040 ResourceIdArray unused;
1041 unused.push_back(id);
1042 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, unused);
1043 }
1040 } 1044 }
1041 } 1045 }
1042 } 1046 }
1043 1047
1044 ResourceProvider::Resource* ResourceProvider::LockForWrite(ResourceId id) { 1048 ResourceProvider::Resource* ResourceProvider::LockForWrite(ResourceId id) {
1045 Resource* resource = GetResource(id); 1049 Resource* resource = GetResource(id);
1046 DCHECK(CanLockForWrite(id)); 1050 DCHECK(CanLockForWrite(id));
1047 if (resource->allocated) 1051 if (resource->allocated)
1048 WaitSyncTokenIfNeeded(id); 1052 WaitSyncTokenIfNeeded(id);
1049 resource->locked_for_write = true; 1053 resource->locked_for_write = true;
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 resources_for_child[resource->child_id].push_back(local_id); 1660 resources_for_child[resource->child_id].push_back(local_id);
1657 } 1661 }
1658 1662
1659 for (const auto& children : resources_for_child) { 1663 for (const auto& children : resources_for_child) {
1660 ChildMap::iterator child_it = children_.find(children.first); 1664 ChildMap::iterator child_it = children_.find(children.first);
1661 DCHECK(child_it != children_.end()); 1665 DCHECK(child_it != children_.end());
1662 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, children.second); 1666 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, children.second);
1663 } 1667 }
1664 } 1668 }
1665 1669
1670 void ResourceProvider::SetBatchReturnResources(bool batch) {
1671 batch_return_resources_ = batch;
1672 if (!batch) {
1673 for (const auto& resources : batched_returning_resources_) {
1674 ChildMap::iterator child_it = children_.find(resources.first);
1675 DCHECK(child_it != children_.end());
Daniele Castagna 2017/03/24 01:44:43 nit: DCHECK_NE?
1676 DeleteAndReturnUnusedResourcesToChild(child_it, NORMAL, resources.second);
1677 }
1678 batched_returning_resources_.clear();
1679 }
1680 }
1681
1666 #if defined(OS_ANDROID) 1682 #if defined(OS_ANDROID)
1667 void ResourceProvider::SendPromotionHints( 1683 void ResourceProvider::SendPromotionHints(
1668 const OverlayCandidateList::PromotionHintInfoMap& promotion_hints) { 1684 const OverlayCandidateList::PromotionHintInfoMap& promotion_hints) {
1669 GLES2Interface* gl = ContextGL(); 1685 GLES2Interface* gl = ContextGL();
1670 if (!gl) 1686 if (!gl)
1671 return; 1687 return;
1672 1688
1673 for (const auto& id : wants_promotion_hints_set_) { 1689 for (const auto& id : wants_promotion_hints_set_) {
1674 const ResourceMap::iterator it = resources_.find(id); 1690 const ResourceMap::iterator it = resources_.find(id);
1675 if (it == resources_.end()) 1691 if (it == resources_.end())
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 2158
2143 const int kImportance = 2; 2159 const int kImportance = 2;
2144 pmd->CreateSharedGlobalAllocatorDump(guid); 2160 pmd->CreateSharedGlobalAllocatorDump(guid);
2145 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2161 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2146 } 2162 }
2147 2163
2148 return true; 2164 return true;
2149 } 2165 }
2150 2166
2151 } // namespace cc 2167 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698