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

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

Issue 2826583002: Use flat_set for ResourceIdSet (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/surfaces/surface_aggregator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 resource->wants_promotion_hint = it->wants_promotion_hint; 1616 resource->wants_promotion_hint = it->wants_promotion_hint;
1617 if (resource->wants_promotion_hint) 1617 if (resource->wants_promotion_hint)
1618 wants_promotion_hints_set_.insert(local_id); 1618 wants_promotion_hints_set_.insert(local_id);
1619 #endif 1619 #endif
1620 resource->color_space = it->color_space; 1620 resource->color_space = it->color_space;
1621 } 1621 }
1622 resource->child_id = child; 1622 resource->child_id = child;
1623 // Don't allocate a texture for a child. 1623 // Don't allocate a texture for a child.
1624 resource->allocated = true; 1624 resource->allocated = true;
1625 resource->imported_count = 1; 1625 resource->imported_count = 1;
1626 child_info.parent_to_child_map[local_id] = it->id; 1626 resource->id_in_child = it->id;
1627 child_info.child_to_parent_map[it->id] = local_id; 1627 child_info.child_to_parent_map[it->id] = local_id;
1628 } 1628 }
1629 } 1629 }
1630 1630
1631 void ResourceProvider::DeclareUsedResourcesFromChild( 1631 void ResourceProvider::DeclareUsedResourcesFromChild(
1632 int child, 1632 int child,
1633 const ResourceIdSet& resources_from_child) { 1633 const ResourceIdSet& resources_from_child) {
1634 DCHECK(thread_checker_.CalledOnValidThread()); 1634 DCHECK(thread_checker_.CalledOnValidThread());
1635 1635
1636 ChildMap::iterator child_it = children_.find(child); 1636 ChildMap::iterator child_it = children_.find(child);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 std::vector<GLbyte*> unverified_sync_tokens; 1828 std::vector<GLbyte*> unverified_sync_tokens;
1829 1829
1830 GLES2Interface* gl = ContextGL(); 1830 GLES2Interface* gl = ContextGL();
1831 1831
1832 for (ResourceId local_id : unused) { 1832 for (ResourceId local_id : unused) {
1833 ResourceMap::iterator it = resources_.find(local_id); 1833 ResourceMap::iterator it = resources_.find(local_id);
1834 CHECK(it != resources_.end()); 1834 CHECK(it != resources_.end());
1835 Resource& resource = it->second; 1835 Resource& resource = it->second;
1836 1836
1837 DCHECK(!resource.locked_for_write); 1837 DCHECK(!resource.locked_for_write);
1838 DCHECK(child_info->parent_to_child_map.count(local_id));
1839 1838
1840 ResourceId child_id = child_info->parent_to_child_map[local_id]; 1839 ResourceId child_id = resource.id_in_child;
1841 DCHECK(child_info->child_to_parent_map.count(child_id)); 1840 DCHECK(child_info->child_to_parent_map.count(child_id));
1842 1841
1843 bool is_lost = resource.lost || 1842 bool is_lost = resource.lost ||
1844 (IsGpuResourceType(resource.type) && lost_context_provider_); 1843 (IsGpuResourceType(resource.type) && lost_context_provider_);
1845 if (resource.exported_count > 0 || resource.lock_for_read_count > 0) { 1844 if (resource.exported_count > 0 || resource.lock_for_read_count > 0) {
1846 if (style != FOR_SHUTDOWN) { 1845 if (style != FOR_SHUTDOWN) {
1847 // Defer this resource deletion. 1846 // Defer this resource deletion.
1848 resource.marked_for_deletion = true; 1847 resource.marked_for_deletion = true;
1849 continue; 1848 continue;
1850 } 1849 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 if (IsGpuResourceType(resource.type) && child_info->needs_sync_tokens) { 1884 if (IsGpuResourceType(resource.type) && child_info->needs_sync_tokens) {
1886 if (resource.needs_sync_token()) { 1885 if (resource.needs_sync_token()) {
1887 need_synchronization_resources.push_back(&to_return.back()); 1886 need_synchronization_resources.push_back(&to_return.back());
1888 } else if (returned.sync_token.HasData() && 1887 } else if (returned.sync_token.HasData() &&
1889 !returned.sync_token.verified_flush()) { 1888 !returned.sync_token.verified_flush()) {
1890 // Before returning any sync tokens, they must be verified. 1889 // Before returning any sync tokens, they must be verified.
1891 unverified_sync_tokens.push_back(returned.sync_token.GetData()); 1890 unverified_sync_tokens.push_back(returned.sync_token.GetData());
1892 } 1891 }
1893 } 1892 }
1894 1893
1895 child_info->parent_to_child_map.erase(local_id);
1896 child_info->child_to_parent_map.erase(child_id); 1894 child_info->child_to_parent_map.erase(child_id);
1897 resource.imported_count = 0; 1895 resource.imported_count = 0;
1898 DeleteResourceInternal(it, style); 1896 DeleteResourceInternal(it, style);
1899 } 1897 }
1900 1898
1901 gpu::SyncToken new_sync_token; 1899 gpu::SyncToken new_sync_token;
1902 if (!need_synchronization_resources.empty()) { 1900 if (!need_synchronization_resources.empty()) {
1903 DCHECK(child_info->needs_sync_tokens); 1901 DCHECK(child_info->needs_sync_tokens);
1904 DCHECK(gl); 1902 DCHECK(gl);
1905 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); 1903 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
(...skipping 11 matching lines...) Expand all
1917 1915
1918 // Set sync token after verification. 1916 // Set sync token after verification.
1919 for (ReturnedResource* returned : need_synchronization_resources) 1917 for (ReturnedResource* returned : need_synchronization_resources)
1920 returned->sync_token = new_sync_token; 1918 returned->sync_token = new_sync_token;
1921 1919
1922 if (!to_return.empty()) 1920 if (!to_return.empty())
1923 child_info->return_callback.Run(to_return, 1921 child_info->return_callback.Run(to_return,
1924 blocking_main_thread_task_runner_); 1922 blocking_main_thread_task_runner_);
1925 1923
1926 if (child_info->marked_for_deletion && 1924 if (child_info->marked_for_deletion &&
1927 child_info->parent_to_child_map.empty()) { 1925 child_info->child_to_parent_map.empty()) {
1928 DCHECK(child_info->child_to_parent_map.empty());
1929 children_.erase(child_it); 1926 children_.erase(child_it);
1930 } 1927 }
1931 } 1928 }
1932 1929
1933 GLenum ResourceProvider::BindForSampling(ResourceId resource_id, 1930 GLenum ResourceProvider::BindForSampling(ResourceId resource_id,
1934 GLenum unit, 1931 GLenum unit,
1935 GLenum filter) { 1932 GLenum filter) {
1936 DCHECK(thread_checker_.CalledOnValidThread()); 1933 DCHECK(thread_checker_.CalledOnValidThread());
1937 GLES2Interface* gl = ContextGL(); 1934 GLES2Interface* gl = ContextGL();
1938 ResourceMap::iterator it = resources_.find(resource_id); 1935 ResourceMap::iterator it = resources_.find(resource_id);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 2194
2198 const int kImportance = 2; 2195 const int kImportance = 2;
2199 pmd->CreateSharedGlobalAllocatorDump(guid); 2196 pmd->CreateSharedGlobalAllocatorDump(guid);
2200 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2197 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2201 } 2198 }
2202 2199
2203 return true; 2200 return true;
2204 } 2201 }
2205 2202
2206 } // namespace cc 2203 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/surfaces/surface_aggregator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698